git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 890707a)
Prevent COPY from using newline or carriage return as delimiter or null.
Fri, 3 Feb 2006 12:41:07 +0000 (12:41 +0000)
Fri, 3 Feb 2006 12:41:07 +0000 (12:41 +0000)
Disallow backslash as the delimiter in non-CVS mode.

David Fetter


diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index f97aafc2034bb24b420b067528995916f0b6ac47..af3df4a689987810528e6753a4ffae9ced61448f 100644 (file)
--- 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.257 2005年12月28日 03:25:32 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.258 2006年02月03日 12:41:07 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -856,6 +856,25 @@ DoCopy(const CopyStmt *stmt)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("COPY delimiter must be a single character")));
+ /* Disallow end-of-line characters */
+ if (strchr(cstate->delim, '\r') != NULL ||
+ strchr(cstate->delim, '\n') != NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY delimiter cannot be newline or carriage return")));
+
+ if (strchr(cstate->null_print, '\r') != NULL ||
+ strchr(cstate->null_print, '\n') != NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY null cannot use newline or carriage return")));
+
+ /* Disallow backslash in non-CSV mode */
+ if (!cstate->csv_mode && strchr(cstate->delim, '\\') != NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("COPY delimiter cannot be backslash")));
+
/* Check header */
if (!cstate->csv_mode && cstate->header_line)
ereport(ERROR,
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /