@@ -109,14 +109,14 @@ free_statement(struct statement * stmt)
109
109
}
110
110
111
111
static int
112
- next_insert (char * text , int pos , bool questionmarks )
112
+ next_insert (char * text , int pos , bool questionmarks , bool std_strings )
113
113
{
114
114
bool string = false;
115
115
int p = pos ;
116
116
117
117
for (; text [p ] != '\0' ; p ++ )
118
118
{
119
- if (text [p ] == '\\' ) /* escape character */
119
+ if (string && ! std_strings && text [p ] == '\\' ) /* escape character */
120
120
p ++ ;
121
121
else if (text [p ] == '\'' )
122
122
string = string ? false : true;
@@ -1104,6 +1104,13 @@ ecpg_build_params(struct statement * stmt)
1104
1104
struct variable * var ;
1105
1105
int desc_counter = 0 ;
1106
1106
int position = 0 ;
1107
+ const char * value ;
1108
+ bool std_strings = false;
1109
+
1110
+ /* Get standard_conforming_strings setting. */
1111
+ value = PQparameterStatus (stmt -> connection -> connection , "standard_conforming_strings" );
1112
+ if (value && strcmp (value , "on" ) == 0 )
1113
+ std_strings = true;
1107
1114
1108
1115
/*
1109
1116
* If the type is one of the fill in types then we take the argument and
@@ -1294,7 +1301,7 @@ ecpg_build_params(struct statement * stmt)
1294
1301
* now tobeinserted points to an area that contains the next
1295
1302
* parameter; now find the position in the string where it belongs
1296
1303
*/
1297
- if ((position = next_insert (stmt -> command , position , stmt -> questionmarks ) + 1 ) == 0 )
1304
+ if ((position = next_insert (stmt -> command , position , stmt -> questionmarks , std_strings ) + 1 ) == 0 )
1298
1305
{
1299
1306
/*
1300
1307
* We have an argument but we dont have the matched up placeholder
@@ -1381,7 +1388,7 @@ ecpg_build_params(struct statement * stmt)
1381
1388
}
1382
1389
1383
1390
/* Check if there are unmatched things left. */
1384
- if (next_insert (stmt -> command , position , stmt -> questionmarks ) >= 0 )
1391
+ if (next_insert (stmt -> command , position , stmt -> questionmarks , std_strings ) >= 0 )
1385
1392
{
1386
1393
ecpg_raise (stmt -> lineno , ECPG_TOO_FEW_ARGUMENTS ,
1387
1394
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS , NULL );
0 commit comments