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

Commit8c3b52e

Browse files
committed
Allow COPY WITH OIDS to system OID values --- rely on unique indexes to
prevent duplicate OIDs from being added. Clean up redundant errormessages.
1 parenta6acf1a commit8c3b52e

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

‎src/backend/commands/copy.c

Lines changed: 17 additions & 15 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.104 2000/04/12 17:14:58 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.105 2000/04/16 04:27:52 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -118,7 +118,7 @@ CopySendData(void *databuf, int datasize, FILE *fp)
118118
{
119119
fwrite(databuf,datasize,1,fp);
120120
if (ferror(fp))
121-
elog(ERROR,"CopySendData: %s",strerror(errno));
121+
elog(ERROR,"CopySendData: %m");
122122
}
123123
}
124124

@@ -350,18 +350,19 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe,
350350
{
351351
mode_toumask;/* Pre-existing umask value */
352352

353-
oumask=umask((mode_t)022);
354-
355353
if (*filename!='/')
356354
elog(ERROR,"Relative path not allowed for server side"
357355
" COPY command.");
358356

357+
oumask=umask((mode_t)022);
358+
359359
#ifndef__CYGWIN32__
360360
fp=AllocateFile(filename,"w");
361361
#else
362362
fp=AllocateFile(filename,"wb");
363363
#endif
364364
umask(oumask);
365+
365366
if (fp==NULL)
366367
elog(ERROR,"COPY command, running in backend with "
367368
"effective uid %d, could not open file '%s' for "
@@ -626,7 +627,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
626627
intn_indices;
627628
InsertIndexResultindexRes;
628629
TupleDesctupDesc;
629-
Oidloaded_oid;
630+
Oidloaded_oid=InvalidOid;
630631
boolskip_tuple= false;
631632

632633
tupDesc=RelationGetDescr(rel);
@@ -775,11 +776,12 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
775776
CancelQuery();
776777
}
777778

779+
lineno++;
780+
778781
if (!binary)
779782
{
780783
intnewline=0;
781784

782-
lineno++;
783785
if (oids)
784786
{
785787
string=CopyReadAttribute(fp,&isnull,delim,&newline,null_print);
@@ -788,8 +790,8 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
788790
else
789791
{
790792
loaded_oid=oidin(string);
791-
if (loaded_oid<BootstrapObjectIdData)
792-
elog(ERROR,"COPY TEXT: Invalid Oid. line: %d",lineno);
793+
if (loaded_oid==InvalidOid)
794+
elog(ERROR,"COPY TEXT: Invalid Oid");
793795
}
794796
}
795797
for (i=0;i<attr_count&& !done;i++)
@@ -822,7 +824,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
822824
*/
823825
if (!PointerIsValid(values[i])&&
824826
!(rel->rd_att->attrs[i]->attbyval))
825-
elog(ERROR,"copy from line %d: Bad file format",lineno);
827+
elog(ERROR,"COPY: Bad file format");
826828
}
827829
}
828830
if (!done)
@@ -838,8 +840,8 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
838840
if (oids)
839841
{
840842
CopyGetData(&loaded_oid,sizeof(int32),fp);
841-
if (loaded_oid<BootstrapObjectIdData)
842-
elog(ERROR,"COPY BINARY: Invalid Oid line: %d",lineno);
843+
if (loaded_oid==InvalidOid)
844+
elog(ERROR,"COPY BINARY: Invalid Oid");
843845
}
844846
CopyGetData(&null_ct,sizeof(int32),fp);
845847
if (null_ct>0)
@@ -878,7 +880,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
878880
ptr+=sizeof(int32);
879881
break;
880882
default:
881-
elog(ERROR,"COPY BINARY: impossible size! line: %d",lineno);
883+
elog(ERROR,"COPY BINARY: impossible size");
882884
break;
883885
}
884886
}
@@ -1044,7 +1046,7 @@ GetTypeElement(Oid type)
10441046
if (HeapTupleIsValid(typeTuple))
10451047
return (int) ((Form_pg_type)GETSTRUCT(typeTuple))->typelem;
10461048

1047-
elog(ERROR,"GetOutputFunction: Cache lookup of type %d failed",type);
1049+
elog(ERROR,"GetOutputFunction: Cache lookup of type %u failed",type);
10481050
returnInvalidOid;
10491051
}
10501052

@@ -1172,7 +1174,7 @@ CopyReadNewline(FILE *fp, int *newline)
11721174
{
11731175
if (!*newline)
11741176
{
1175-
elog(NOTICE,"CopyReadNewline:line %d -extra fields ignored",lineno);
1177+
elog(NOTICE,"CopyReadNewline: extra fields ignored");
11761178
while (!CopyGetEof(fp)&& (CopyGetChar(fp)!='\n'));
11771179
}
11781180
*newline=0;
@@ -1307,7 +1309,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
13071309
case'.':
13081310
c=CopyGetChar(fp);
13091311
if (c!='\n')
1310-
elog(ERROR,"CopyReadAttribute -end of record marker corrupted. line: %d",lineno);
1312+
elog(ERROR,"CopyReadAttribute:end of record marker corrupted");
13111313
gotoendOfFile;
13121314
}
13131315
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp