summaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/lsyscache.c
diff options
context:
space:
mode:
authorTom Lane2002-07-12 18:43:19 +0000
committerTom Lane2002-07-12 18:43:19 +0000
commit7c6df91dda27accab3097390ef0d21d93028c7a1 (patch)
tree5705b975e8de4edf82252e6df28e0bd57c83cb95 /src/backend/utils/cache/lsyscache.c
parent791a40f943e2a9353c5823fb4f2bd446ec623d38 (diff)
Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY constraints all have real live entries in pg_constraint. pg_depend exists, and RESTRICT/CASCADE options work on most kinds of DROP; however, pg_depend is not yet very well populated with dependencies. (Most of the ones that are present at this point just replace formerly hardwired associations, such as the implicit drop of a relation's pg_type entry when the relation is dropped.) Need to add more logic to create dependency entries, improve pg_dump to dump constraints in place of indexes and triggers, and add some regression tests.
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r--src/backend/utils/cache/lsyscache.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 5063225afce..e383ab892d1 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.75 2002/07/06 20:16:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.76 2002/07/12 18:43:18 tgl Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -671,6 +671,25 @@ get_relname_relid(const char *relname, Oid relnamespace)
0, 0);
}
+/*
+ * get_system_catalog_relid
+ * Get the OID of a system catalog identified by name.
+ */
+Oid
+get_system_catalog_relid(const char *catname)
+{
+ Oid relid;
+
+ relid = GetSysCacheOid(RELNAMENSP,
+ PointerGetDatum(catname),
+ ObjectIdGetDatum(PG_CATALOG_NAMESPACE),
+ 0, 0);
+ if (!OidIsValid(relid))
+ elog(ERROR, "get_system_catalog_relid: cannot find %s", catname);
+
+ return relid;
+}
+
#ifdef NOT_USED
/*
* get_relnatts
@@ -1060,7 +1079,7 @@ getBaseType(Oid typid)
/*
* getBaseTypeTypeMod
* If the given type is a domain, return its base type;
- * otherwise return the type's own OID.
+ * otherwise return the type's own OID. Also return base typmod.
*/
Oid
getBaseTypeTypeMod(Oid typid, int32 *typmod)
@@ -1077,7 +1096,7 @@ getBaseTypeTypeMod(Oid typid, int32 *typmod)
ObjectIdGetDatum(typid),
0, 0, 0);
if (!HeapTupleIsValid(tup))
- elog(ERROR, "getBaseType: failed to lookup type %u", typid);
+ elog(ERROR, "getBaseTypeTypeMod: failed to lookup type %u", typid);
typTup = (Form_pg_type) GETSTRUCT(tup);
if (typTup->typtype != 'd')
{