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

Commit5fdefbc

Browse files
committed
From: t-ishii@sra.co.jpAs mentioned around line 1153 in backend/commands/copy.c, the methodof array checking is not perfect.test=> create table t1 (i text);test=> insert into t1 values('{\\.}');INSERT 2645600 1test=> select * from t1;i-----{\\.}(2 rows)test=> copy t1 to '/tmp/aaa';test=> copy t1 from '/tmp/aaa';ERROR: CopyReadAttribute - end of record marker corruptedCopy cannot read data produced by itself!
1 parent7a7770e commit5fdefbc

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

‎src/backend/commands/copy.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.46 1998/06/15 19:28:13 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.47 1998/06/19 11:40:46 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -61,7 +61,7 @@ static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline
6161
staticchar*CopyReadAttribute(FILE*fp,bool*isnull,char*delim);
6262

6363
#endif
64-
staticvoidCopyAttributeOut(FILE*fp,char*string,char*delim);
64+
staticvoidCopyAttributeOut(FILE*fp,char*string,char*delim,intis_array);
6565
staticintCountTuples(Relationrelation);
6666

6767
externFILE*Pfout,
@@ -277,7 +277,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
277277
{
278278
string= (char*) (*fmgr_faddr(&out_functions[i]))
279279
(value,elements[i],typmod[i]);
280-
CopyAttributeOut(fp,string,delim);
280+
CopyAttributeOut(fp,string,delim,attr[i]->attnelems);
281281
pfree(string);
282282
}
283283
else
@@ -554,7 +554,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
554554
{
555555
loaded_oid=oidin(string);
556556
if (loaded_oid<BootstrapObjectIdData)
557-
elog(ERROR,"COPY TEXT: Invalid Oid");
557+
elog(ERROR,"COPY TEXT: Invalid Oid. line: %d",lineno);
558558
}
559559
}
560560
for (i=0;i<attr_count&& !done;i++)
@@ -603,7 +603,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
603603
{
604604
fread(&loaded_oid,sizeof(int32),1,fp);
605605
if (loaded_oid<BootstrapObjectIdData)
606-
elog(ERROR,"COPY BINARY: Invalid Oid");
606+
elog(ERROR,"COPY BINARY: Invalid Oid line: %d",lineno);
607607
}
608608
fread(&null_ct,sizeof(int32),1,fp);
609609
if (null_ct>0)
@@ -642,7 +642,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
642642
ptr+=sizeof(int32);
643643
break;
644644
default:
645-
elog(ERROR,"COPY BINARY: impossible size!");
645+
elog(ERROR,"COPY BINARY: impossible size! line: %d",lineno);
646646
break;
647647
}
648648
}
@@ -1099,7 +1099,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
10991099
case'.':
11001100
c=getc(fp);
11011101
if (c!='\n')
1102-
elog(ERROR,"CopyReadAttribute - end of record marker corrupted");
1102+
elog(ERROR,"CopyReadAttribute - end of record marker corrupted. line: %d",lineno);
11031103
return (NULL);
11041104
break;
11051105
}
@@ -1115,22 +1115,16 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
11151115
if (!done)
11161116
attribute[i++]=c;
11171117
if (i==EXT_ATTLEN-1)
1118-
elog(ERROR,"CopyReadAttribute - attribute length too long");
1118+
elog(ERROR,"CopyReadAttribute - attribute length too long. line: %d",lineno);
11191119
}
11201120
attribute[i]='\0';
11211121
return (&attribute[0]);
11221122
}
11231123

11241124
staticvoid
1125-
CopyAttributeOut(FILE*fp,char*string,char*delim)
1125+
CopyAttributeOut(FILE*fp,char*string,char*delim,intis_array)
11261126
{
11271127
charc;
1128-
intis_array= false;
1129-
intlen=strlen(string);
1130-
1131-
/* XXX - This is a kludge, we should check the data type */
1132-
if (len&& (string[0]=='{')&& (string[len-1]=='}'))
1133-
is_array= true;
11341128

11351129
for (; (c=*string)!='\0';string++)
11361130
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp