Skip to content

Commit c7d1a8d

Browse files
committed
Fix some corner-case bugs in _sendSQLLine's parsing of SQL commands
> found in a pg_dump archive. It had problems with dollar-quote tags broken across bufferload boundaries (this may explain bug report from Rod Taylor), also with dollar-quote literals of the form $a$a$..., and was also confused about the rules for backslash in double quoted identifiers (ie, they're not special). Also put in placeholder support for E'...' literals --- this will need more work later.
1 parent e1a7d1b commit c7d1a8d

File tree

2 files changed

+186
-212
lines changed

2 files changed

+186
-212
lines changed

src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.66 2005/07/27 12:44:10 neilc Exp $
20+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.67 2005/09/11 04:10:25 tgl Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -136,22 +136,24 @@ typedef struct _outputContext
136136

137137
typedef enum
138138
{
139-
SQL_SCAN = 0,
140-
SQL_IN_SQL_COMMENT,
141-
SQL_IN_EXT_COMMENT,
142-
SQL_IN_QUOTE,
143-
SQL_IN_DOLLARTAG,
144-
SQL_IN_DOLLARQUOTE
139+
SQL_SCAN = 0, /* normal */
140+
SQL_IN_SQL_COMMENT, /* -- comment */
141+
SQL_IN_EXT_COMMENT, /* slash-star comment */
142+
SQL_IN_SINGLE_QUOTE, /* '...' literal */
143+
SQL_IN_E_QUOTE, /* E'...' literal */
144+
SQL_IN_DOUBLE_QUOTE, /* "..." identifier */
145+
SQL_IN_DOLLAR_TAG, /* possible dollar-quote starting tag */
146+
SQL_IN_DOLLAR_QUOTE /* body of dollar quote */
145147
} sqlparseState;
146148

147149
typedef struct
148150
{
149-
int backSlash;
150-
sqlparseState state;
151-
char lastChar;
152-
char quoteChar;
153-
int braceDepth;
154-
PQExpBuffer tagBuf;
151+
sqlparseState state; /* see above */
152+
char lastChar; /* preceding char, or '\0' initially */
153+
bool backSlash; /* next char is backslash quoted? */
154+
int braceDepth; /* parenthesis nesting depth */
155+
PQExpBuffer tagBuf; /* dollar quote tag (NULL if not created) */
156+
int minTagEndPos; /* first possible end position of $-quote */
155157
} sqlparseInfo;
156158

157159
typedef enum

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