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