Skip to content

Commit df40234

Browse files
author
Thomas G. Lockhart
committed
Support SQL99 embedded double-quote syntax for quoted identifiers.
Allow this in the parser and in pg_dump, but it is probably not enough for a complete solution. Better to have the feature started then never here.
1 parent c3e2a95 commit df40234

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/backend/parser/scan.l

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.73 2000/07/14 15:43:32 thomas Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.74 2000/08/06 17:50:38 thomas Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -136,6 +136,7 @@ xqcat {quote}{whitespace_with_newline}{quote}
136136
dquote \"
137137
xdstart {dquote}
138138
xdstop {dquote}
139+
xddouble {dquote}{dquote}
139140
xdinside [^"]+
140141

141142
/* C-style comments
@@ -351,6 +352,9 @@ other .
351352
yylval.str = pstrdup(literalbuf);
352353
return IDENT;
353354
}
355+
<xd>{xddouble} {
356+
addlit(yytext, yyleng-1);
357+
}
354358
<xd>{xdinside} {
355359
addlit(yytext, yyleng);
356360
}

src/bin/pg_dump/common.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.44 2000/07/04 14:25:27 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.45 2000/08/06 17:50:48 thomas Exp $
1212
*
1313
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1414
*
@@ -517,8 +517,10 @@ fmtId(const char *rawid, bool force_quotes)
517517

518518
if (!force_quotes)
519519
{
520+
/* do a quick check on the first character... */
520521
if (!islower((int) *rawid))
521522
force_quotes = true;
523+
/* otherwise check the entire string */
522524
else
523525
for (cp = rawid; *cp; cp++)
524526
{
@@ -541,8 +543,15 @@ fmtId(const char *rawid, bool force_quotes)
541543
appendPQExpBufferChar(id_return, '\"');
542544
for (cp = rawid; *cp; cp++)
543545
{
546+
/* Did we find a double-quote in the string?
547+
* Then make this a double double-quote per SQL99.
548+
* Before, we put in a backslash/double-quote pair.
549+
* - thomas 2000-08-05 */
544550
if (*cp == '\"')
545-
appendPQExpBufferChar(id_return, '\\');
551+
{
552+
appendPQExpBufferChar(id_return, '\"');
553+
appendPQExpBufferChar(id_return, '\"');
554+
}
546555
appendPQExpBufferChar(id_return, *cp);
547556
}
548557
appendPQExpBufferChar(id_return, '\"');

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