diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2023-09-30 12:34:41 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2023-09-30 12:34:41 -0400 |
commit | f6d4c9cf162b70f2837fb6c2a83e80a3f3410695 (patch) | |
tree | 23d62216e9b51f67ea5aff1bad95f5434b2bcd1c /src/backend/commands/copy.c | |
parent | c181f2e2bcecc2704c6461a0543894a38d7143df (diff) | |
download | postgresql-f6d4c9cf162b70f2837fb6c2a83e80a3f3410695.tar.gz postgresql-f6d4c9cf162b70f2837fb6c2a83e80a3f3410695.zip |
Provide FORCE_NULL * and FORCE_NOT_NULL * options for COPY FROM
These options already exist, but you need to specify a column list for
them, which can be cumbersome. We already have the possibility of all
columns for FORCE QUOTE, so this is simply extending that facility to
FORCE_NULL and FORCE_NOT_NULL.
Author: Zhang Mingli
Reviewed-By: Richard Guo, Kyatoro Horiguchi, Michael Paquier.
Discussion: https://postgr.es/m/CACJufxEnVqzOFtqhexF2+AwOKFrV8zHOY3y=p+gPK6eB14pn_w@mail.gmail.com
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r-- | src/backend/commands/copy.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index f14fae33083..c5d7d78645a 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -512,9 +512,11 @@ ProcessCopyOptions(ParseState *pstate, } else if (strcmp(defel->defname, "force_not_null") == 0) { - if (opts_out->force_notnull) + if (opts_out->force_notnull || opts_out->force_notnull_all) errorConflictingDefElem(defel, pstate); - if (defel->arg && IsA(defel->arg, List)) + if (defel->arg && IsA(defel->arg, A_Star)) + opts_out->force_notnull_all = true; + else if (defel->arg && IsA(defel->arg, List)) opts_out->force_notnull = castNode(List, defel->arg); else ereport(ERROR, @@ -525,9 +527,11 @@ ProcessCopyOptions(ParseState *pstate, } else if (strcmp(defel->defname, "force_null") == 0) { - if (opts_out->force_null) + if (opts_out->force_null || opts_out->force_null_all) errorConflictingDefElem(defel, pstate); - if (defel->arg && IsA(defel->arg, List)) + if (defel->arg && IsA(defel->arg, A_Star)) + opts_out->force_null_all = true; + else if (defel->arg && IsA(defel->arg, List)) opts_out->force_null = castNode(List, defel->arg); else ereport(ERROR, |