@@ -945,7 +945,7 @@ copy_statement_with_parameters(StatementClass *stmt)
945
945
int param_number ;
946
946
Int2 param_ctype ,
947
947
param_sqltype ;
948
- char * old_statement = stmt -> statement ;
948
+ char * old_statement = stmt -> statement , oldchar ;
949
949
char * new_statement = stmt -> stmt_with_params ;
950
950
unsigned int new_stsize = 0 ;
951
951
SIMPLE_TIME st ;
@@ -999,46 +999,49 @@ copy_statement_with_parameters(StatementClass *stmt)
999
999
1000
1000
for (opos = 0 ; opos < oldstmtlen ; opos ++ )
1001
1001
{
1002
+ oldchar = old_statement [opos ];
1002
1003
#ifdef MULTIBYTE
1003
- if (multibyte_char_check (old_statement [ opos ] ) != 0 )
1004
+ if (multibyte_char_check (oldchar ) != 0 )
1004
1005
{
1005
- CVT_APPEND_CHAR (old_statement [ opos ] );
1006
+ CVT_APPEND_CHAR (oldchar );
1006
1007
continue ;
1007
1008
}
1008
1009
/*
1009
1010
* From here we are guaranteed to handle a
1010
1011
* 1-byte character.
1011
1012
*/
1012
1013
#endif
1013
- /* Squeeze carriage-return/linefeed pairs to linefeed only */
1014
- if (old_statement [opos ] == '\r' && opos + 1 < oldstmtlen &&
1015
- old_statement [opos + 1 ] == '\n' )
1016
- continue ;
1017
1014
1018
- else if (in_escape ) /* escape check */
1015
+ if (in_escape ) /* escape check */
1019
1016
{
1020
1017
in_escape = FALSE;
1021
- CVT_APPEND_CHAR (old_statement [ opos ] );
1018
+ CVT_APPEND_CHAR (oldchar );
1022
1019
continue ;
1023
1020
}
1024
1021
else if (in_quote || in_dquote ) /* quote/double quote check */
1025
1022
{
1026
- if (old_statement [opos ] == '\'' && in_quote )
1023
+ if (oldchar == '\\' )
1024
+ in_escape = TRUE;
1025
+ else if (oldchar == '\'' && in_quote )
1027
1026
in_quote = FALSE;
1028
- else if (old_statement [ opos ] == '\"' && in_dquote )
1027
+ else if (oldchar == '\"' && in_dquote )
1029
1028
in_dquote = FALSE;
1030
- CVT_APPEND_CHAR (old_statement [ opos ] );
1029
+ CVT_APPEND_CHAR (oldchar );
1031
1030
continue ;
1032
1031
}
1033
1032
/*
1034
1033
* From here we are guranteed to be in neither
1035
- * an escape nor a quote nor a double quote.
1034
+ * an escape, a quote nor a double quote.
1036
1035
*/
1036
+ /* Squeeze carriage-return/linefeed pairs to linefeed only */
1037
+ else if (oldchar == '\r' && opos + 1 < oldstmtlen &&
1038
+ old_statement [opos + 1 ] == '\n' )
1039
+ continue ;
1037
1040
/*
1038
1041
* Handle literals (date, time, timestamp) and ODBC scalar
1039
1042
* functions
1040
1043
*/
1041
- else if (old_statement [ opos ] == '{' )
1044
+ else if (oldchar == '{' )
1042
1045
{
1043
1046
char * esc ;
1044
1047
char * begin = & old_statement [opos + 1 ];
@@ -1064,7 +1067,7 @@ copy_statement_with_parameters(StatementClass *stmt)
1064
1067
else
1065
1068
{ /* it's not a valid literal so just copy */
1066
1069
* end = '}' ;
1067
- CVT_APPEND_CHAR (old_statement [ opos ] );
1070
+ CVT_APPEND_CHAR (oldchar );
1068
1071
continue ;
1069
1072
}
1070
1073
@@ -1078,15 +1081,15 @@ copy_statement_with_parameters(StatementClass *stmt)
1078
1081
* so. All the queries I've seen expect the driver to put quotes
1079
1082
* if needed.
1080
1083
*/
1081
- else if (old_statement [ opos ] == '?' )
1084
+ else if (oldchar == '?' )
1082
1085
; /* ok */
1083
1086
else
1084
1087
{
1085
- if (old_statement [ opos ] == '\'' )
1088
+ if (oldchar == '\'' )
1086
1089
in_quote = TRUE;
1087
- else if (old_statement [ opos ] == '\\' )
1090
+ else if (oldchar == '\\' )
1088
1091
in_escape = TRUE;
1089
- else if (old_statement [ opos ] == '\"' )
1092
+ else if (oldchar == '\"' )
1090
1093
in_dquote = TRUE;
1091
1094
else if (check_select_into && /* select into check */
1092
1095
opos > 0 &&
@@ -1097,7 +1100,7 @@ copy_statement_with_parameters(StatementClass *stmt)
1097
1100
memmove (new_statement , new_statement + declare_pos , npos - declare_pos );
1098
1101
npos -= declare_pos ;
1099
1102
}
1100
- CVT_APPEND_CHAR (old_statement [ opos ] );
1103
+ CVT_APPEND_CHAR (oldchar );
1101
1104
continue ;
1102
1105
}
1103
1106
0 commit comments