Skip to content

Commit 8e621c1

Browse files
committed
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
1 parent 7c335b7 commit 8e621c1

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

src/backend/commands/copyto.c

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -608,52 +608,6 @@ BeginCopyTo(ParseState *pstate,
608608
}
609609
}
610610

611-
/* Convert FORCE_NOT_NULL name list to per-column flags, check validity */
612-
cstate->opts.force_notnull_flags = (bool *) palloc0(num_phys_attrs * sizeof(bool));
613-
if (cstate->opts.force_notnull)
614-
{
615-
List *attnums;
616-
ListCell *cur;
617-
618-
attnums = CopyGetAttnums(tupDesc, cstate->rel, cstate->opts.force_notnull);
619-
620-
foreach(cur, attnums)
621-
{
622-
int attnum = lfirst_int(cur);
623-
Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
624-
625-
if (!list_member_int(cstate->attnumlist, attnum))
626-
ereport(ERROR,
627-
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
628-
errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY",
629-
NameStr(attr->attname))));
630-
cstate->opts.force_notnull_flags[attnum - 1] = true;
631-
}
632-
}
633-
634-
/* Convert FORCE_NULL name list to per-column flags, check validity */
635-
cstate->opts.force_null_flags = (bool *) palloc0(num_phys_attrs * sizeof(bool));
636-
if (cstate->opts.force_null)
637-
{
638-
List *attnums;
639-
ListCell *cur;
640-
641-
attnums = CopyGetAttnums(tupDesc, cstate->rel, cstate->opts.force_null);
642-
643-
foreach(cur, attnums)
644-
{
645-
int attnum = lfirst_int(cur);
646-
Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1);
647-
648-
if (!list_member_int(cstate->attnumlist, attnum))
649-
ereport(ERROR,
650-
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
651-
errmsg("FORCE_NULL column \"%s\" not referenced by COPY",
652-
NameStr(attr->attname))));
653-
cstate->opts.force_null_flags[attnum - 1] = true;
654-
}
655-
}
656-
657611
/* Use client encoding when ENCODING option is not specified. */
658612
if (cstate->opts.file_encoding < 0)
659613
cstate->file_encoding = pg_get_client_encoding();

0 commit comments

Comments
 (0)