@@ -120,7 +120,6 @@ static bool var_is_current_source(PsqlScanState state, const char *varname);
120120static YY_BUFFER_STATEprepare_buffer (const char *txt,int len,
121121char **txtcopy);
122122static void emit (const char *txt,int len);
123- static bool is_utf16_surrogate_first (uint32 c);
124123static void escape_variable (bool as_ident);
125124
126125#define ECHO emit (yytext, yyleng)
@@ -163,7 +162,11 @@ static void escape_variable(bool as_ident);
163162 * <xdolq> $foo$ quoted strings
164163 * <xui> quoted identifier with Unicode escapes
165164 * <xus> quoted string with Unicode escapes
166- * <xeu> Unicode surrogate pair in extended quoted string
165+ *
166+ * Note: we intentionally don't mimic the backend's <xeu> state; we have
167+ * no need to distinguish it from <xe> state, and no good way to get out
168+ * of it in error cases. The backend just throws yyerror() in those
169+ * cases, but that's not an option here.
167170*/
168171
169172%x xb
@@ -175,7 +178,6 @@ static void escape_variable(bool as_ident);
175178%x xdolq
176179%x xui
177180%x xus
178- %x xeu
179181/* Additional exclusive states for psql only: lex backslash commands*/
180182%x xslashcmd
181183%x xslasharg
@@ -529,19 +531,9 @@ other.
529531ECHO;
530532}
531533<xe>{xeunicode} {
532- uint32 c =strtoul (yytext+2 ,NULL ,16 );
533-
534- if (is_utf16_surrogate_first (c))
535- BEGIN (xeu);
536- ECHO;
537- }
538- <xeu>{xeunicode} {
539- BEGIN (xe);
540534ECHO;
541535}
542- <xeu>.{ ECHO; }
543- <xeu>\n{ ECHO; }
544- <xe,xeu>{xeunicodefail}{
536+ <xe>{xeunicodefail}{
545537ECHO;
546538}
547539<xe>{xeescape} {
@@ -1242,6 +1234,7 @@ psql_scan(PsqlScanState state,
12421234case LEXRES_EOL:/* end of input */
12431235switch (state->start_state )
12441236{
1237+ /* This switch must cover all non-slash-command states. */
12451238case INITIAL:
12461239if (state->paren_depth >0 )
12471240{
@@ -1276,18 +1269,26 @@ psql_scan(PsqlScanState state,
12761269result = PSCAN_INCOMPLETE;
12771270*prompt = PROMPT_SINGLEQUOTE;
12781271break ;
1279- case xq :
1272+ case xe :
12801273result = PSCAN_INCOMPLETE;
12811274*prompt = PROMPT_SINGLEQUOTE;
12821275break ;
1283- case xe :
1276+ case xq :
12841277result = PSCAN_INCOMPLETE;
12851278*prompt = PROMPT_SINGLEQUOTE;
12861279break ;
12871280case xdolq:
12881281result = PSCAN_INCOMPLETE;
12891282*prompt = PROMPT_DOLLARQUOTE;
12901283break ;
1284+ case xui:
1285+ result = PSCAN_INCOMPLETE;
1286+ *prompt = PROMPT_DOUBLEQUOTE;
1287+ break ;
1288+ case xus:
1289+ result = PSCAN_INCOMPLETE;
1290+ *prompt = PROMPT_SINGLEQUOTE;
1291+ break ;
12911292default :
12921293/* can't get here */
12931294fprintf (stderr," invalid YY_START\n " );
@@ -1814,12 +1815,6 @@ emit(const char *txt, int len)
18141815}
18151816}
18161817
1817- static bool
1818- is_utf16_surrogate_first (uint32 c)
1819- {
1820- return (c >=0xD800 && c <=0xDBFF );
1821- }
1822-
18231818static void
18241819escape_variable (bool as_ident)
18251820{