mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Adjust many backend functions to return OID rather than void.
Extracted from a larger patch by Dimitri Fontaine. It is hoped that this will provide infrastructure for enriching the new event trigger functionality, but it seems possibly useful for other purposes as well.
This commit is contained in:
@@ -2098,7 +2098,7 @@ renameatt_internal(Oid myrelid,
|
||||
Relation targetrelation;
|
||||
Relation attrelation;
|
||||
HeapTuple atttup;
|
||||
Form_pg_attribute attform;
|
||||
Form_pg_attribute attform;
|
||||
int attnum;
|
||||
|
||||
/*
|
||||
@@ -2248,7 +2248,7 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
/*
|
||||
* renameatt - changes the name of a attribute in a relation
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
renameatt(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid;
|
||||
@@ -2264,7 +2264,7 @@ renameatt(RenameStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
renameatt_internal(relid,
|
||||
@@ -2274,13 +2274,16 @@ renameatt(RenameStmt *stmt)
|
||||
false, /* recursing? */
|
||||
0, /* expected inhcount */
|
||||
stmt->behavior);
|
||||
|
||||
/* This is an ALTER TABLE command so it's about the relid */
|
||||
return relid;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* same logic as renameatt_internal
|
||||
*/
|
||||
static void
|
||||
static Oid
|
||||
rename_constraint_internal(Oid myrelid,
|
||||
Oid mytypid,
|
||||
const char *oldconname,
|
||||
@@ -2372,9 +2375,11 @@ rename_constraint_internal(Oid myrelid,
|
||||
|
||||
if (targetrelation)
|
||||
relation_close(targetrelation, NoLock); /* close rel but keep lock */
|
||||
|
||||
return constraintOid;
|
||||
}
|
||||
|
||||
void
|
||||
Oid
|
||||
RenameConstraint(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid = InvalidOid;
|
||||
@@ -2403,18 +2408,20 @@ RenameConstraint(RenameStmt *stmt)
|
||||
NULL);
|
||||
}
|
||||
|
||||
rename_constraint_internal(relid, typid,
|
||||
stmt->subname,
|
||||
stmt->newname,
|
||||
stmt->relation ? interpretInhOption(stmt->relation->inhOpt) : false, /* recursive? */
|
||||
false, /* recursing? */
|
||||
0 /* expected inhcount */ );
|
||||
return
|
||||
rename_constraint_internal(relid, typid,
|
||||
stmt->subname,
|
||||
stmt->newname,
|
||||
stmt->relation ? interpretInhOption(stmt->relation->inhOpt) : false, /* recursive? */
|
||||
false, /* recursing? */
|
||||
0 /* expected inhcount */ );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute ALTER TABLE/INDEX/SEQUENCE/VIEW/FOREIGN TABLE RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameRelation(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid;
|
||||
@@ -2436,11 +2443,13 @@ RenameRelation(RenameStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
/* Do the work */
|
||||
RenameRelationInternal(relid, stmt->newname);
|
||||
|
||||
return relid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -9746,7 +9755,7 @@ ATExecGenericOptions(Relation rel, List *options)
|
||||
/*
|
||||
* Execute ALTER TABLE SET SCHEMA
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterTableNamespace(AlterObjectSchemaStmt *stmt)
|
||||
{
|
||||
Relation rel;
|
||||
@@ -9766,7 +9775,7 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
rel = relation_open(relid, NoLock);
|
||||
@@ -9801,6 +9810,8 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt)
|
||||
|
||||
/* close rel, but keep lock until commit */
|
||||
relation_close(rel, NoLock);
|
||||
|
||||
return relid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user