diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-07-29 23:46:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-07-29 23:46:35 +0000 |
commit | b5eebc1fd4ebfe91f9a014af7c7ec739336ca02d (patch) | |
tree | 579173e7497422f3cd6d9eaec94d22dc6d53d7a4 /src/backend/commands/opclasscmds.c | |
parent | 7b970bc1bcd63b840a307ae96318b9472d730b52 (diff) | |
download | postgresql-b5eebc1fd4ebfe91f9a014af7c7ec739336ca02d.tar.gz postgresql-b5eebc1fd4ebfe91f9a014af7c7ec739336ca02d.zip |
Centralize code for interpreting schema references, which had gotten
copied more places than I first thought it would. This fixes a bug:
a couple of these places were neglecting to enforce USAGE access on
explicitly-referenced schemas.
Diffstat (limited to 'src/backend/commands/opclasscmds.c')
-rw-r--r-- | src/backend/commands/opclasscmds.c | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index fb86c980b98..c56b0e1fa84 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.1 2002/07/29 22:14:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.2 2002/07/29 23:46:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -467,10 +467,9 @@ storeProcedures(Oid opclassoid, int numProcs, Oid *procedures) void RemoveOpClass(RemoveOpClassStmt *stmt) { - Oid amID, opcID; - char *catalogname; - char *schemaname = NULL; - char *opcname = NULL; + Oid amID, opcID; + char *schemaname; + char *opcname; HeapTuple tuple; ObjectAddress object; @@ -489,42 +488,14 @@ RemoveOpClass(RemoveOpClassStmt *stmt) */ /* deconstruct the name list */ - switch (length(stmt->opclassname)) - { - case 1: - opcname = strVal(lfirst(stmt->opclassname)); - break; - case 2: - schemaname = strVal(lfirst(stmt->opclassname)); - opcname = strVal(lsecond(stmt->opclassname)); - break; - case 3: - catalogname = strVal(lfirst(stmt->opclassname)); - schemaname = strVal(lsecond(stmt->opclassname)); - opcname = strVal(lfirst(lnext(lnext(stmt->opclassname)))); - /* - * We check the catalog name and then ignore it. - */ - if (strcmp(catalogname, DatabaseName) != 0) - elog(ERROR, "Cross-database references are not implemented"); - break; - default: - elog(ERROR, "Improper opclass name (too many dotted names): %s", - NameListToString(stmt->opclassname)); - break; - } + DeconstructQualifiedName(stmt->opclassname, &schemaname, &opcname); if (schemaname) { /* Look in specific schema only */ Oid namespaceId; - namespaceId = GetSysCacheOid(NAMESPACENAME, - CStringGetDatum(schemaname), - 0, 0, 0); - if (!OidIsValid(namespaceId)) - elog(ERROR, "Namespace \"%s\" does not exist", - schemaname); + namespaceId = LookupExplicitNamespace(schemaname); tuple = SearchSysCache(CLAAMNAMENSP, ObjectIdGetDatum(amID), PointerGetDatum(opcname), |