aboutsummaryrefslogtreecommitdiff
path: root/src/include/commands/copyfrom_internal.h
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2023-03-13 10:01:56 -0400
committerAndrew Dunstan <andrew@dunslane.net>2023-03-13 10:01:56 -0400
commit9f8377f7a27910bf0f35bf5169a8046731948a79 (patch)
treee0a19449e4cebb8923dfcd1bba95a1d3363faa32 /src/include/commands/copyfrom_internal.h
parent7b14e20b12cc8358cad9bdd05dd6b7de7f73c431 (diff)
downloadpostgresql-9f8377f7a27910bf0f35bf5169a8046731948a79.tar.gz
postgresql-9f8377f7a27910bf0f35bf5169a8046731948a79.zip
Add a DEFAULT option to COPY FROM
This allows for a string which if an input field matches causes the column's default value to be inserted. The advantage of this is that the default can be inserted in some rows and not others, for which non-default data is available. The file_fdw extension is also modified to take allow use of this option. Israel Barth Rubio Discussion: https://postgr.es/m/CAO_rXXAcqesk6DsvioOZ5zmeEmpUN5ktZf-9=9yu+DTr0Xr8Uw@mail.gmail.com
Diffstat (limited to 'src/include/commands/copyfrom_internal.h')
-rw-r--r--src/include/commands/copyfrom_internal.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/include/commands/copyfrom_internal.h b/src/include/commands/copyfrom_internal.h
index 7b1c4327bd3..ac2c16f8b86 100644
--- a/src/include/commands/copyfrom_internal.h
+++ b/src/include/commands/copyfrom_internal.h
@@ -44,8 +44,7 @@ typedef enum EolType
*/
typedef enum CopyInsertMethod
{
- CIM_SINGLE, /* use table_tuple_insert or
- * ExecForeignInsert */
+ CIM_SINGLE, /* use table_tuple_insert or ExecForeignInsert */
CIM_MULTI, /* always use table_multi_insert or
* ExecForeignBatchInsert */
CIM_MULTI_CONDITIONAL /* use table_multi_insert or
@@ -91,11 +90,16 @@ typedef struct CopyFromStateData
*/
MemoryContext copycontext; /* per-copy execution context */
- AttrNumber num_defaults;
+ AttrNumber num_defaults; /* count of att that are missing and have
+ * default value */
FmgrInfo *in_functions; /* array of input functions for each attrs */
Oid *typioparams; /* array of element types for in_functions */
- int *defmap; /* array of default att numbers */
- ExprState **defexprs; /* array of default att expressions */
+ int *defmap; /* array of default att numbers related to
+ * missing att */
+ ExprState **defexprs; /* array of default att expressions for all
+ * att */
+ bool *defaults; /* if DEFAULT marker was found for
+ * corresponding att */
bool volatile_defexprs; /* is any of defexprs volatile? */
List *range_table; /* single element list of RangeTblEntry */
List *rteperminfos; /* single element list of RTEPermissionInfo */