Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb7bd06

Browse files
committed
Prevent COPY from using newline or carriage return as delimiter or null.
Disallow backslash as the delimiter in non-CVS mode.David Fetter
1 parent890707a commiteb7bd06

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎src/backend/commands/copy.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.257 2005/12/28 03:25:32 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.258 2006/02/03 12:41:07 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -856,6 +856,25 @@ DoCopy(const CopyStmt *stmt)
856856
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
857857
errmsg("COPY delimiter must be a single character")));
858858

859+
/* Disallow end-of-line characters */
860+
if (strchr(cstate->delim,'\r')!=NULL||
861+
strchr(cstate->delim,'\n')!=NULL)
862+
ereport(ERROR,
863+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
864+
errmsg("COPY delimiter cannot be newline or carriage return")));
865+
866+
if (strchr(cstate->null_print,'\r')!=NULL||
867+
strchr(cstate->null_print,'\n')!=NULL)
868+
ereport(ERROR,
869+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
870+
errmsg("COPY null cannot use newline or carriage return")));
871+
872+
/* Disallow backslash in non-CSV mode */
873+
if (!cstate->csv_mode&&strchr(cstate->delim,'\\')!=NULL)
874+
ereport(ERROR,
875+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
876+
errmsg("COPY delimiter cannot be backslash")));
877+
859878
/* Check header */
860879
if (!cstate->csv_mode&&cstate->header_line)
861880
ereport(ERROR,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp