diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2023-03-15 17:16:57 -0400 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2023-03-15 17:20:42 -0400 |
commit | b85e91023bf3fd5b4dbd35dc3eddbf0dc291c8ad (patch) | |
tree | 9346f968ba334a4dc7bfa176d42f86c944d1abf1 | |
parent | 483bdb2afec9e33ff05fd48a00e2656e30e714b7 (diff) | |
download | postgresql-b85e91023bf3fd5b4dbd35dc3eddbf0dc291c8ad.tar.gz |
Don't try to read default for a non-existent attribute
Oversight in commit 9f8377f7a2 for COPY .. DEFAULT
per report from Alexander Lakhin
-rw-r--r-- | src/backend/commands/copyfromparse.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c index c346486cd3..3853902a16 100644 --- a/src/backend/commands/copyfromparse.c +++ b/src/backend/commands/copyfromparse.c @@ -1683,7 +1683,8 @@ CopyReadAttributesText(CopyFromState cstate) strncmp(start_ptr, cstate->opts.null_print, input_len) == 0) cstate->raw_fields[fieldno] = NULL; /* Check whether raw input matched default marker */ - else if (cstate->opts.default_print && + else if (fieldno < list_length(cstate->attnumlist) && + cstate->opts.default_print && input_len == cstate->opts.default_print_len && strncmp(start_ptr, cstate->opts.default_print, input_len) == 0) { @@ -1897,7 +1898,8 @@ endfield: strncmp(start_ptr, cstate->opts.null_print, input_len) == 0) cstate->raw_fields[fieldno] = NULL; /* Check whether raw input matched default marker */ - else if (cstate->opts.default_print && + else if (fieldno < list_length(cstate->attnumlist) && + cstate->opts.default_print && input_len == cstate->opts.default_print_len && strncmp(start_ptr, cstate->opts.default_print, input_len) == 0) { |