Have psql escape bytes in strings for variables follow the backend
authorBruce Momjian <[email protected]>
Mon, 30 May 2005 14:50:35 +0000 (14:50 +0000)
committerBruce Momjian <[email protected]>
Mon, 30 May 2005 14:50:35 +0000 (14:50 +0000)
conventions of only allowing octal, like \045.  Remove support for
\decimal, \0octal, and \0xhex which matches the strtol() function but
didn't make sense with backslashes.

These now return the same character:

test=> \set x '\54'
test=> \echo :x
,
test=> \set x '\054'
test=> \echo :x
,

THIS IS A BACKWARD COMPATIBILITY CHANGE.

src/bin/psql/psqlscan.l

index 4b44822579b9739bd95d51cc281972b268cf08d5..f0487e925f73876a93a4ef88f146eebc6a27c246 100644 (file)
@@ -849,29 +849,10 @@ other                     .
 "\\r"                  { appendPQExpBufferChar(output_buf, '\r'); }
 "\\f"                  { appendPQExpBufferChar(output_buf, '\f'); }
 
-"\\"[1-9][0-9]*        {
-                                       /* decimal case */
-                                       appendPQExpBufferChar(output_buf,
-                                                                                 (char) strtol(yytext + 1, NULL, 0));
-                               }
-
-"\\"0[0-7]*            {
+"\\"[0-7]{1,3} {
                                        /* octal case */
                                        appendPQExpBufferChar(output_buf,
-                                                                                 (char) strtol(yytext + 1, NULL, 0));
-                               }
-
-"\\"0[xX][0-9A-Fa-f]+  {
-                                       /* hex case */
-                                       appendPQExpBufferChar(output_buf,
-                                                                                 (char) strtol(yytext + 1, NULL, 0));
-                               }
-
-"\\"0[xX]      {
-                                       /* failed hex case */
-                                       yyless(2);
-                                       appendPQExpBufferChar(output_buf,
-                                                                                 (char) strtol(yytext + 1, NULL, 0));
+                                                                                 (char) strtol(yytext + 1, NULL, 8));
                                }
 
 "\\".                  { emit(yytext + 1, 1); }