@@ -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;
@@ -1110,6 +1110,13 @@ ecpg_build_params(struct statement * stmt)
1110
1110
struct variable * var ;
1111
1111
int desc_counter = 0 ;
1112
1112
int position = 0 ;
1113
+ const char * value ;
1114
+ bool std_strings = false;
1115
+
1116
+ /* Get standard_conforming_strings setting. */
1117
+ value = PQparameterStatus (stmt -> connection -> connection , "standard_conforming_strings" );
1118
+ if (value && strcmp (value , "on" ) == 0 )
1119
+ std_strings = true;
1113
1120
1114
1121
/*
1115
1122
* If the type is one of the fill in types then we take the argument and
@@ -1300,7 +1307,7 @@ ecpg_build_params(struct statement * stmt)
1300
1307
* now tobeinserted points to an area that contains the next
1301
1308
* parameter; now find the position in the string where it belongs
1302
1309
*/
1303
- if ((position = next_insert (stmt -> command , position , stmt -> questionmarks ) + 1 ) == 0 )
1310
+ if ((position = next_insert (stmt -> command , position , stmt -> questionmarks , std_strings ) + 1 ) == 0 )
1304
1311
{
1305
1312
/*
1306
1313
* We have an argument but we dont have the matched up placeholder
@@ -1387,7 +1394,7 @@ ecpg_build_params(struct statement * stmt)
1387
1394
}
1388
1395
1389
1396
/* Check if there are unmatched things left. */
1390
- if (next_insert (stmt -> command , position , stmt -> questionmarks ) >= 0 )
1397
+ if (next_insert (stmt -> command , position , stmt -> questionmarks , std_strings ) >= 0 )
1391
1398
{
1392
1399
ecpg_raise (stmt -> lineno , ECPG_TOO_FEW_ARGUMENTS ,
1393
1400
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS , NULL );
0 commit comments