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/indexcmds.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/indexcmds.c')
-rw-r--r-- | src/backend/commands/indexcmds.c | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index f36bad8ada1..4049e7435c5 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.78 2002/07/20 05:16:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.79 2002/07/29 23:46:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -410,9 +410,8 @@ static Oid GetAttrOpClass(IndexElem *attribute, Oid attrType, char *accessMethodName, Oid accessMethodId) { - char *catalogname; - char *schemaname = NULL; - char *opcname = NULL; + char *schemaname; + char *opcname; HeapTuple tuple; Oid opClassId, opInputType; @@ -434,42 +433,14 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType, */ /* deconstruct the name list */ - switch (length(attribute->opclass)) - { - case 1: - opcname = strVal(lfirst(attribute->opclass)); - break; - case 2: - schemaname = strVal(lfirst(attribute->opclass)); - opcname = strVal(lsecond(attribute->opclass)); - break; - case 3: - catalogname = strVal(lfirst(attribute->opclass)); - schemaname = strVal(lsecond(attribute->opclass)); - opcname = strVal(lfirst(lnext(lnext(attribute->opclass)))); - /* - * 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(attribute->opclass)); - break; - } + DeconstructQualifiedName(attribute->opclass, &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(accessMethodId), PointerGetDatum(opcname), |