aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-11-02 10:15:19 +0900
committerMichael Paquier <michael@paquier.xyz>2022-11-02 10:15:19 +0900
commit8e621c10c73a93e1078ad85fe70fb4478537a798 (patch)
treead48ed95dbbd88dbc2a42aea64e4a852410f39b0
parent7c335b7a20278079e796d62122ef4b821c7fcdf5 (diff)
downloadpostgresql-8e621c10c73a93e1078ad85fe70fb4478537a798.tar.gz
postgresql-8e621c10c73a93e1078ad85fe70fb4478537a798.zip
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
-rw-r--r--src/backend/commands/copyto.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index 2527e660598..f26cc0d162f 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();