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

Commit969cc16

Browse files
committed
Enforce restriction that COPY DELIMITERS string must be exactly one
character; replace strchr() search with simple comparison to speed upCOPY IN. Per discussion in pghackers.
1 parenta0734d1 commit969cc16

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

‎doc/src/sgml/ref/copy.sgml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v 1.24 2001/09/13 15:55:24 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v 1.25 2001/12/04 21:19:57 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -227,9 +227,6 @@ ERROR: <replaceable>reason</replaceable>
227227
character with the keyword phrase USING DELIMITERS. Characters
228228
in data fields which happen to match the delimiter character will
229229
be backslash quoted.
230-
Note that the delimiter is always a single character.
231-
If multiple characters are specified in the delimiter string,
232-
only the first character is used.
233230
</para>
234231

235232
<para>

‎src/backend/commands/copy.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.143 2001/12/04 19:40:16 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.144 2001/12/0421:19:57 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -288,6 +288,12 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
288288
if (pipe&&binary)
289289
elog(ERROR,"COPY BINARY is not supported to stdout or from stdin");
290290

291+
/*
292+
* Presently, only single-character delimiter strings are supported.
293+
*/
294+
if (strlen(delim)!=1)
295+
elog(ERROR,"COPY delimiter must be a single character");
296+
291297
/*
292298
* Set up variables to avoid per-attribute overhead.
293299
*/
@@ -1009,7 +1015,7 @@ CopyReadNewline(FILE *fp, int *newline)
10091015
* Note that the caller should not pfree the string!
10101016
*
10111017
* *isnull is set true if a null attribute, else false.
1012-
* delim is the stringof acceptable delimiter characters(s).
1018+
* delim is thecolumn delimiterstring(currently always 1 character).
10131019
* *newline remembers whether we've seen a newline ending this tuple.
10141020
* null_print says how NULL values are represented
10151021
*/
@@ -1018,6 +1024,7 @@ static char *
10181024
CopyReadAttribute(FILE*fp,bool*isnull,char*delim,int*newline,char*null_print)
10191025
{
10201026
intc;
1027+
intdelimc=delim[0];
10211028

10221029
#ifdefMULTIBYTE
10231030
intmblen;
@@ -1051,7 +1058,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
10511058
*newline=1;
10521059
break;
10531060
}
1054-
if (strchr(delim,c))
1061+
if (c==delimc)
10551062
break;
10561063
if (c=='\\')
10571064
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp