aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-04-06 13:21:33 +0000
committerBruce Momjian <bruce@momjian.us>2004-04-06 13:21:33 +0000
commit4a72dbc1aee1890f2952070ba125796ab0309367 (patch)
tree721277a412fc7d37d09f958740a59e498518d9fa /src
parent5e9f4d26bce4082033dfc5c3c84e0011e7714f1d (diff)
downloadpostgresql-4a72dbc1aee1890f2952070ba125796ab0309367.tar.gz
postgresql-4a72dbc1aee1890f2952070ba125796ab0309367.zip
The attached applied patch throws an error if the delimiter appears in
the COPY NULL string: test=> copy pg_language to '/tmp/x' with delimiter '|'; COPY test=> copy pg_language to '/tmp/x' with delimiter '|' null '|x'; ERROR: COPY delimiter must not appear in the NULL specification test=> copy pg_language from '/tmp/x' with delimiter '|' null '|x'; ERROR: COPY delimiter must not appear in the NULL specification It also throws an error if it conflicts with the default NULL string: test=> copy pg_language to '/tmp/x' with delimiter '\\'; ERROR: COPY delimiter must not appear in the NULL specification test=> copy pg_language to '/tmp/x' with delimiter '\\' NULL 'x'; COPY
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/copy.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 7af8200e063..045b40ec1de 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.218 2004/02/10 01:55:24 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.219 2004/04/06 13:21:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -780,6 +780,14 @@ DoCopy(const CopyStmt *stmt)
errmsg("COPY delimiter must be a single character")));
/*
+ * Don't allow the delimiter to appear in the null string.
+ */
+ if (strchr(null_print, delim[0]) != NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("COPY delimiter must not appear in the NULL specification")));
+
+ /*
* Don't allow COPY w/ OIDs to or from a table without them
*/
if (oids && !rel->rd_rel->relhasoids)