|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.21 1997/09/13 03:12:55 thomas Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.22 1997/09/24 17:48:25 thomas Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -91,8 +91,9 @@ quote '
|
91 | 91 | xqstart {quote}
|
92 | 92 | xqstop {quote}
|
93 | 93 | xqdouble {quote}{quote}
|
94 |
| -xqinside [^\']* |
95 |
| -xqliteral [\\]. |
| 94 | +xqinside [^\\']* |
| 95 | +xqembedded "\\'" |
| 96 | +xqliteral [\\](.|\n) |
96 | 97 |
|
97 | 98 | xcline [\/][\*].*[\*][\/]{space}*\n*
|
98 | 99 | xcstart [\/][\*]{op_and_self}*
|
@@ -132,6 +133,14 @@ other .
|
132 | 133 | /* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION.
|
133 | 134 | * AT&T lex does not properly handle C-style comments in this second lex block.
|
134 | 135 | * So, put comments here. tgl - 1997-09-08
|
| 136 | + * |
| 137 | + * Quoted strings must allow some special characters such as single-quote |
| 138 | + * and newline. |
| 139 | + * Embedded single-quotes are implemented both in the SQL/92-standard |
| 140 | + * style of two adjacent single quotes "''" and in the Postgres/Java style |
| 141 | + * of escaped-quote "\'". |
| 142 | + * Other embedded escaped characters are matched explicitly and the leading |
| 143 | + * backslash is dropped from the string. - thomas 1997-09-24 |
135 | 144 | */
|
136 | 145 |
|
137 | 146 | %%
|
@@ -163,6 +172,14 @@ other .
|
163 | 172 | memcpy(literal+llen, yytext, yyleng+1);
|
164 | 173 | llen += yyleng;
|
165 | 174 | }
|
| 175 | +<xq>{xqembedded} { |
| 176 | + if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1)) |
| 177 | + elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER); |
| 178 | + memcpy(literal+llen, yytext, yyleng+1); |
| 179 | + *(literal+llen) = '\''; |
| 180 | + llen += yyleng; |
| 181 | + } |
| 182 | + |
166 | 183 | <xq>{xqliteral} {
|
167 | 184 | if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1))
|
168 | 185 | elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER);
|
|
0 commit comments