Commit c7d1a8d4 authored by Tom Lane's avatar Tom Lane

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.
parent e1a7d1b9
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.66 2005/07/27 12:44:10 neilc Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.67 2005/09/11 04:10:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -136,22 +136,24 @@ typedef struct _outputContext ...@@ -136,22 +136,24 @@ typedef struct _outputContext
typedef enum typedef enum
{ {
SQL_SCAN = 0, SQL_SCAN = 0, /* normal */
SQL_IN_SQL_COMMENT, SQL_IN_SQL_COMMENT, /* -- comment */
SQL_IN_EXT_COMMENT, SQL_IN_EXT_COMMENT, /* slash-star comment */
SQL_IN_QUOTE, SQL_IN_SINGLE_QUOTE, /* '...' literal */
SQL_IN_DOLLARTAG, SQL_IN_E_QUOTE, /* E'...' literal */
SQL_IN_DOLLARQUOTE SQL_IN_DOUBLE_QUOTE, /* "..." identifier */
SQL_IN_DOLLAR_TAG, /* possible dollar-quote starting tag */
SQL_IN_DOLLAR_QUOTE /* body of dollar quote */
} sqlparseState; } sqlparseState;
typedef struct typedef struct
{ {
int backSlash; sqlparseState state; /* see above */
sqlparseState state; char lastChar; /* preceding char, or '\0' initially */
char lastChar; bool backSlash; /* next char is backslash quoted? */
char quoteChar; int braceDepth; /* parenthesis nesting depth */
int braceDepth; PQExpBuffer tagBuf; /* dollar quote tag (NULL if not created) */
PQExpBuffer tagBuf; int minTagEndPos; /* first possible end position of $-quote */
} sqlparseInfo; } sqlparseInfo;
typedef enum typedef enum
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment