mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Remove code handling FORCE_NULL and FORCE_NOT_NULL for COPY TO
These two options are only available with COPY FROM, so the extra logic in charge of checking the validity of the attributes given has no purpose. Author: Zhang Mingli Reviewed-by: Richard Guo, Kyotaro Horiguchi Discussion: https://postgr.es/m/F28F0B5A-766F-4D33-BF44-43B3A052D833@gmail.com
This commit is contained in:
parent
7c335b7a20
commit
8e621c10c7
@ -608,52 +608,6 @@ BeginCopyTo(ParseState *pstate,
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert FORCE_NOT_NULL name list to per-column flags, check validity */
|
||||
cstate->opts.force_notnull_flags = (bool *) palloc0(num_phys_attrs * sizeof(bool));
|
||||
if (cstate->opts.force_notnull)
|
||||
{
|
||||
List *attnums;
|
||||
ListCell *cur;
|
||||
|
||||
attnums = CopyGetAttnums(tupDesc, cstate->rel, cstate->opts.force_notnull);
|
||||
|
||||
foreach(cur, attnums)
|
||||
{
|
||||
int attnum = lfirst_int(cur);
|
||||
Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
|
||||
|
||||
if (!list_member_int(cstate->attnumlist, attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY",
|
||||
NameStr(attr->attname))));
|
||||
cstate->opts.force_notnull_flags[attnum - 1] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert FORCE_NULL name list to per-column flags, check validity */
|
||||
cstate->opts.force_null_flags = (bool *) palloc0(num_phys_attrs * sizeof(bool));
|
||||
if (cstate->opts.force_null)
|
||||
{
|
||||
List *attnums;
|
||||
ListCell *cur;
|
||||
|
||||
attnums = CopyGetAttnums(tupDesc, cstate->rel, cstate->opts.force_null);
|
||||
|
||||
foreach(cur, attnums)
|
||||
{
|
||||
int attnum = lfirst_int(cur);
|
||||
Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
|
||||
|
||||
if (!list_member_int(cstate->attnumlist, attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("FORCE_NULL column \"%s\" not referenced by COPY",
|
||||
NameStr(attr->attname))));
|
||||
cstate->opts.force_null_flags[attnum - 1] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Use client encoding when ENCODING option is not specified. */
|
||||
if (cstate->opts.file_encoding < 0)
|
||||
cstate->file_encoding = pg_get_client_encoding();
|
||||
|
Loading…
Reference in New Issue
Block a user