diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-10-19 23:25:20 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-10-19 23:27:19 -0400 |
commit | 82a4a777d94bec965ab2f1d04b6e6a3f0447b377 (patch) | |
tree | b3560173b695b8391ca81edf47c4b364005a608b /src/backend/commands/collationcmds.c | |
parent | 3301c83536e9da1e573e24ded2e610062dbf9cdc (diff) | |
download | postgresql-82a4a777d94bec965ab2f1d04b6e6a3f0447b377.tar.gz postgresql-82a4a777d94bec965ab2f1d04b6e6a3f0447b377.zip |
Consolidate DROP handling for some object types.
This gets rid of a significant amount of duplicative code.
KaiGai Kohei, reviewed in earlier versions by Dimitri Fontaine, with
further review and cleanup by me.
Diffstat (limited to 'src/backend/commands/collationcmds.c')
-rw-r--r-- | src/backend/commands/collationcmds.c | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index a0a0c7d0682..20aa204403d 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -145,67 +145,6 @@ DefineCollation(List *names, List *parameters) } /* - * DROP COLLATION - */ -void -DropCollationsCommand(DropStmt *drop) -{ - ObjectAddresses *objects; - ListCell *cell; - - /* - * First we identify all the collations, then we delete them in a single - * performMultipleDeletions() call. This is to avoid unwanted DROP - * RESTRICT errors if one of the collations depends on another. (Not that - * that is very likely, but we may as well do this consistently.) - */ - objects = new_object_addresses(); - - foreach(cell, drop->objects) - { - List *name = (List *) lfirst(cell); - Oid collationOid; - HeapTuple tuple; - Form_pg_collation coll; - ObjectAddress object; - - collationOid = get_collation_oid(name, drop->missing_ok); - - if (!OidIsValid(collationOid)) - { - ereport(NOTICE, - (errmsg("collation \"%s\" does not exist, skipping", - NameListToString(name)))); - continue; - } - - tuple = SearchSysCache1(COLLOID, ObjectIdGetDatum(collationOid)); - if (!HeapTupleIsValid(tuple)) - elog(ERROR, "cache lookup failed for collation %u", - collationOid); - coll = (Form_pg_collation) GETSTRUCT(tuple); - - /* Permission check: must own collation or its namespace */ - if (!pg_collation_ownercheck(collationOid, GetUserId()) && - !pg_namespace_ownercheck(coll->collnamespace, GetUserId())) - aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_COLLATION, - NameStr(coll->collname)); - - object.classId = CollationRelationId; - object.objectId = collationOid; - object.objectSubId = 0; - - add_exact_object_address(&object, objects); - - ReleaseSysCache(tuple); - } - - performMultipleDeletions(objects, drop->behavior); - - free_object_addresses(objects); -} - -/* * Rename collation */ void |