mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Add support for ALTER TABLE IF EXISTS ... RENAME CONSTRAINT
Also add regression test. Previously this was documented to work, but didn't.
This commit is contained in:
@@ -2497,9 +2497,16 @@ RenameConstraint(RenameStmt *stmt)
|
||||
{
|
||||
/* lock level taken here should match rename_constraint_internal */
|
||||
relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock,
|
||||
false, false,
|
||||
stmt->missing_ok, false,
|
||||
RangeVarCallbackForRenameAttribute,
|
||||
NULL);
|
||||
if (!OidIsValid(relid))
|
||||
{
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return InvalidObjectAddress;
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -7706,6 +7706,17 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
|
||||
n->relation = $3;
|
||||
n->subname = $6;
|
||||
n->newname = $8;
|
||||
n->missing_ok = false;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER TABLE IF_P EXISTS relation_expr RENAME CONSTRAINT name TO name
|
||||
{
|
||||
RenameStmt *n = makeNode(RenameStmt);
|
||||
n->renameType = OBJECT_TABCONSTRAINT;
|
||||
n->relation = $5;
|
||||
n->subname = $8;
|
||||
n->newname = $10;
|
||||
n->missing_ok = true;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| ALTER FOREIGN TABLE relation_expr RENAME opt_column name TO name
|
||||
|
||||
Reference in New Issue
Block a user