Fix lexing of U& sequences just before EOF.
authorTom Lane
Tue, 4 Feb 2014 00:48:00 +0000 (19:48 -0500)
committerTom Lane
Tue, 4 Feb 2014 00:48:00 +0000 (19:48 -0500)
Commit a5ff502fceadc7c203b0d7a11b45c73f1b421f69 was a brick shy of a load
in the backend lexer too, not just psql.  Per further testing of bug #9068.

In passing, improve related comments.

src/backend/parser/scan.l
src/bin/psql/psqlscan.l

index 92f38a2a07ae2fcc748d69c08a0582c328180af0..b65ee3e667ab637df3762060b1c5e957712aeee4 100644 (file)
@@ -155,6 +155,9 @@ extern void core_yyset_column(int column_no, yyscan_t yyscanner);
  *   quoted string with Unicode escapes
  *   end of a quoted string with Unicode escapes, UESCAPE can follow
  *   Unicode surrogate pair in extended quoted string
+ *
+ * Remember to add an <> case whenever you add a new exclusive state!
+ * The default one is probably not the right thing.
  */
 
 %x xb
@@ -545,12 +548,13 @@ other         .
 {quotefail} {
                    /* throw back all but the quote */
                    yyless(1);
-                   /* handle possible UESCAPE in xusend mode */
+                   /* xusend state looks for possible UESCAPE */
                    BEGIN(xusend);
                }
-{whitespace}
+{whitespace} { /* stay in xusend state over whitespace */ }
 {other} |
-{xustop1} {
+{xustop1} |
+<>    {
                    /* no UESCAPE after the quote, throw back everything */
                    yyless(0);
                    BEGIN(INITIAL);
@@ -725,12 +729,13 @@ other         .
                }
 {dquote} {
                    yyless(1);
-                   /* handle possible UESCAPE in xuiend mode */
+                   /* xuiend state looks for possible UESCAPE */
                    BEGIN(xuiend);
                }
-{whitespace} { }
+{whitespace} { /* stay in xuiend state over whitespace */ }
 {other} |
-{xustop1} {
+{xustop1} |
+<>    {
                    /* no UESCAPE after the quote, throw back everything */
                    char           *ident;
 
index dd80611d738a3c944e43b49342f1fc5ea6ed4379..20ffa3ab5b6bd4e37d105e48c61f68aec144ec6e 100644 (file)
@@ -166,7 +166,8 @@ static void escape_variable(bool as_ident);
  *   extended quoted strings (support backslash escape sequences)
  *   $foo$ quoted strings
  *   quoted identifier with Unicode escapes
- *   end of a quoted identifier with Unicode escapes, UESCAPE can follow *   quoted string with Unicode escapes
+ *   end of a quoted identifier with Unicode escapes, UESCAPE can follow
+ *   quoted string with Unicode escapes
  *   end of a quoted string with Unicode escapes, UESCAPE can follow
  *
  * Note: we intentionally don't mimic the backend's  state; we have