summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-02-02 17:11:55 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-02-02 17:11:55 -0500
commit62f34097c88433ef1f3de604714fe7e7024f2fdf (patch)
tree6bcedf1e516ad5ebfca4c93d94469ebf2733caf1 /src/include
parent479331406e8403cc2e75d1082f8c613e7669c113 (diff)
downloadpostgresql-62f34097c88433ef1f3de604714fe7e7024f2fdf.tar.gz
Build in some knowledge about foreign-key relationships in the catalogs.
This follows in the spirit of commit dfb75e478, which created primary key and uniqueness constraints to improve the visibility of constraints imposed on the system catalogs. While our catalogs contain many foreign-key-like relationships, they don't quite follow SQL semantics, in that the convention for an omitted reference is to write zero not NULL. Plus, we have some cases in which there are arrays each of whose elements is supposed to be an FK reference; SQL has no way to model that. So we can't create actual foreign key constraints to describe the situation. Nonetheless, we can collect and use knowledge about these relationships. This patch therefore adds annotations to the catalog header files to declare foreign-key relationships. (The BKI_LOOKUP annotations cover simple cases, but we weren't previously distinguishing which such columns are allowed to contain zeroes; we also need new markings for multi-column FK references.) Then, Catalog.pm and genbki.pl are taught to collect this information into a table in a new generated header "system_fk_info.h". The only user of that at the moment is a new SQL function pg_get_catalog_foreign_keys(), which exposes the table to SQL. The oidjoins regression test is rewritten to use pg_get_catalog_foreign_keys() to find out which columns to check. Aside from removing the need for manual maintenance of that test script, this allows it to cover numerous relationships that were not checked by the old implementation based on findoidjoins. (As of this commit, 217 relationships are checked by the test, versus 181 before.) Discussion: https://postgr.es/m/3240355.1612129197@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile5
-rw-r--r--src/include/catalog/.gitignore1
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/genbki.h36
-rw-r--r--src/include/catalog/pg_aggregate.h18
-rw-r--r--src/include/catalog/pg_amop.h2
-rw-r--r--src/include/catalog/pg_attrdef.h5
-rw-r--r--src/include/catalog/pg_attribute.h14
-rw-r--r--src/include/catalog/pg_auth_members.h6
-rw-r--r--src/include/catalog/pg_cast.h2
-rw-r--r--src/include/catalog/pg_class.h22
-rw-r--r--src/include/catalog/pg_collation.dat15
-rw-r--r--src/include/catalog/pg_collation.h5
-rw-r--r--src/include/catalog/pg_constraint.h29
-rw-r--r--src/include/catalog/pg_conversion.h4
-rw-r--r--src/include/catalog/pg_database.h2
-rw-r--r--src/include/catalog/pg_db_role_setting.h7
-rw-r--r--src/include/catalog/pg_default_acl.h6
-rw-r--r--src/include/catalog/pg_depend.h6
-rw-r--r--src/include/catalog/pg_description.h3
-rw-r--r--src/include/catalog/pg_enum.h2
-rw-r--r--src/include/catalog/pg_event_trigger.h5
-rw-r--r--src/include/catalog/pg_extension.h8
-rw-r--r--src/include/catalog/pg_foreign_data_wrapper.h9
-rw-r--r--src/include/catalog/pg_foreign_server.h4
-rw-r--r--src/include/catalog/pg_foreign_table.h4
-rw-r--r--src/include/catalog/pg_index.h12
-rw-r--r--src/include/catalog/pg_inherits.h4
-rw-r--r--src/include/catalog/pg_init_privs.h3
-rw-r--r--src/include/catalog/pg_language.h8
-rw-r--r--src/include/catalog/pg_largeobject.h3
-rw-r--r--src/include/catalog/pg_largeobject_metadata.h3
-rw-r--r--src/include/catalog/pg_namespace.dat6
-rw-r--r--src/include/catalog/pg_namespace.h2
-rw-r--r--src/include/catalog/pg_opclass.h8
-rw-r--r--src/include/catalog/pg_operator.h22
-rw-r--r--src/include/catalog/pg_opfamily.h4
-rw-r--r--src/include/catalog/pg_partitioned_table.h17
-rw-r--r--src/include/catalog/pg_policy.h7
-rw-r--r--src/include/catalog/pg_proc.dat12
-rw-r--r--src/include/catalog/pg_proc.h12
-rw-r--r--src/include/catalog/pg_publication.h2
-rw-r--r--src/include/catalog/pg_publication_rel.h4
-rw-r--r--src/include/catalog/pg_range.h6
-rw-r--r--src/include/catalog/pg_rewrite.h2
-rw-r--r--src/include/catalog/pg_seclabel.h3
-rw-r--r--src/include/catalog/pg_sequence.h4
-rw-r--r--src/include/catalog/pg_shdepend.h9
-rw-r--r--src/include/catalog/pg_shdescription.h3
-rw-r--r--src/include/catalog/pg_shseclabel.h3
-rw-r--r--src/include/catalog/pg_statistic.h25
-rw-r--r--src/include/catalog/pg_statistic_ext.h10
-rw-r--r--src/include/catalog/pg_statistic_ext_data.h3
-rw-r--r--src/include/catalog/pg_subscription.h5
-rw-r--r--src/include/catalog/pg_subscription_rel.h4
-rw-r--r--src/include/catalog/pg_tablespace.dat6
-rw-r--r--src/include/catalog/pg_tablespace.h2
-rw-r--r--src/include/catalog/pg_transform.h8
-rw-r--r--src/include/catalog/pg_trigger.h21
-rw-r--r--src/include/catalog/pg_ts_config.h4
-rw-r--r--src/include/catalog/pg_ts_dict.h4
-rw-r--r--src/include/catalog/pg_ts_parser.h4
-rw-r--r--src/include/catalog/pg_ts_template.h4
-rw-r--r--src/include/catalog/pg_type.h26
-rw-r--r--src/include/catalog/pg_user_mapping.h8
65 files changed, 312 insertions, 203 deletions
diff --git a/src/include/Makefile b/src/include/Makefile
index c557375ae3..5f257a958c 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -54,7 +54,7 @@ install: all installdirs
cp $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir/ || exit; \
done
ifeq ($(vpath_build),yes)
- for file in catalog/schemapg.h catalog/pg_*_d.h parser/gram.h storage/lwlocknames.h utils/probes.h; do \
+ for file in catalog/schemapg.h catalog/system_fk_info.h catalog/pg_*_d.h parser/gram.h storage/lwlocknames.h utils/probes.h; do \
cp $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
done
endif
@@ -79,7 +79,8 @@ uninstall:
clean:
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
rm -f parser/gram.h storage/lwlocknames.h utils/probes.h
- rm -f catalog/schemapg.h catalog/pg_*_d.h catalog/header-stamp
+ rm -f catalog/schemapg.h catalog/system_fk_info.h
+ rm -f catalog/pg_*_d.h catalog/header-stamp
distclean maintainer-clean: clean
rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/catalog/.gitignore b/src/include/catalog/.gitignore
index 6c8da5401d..6b83d4c7e6 100644
--- a/src/include/catalog/.gitignore
+++ b/src/include/catalog/.gitignore
@@ -1,3 +1,4 @@
/schemapg.h
+/system_fk_info.h
/pg_*_d.h
/header-stamp
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 133f4ee309..638830aaac 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202101311
+#define CATALOG_VERSION_NO 202102021
#endif
diff --git a/src/include/catalog/genbki.h b/src/include/catalog/genbki.h
index 5d05fafb5d..b1fee54d3c 100644
--- a/src/include/catalog/genbki.h
+++ b/src/include/catalog/genbki.h
@@ -36,10 +36,15 @@
/* Specifies a default value for auto-generated array types */
#define BKI_ARRAY_DEFAULT(value)
/*
- * Indicates how to perform name lookups, typically for an OID or
- * OID-array field
+ * Indicates that the attribute contains OIDs referencing the named catalog;
+ * can be applied to columns of oid, regproc, oid[], or oidvector type.
+ * genbki.pl uses this to know how to perform name lookups in the initial
+ * data (if any), and it also feeds into regression-test validity checks.
+ * The _OPT suffix indicates that values can be zero instead of
+ * a valid OID reference.
*/
#define BKI_LOOKUP(catalog)
+#define BKI_LOOKUP_OPT(catalog)
/*
* These lines are processed by genbki.pl to create the statements
@@ -75,6 +80,33 @@
#define DECLARE_UNIQUE_INDEX(name,oid,decl) extern int no_such_variable
#define DECLARE_UNIQUE_INDEX_PKEY(name,oid,decl) extern int no_such_variable
+/*
+ * These lines are processed by genbki.pl to create a table for use
+ * by the pg_get_catalog_foreign_keys() function. We do not have any
+ * mechanism that actually enforces foreign-key relationships in the
+ * system catalogs, but it is still useful to record the intended
+ * relationships in a machine-readable form.
+ *
+ * The keyword is DECLARE_FOREIGN_KEY[_OPT] or DECLARE_ARRAY_FOREIGN_KEY[_OPT].
+ * The first argument is a parenthesized list of the referencing columns;
+ * the second, the name of the referenced table; the third, a parenthesized
+ * list of the referenced columns. Use of the ARRAY macros means that the
+ * last referencing column is an array, each of whose elements is supposed
+ * to match some entry in the last referenced column. Use of the OPT suffix
+ * indicates that the referencing column(s) can be zero instead of a valid
+ * reference.
+ *
+ * Columns that are marked with a BKI_LOOKUP rule do not need an explicit
+ * DECLARE_FOREIGN_KEY macro, as genbki.pl can infer the FK relationship
+ * from that. Thus, these macros are only needed in special cases.
+ *
+ * The macro definitions are just to keep the C compiler from spitting up.
+ */
+#define DECLARE_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable
+#define DECLARE_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable
+#define DECLARE_ARRAY_FOREIGN_KEY(cols,reftbl,refcols) extern int no_such_variable
+#define DECLARE_ARRAY_FOREIGN_KEY_OPT(cols,reftbl,refcols) extern int no_such_variable
+
/* The following are never defined; they are here only for documentation. */
/*
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index 8b03cdeea2..25feb41678 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -44,25 +44,25 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
regproc aggtransfn BKI_LOOKUP(pg_proc);
/* final function (0 if none) */
- regproc aggfinalfn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggfinalfn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* combine function (0 if none) */
- regproc aggcombinefn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggcombinefn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* function to convert transtype to bytea (0 if none) */
- regproc aggserialfn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggserialfn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* function to convert bytea to transtype (0 if none) */
- regproc aggdeserialfn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggdeserialfn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* forward function for moving-aggregate mode (0 if none) */
- regproc aggmtransfn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggmtransfn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* inverse function for moving-aggregate mode (0 if none) */
- regproc aggminvtransfn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggminvtransfn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* final function for moving-aggregate mode (0 if none) */
- regproc aggmfinalfn BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc aggmfinalfn BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* true to pass extra dummy arguments to aggfinalfn */
bool aggfinalextra BKI_DEFAULT(f);
@@ -77,7 +77,7 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
char aggmfinalmodify BKI_DEFAULT(r);
/* associated sort operator (0 if none) */
- Oid aggsortop BKI_DEFAULT(0) BKI_LOOKUP(pg_operator);
+ Oid aggsortop BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_operator);
/* type of aggregate's transition (state) data */
Oid aggtranstype BKI_LOOKUP(pg_type);
@@ -86,7 +86,7 @@ CATALOG(pg_aggregate,2600,AggregateRelationId)
int32 aggtransspace BKI_DEFAULT(0);
/* type of moving-aggregate state data (0 if none) */
- Oid aggmtranstype BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
+ Oid aggmtranstype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
/* estimated size of moving-agg state (0 for default est) */
int32 aggmtransspace BKI_DEFAULT(0);
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 554fc41497..e1cca35e31 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -77,7 +77,7 @@ CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
Oid amopmethod BKI_LOOKUP(pg_am);
/* ordering opfamily OID, or 0 if search op */
- Oid amopsortfamily BKI_DEFAULT(0) BKI_LOOKUP(pg_opfamily);
+ Oid amopsortfamily BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_opfamily);
} FormData_pg_amop;
/* ----------------
diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h
index 03efaaded9..d689ca20c8 100644
--- a/src/include/catalog/pg_attrdef.h
+++ b/src/include/catalog/pg_attrdef.h
@@ -30,7 +30,8 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
{
Oid oid; /* oid */
- Oid adrelid; /* OID of table containing attribute */
+ Oid adrelid BKI_LOOKUP(pg_class); /* OID of table containing
+ * attribute */
int16 adnum; /* attnum of attribute */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
@@ -53,4 +54,6 @@ DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, on pg_attrdef using b
DECLARE_UNIQUE_INDEX_PKEY(pg_attrdef_oid_index, 2657, on pg_attrdef using btree(oid oid_ops));
#define AttrDefaultOidIndexId 2657
+DECLARE_FOREIGN_KEY((adrelid, adnum), pg_attribute, (attrelid, attnum));
+
#endif /* PG_ATTRDEF_H */
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index ba0efff08c..3db42abf08 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -36,7 +36,8 @@
*/
CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,AttributeRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
- Oid attrelid; /* OID of relation containing this attribute */
+ Oid attrelid BKI_LOOKUP(pg_class); /* OID of relation containing
+ * this attribute */
NameData attname; /* name of attribute */
/*
@@ -44,9 +45,12 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* defines the data type of this attribute (e.g. int4). Information in
* that instance is redundant with the attlen, attbyval, and attalign
* attributes of this instance, so they had better match or Postgres will
- * fail.
+ * fail. In an entry for a dropped column, this field is set to zero
+ * since the pg_type entry may no longer exist; but we rely on attlen,
+ * attbyval, and attalign to still tell us how large the values in the
+ * table are.
*/
- Oid atttypid;
+ Oid atttypid BKI_LOOKUP_OPT(pg_type);
/*
* attstattarget is the target number of statistics datapoints to collect
@@ -153,8 +157,8 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
/* Number of times inherited from direct parent relation(s) */
int32 attinhcount BKI_DEFAULT(0);
- /* attribute's collation */
- Oid attcollation;
+ /* attribute's collation, if any */
+ Oid attcollation BKI_LOOKUP_OPT(pg_collation);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* NOTE: The following fields are not present in tuple descriptors. */
diff --git a/src/include/catalog/pg_auth_members.h b/src/include/catalog/pg_auth_members.h
index e90c395640..76ab90c939 100644
--- a/src/include/catalog/pg_auth_members.h
+++ b/src/include/catalog/pg_auth_members.h
@@ -29,9 +29,9 @@
*/
CATALOG(pg_auth_members,1261,AuthMemRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(2843,AuthMemRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
- Oid roleid; /* ID of a role */
- Oid member; /* ID of a member of that role */
- Oid grantor; /* who granted the membership */
+ Oid roleid BKI_LOOKUP(pg_authid); /* ID of a role */
+ Oid member BKI_LOOKUP(pg_authid); /* ID of a member of that role */
+ Oid grantor BKI_LOOKUP(pg_authid); /* who granted the membership */
bool admin_option; /* granted with admin option? */
} FormData_pg_auth_members;
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index 2d36628c20..f64a9df54c 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -40,7 +40,7 @@ CATALOG(pg_cast,2605,CastRelationId)
Oid casttarget BKI_LOOKUP(pg_type);
/* cast function; 0 = binary coercible */
- Oid castfunc BKI_LOOKUP(pg_proc);
+ Oid castfunc BKI_LOOKUP_OPT(pg_proc);
/* contexts in which cast can be used */
char castcontext;
diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h
index eca306ca98..bb6938caa2 100644
--- a/src/include/catalog/pg_class.h
+++ b/src/include/catalog/pg_class.h
@@ -38,26 +38,26 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
NameData relname;
/* OID of namespace containing this class */
- Oid relnamespace BKI_DEFAULT(PGNSP);
+ Oid relnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
- /* OID of entry in pg_type for table's implicit row type */
- Oid reltype BKI_LOOKUP(pg_type);
+ /* OID of entry in pg_type for relation's implicit row type, if any */
+ Oid reltype BKI_LOOKUP_OPT(pg_type);
- /* OID of entry in pg_type for underlying composite type */
- Oid reloftype BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
+ /* OID of entry in pg_type for underlying composite type, if any */
+ Oid reloftype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
/* class owner */
- Oid relowner BKI_DEFAULT(PGUID);
+ Oid relowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* access method; 0 if not a table / index */
- Oid relam BKI_DEFAULT(heap) BKI_LOOKUP(pg_am);
+ Oid relam BKI_DEFAULT(heap) BKI_LOOKUP_OPT(pg_am);
/* identifier of physical storage file */
/* relfilenode == 0 means it is a "mapped" relation, see relmapper.c */
Oid relfilenode BKI_DEFAULT(0);
/* identifier of table space for relation (0 means default for database) */
- Oid reltablespace BKI_DEFAULT(0) BKI_LOOKUP(pg_tablespace);
+ Oid reltablespace BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_tablespace);
/* # of blocks (not always up-to-date) */
int32 relpages BKI_DEFAULT(0);
@@ -69,7 +69,7 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
int32 relallvisible BKI_DEFAULT(0);
/* OID of toast table; 0 if none */
- Oid reltoastrelid BKI_DEFAULT(0);
+ Oid reltoastrelid BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class);
/* T if has (or has had) any indexes */
bool relhasindex BKI_DEFAULT(f);
@@ -119,8 +119,8 @@ CATALOG(pg_class,1259,RelationRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83,Relat
/* is relation a partition? */
bool relispartition BKI_DEFAULT(f);
- /* heap for rewrite during DDL, link to original rel */
- Oid relrewrite BKI_DEFAULT(0);
+ /* link to original rel during table rewrite; otherwise 0 */
+ Oid relrewrite BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_class);
/* all Xids < this are frozen in this rel */
TransactionId relfrozenxid BKI_DEFAULT(3); /* FirstNormalTransactionId */
diff --git a/src/include/catalog/pg_collation.dat b/src/include/catalog/pg_collation.dat
index ad57b0fa6d..6e0ab1ab4b 100644
--- a/src/include/catalog/pg_collation.dat
+++ b/src/include/catalog/pg_collation.dat
@@ -14,18 +14,15 @@
{ oid => '100', oid_symbol => 'DEFAULT_COLLATION_OID',
descr => 'database\'s default collation',
- collname => 'default', collnamespace => 'PGNSP', collowner => 'PGUID',
- collprovider => 'd', collencoding => '-1', collcollate => '',
- collctype => '' },
+ collname => 'default', collprovider => 'd', collencoding => '-1',
+ collcollate => '', collctype => '' },
{ oid => '950', oid_symbol => 'C_COLLATION_OID',
descr => 'standard C collation',
- collname => 'C', collnamespace => 'PGNSP', collowner => 'PGUID',
- collprovider => 'c', collencoding => '-1', collcollate => 'C',
- collctype => 'C' },
+ collname => 'C', collprovider => 'c', collencoding => '-1',
+ collcollate => 'C', collctype => 'C' },
{ oid => '951', oid_symbol => 'POSIX_COLLATION_OID',
descr => 'standard POSIX collation',
- collname => 'POSIX', collnamespace => 'PGNSP', collowner => 'PGUID',
- collprovider => 'c', collencoding => '-1', collcollate => 'POSIX',
- collctype => 'POSIX' },
+ collname => 'POSIX', collprovider => 'c', collencoding => '-1',
+ collcollate => 'POSIX', collctype => 'POSIX' },
]
diff --git a/src/include/catalog/pg_collation.h b/src/include/catalog/pg_collation.h
index 3c496ea914..3bd7873c68 100644
--- a/src/include/catalog/pg_collation.h
+++ b/src/include/catalog/pg_collation.h
@@ -30,8 +30,9 @@ CATALOG(pg_collation,3456,CollationRelationId)
{
Oid oid; /* oid */
NameData collname; /* collation name */
- Oid collnamespace; /* OID of namespace containing collation */
- Oid collowner; /* owner of collation */
+ Oid collnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace); /* OID of namespace
+ * containing collation */
+ Oid collowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid); /* owner of collation */
char collprovider; /* see constants below */
bool collisdeterministic BKI_DEFAULT(t);
int32 collencoding; /* encoding for this collation; -1 = "all" */
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index 6449937b35..63f0f8bf41 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -46,7 +46,8 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
* conrelid + contypid + conname.
*/
NameData conname; /* name of this constraint */
- Oid connamespace; /* OID of namespace containing constraint */
+ Oid connamespace BKI_LOOKUP(pg_namespace); /* OID of namespace
+ * containing constraint */
char contype; /* constraint type; see codes below */
bool condeferrable; /* deferrable constraint? */
bool condeferred; /* deferred by default? */
@@ -57,7 +58,8 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
* specific relation (this excludes domain constraints and assertions).
* Otherwise conrelid is 0 and conkey is NULL.
*/
- Oid conrelid; /* relation this constraint constrains */
+ Oid conrelid BKI_LOOKUP_OPT(pg_class); /* relation this
+ * constraint constrains */
/*
* contypid links to the pg_type row for a domain if this is a domain
@@ -66,7 +68,8 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
* For SQL-style global ASSERTIONs, both conrelid and contypid would be
* zero. This is not presently supported, however.
*/
- Oid contypid; /* domain this constraint constrains */
+ Oid contypid BKI_LOOKUP_OPT(pg_type); /* domain this constraint
+ * constrains */
/*
* conindid links to the index supporting the constraint, if any;
@@ -76,19 +79,21 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
* columns). Notice that the index is on conrelid in the first case but
* confrelid in the second.
*/
- Oid conindid; /* index supporting this constraint */
+ Oid conindid BKI_LOOKUP_OPT(pg_class); /* index supporting this
+ * constraint */
/*
* If this constraint is on a partition inherited from a partitioned
* table, this is the OID of the corresponding constraint in the parent.
*/
- Oid conparentid;
+ Oid conparentid BKI_LOOKUP_OPT(pg_constraint);
/*
* These fields, plus confkey, are only meaningful for a foreign-key
* constraint. Otherwise confrelid is 0 and the char fields are spaces.
*/
- Oid confrelid; /* relation referenced by foreign key */
+ Oid confrelid BKI_LOOKUP_OPT(pg_class); /* relation referenced by
+ * foreign key */
char confupdtype; /* foreign key's ON UPDATE action */
char confdeltype; /* foreign key's ON DELETE action */
char confmatchtype; /* foreign key's match type */
@@ -119,25 +124,25 @@ CATALOG(pg_constraint,2606,ConstraintRelationId)
* If a foreign key, the OIDs of the PK = FK equality operators for each
* column of the constraint
*/
- Oid conpfeqop[1];
+ Oid conpfeqop[1] BKI_LOOKUP(pg_operator);
/*
* If a foreign key, the OIDs of the PK = PK equality operators for each
* column of the constraint (i.e., equality for the referenced columns)
*/
- Oid conppeqop[1];
+ Oid conppeqop[1] BKI_LOOKUP(pg_operator);
/*
* If a foreign key, the OIDs of the FK = FK equality operators for each
* column of the constraint (i.e., equality for the referencing columns)
*/
- Oid conffeqop[1];
+ Oid conffeqop[1] BKI_LOOKUP(pg_operator);
/*
* If an exclusion constraint, the OIDs of the exclusion operators for
* each column of the constraint
*/
- Oid conexclop[1];
+ Oid conexclop[1] BKI_LOOKUP(pg_operator);
/*
* If a check constraint, nodeToString representation of expression
@@ -166,6 +171,10 @@ DECLARE_UNIQUE_INDEX_PKEY(pg_constraint_oid_index, 2667, on pg_constraint using
DECLARE_INDEX(pg_constraint_conparentid_index, 2579, on pg_constraint using btree(conparentid oid_ops));
#define ConstraintParentIndexId 2579
+/* conkey can contain zero (InvalidAttrNumber) if a whole-row Var is used */
+DECLARE_ARRAY_FOREIGN_KEY_OPT((conrelid, conkey), pg_attribute, (attrelid, attnum));
+DECLARE_ARRAY_FOREIGN_KEY((confrelid, confkey), pg_attribute, (attrelid, attnum));
+
#ifdef EXPOSE_TO_CLIENT_CODE
/* Valid values for contype */
diff --git a/src/include/catalog/pg_conversion.h b/src/include/catalog/pg_conversion.h
index b02dfe0c3f..96bb92f251 100644
--- a/src/include/catalog/pg_conversion.h
+++ b/src/include/catalog/pg_conversion.h
@@ -35,10 +35,10 @@ CATALOG(pg_conversion,2607,ConversionRelationId)
NameData conname;
/* namespace that the conversion belongs to */
- Oid connamespace BKI_DEFAULT(PGNSP);
+ Oid connamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* owner of the conversion */
- Oid conowner BKI_DEFAULT(PGUID);
+ Oid conowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* FOR encoding id */
int32 conforencoding BKI_LOOKUP(encoding);
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index b7a0b6a381..f0240c58cf 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -35,7 +35,7 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
NameData datname;
/* owner of database */
- Oid datdba BKI_DEFAULT(PGUID);
+ Oid datdba BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* character encoding */
int32 encoding;
diff --git a/src/include/catalog/pg_db_role_setting.h b/src/include/catalog/pg_db_role_setting.h
index f18819d670..705f698ae7 100644
--- a/src/include/catalog/pg_db_role_setting.h
+++ b/src/include/catalog/pg_db_role_setting.h
@@ -33,8 +33,11 @@
*/
CATALOG(pg_db_role_setting,2964,DbRoleSettingRelationId) BKI_SHARED_RELATION
{
- Oid setdatabase; /* database */
- Oid setrole; /* role */
+ /* database, or 0 for a role-specific setting */
+ Oid setdatabase BKI_LOOKUP_OPT(pg_database);
+
+ /* role, or 0 for a database-specific setting */
+ Oid setrole BKI_LOOKUP_OPT(pg_authid);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text setconfig[1]; /* GUC settings to apply at login */
diff --git a/src/include/catalog/pg_default_acl.h b/src/include/catalog/pg_default_acl.h
index bb7db32cd6..156fc0712d 100644
--- a/src/include/catalog/pg_default_acl.h
+++ b/src/include/catalog/pg_default_acl.h
@@ -30,8 +30,10 @@
CATALOG(pg_default_acl,826,DefaultAclRelationId)
{
Oid oid; /* oid */
- Oid defaclrole; /* OID of role owning this ACL */
- Oid defaclnamespace; /* OID of namespace, or 0 for all */
+ Oid defaclrole BKI_LOOKUP(pg_authid); /* OID of role owning this
+ * ACL */
+ Oid defaclnamespace BKI_LOOKUP_OPT(pg_namespace); /* OID of namespace, or
+ * 0 for all */
char defaclobjtype; /* see DEFACLOBJ_xxx constants below */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
diff --git a/src/include/catalog/pg_depend.h b/src/include/catalog/pg_depend.h
index b083790180..606a2a8e19 100644
--- a/src/include/catalog/pg_depend.h
+++ b/src/include/catalog/pg_depend.h
@@ -45,14 +45,16 @@ CATALOG(pg_depend,2608,DependRelationId)
*
* These fields are all zeroes for a DEPENDENCY_PIN entry.
*/
- Oid classid; /* OID of table containing object */
+ Oid classid BKI_LOOKUP_OPT(pg_class); /* OID of table containing
+ * object */
Oid objid; /* OID of object itself */
int32 objsubid; /* column number, or 0 if not used */
/*
* Identification of the independent (referenced) object.
*/
- Oid refclassid; /* OID of table containing object */
+ Oid refclassid BKI_LOOKUP(pg_class); /* OID of table containing
+ * object */
Oid refobjid; /* OID of object itself */
int32 refobjsubid; /* column number, or 0 if not used */
diff --git a/src/include/catalog/pg_description.h b/src/include/catalog/pg_description.h
index ad9de5e0a0..adc06a854d 100644
--- a/src/include/catalog/pg_description.h
+++ b/src/include/catalog/pg_description.h
@@ -68,4 +68,7 @@ DECLARE_TOAST(pg_description, 2834, 2835);
DECLARE_UNIQUE_INDEX_PKEY(pg_description_o_c_o_index, 2675, on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops));
#define DescriptionObjIndexId 2675
+/* We do not use BKI_LOOKUP here because it causes problems for genbki.pl */
+DECLARE_FOREIGN_KEY((classoid), pg_class, (oid));
+
#endif /* PG_DESCRIPTION_H */
diff --git a/src/include/catalog/pg_enum.h b/src/include/catalog/pg_enum.h
index 5eaf70772c..78a183b27d 100644
--- a/src/include/catalog/pg_enum.h
+++ b/src/include/catalog/pg_enum.h
@@ -31,7 +31,7 @@
CATALOG(pg_enum,3501,EnumRelationId)
{
Oid oid; /* oid */
- Oid enumtypid; /* OID of owning enum type */
+ Oid enumtypid BKI_LOOKUP(pg_type); /* OID of owning enum type */
float4 enumsortorder; /* sort position of this enum value */
NameData enumlabel; /* text representation of enum value */
} FormData_pg_enum;
diff --git a/src/include/catalog/pg_event_trigger.h b/src/include/catalog/pg_event_trigger.h
index 6f0266ed0f..eeaa6be518 100644
--- a/src/include/catalog/pg_event_trigger.h
+++ b/src/include/catalog/pg_event_trigger.h
@@ -31,8 +31,9 @@ CATALOG(pg_event_trigger,3466,EventTriggerRelationId)
Oid oid; /* oid */
NameData evtname; /* trigger's name */
NameData evtevent; /* trigger's event */
- Oid evtowner; /* trigger's owner */
- Oid evtfoid; /* OID of function to be called */
+ Oid evtowner BKI_LOOKUP(pg_authid); /* trigger's owner */
+ Oid evtfoid BKI_LOOKUP(pg_proc); /* OID of function to be
+ * called */
char evtenabled; /* trigger's firing configuration WRT
* session_replication_role */
diff --git a/src/include/catalog/pg_extension.h b/src/include/catalog/pg_extension.h
index af119bfea7..2d6ad9fa88 100644
--- a/src/include/catalog/pg_extension.h
+++ b/src/include/catalog/pg_extension.h
@@ -30,14 +30,16 @@ CATALOG(pg_extension,3079,ExtensionRelationId)
{
Oid oid; /* oid */
NameData extname; /* extension name */
- Oid extowner; /* extension owner */
- Oid extnamespace; /* namespace of contained objects */
+ Oid extowner BKI_LOOKUP(pg_authid); /* extension owner */
+ Oid extnamespace BKI_LOOKUP(pg_namespace); /* namespace of
+ * contained objects */
bool extrelocatable; /* if true, allow ALTER EXTENSION SET SCHEMA */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* extversion may never be null, but the others can be. */
text extversion BKI_FORCE_NOT_NULL; /* extension version name */
- Oid extconfig[1]; /* dumpable configuration tables */
+ Oid extconfig[1] BKI_LOOKUP(pg_class); /* dumpable configuration
+ * tables */
text extcondition[1]; /* WHERE clauses for config tables */
#endif
} FormData_pg_extension;
diff --git a/src/include/catalog/pg_foreign_data_wrapper.h b/src/include/catalog/pg_foreign_data_wrapper.h
index 0f523a26b9..f6240d9eb3 100644
--- a/src/include/catalog/pg_foreign_data_wrapper.h
+++ b/src/include/catalog/pg_foreign_data_wrapper.h
@@ -30,9 +30,12 @@ CATALOG(pg_foreign_data_wrapper,2328,ForeignDataWrapperRelationId)
{
Oid oid; /* oid */
NameData fdwname; /* foreign-data wrapper name */
- Oid fdwowner; /* FDW owner */
- Oid fdwhandler; /* handler function, or 0 if none */
- Oid fdwvalidator; /* option validation function, or 0 if none */
+ Oid fdwowner BKI_LOOKUP(pg_authid); /* FDW owner */
+ Oid fdwhandler BKI_LOOKUP_OPT(pg_proc); /* handler function, or 0
+ * if none */
+ Oid fdwvalidator BKI_LOOKUP_OPT(pg_proc); /* option validation
+ * function, or 0 if
+ * none */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
aclitem fdwacl[1]; /* access permissions */
diff --git a/src/include/catalog/pg_foreign_server.h b/src/include/catalog/pg_foreign_server.h
index 385b896e97..a173699aef 100644
--- a/src/include/catalog/pg_foreign_server.h
+++ b/src/include/catalog/pg_foreign_server.h
@@ -29,8 +29,8 @@ CATALOG(pg_foreign_server,1417,ForeignServerRelationId)
{
Oid oid; /* oid */
NameData srvname; /* foreign server name */
- Oid srvowner; /* server owner */
- Oid srvfdw; /* server FDW */
+ Oid srvowner BKI_LOOKUP(pg_authid); /* server owner */
+ Oid srvfdw BKI_LOOKUP(pg_foreign_data_wrapper); /* server FDW */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text srvtype;
diff --git a/src/include/catalog/pg_foreign_table.h b/src/include/catalog/pg_foreign_table.h
index 24f7f2998e..3b6221b0e6 100644
--- a/src/include/catalog/pg_foreign_table.h
+++ b/src/include/catalog/pg_foreign_table.h
@@ -27,8 +27,8 @@
*/
CATALOG(pg_foreign_table,3118,ForeignTableRelationId)
{
- Oid ftrelid; /* OID of foreign table */
- Oid ftserver; /* OID of foreign server */
+ Oid ftrelid BKI_LOOKUP(pg_class); /* OID of foreign table */
+ Oid ftserver BKI_LOOKUP(pg_foreign_server); /* OID of foreign server */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text ftoptions[1]; /* FDW-specific options */
diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h
index 1a7aef18ce..00d0b439f5 100644
--- a/src/include/catalog/pg_index.h
+++ b/src/include/catalog/pg_index.h
@@ -28,8 +28,9 @@
*/
CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
{
- Oid indexrelid; /* OID of the index */
- Oid indrelid; /* OID of the relation it indexes */
+ Oid indexrelid BKI_LOOKUP(pg_class); /* OID of the index */
+ Oid indrelid BKI_LOOKUP(pg_class); /* OID of the relation it
+ * indexes */
int16 indnatts; /* total number of columns in index */
int16 indnkeyatts; /* number of key columns in index */
bool indisunique; /* is this a unique index? */
@@ -48,8 +49,8 @@ CATALOG(pg_index,2610,IndexRelationId) BKI_SCHEMA_MACRO
* or 0 */
#ifdef CATALOG_VARLEN
- oidvector indcollation BKI_FORCE_NOT_NULL; /* collation identifiers */
- oidvector indclass BKI_FORCE_NOT_NULL; /* opclass identifiers */
+ oidvector indcollation BKI_LOOKUP_OPT(pg_collation) BKI_FORCE_NOT_NULL; /* collation identifiers */
+ oidvector indclass BKI_LOOKUP(pg_opclass) BKI_FORCE_NOT_NULL; /* opclass identifiers */
int2vector indoption BKI_FORCE_NOT_NULL; /* per-column flags
* (AM-specific meanings) */
pg_node_tree indexprs; /* expression trees for index attributes that
@@ -72,6 +73,9 @@ DECLARE_INDEX(pg_index_indrelid_index, 2678, on pg_index using btree(indrelid oi
DECLARE_UNIQUE_INDEX_PKEY(pg_index_indexrelid_index, 2679, on pg_index using btree(indexrelid oid_ops));
#define IndexRelidIndexId 2679
+/* indkey can contain zero (InvalidAttrNumber) to represent expressions */
+DECLARE_ARRAY_FOREIGN_KEY_OPT((indrelid, indkey), pg_attribute, (attrelid, attnum));
+
#ifdef EXPOSE_TO_CLIENT_CODE
/*
diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h
index b8147796d8..2b71cad9a2 100644
--- a/src/include/catalog/pg_inherits.h
+++ b/src/include/catalog/pg_inherits.h
@@ -31,8 +31,8 @@
*/
CATALOG(pg_inherits,2611,InheritsRelationId)
{
- Oid inhrelid;
- Oid inhparent;
+ Oid inhrelid BKI_LOOKUP(pg_class);
+ Oid inhparent BKI_LOOKUP(pg_class);
int32 inhseqno;
} FormData_pg_inherits;
diff --git a/src/include/catalog/pg_init_privs.h b/src/include/catalog/pg_init_privs.h
index 983b1857c0..4aafeb246d 100644
--- a/src/include/catalog/pg_init_privs.h
+++ b/src/include/catalog/pg_init_privs.h
@@ -46,7 +46,8 @@
CATALOG(pg_init_privs,3394,InitPrivsRelationId)
{
Oid objoid; /* OID of object itself */
- Oid classoid; /* OID of table containing object */
+ Oid classoid BKI_LOOKUP(pg_class); /* OID of table containing
+ * object */
int32 objsubid; /* column number, or 0 if not used */
char privtype; /* from initdb or extension? */
diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h
index b1dcd0a4f5..e9df9dac09 100644
--- a/src/include/catalog/pg_language.h
+++ b/src/include/catalog/pg_language.h
@@ -34,7 +34,7 @@ CATALOG(pg_language,2612,LanguageRelationId)
NameData lanname;
/* Language's owner */
- Oid lanowner BKI_DEFAULT(PGUID);
+ Oid lanowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* Is a procedural language */
bool lanispl BKI_DEFAULT(f);
@@ -43,13 +43,13 @@ CATALOG(pg_language,2612,LanguageRelationId)
bool lanpltrusted BKI_DEFAULT(f);
/* Call handler, if it's a PL */
- Oid lanplcallfoid BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
+ Oid lanplcallfoid BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_proc);
/* Optional anonymous-block handler function */
- Oid laninline BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
+ Oid laninline BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_proc);
/* Optional validation function */
- Oid lanvalidator BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
+ Oid lanvalidator BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_proc);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Access privileges */
diff --git a/src/include/catalog/pg_largeobject.h b/src/include/catalog/pg_largeobject.h
index f453319322..32225f4de7 100644
--- a/src/include/catalog/pg_largeobject.h
+++ b/src/include/catalog/pg_largeobject.h
@@ -28,7 +28,8 @@
*/
CATALOG(pg_largeobject,2613,LargeObjectRelationId)
{
- Oid loid; /* Identifier of large object */
+ Oid loid BKI_LOOKUP(pg_largeobject_metadata); /* Identifier of large
+ * object */
int32 pageno; /* Page number (starting from 0) */
/* data has variable length, but we allow direct access; see inv_api.c */
diff --git a/src/include/catalog/pg_largeobject_metadata.h b/src/include/catalog/pg_largeobject_metadata.h
index 220988b0ad..9b689bab84 100644
--- a/src/include/catalog/pg_largeobject_metadata.h
+++ b/src/include/catalog/pg_largeobject_metadata.h
@@ -31,7 +31,8 @@ CATALOG(pg_largeobject_metadata,2995,LargeObjectMetadataRelationId)
{
Oid oid; /* oid */
- Oid lomowner; /* OID of the largeobject owner */
+ Oid lomowner BKI_LOOKUP(pg_authid); /* OID of the largeobject
+ * owner */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
aclitem lomacl[1]; /* access permissions */
diff --git a/src/include/catalog/pg_namespace.dat b/src/include/catalog/pg_namespace.dat
index 76257e98fc..2ed136b787 100644
--- a/src/include/catalog/pg_namespace.dat
+++ b/src/include/catalog/pg_namespace.dat
@@ -14,12 +14,12 @@
{ oid => '11', oid_symbol => 'PG_CATALOG_NAMESPACE',
descr => 'system catalog schema',
- nspname => 'pg_catalog', nspowner => 'PGUID', nspacl => '_null_' },
+ nspname => 'pg_catalog', nspacl => '_null_' },
{ oid => '99', oid_symbol => 'PG_TOAST_NAMESPACE',
descr => 'reserved schema for TOAST tables',
- nspname => 'pg_toast', nspowner => 'PGUID', nspacl => '_null_' },
+ nspname => 'pg_toast', nspacl => '_null_' },
{ oid => '2200', oid_symbol => 'PG_PUBLIC_NAMESPACE',
descr => 'standard public schema',
- nspname => 'public', nspowner => 'PGUID', nspacl => '_null_' },
+ nspname => 'public', nspacl => '_null_' },
]
diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h
index 0a68958b1c..d920c6cfc6 100644
--- a/src/include/catalog/pg_namespace.h
+++ b/src/include/catalog/pg_namespace.h
@@ -37,7 +37,7 @@ CATALOG(pg_namespace,2615,NamespaceRelationId)
Oid oid; /* oid */
NameData nspname;
- Oid nspowner;
+ Oid nspowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
aclitem nspacl[1];
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index d132df1f2f..9f321f2a85 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -57,10 +57,10 @@ CATALOG(pg_opclass,2616,OperatorClassRelationId)
NameData opcname;
/* namespace of this opclass */
- Oid opcnamespace BKI_DEFAULT(PGNSP);
+ Oid opcnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* opclass owner */
- Oid opcowner BKI_DEFAULT(PGUID);
+ Oid opcowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* containing operator family */
Oid opcfamily BKI_LOOKUP(pg_opfamily);
@@ -71,8 +71,8 @@ CATALOG(pg_opclass,2616,OperatorClassRelationId)
/* T if opclass is default for opcintype */
bool opcdefault BKI_DEFAULT(t);
- /* type of data in index, or InvalidOid */
- Oid opckeytype BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
+ /* type of data in index, or InvalidOid if same as input column type */
+ Oid opckeytype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
} FormData_pg_opclass;
/* ----------------
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index 3ca57e7c1b..7f06abaeec 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -36,10 +36,10 @@ CATALOG(pg_operator,2617,OperatorRelationId)
NameData oprname;
/* OID of namespace containing this oper */
- Oid oprnamespace BKI_DEFAULT(PGNSP);
+ Oid oprnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* operator owner */
- Oid oprowner BKI_DEFAULT(PGUID);
+ Oid oprowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* 'l' for prefix or 'b' for infix */
char oprkind BKI_DEFAULT(b);
@@ -51,28 +51,28 @@ CATALOG(pg_operator,2617,OperatorRelationId)
bool oprcanhash BKI_DEFAULT(f);
/* left arg type, or 0 if prefix operator */
- Oid oprleft BKI_LOOKUP(pg_type);
+ Oid oprleft BKI_LOOKUP_OPT(pg_type);
/* right arg type */
Oid oprright BKI_LOOKUP(pg_type);
- /* result datatype */
- Oid oprresult BKI_LOOKUP(pg_type);
+ /* result datatype; can be 0 in a "shell" operator */
+ Oid oprresult BKI_LOOKUP_OPT(pg_type);
/* OID of commutator oper, or 0 if none */
- Oid oprcom BKI_DEFAULT(0) BKI_LOOKUP(pg_operator);
+ Oid oprcom BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_operator);
/* OID of negator oper, or 0 if none */
- Oid oprnegate BKI_DEFAULT(0) BKI_LOOKUP(pg_operator);
+ Oid oprnegate BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_operator);
- /* OID of underlying function */
- regproc oprcode BKI_LOOKUP(pg_proc);
+ /* OID of underlying function; can be 0 in a "shell" operator */
+ regproc oprcode BKI_LOOKUP_OPT(pg_proc);
/* OID of restriction estimator, or 0 */
- regproc oprrest BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc oprrest BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/* OID of join estimator, or 0 */
- regproc oprjoin BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc oprjoin BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
} FormData_pg_operator;
/* ----------------
diff --git a/src/include/catalog/pg_opfamily.h b/src/include/catalog/pg_opfamily.h
index 18385a6fd6..1a723b76f6 100644
--- a/src/include/catalog/pg_opfamily.h
+++ b/src/include/catalog/pg_opfamily.h
@@ -37,10 +37,10 @@ CATALOG(pg_opfamily,2753,OperatorFamilyRelationId)
NameData opfname;
/* namespace of this opfamily */
- Oid opfnamespace BKI_DEFAULT(PGNSP);
+ Oid opfnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* opfamily owner */
- Oid opfowner BKI_DEFAULT(PGUID);
+ Oid opfowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
} FormData_pg_opfamily;
/* ----------------
diff --git a/src/include/catalog/pg_partitioned_table.h b/src/include/catalog/pg_partitioned_table.h
index 038730b005..48cbaf30ff 100644
--- a/src/include/catalog/pg_partitioned_table.h
+++ b/src/include/catalog/pg_partitioned_table.h
@@ -29,11 +29,11 @@
*/
CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
{
- Oid partrelid; /* partitioned table oid */
+ Oid partrelid BKI_LOOKUP(pg_class); /* partitioned table oid */
char partstrat; /* partitioning strategy */
int16 partnatts; /* number of partition key columns */
- Oid partdefid; /* default partition oid; InvalidOid if there
- * isn't one */
+ Oid partdefid BKI_LOOKUP_OPT(pg_class); /* default partition oid;
+ * 0 if there isn't one */
/*
* variable-length fields start here, but we allow direct access to
@@ -48,10 +48,10 @@ CATALOG(pg_partitioned_table,3350,PartitionedRelationId)
* an expression */
#ifdef CATALOG_VARLEN
- oidvector partclass BKI_FORCE_NOT_NULL; /* operator class to compare
- * keys */
- oidvector partcollation BKI_FORCE_NOT_NULL; /* user-specified
- * collation for keys */
+ oidvector partclass BKI_LOOKUP(pg_opclass) BKI_FORCE_NOT_NULL; /* operator class to
+ * compare keys */
+ oidvector partcollation BKI_LOOKUP_OPT(pg_collation) BKI_FORCE_NOT_NULL; /* user-specified
+ * collation for keys */
pg_node_tree partexprs; /* list of expressions in the partition key;
* one item for each zero entry in partattrs[] */
#endif
@@ -69,4 +69,7 @@ DECLARE_TOAST(pg_partitioned_table, 4165, 4166);
DECLARE_UNIQUE_INDEX_PKEY(pg_partitioned_table_partrelid_index, 3351, on pg_partitioned_table using btree(partrelid oid_ops));
#define PartitionedRelidIndexId 3351
+/* partattrs can contain zero (InvalidAttrNumber) to represent expressions */
+DECLARE_ARRAY_FOREIGN_KEY_OPT((partrelid, partattrs), pg_attribute, (attrelid, attnum));
+
#endif /* PG_PARTITIONED_TABLE_H */
diff --git a/src/include/catalog/pg_policy.h b/src/include/catalog/pg_policy.h
index 44197613e0..645b8fe498 100644
--- a/src/include/catalog/pg_policy.h
+++ b/src/include/catalog/pg_policy.h
@@ -30,13 +30,14 @@ CATALOG(pg_policy,3256,PolicyRelationId)
{
Oid oid; /* oid */
NameData polname; /* Policy name. */
- Oid polrelid; /* Oid of the relation with policy. */
+ Oid polrelid BKI_LOOKUP(pg_class); /* Oid of the relation with
+ * policy. */
char polcmd; /* One of ACL_*_CHR, or '*' for all */
bool polpermissive; /* restrictive or permissive policy */
#ifdef CATALOG_VARLEN
- Oid polroles[1] BKI_FORCE_NOT_NULL; /* Roles associated with
- * policy */
+ /* Roles to which the policy is applied; zero means PUBLIC */
+ Oid polroles[1] BKI_LOOKUP_OPT(pg_authid) BKI_FORCE_NOT_NULL;
pg_node_tree polqual; /* Policy quals. */
pg_node_tree polwithcheck; /* WITH CHECK quals. */
#endif
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index f8174061ef..4e0c9be58c 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2405,7 +2405,7 @@
{ oid => '1215', descr => 'get description for object id and catalog name',
proname => 'obj_description', prolang => 'sql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
- prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
+ prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = \'pg_catalog\'::pg_catalog.regnamespace) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
proname => 'col_description', prolang => 'sql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
@@ -2414,7 +2414,7 @@
descr => 'get description for object id and shared catalog name',
proname => 'shobj_description', prolang => 'sql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
- prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
+ prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = \'pg_catalog\'::pg_catalog.regnamespace)' },
{ oid => '1217',
descr => 'truncate timestamp with time zone to specified units',
@@ -3698,6 +3698,14 @@
proargnames => '{word,catcode,barelabel,catdesc,baredesc}',
prosrc => 'pg_get_keywords' },
+{ oid => '8103', descr => 'list of catalog foreign key relationships',
+ proname => 'pg_get_catalog_foreign_keys', procost => '10', prorows => '250',
+ proretset => 't', provolatile => 's', prorettype => 'record',
+ proargtypes => '', proallargtypes => '{regclass,_text,regclass,_text,bool,bool}',
+ proargmodes => '{o,o,o,o,o,o}',
+ proargnames => '{fktable,fkcols,pktable,pkcols,is_array,is_opt}',
+ prosrc => 'pg_get_catalog_foreign_keys' },
+
{ oid => '2289', descr => 'convert generic options array to name/value table',
proname => 'pg_options_to_table', prorows => '3', proretset => 't',
provolatile => 's', prorettype => 'record', proargtypes => '_text',
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 03c8bef422..2f54aa171e 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -35,10 +35,10 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
NameData proname;
/* OID of namespace containing this proc */
- Oid pronamespace BKI_DEFAULT(PGNSP);
+ Oid pronamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* procedure owner */
- Oid proowner BKI_DEFAULT(PGUID);
+ Oid proowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* OID of pg_language entry */
Oid prolang BKI_DEFAULT(internal) BKI_LOOKUP(pg_language);
@@ -49,11 +49,11 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
/* estimated # of rows out (if proretset) */
float4 prorows BKI_DEFAULT(0);
- /* element type of variadic array, or 0 */
- Oid provariadic BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
+ /* element type of variadic array, or 0 if not variadic */
+ Oid provariadic BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
/* planner support function for this function, or 0 if none */
- regproc prosupport BKI_DEFAULT(0) BKI_LOOKUP(pg_proc);
+ regproc prosupport BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_proc);
/* see PROKIND_ categories below */
char prokind BKI_DEFAULT(f);
@@ -109,7 +109,7 @@ CATALOG(pg_proc,1255,ProcedureRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81,Proce
pg_node_tree proargdefaults BKI_DEFAULT(_null_);
/* types for which to apply transforms */
- Oid protrftypes[1] BKI_DEFAULT(_null_);
+ Oid protrftypes[1] BKI_DEFAULT(_null_) BKI_LOOKUP(pg_type);
/* procedure source text */
text prosrc BKI_FORCE_NOT_NULL;
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index 4127611f5a..1b31fee9e3 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -32,7 +32,7 @@ CATALOG(pg_publication,6104,PublicationRelationId)
NameData pubname; /* name of the publication */
- Oid pubowner; /* publication owner */
+ Oid pubowner BKI_LOOKUP(pg_authid); /* publication owner */
/*
* indicates that this is special publication which should encompass all
diff --git a/src/include/catalog/pg_publication_rel.h b/src/include/catalog/pg_publication_rel.h
index c79b7fb487..aecf53b3b3 100644
--- a/src/include/catalog/pg_publication_rel.h
+++ b/src/include/catalog/pg_publication_rel.h
@@ -29,8 +29,8 @@
CATALOG(pg_publication_rel,6106,PublicationRelRelationId)
{
Oid oid; /* oid */
- Oid prpubid; /* Oid of the publication */
- Oid prrelid; /* Oid of the relation */
+ Oid prpubid BKI_LOOKUP(pg_publication); /* Oid of the publication */
+ Oid prrelid BKI_LOOKUP(pg_class); /* Oid of the relation */
} FormData_pg_publication_rel;
/* ----------------
diff --git a/src/include/catalog/pg_range.h b/src/include/catalog/pg_range.h
index 2ec6a4b126..5dfa4eef8b 100644
--- a/src/include/catalog/pg_range.h
+++ b/src/include/catalog/pg_range.h
@@ -38,16 +38,16 @@ CATALOG(pg_range,3541,RangeRelationId)
Oid rngmultitypid BKI_LOOKUP(pg_type);
/* collation for this range type, or 0 */
- Oid rngcollation BKI_DEFAULT(0);
+ Oid rngcollation BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_collation);
/* subtype's btree opclass */
Oid rngsubopc BKI_LOOKUP(pg_opclass);
/* canonicalize range, or 0 */
- regproc rngcanonical BKI_LOOKUP(pg_proc);
+ regproc rngcanonical BKI_LOOKUP_OPT(pg_proc);
/* subtype difference as a float8, or 0 */
- regproc rngsubdiff BKI_LOOKUP(pg_proc);
+ regproc rngsubdiff BKI_LOOKUP_OPT(pg_proc);
} FormData_pg_range;
/* ----------------
diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h
index 36f92b1cf1..89c72545d0 100644
--- a/src/include/catalog/pg_rewrite.h
+++ b/src/include/catalog/pg_rewrite.h
@@ -33,7 +33,7 @@ CATALOG(pg_rewrite,2618,RewriteRelationId)
{
Oid oid; /* oid */
NameData rulename;
- Oid ev_class;
+ Oid ev_class BKI_LOOKUP(pg_class);
char ev_type;
char ev_enabled;
bool is_instead;
diff --git a/src/include/catalog/pg_seclabel.h b/src/include/catalog/pg_seclabel.h
index b14fd7febe..0a12225eb7 100644
--- a/src/include/catalog/pg_seclabel.h
+++ b/src/include/catalog/pg_seclabel.h
@@ -28,7 +28,8 @@
CATALOG(pg_seclabel,3596,SecLabelRelationId)
{
Oid objoid; /* OID of the object itself */
- Oid classoid; /* OID of table containing the object */
+ Oid classoid BKI_LOOKUP(pg_class); /* OID of table containing the
+ * object */
int32 objsubid; /* column number, or 0 if not used */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
diff --git a/src/include/catalog/pg_sequence.h b/src/include/catalog/pg_sequence.h
index addf21abce..8d0a00baf6 100644
--- a/src/include/catalog/pg_sequence.h
+++ b/src/include/catalog/pg_sequence.h
@@ -22,8 +22,8 @@
CATALOG(pg_sequence,2224,SequenceRelationId)
{
- Oid seqrelid;
- Oid seqtypid;
+ Oid seqrelid BKI_LOOKUP(pg_class);
+ Oid seqtypid BKI_LOOKUP(pg_type);
int64 seqstart;
int64 seqincrement;
int64 seqmax;
diff --git a/src/include/catalog/pg_shdepend.h b/src/include/catalog/pg_shdepend.h
index f5863954e9..4faa95794d 100644
--- a/src/include/catalog/pg_shdepend.h
+++ b/src/include/catalog/pg_shdepend.h
@@ -42,8 +42,10 @@ CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION
* These fields are all zeroes for a DEPENDENCY_PIN entry. Also, dbid can
* be zero to denote a shared object.
*/
- Oid dbid; /* OID of database containing object */
- Oid classid; /* OID of table containing object */
+ Oid dbid BKI_LOOKUP_OPT(pg_database); /* OID of database
+ * containing object */
+ Oid classid BKI_LOOKUP_OPT(pg_class); /* OID of table containing
+ * object */
Oid objid; /* OID of object itself */
int32 objsubid; /* column number, or 0 if not used */
@@ -52,7 +54,8 @@ CATALOG(pg_shdepend,1214,SharedDependRelationId) BKI_SHARED_RELATION
* a shared object, so we need no database ID field. We don't bother with
* a sub-object ID either.
*/
- Oid refclassid; /* OID of table containing object */
+ Oid refclassid BKI_LOOKUP(pg_class); /* OID of table containing
+ * object */
Oid refobjid; /* OID of object itself */
/*
diff --git a/src/include/catalog/pg_shdescription.h b/src/include/catalog/pg_shdescription.h
index a37db4fa0b..543e216710 100644
--- a/src/include/catalog/pg_shdescription.h
+++ b/src/include/catalog/pg_shdescription.h
@@ -62,4 +62,7 @@ DECLARE_TOAST(pg_shdescription, 2846, 2847);
DECLARE_UNIQUE_INDEX_PKEY(pg_shdescription_o_c_index, 2397, on pg_shdescription using btree(objoid oid_ops, classoid oid_ops));
#define SharedDescriptionObjIndexId 2397
+/* We do not use BKI_LOOKUP here because it causes problems for genbki.pl */
+DECLARE_FOREIGN_KEY((classoid), pg_class, (oid));
+
#endif /* PG_SHDESCRIPTION_H */
diff --git a/src/include/catalog/pg_shseclabel.h b/src/include/catalog/pg_shseclabel.h
index 406f5328a7..5d6864cf8c 100644
--- a/src/include/catalog/pg_shseclabel.h
+++ b/src/include/catalog/pg_shseclabel.h
@@ -28,7 +28,8 @@
CATALOG(pg_shseclabel,3592,SharedSecLabelRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(4066,SharedSecLabelRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid objoid; /* OID of the shared object itself */
- Oid classoid; /* OID of table containing the shared object */
+ Oid classoid BKI_LOOKUP(pg_class); /* OID of table containing the
+ * shared object */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text provider BKI_FORCE_NOT_NULL; /* name of label provider */
diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h
index 4a66bda879..d1827858e2 100644
--- a/src/include/catalog/pg_statistic.h
+++ b/src/include/catalog/pg_statistic.h
@@ -29,7 +29,8 @@
CATALOG(pg_statistic,2619,StatisticRelationId)
{
/* These fields form the unique key for the entry: */
- Oid starelid; /* relation containing attribute */
+ Oid starelid BKI_LOOKUP(pg_class); /* relation containing
+ * attribute */
int16 staattnum; /* attribute (column) stats are for */
bool stainherit; /* true if inheritance children are included */
@@ -90,17 +91,17 @@ CATALOG(pg_statistic,2619,StatisticRelationId)
int16 stakind4;
int16 stakind5;
- Oid staop1;
- Oid staop2;
- Oid staop3;
- Oid staop4;
- Oid staop5;
+ Oid staop1 BKI_LOOKUP_OPT(pg_operator);
+ Oid staop2 BKI_LOOKUP_OPT(pg_operator);
+ Oid staop3 BKI_LOOKUP_OPT(pg_operator);
+ Oid staop4 BKI_LOOKUP_OPT(pg_operator);
+ Oid staop5 BKI_LOOKUP_OPT(pg_operator);
- Oid stacoll1;
- Oid stacoll2;
- Oid stacoll3;
- Oid stacoll4;
- Oid stacoll5;
+ Oid stacoll1 BKI_LOOKUP_OPT(pg_collation);
+ Oid stacoll2 BKI_LOOKUP_OPT(pg_collation);
+ Oid stacoll3 BKI_LOOKUP_OPT(pg_collation);
+ Oid stacoll4 BKI_LOOKUP_OPT(pg_collation);
+ Oid stacoll5 BKI_LOOKUP_OPT(pg_collation);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
float4 stanumbers1[1];
@@ -138,6 +139,8 @@ DECLARE_TOAST(pg_statistic, 2840, 2841);
DECLARE_UNIQUE_INDEX_PKEY(pg_statistic_relid_att_inh_index, 2696, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops, stainherit bool_ops));
#define StatisticRelidAttnumInhIndexId 2696
+DECLARE_FOREIGN_KEY((starelid, staattnum), pg_attribute, (attrelid, attnum));
+
#ifdef EXPOSE_TO_CLIENT_CODE
/*
diff --git a/src/include/catalog/pg_statistic_ext.h b/src/include/catalog/pg_statistic_ext.h
index 10f52f912c..29649f5814 100644
--- a/src/include/catalog/pg_statistic_ext.h
+++ b/src/include/catalog/pg_statistic_ext.h
@@ -34,13 +34,15 @@ CATALOG(pg_statistic_ext,3381,StatisticExtRelationId)
{
Oid oid; /* oid */
- Oid stxrelid; /* relation containing attributes */
+ Oid stxrelid BKI_LOOKUP(pg_class); /* relation containing
+ * attributes */
/* These two fields form the unique key for the entry: */
NameData stxname; /* statistics object name */
- Oid stxnamespace; /* OID of statistics object's namespace */
+ Oid stxnamespace BKI_LOOKUP(pg_namespace); /* OID of statistics
+ * object's namespace */
- Oid stxowner; /* statistics object's owner */
+ Oid stxowner BKI_LOOKUP(pg_authid); /* statistics object's owner */
int32 stxstattarget BKI_DEFAULT(-1); /* statistics target */
/*
@@ -72,6 +74,8 @@ DECLARE_UNIQUE_INDEX(pg_statistic_ext_name_index, 3997, on pg_statistic_ext usin
DECLARE_INDEX(pg_statistic_ext_relid_index, 3379, on pg_statistic_ext using btree(stxrelid oid_ops));
#define StatisticExtRelidIndexId 3379
+DECLARE_ARRAY_FOREIGN_KEY((stxrelid, stxkeys), pg_attribute, (attrelid, attnum));
+
#ifdef EXPOSE_TO_CLIENT_CODE
#define STATS_EXT_NDISTINCT 'd'
diff --git a/src/include/catalog/pg_statistic_ext_data.h b/src/include/catalog/pg_statistic_ext_data.h
index 6f7a36c141..2f2577c218 100644
--- a/src/include/catalog/pg_statistic_ext_data.h
+++ b/src/include/catalog/pg_statistic_ext_data.h
@@ -30,7 +30,8 @@
*/
CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId)
{
- Oid stxoid; /* statistics object this data is for */
+ Oid stxoid BKI_LOOKUP(pg_statistic_ext); /* statistics object
+ * this data is for */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_subscription.h
index 4e44c29149..a5d6efdf20 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_subscription.h
@@ -40,10 +40,11 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
{
Oid oid; /* oid */
- Oid subdbid; /* Database the subscription is in. */
+ Oid subdbid BKI_LOOKUP(pg_database); /* Database the
+ * subscription is in. */
NameData subname; /* Name of the subscription */
- Oid subowner; /* Owner of the subscription */
+ Oid subowner BKI_LOOKUP(pg_authid); /* Owner of the subscription */
bool subenabled; /* True if the subscription is enabled (the
* worker should be running) */
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_subscription_rel.h
index ab1202cf9b..2bea2c52aa 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_subscription_rel.h
@@ -30,8 +30,8 @@
*/
CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
{
- Oid srsubid; /* Oid of subscription */
- Oid srrelid; /* Oid of relation */
+ Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */
+ Oid srrelid BKI_LOOKUP(pg_class); /* Oid of relation */
char srsubstate; /* state of the relation in subscription */
/*
diff --git a/src/include/catalog/pg_tablespace.dat b/src/include/catalog/pg_tablespace.dat
index 212a0ad07f..bf0d81d306 100644
--- a/src/include/catalog/pg_tablespace.dat
+++ b/src/include/catalog/pg_tablespace.dat
@@ -13,10 +13,8 @@
[
{ oid => '1663', oid_symbol => 'DEFAULTTABLESPACE_OID',
- spcname => 'pg_default', spcowner => 'PGUID', spcacl => '_null_',
- spcoptions => '_null_' },
+ spcname => 'pg_default', spcacl => '_null_', spcoptions => '_null_' },
{ oid => '1664', oid_symbol => 'GLOBALTABLESPACE_OID',
- spcname => 'pg_global', spcowner => 'PGUID', spcacl => '_null_',
- spcoptions => '_null_' },
+ spcname => 'pg_global', spcacl => '_null_', spcoptions => '_null_' },
]
diff --git a/src/include/catalog/pg_tablespace.h b/src/include/catalog/pg_tablespace.h
index 6a6c66a61c..ed38e6950d 100644
--- a/src/include/catalog/pg_tablespace.h
+++ b/src/include/catalog/pg_tablespace.h
@@ -30,7 +30,7 @@ CATALOG(pg_tablespace,1213,TableSpaceRelationId) BKI_SHARED_RELATION
{
Oid oid; /* oid */
NameData spcname; /* tablespace name */
- Oid spcowner; /* owner of tablespace */
+ Oid spcowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid); /* owner of tablespace */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
aclitem spcacl[1]; /* access permissions */
diff --git a/src/include/catalog/pg_transform.h b/src/include/catalog/pg_transform.h
index ad25db1841..d603246138 100644
--- a/src/include/catalog/pg_transform.h
+++ b/src/include/catalog/pg_transform.h
@@ -29,10 +29,10 @@
CATALOG(pg_transform,3576,TransformRelationId)
{
Oid oid; /* oid */
- Oid trftype;
- Oid trflang;
- regproc trffromsql;
- regproc trftosql;
+ Oid trftype BKI_LOOKUP(pg_type);
+ Oid trflang BKI_LOOKUP(pg_language);
+ regproc trffromsql BKI_LOOKUP_OPT(pg_proc);
+ regproc trftosql BKI_LOOKUP_OPT(pg_proc);
} FormData_pg_transform;
/* ----------------
diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h
index 55111ed864..2e3d233876 100644
--- a/src/include/catalog/pg_trigger.h
+++ b/src/include/catalog/pg_trigger.h
@@ -34,18 +34,25 @@
CATALOG(pg_trigger,2620,TriggerRelationId)
{
Oid oid; /* oid */
- Oid tgrelid; /* relation trigger is attached to */
- Oid tgparentid; /* OID of parent trigger, if any */
+ Oid tgrelid BKI_LOOKUP(pg_class); /* relation trigger is
+ * attached to */
+ Oid tgparentid BKI_LOOKUP_OPT(pg_trigger); /* OID of parent
+ * trigger, if any */
NameData tgname; /* trigger's name */
- Oid tgfoid; /* OID of function to be called */
+ Oid tgfoid BKI_LOOKUP(pg_proc); /* OID of function to be called */
int16 tgtype; /* BEFORE/AFTER/INSTEAD, UPDATE/DELETE/INSERT,
* ROW/STATEMENT; see below */
char tgenabled; /* trigger's firing configuration WRT
* session_replication_role */
bool tgisinternal; /* trigger is system-generated */
- Oid tgconstrrelid; /* constraint's FROM table, if any */
- Oid tgconstrindid; /* constraint's supporting index, if any */
- Oid tgconstraint; /* associated pg_constraint entry, if any */
+ Oid tgconstrrelid BKI_LOOKUP_OPT(pg_class); /* constraint's FROM
+ * table, if any */
+ Oid tgconstrindid BKI_LOOKUP_OPT(pg_class); /* constraint's
+ * supporting index, if
+ * any */
+ Oid tgconstraint BKI_LOOKUP_OPT(pg_constraint); /* associated
+ * pg_constraint entry,
+ * if any */
bool tgdeferrable; /* constraint trigger is deferrable */
bool tginitdeferred; /* constraint trigger is deferred initially */
int16 tgnargs; /* # of extra arguments in tgargs */
@@ -81,6 +88,8 @@ DECLARE_UNIQUE_INDEX(pg_trigger_tgrelid_tgname_index, 2701, on pg_trigger using
DECLARE_UNIQUE_INDEX_PKEY(pg_trigger_oid_index, 2702, on pg_trigger using btree(oid oid_ops));
#define TriggerOidIndexId 2702
+DECLARE_ARRAY_FOREIGN_KEY((tgrelid, tgattr), pg_attribute, (attrelid, attnum));
+
#ifdef EXPOSE_TO_CLIENT_CODE
/* Bits within tgtype */
diff --git a/src/include/catalog/pg_ts_config.h b/src/include/catalog/pg_ts_config.h
index 02ef1a1554..e705899b17 100644
--- a/src/include/catalog/pg_ts_config.h
+++ b/src/include/catalog/pg_ts_config.h
@@ -36,10 +36,10 @@ CATALOG(pg_ts_config,3602,TSConfigRelationId)
NameData cfgname;
/* name space */
- Oid cfgnamespace BKI_DEFAULT(PGNSP);
+ Oid cfgnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* owner */
- Oid cfgowner BKI_DEFAULT(PGUID);
+ Oid cfgowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* OID of parser */
Oid cfgparser BKI_LOOKUP(pg_ts_parser);
diff --git a/src/include/catalog/pg_ts_dict.h b/src/include/catalog/pg_ts_dict.h
index bfe3378ff8..57f626e7b5 100644
--- a/src/include/catalog/pg_ts_dict.h
+++ b/src/include/catalog/pg_ts_dict.h
@@ -35,10 +35,10 @@ CATALOG(pg_ts_dict,3600,TSDictionaryRelationId)
NameData dictname;
/* name space */
- Oid dictnamespace BKI_DEFAULT(PGNSP);
+ Oid dictnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* owner */
- Oid dictowner BKI_DEFAULT(PGUID);
+ Oid dictowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/* dictionary's template */
Oid dicttemplate BKI_LOOKUP(pg_ts_template);
diff --git a/src/include/catalog/pg_ts_parser.h b/src/include/catalog/pg_ts_parser.h
index f9f22716fd..e0d705fd9a 100644
--- a/src/include/catalog/pg_ts_parser.h
+++ b/src/include/catalog/pg_ts_parser.h
@@ -34,7 +34,7 @@ CATALOG(pg_ts_parser,3601,TSParserRelationId)
NameData prsname;
/* name space */
- Oid prsnamespace BKI_DEFAULT(PGNSP);
+ Oid prsnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* init parsing session */
regproc prsstart BKI_LOOKUP(pg_proc);
@@ -46,7 +46,7 @@ CATALOG(pg_ts_parser,3601,TSParserRelationId)
regproc prsend BKI_LOOKUP(pg_proc);
/* return data for headline creation */
- regproc prsheadline BKI_LOOKUP(pg_proc);
+ regproc prsheadline BKI_LOOKUP_OPT(pg_proc);
/* return descriptions of lexeme's types */
regproc prslextype BKI_LOOKUP(pg_proc);
diff --git a/src/include/catalog/pg_ts_template.h b/src/include/catalog/pg_ts_template.h
index ae91922688..2ee1ae4e85 100644
--- a/src/include/catalog/pg_ts_template.h
+++ b/src/include/catalog/pg_ts_template.h
@@ -34,10 +34,10 @@ CATALOG(pg_ts_template,3764,TSTemplateRelationId)
NameData tmplname;
/* name space */
- Oid tmplnamespace BKI_DEFAULT(PGNSP);
+ Oid tmplnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* initialization method of dict (may be 0) */
- regproc tmplinit BKI_LOOKUP(pg_proc);
+ regproc tmplinit BKI_LOOKUP_OPT(pg_proc);
/* base method of dictionary */
regproc tmpllexize BKI_LOOKUP(pg_proc);
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 0d6981bc87..1ec8606703 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -41,10 +41,10 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
NameData typname;
/* OID of namespace containing this type */
- Oid typnamespace BKI_DEFAULT(PGNSP);
+ Oid typnamespace BKI_DEFAULT(PGNSP) BKI_LOOKUP(pg_namespace);
/* type owner */
- Oid typowner BKI_DEFAULT(PGUID);
+ Oid typowner BKI_DEFAULT(PGUID) BKI_LOOKUP(pg_authid);
/*
* For a fixed-size type, typlen is the number of bytes we use to
@@ -98,7 +98,7 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
char typdelim BKI_DEFAULT(',');
/* associated pg_class OID if a composite type, else 0 */
- Oid typrelid BKI_DEFAULT(0) BKI_ARRAY_DEFAULT(0) BKI_LOOKUP(pg_class);
+ Oid typrelid BKI_DEFAULT(0) BKI_ARRAY_DEFAULT(0) BKI_LOOKUP_OPT(pg_class);
/*
* Type-specific subscripting handler. If typsubscript is 0, it means
@@ -106,7 +106,7 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
* of the system deem types to be "true" array types only if their
* typsubscript is array_subscript_handler.
*/
- regproc typsubscript BKI_DEFAULT(-) BKI_ARRAY_DEFAULT(array_subscript_handler) BKI_LOOKUP(pg_proc);
+ regproc typsubscript BKI_DEFAULT(-) BKI_ARRAY_DEFAULT(array_subscript_handler) BKI_LOOKUP_OPT(pg_proc);
/*
* If typelem is not 0 then it identifies another row in pg_type, defining
@@ -117,13 +117,13 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
* of the element type in this type; so DDL changes on the element type
* might be restricted by the presence of this type.
*/
- Oid typelem BKI_DEFAULT(0) BKI_LOOKUP(pg_type);
+ Oid typelem BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
/*
* If there is a "true" array type having this type as element type,
* typarray links to it. Zero if no associated "true" array type.
*/
- Oid typarray BKI_DEFAULT(0) BKI_ARRAY_DEFAULT(0) BKI_LOOKUP(pg_type);
+ Oid typarray BKI_DEFAULT(0) BKI_ARRAY_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
/*
* I/O conversion procedures for the datatype.
@@ -134,19 +134,19 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
regproc typoutput BKI_ARRAY_DEFAULT(array_out) BKI_LOOKUP(pg_proc);
/* binary format (optional) */
- regproc typreceive BKI_ARRAY_DEFAULT(array_recv) BKI_LOOKUP(pg_proc);
- regproc typsend BKI_ARRAY_DEFAULT(array_send) BKI_LOOKUP(pg_proc);
+ regproc typreceive BKI_ARRAY_DEFAULT(array_recv) BKI_LOOKUP_OPT(pg_proc);
+ regproc typsend BKI_ARRAY_DEFAULT(array_send) BKI_LOOKUP_OPT(pg_proc);
/*
* I/O functions for optional type modifiers.
*/
- regproc typmodin BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
- regproc typmodout BKI_DEFAULT(-) BKI_LOOKUP(pg_proc);
+ regproc typmodin BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
+ regproc typmodout BKI_DEFAULT(-) BKI_LOOKUP_OPT(pg_proc);
/*
* Custom ANALYZE procedure for the datatype (0 selects the default).
*/
- regproc typanalyze BKI_DEFAULT(-) BKI_ARRAY_DEFAULT(array_typanalyze) BKI_LOOKUP(pg_proc);
+ regproc typanalyze BKI_DEFAULT(-) BKI_ARRAY_DEFAULT(array_typanalyze) BKI_LOOKUP_OPT(pg_proc);
/* ----------------
* typalign is the alignment required when storing a value of this
@@ -205,7 +205,7 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
* Domains use typbasetype to show the base (or domain) type that the
* domain is based on. Zero if the type is not a domain.
*/
- Oid typbasetype BKI_DEFAULT(0);
+ Oid typbasetype BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_type);
/*
* Domains use typtypmod to record the typmod to be applied to their base
@@ -225,7 +225,7 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati
* DEFAULT_COLLATION_OID) for collatable base types, possibly some other
* OID for domains over collatable types
*/
- Oid typcollation BKI_DEFAULT(0) BKI_LOOKUP(pg_collation);
+ Oid typcollation BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_collation);
#ifdef CATALOG_VARLEN /* variable-length fields start here */
diff --git a/src/include/catalog/pg_user_mapping.h b/src/include/catalog/pg_user_mapping.h
index cabca048a9..d440c67da1 100644
--- a/src/include/catalog/pg_user_mapping.h
+++ b/src/include/catalog/pg_user_mapping.h
@@ -29,9 +29,11 @@ CATALOG(pg_user_mapping,1418,UserMappingRelationId)
{
Oid oid; /* oid */
- Oid umuser; /* Id of the user, InvalidOid if PUBLIC is
- * wanted */
- Oid umserver; /* server of this mapping */
+ Oid umuser BKI_LOOKUP_OPT(pg_authid); /* Id of the user,
+ * InvalidOid if PUBLIC is
+ * wanted */
+ Oid umserver BKI_LOOKUP(pg_foreign_server); /* server of this
+ * mapping */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text umoptions[1]; /* user mapping options */