Skip to content

Commit f13c132

Browse files
committed
Have psql escape bytes in strings for variables follow the backend
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.
1 parent 6616e23 commit f13c132

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

src/bin/psql/psqlscan.l

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* Portions Copyright (c) 1994, Regents of the University of California
3434
*
3535
* IDENTIFICATION
36-
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.10 2005/05/26 01:24:29 tgl Exp $
36+
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.11 2005/05/30 14:50:35 momjian Exp $
3737
*
3838
*-------------------------------------------------------------------------
3939
*/
@@ -849,29 +849,10 @@ other .
849849
"\\r" { appendPQExpBufferChar(output_buf, '\r'); }
850850
"\\f" { appendPQExpBufferChar(output_buf, '\f'); }
851851

852-
"\\"[1-9][0-9]* {
853-
/* decimal case */
854-
appendPQExpBufferChar(output_buf,
855-
(char) strtol(yytext + 1, NULL, 0));
856-
}
857-
858-
"\\"0[0-7]* {
852+
"\\"[0-7]{1,3} {
859853
/* octal case */
860854
appendPQExpBufferChar(output_buf,
861-
(char) strtol(yytext + 1, NULL, 0));
862-
}
863-
864-
"\\"0[xX][0-9A-Fa-f]+ {
865-
/* hex case */
866-
appendPQExpBufferChar(output_buf,
867-
(char) strtol(yytext + 1, NULL, 0));
868-
}
869-
870-
"\\"0[xX] {
871-
/* failed hex case */
872-
yyless(2);
873-
appendPQExpBufferChar(output_buf,
874-
(char) strtol(yytext + 1, NULL, 0));
855+
(char) strtol(yytext + 1, NULL, 8));
875856
}
876857

877858
"\\". { emit(yytext + 1, 1); }

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy