From 8e621c10c73a93e1078ad85fe70fb4478537a798 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 2 Nov 2022 10:15:19 +0900 Subject: [PATCH] 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 --- src/backend/commands/copyto.c | 46 ----------------------------------- 1 file changed, 46 deletions(-) diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c index 2527e66059..f26cc0d162 100644 --- a/src/backend/commands/copyto.c +++ b/src/backend/commands/copyto.c @@ -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();