@@ -945,7 +945,7 @@ copy_statement_with_parameters(StatementClass *stmt)
945945int param_number ;
946946Int2 param_ctype ,
947947param_sqltype ;
948- char * old_statement = stmt -> statement ;
948+ char * old_statement = stmt -> statement , oldchar ;
949949char * new_statement = stmt -> stmt_with_params ;
950950unsignedint new_stsize = 0 ;
951951SIMPLE_TIME st ;
@@ -999,46 +999,49 @@ copy_statement_with_parameters(StatementClass *stmt)
999999
10001000for (opos = 0 ;opos < oldstmtlen ;opos ++ )
10011001{
1002+ oldchar = old_statement [opos ];
10021003#ifdef MULTIBYTE
1003- if (multibyte_char_check (old_statement [ opos ] )!= 0 )
1004+ if (multibyte_char_check (oldchar )!= 0 )
10041005{
1005- CVT_APPEND_CHAR (old_statement [ opos ] );
1006+ CVT_APPEND_CHAR (oldchar );
10061007continue ;
10071008}
10081009/*
10091010 *From here we are guaranteed to handle a
10101011 *1-byte character.
10111012 */
10121013#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 ;
10171014
1018- else if (in_escape )/* escape check */
1015+ if (in_escape )/* escape check */
10191016{
10201017in_escape = FALSE;
1021- CVT_APPEND_CHAR (old_statement [ opos ] );
1018+ CVT_APPEND_CHAR (oldchar );
10221019continue ;
10231020}
10241021else if (in_quote || in_dquote )/* quote/double quote check */
10251022{
1026- if (old_statement [opos ]== '\'' && in_quote )
1023+ if (oldchar == '\\' )
1024+ in_escape = TRUE;
1025+ else if (oldchar == '\'' && in_quote )
10271026in_quote = FALSE;
1028- else if (old_statement [ opos ] == '\"' && in_dquote )
1027+ else if (oldchar == '\"' && in_dquote )
10291028in_dquote = FALSE;
1030- CVT_APPEND_CHAR (old_statement [ opos ] );
1029+ CVT_APPEND_CHAR (oldchar );
10311030continue ;
10321031}
10331032/*
10341033 *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.
10361035 */
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 ;
10371040/*
10381041 * Handle literals (date, time, timestamp) and ODBC scalar
10391042 * functions
10401043 */
1041- else if (old_statement [ opos ] == '{' )
1044+ else if (oldchar == '{' )
10421045{
10431046char * esc ;
10441047char * begin = & old_statement [opos + 1 ];
@@ -1064,7 +1067,7 @@ copy_statement_with_parameters(StatementClass *stmt)
10641067else
10651068{/* it's not a valid literal so just copy */
10661069* end = '}' ;
1067- CVT_APPEND_CHAR (old_statement [ opos ] );
1070+ CVT_APPEND_CHAR (oldchar );
10681071continue ;
10691072}
10701073
@@ -1078,15 +1081,15 @@ copy_statement_with_parameters(StatementClass *stmt)
10781081 * so. All the queries I've seen expect the driver to put quotes
10791082 * if needed.
10801083 */
1081- else if (old_statement [ opos ] == '?' )
1084+ else if (oldchar == '?' )
10821085;/* ok */
10831086else
10841087{
1085- if (old_statement [ opos ] == '\'' )
1088+ if (oldchar == '\'' )
10861089in_quote = TRUE;
1087- else if (old_statement [ opos ] == '\\' )
1090+ else if (oldchar == '\\' )
10881091in_escape = TRUE;
1089- else if (old_statement [ opos ] == '\"' )
1092+ else if (oldchar == '\"' )
10901093in_dquote = TRUE;
10911094else if (check_select_into && /* select into check */
10921095opos > 0 &&
@@ -1097,7 +1100,7 @@ copy_statement_with_parameters(StatementClass *stmt)
10971100memmove (new_statement ,new_statement + declare_pos ,npos - declare_pos );
10981101npos -= declare_pos ;
10991102}
1100- CVT_APPEND_CHAR (old_statement [ opos ] );
1103+ CVT_APPEND_CHAR (oldchar );
11011104continue ;
11021105}
11031106