mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Restore proper behavior for escaped quotes and for escaped literals
like newline inside quoted strings.
This commit is contained in:
parent
c7dbd366ba
commit
53ad0aa262
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.21 1997/09/13 03:12:55 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.22 1997/09/24 17:48:25 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -91,8 +91,9 @@ quote '
|
|||||||
xqstart {quote}
|
xqstart {quote}
|
||||||
xqstop {quote}
|
xqstop {quote}
|
||||||
xqdouble {quote}{quote}
|
xqdouble {quote}{quote}
|
||||||
xqinside [^\']*
|
xqinside [^\\']*
|
||||||
xqliteral [\\].
|
xqembedded "\\'"
|
||||||
|
xqliteral [\\](.|\n)
|
||||||
|
|
||||||
xcline [\/][\*].*[\*][\/]{space}*\n*
|
xcline [\/][\*].*[\*][\/]{space}*\n*
|
||||||
xcstart [\/][\*]{op_and_self}*
|
xcstart [\/][\*]{op_and_self}*
|
||||||
@ -132,6 +133,14 @@ other .
|
|||||||
/* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION.
|
/* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION.
|
||||||
* AT&T lex does not properly handle C-style comments in this second lex block.
|
* AT&T lex does not properly handle C-style comments in this second lex block.
|
||||||
* So, put comments here. tgl - 1997-09-08
|
* So, put comments here. tgl - 1997-09-08
|
||||||
|
*
|
||||||
|
* Quoted strings must allow some special characters such as single-quote
|
||||||
|
* and newline.
|
||||||
|
* Embedded single-quotes are implemented both in the SQL/92-standard
|
||||||
|
* style of two adjacent single quotes "''" and in the Postgres/Java style
|
||||||
|
* of escaped-quote "\'".
|
||||||
|
* Other embedded escaped characters are matched explicitly and the leading
|
||||||
|
* backslash is dropped from the string. - thomas 1997-09-24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@ -163,6 +172,14 @@ other .
|
|||||||
memcpy(literal+llen, yytext, yyleng+1);
|
memcpy(literal+llen, yytext, yyleng+1);
|
||||||
llen += yyleng;
|
llen += yyleng;
|
||||||
}
|
}
|
||||||
|
<xq>{xqembedded} {
|
||||||
|
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
|
||||||
|
elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
||||||
|
memcpy(literal+llen, yytext, yyleng+1);
|
||||||
|
*(literal+llen) = '\'';
|
||||||
|
llen += yyleng;
|
||||||
|
}
|
||||||
|
|
||||||
<xq>{xqliteral} {
|
<xq>{xqliteral} {
|
||||||
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
|
if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
|
||||||
elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user