mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Remove objname/objargs split for referring to objects
In simpler times, it might have worked to refer to all kinds of objects by a list of name components and an optional argument list. But this doesn't work for all objects, which has resulted in a collection of hacks to place various other nodes types into these fields, which have to be unpacked at the other end. This makes it also weird to represent lists of such things in the grammar, because they would have to be lists of singleton lists, to make the unpacking work consistently. The other problem is that keeping separate name and args fields makes it awkward to deal with lists of functions. Change that by dropping the objargs field and have objname, renamed to object, be a generic Node, which can then be flexibly assigned and managed using the normal Node mechanisms. In many cases it will still be a List of names, in some cases it will be a string Value, for types it will be the existing Typename, for functions it will now use the existing ObjectWithArgs node type. Some of the more obscure object types still use somewhat arbitrary nested lists. Reviewed-by: Jim Nasby <Jim.Nasby@BlueTreble.com> Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
@ -48,12 +48,11 @@ CommentObject(CommentStmt *stmt)
|
||||
* (which is really pg_restore's fault, but for now we will work around
|
||||
* the problem here). Consensus is that the best fix is to treat wrong
|
||||
* database name as a WARNING not an ERROR; hence, the following special
|
||||
* case. (If the length of stmt->objname is not 1, get_object_address
|
||||
* will throw an error below; that's OK.)
|
||||
* case.
|
||||
*/
|
||||
if (stmt->objtype == OBJECT_DATABASE && list_length(stmt->objname) == 1)
|
||||
if (stmt->objtype == OBJECT_DATABASE)
|
||||
{
|
||||
char *database = strVal(linitial(stmt->objname));
|
||||
char *database = strVal((Value *) stmt->object);
|
||||
|
||||
if (!OidIsValid(get_database_oid(database, true)))
|
||||
{
|
||||
@ -70,12 +69,12 @@ CommentObject(CommentStmt *stmt)
|
||||
* does not exist, and will also acquire a lock on the target to guard
|
||||
* against concurrent DROP operations.
|
||||
*/
|
||||
address = get_object_address(stmt->objtype, stmt->objname, stmt->objargs,
|
||||
address = get_object_address(stmt->objtype, stmt->object,
|
||||
&relation, ShareUpdateExclusiveLock, false);
|
||||
|
||||
/* Require ownership of the target object. */
|
||||
check_object_ownership(GetUserId(), stmt->objtype, address,
|
||||
stmt->objname, stmt->objargs, relation);
|
||||
stmt->object, relation);
|
||||
|
||||
/* Perform other integrity checks as needed. */
|
||||
switch (stmt->objtype)
|
||||
|
Reference in New Issue
Block a user