1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-19 15:49:24 +03:00

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
This commit is contained in:
Andrew Dunstan
2023-03-13 10:01:56 -04:00
parent 7b14e20b12
commit 9f8377f7a2
15 changed files with 447 additions and 24 deletions

View File

@@ -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 */