naisila/add_column
naisila 2022-10-04 14:19:53 +03:00
parent 580ab012bf
commit c85a7cdd25
2 changed files with 2 additions and 18 deletions

View File

@ -962,6 +962,8 @@ PreprocessAlterTableStmt(Node *node, const char *alterTableCommand,
}
else if (alterTableType == AT_AddColumn)
{
deparseAT = true;
/*
* TODO: This code path is nothing beneficial since we do not
* support ALTER TABLE %s ADD COLUMN %s [constraint] for foreign keys.
@ -1010,7 +1012,6 @@ PreprocessAlterTableStmt(Node *node, const char *alterTableCommand,
if (contain_nextval_expression_walker(expr, NULL))
{
deparseAT = true;
useInitialDDLCommandString = false;
/* the new column definition will have no constraint */
@ -1041,8 +1042,6 @@ PreprocessAlterTableStmt(Node *node, const char *alterTableCommand,
strcmp(typeName, "bigserial") == 0 ||
strcmp(typeName, "serial8") == 0)
{
deparseAT = true;
ColumnDef *newColDef = copyObject(columnDefinition);
newColDef->is_not_null = false;

View File

@ -141,15 +141,6 @@ AppendAlterTableCmdAddColumn(StringInfo buf, AlterTableCmd *alterTableCmd)
ColumnDef *columnDefinition = (ColumnDef *) alterTableCmd->def;
/*
* the way we use the deparser now, constraints are always NULL
* adding this check for ColumnDef consistency
*/
if (columnDefinition->constraints != NULL)
{
ereport(ERROR, (errmsg("Constraints are not supported for AT_AddColumn")));
}
if (columnDefinition->colname)
{
appendStringInfo(buf, "%s ", quote_identifier(columnDefinition->colname));
@ -166,12 +157,6 @@ AppendAlterTableCmdAddColumn(StringInfo buf, AlterTableCmd *alterTableCmd)
appendStringInfoString(buf, " NOT NULL");
}
/*
* the way we use the deparser now, collation is never used
* since the data type of columns that use sequences for default
* are only int,smallint and bigint (never text, varchar, char)
* Adding this part only for ColumnDef consistency
*/
Oid collationOid = GetColumnDefCollation(NULL, columnDefinition, typeOid);
if (OidIsValid(collationOid))
{