Skip to content

Commit b513663

Browse files
committed
Add support for \x hex strings in psql variables.
1 parent 65537ac commit b513663

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.137 2005/05/30 15:24:23 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.138 2005/06/02 01:23:48 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -589,8 +589,9 @@ testdb=&gt;
589589
single quote. To include a single quote into such an argument,
590590
precede it by a backslash. Anything contained in single quotes is
591591
furthermore subject to C-like substitutions for
592-
<literal>\n</literal> (new line), <literal>\t</literal> (tab), and
593-
<literal>\</literal><replaceable>digits</replaceable> (octal).
592+
<literal>\n</literal> (new line), <literal>\t</literal> (tab),
593+
<literal>\</literal><replaceable>digits</replaceable> (octal),
594+
<literal>\x</literal><replaceable>digits</replaceable> (hexadecimal).
594595
</para>
595596

596597
<para>

src/bin/psql/psqlscan.l

Lines changed: 12 additions & 2 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.12 2005/05/30 16:48:47 momjian Exp $
36+
* $PostgreSQL: pgsql/src/bin/psql/psqlscan.l,v 1.13 2005/06/02 01:23:48 momjian Exp $
3737
*
3838
*-------------------------------------------------------------------------
3939
*/
@@ -250,8 +250,9 @@ xnstart [nN]{quote}
250250
xqstart {quote}
251251
xqdouble {quote}{quote}
252252
xqinside [^\\']+
253-
xqescape [\\][^0-7]
253+
xqescape [\\][^0-7x]
254254
xqoctesc [\\][0-7]{1,3}
255+
xqhexesc [\\]x[0-9A-Fa-f]{1,2}
255256
256257
/* $foo$ style quotes ("dollar quoting")
257258
* The quoted string starts with $foo$ where "foo" is an optional string
@@ -467,6 +468,9 @@ other .
467468
<xq>{xqoctesc} {
468469
ECHO;
469470
}
471+
<xq>{xqhexesc} {
472+
ECHO;
473+
}
470474
<xq>{quotecontinue} {
471475
ECHO;
472476
}
@@ -855,6 +859,12 @@ other .
855859
(char) strtol(yytext + 1, NULL, 8));
856860
}
857861

862+
{xqhexesc} {
863+
/* hex case */
864+
appendPQExpBufferChar(output_buf,
865+
(char) strtol(yytext + 2, NULL, 16));
866+
}
867+
858868
"\\". { emit(yytext + 1, 1); }
859869

860870
{other}|\n { ECHO; }

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