mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Allow per-column foreign data wrapper options.
Shigeru Hanada, with fairly minor editing by me.
This commit is contained in:
@ -1769,6 +1769,15 @@ alter_table_cmd:
|
||||
def->raw_default = $8;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER FOREIGN TABLE <name> ALTER [COLUMN] <colname> OPTIONS */
|
||||
| ALTER opt_column ColId alter_generic_options
|
||||
{
|
||||
AlterTableCmd *n = makeNode(AlterTableCmd);
|
||||
n->subtype = AT_AlterColumnGenericOptions;
|
||||
n->name = $3;
|
||||
n->def = (Node *) $4;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER TABLE <name> ADD CONSTRAINT ... */
|
||||
| ADD_P TableConstraint
|
||||
{
|
||||
@ -2497,7 +2506,7 @@ TypedTableElement:
|
||||
| TableConstraint { $$ = $1; }
|
||||
;
|
||||
|
||||
columnDef: ColId Typename ColQualList
|
||||
columnDef: ColId Typename create_generic_options ColQualList
|
||||
{
|
||||
ColumnDef *n = makeNode(ColumnDef);
|
||||
n->colname = $1;
|
||||
@ -2510,7 +2519,8 @@ columnDef: ColId Typename ColQualList
|
||||
n->raw_default = NULL;
|
||||
n->cooked_default = NULL;
|
||||
n->collOid = InvalidOid;
|
||||
SplitColQualList($3, &n->constraints, &n->collClause,
|
||||
n->fdwoptions = $3;
|
||||
SplitColQualList($4, &n->constraints, &n->collClause,
|
||||
yyscanner);
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
|
@ -559,6 +559,31 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate ALTER FOREIGN TABLE ALTER COLUMN statement which adds
|
||||
* per-column foreign data wrapper options for this column.
|
||||
*/
|
||||
if (column->fdwoptions != NIL)
|
||||
{
|
||||
AlterTableStmt *stmt;
|
||||
AlterTableCmd *cmd;
|
||||
|
||||
cmd = makeNode(AlterTableCmd);
|
||||
cmd->subtype = AT_AlterColumnGenericOptions;
|
||||
cmd->name = column->colname;
|
||||
cmd->def = (Node *) column->fdwoptions;
|
||||
cmd->behavior = DROP_RESTRICT;
|
||||
cmd->missing_ok = false;
|
||||
|
||||
stmt = makeNode(AlterTableStmt);
|
||||
stmt->relation = cxt->relation;
|
||||
stmt->cmds = NIL;
|
||||
stmt->relkind = OBJECT_FOREIGN_TABLE;
|
||||
stmt->cmds = lappend(stmt->cmds, cmd);
|
||||
|
||||
cxt->alist = lappend(cxt->alist, stmt);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user