postgresql/src/backend/utils/adt
Tom Lane 62f34097c8 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
2021-02-02 17:11:55 -05:00
..
.gitignore Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
Makefile Implementation of subscripting for jsonb 2021-01-31 23:50:40 +03:00
acl.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
amutils.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_expanded.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_typanalyze.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
array_userfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
arrayfuncs.c Rethink the "read/write parameter" mechanism in pl/pgsql. 2021-01-04 12:39:27 -05:00
arraysubs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
arrayutils.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
ascii.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
bool.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
cash.c Expose internal function for converting int64 to numeric 2020-09-09 20:16:28 +02:00
char.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
cryptohashfuncs.c Refactor SQL functions of SHA-2 in cryptohashfuncs.c 2021-01-28 16:13:26 +09:00
date.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
datetime.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
datum.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
dbsize.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
domains.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
encode.c Rework refactoring of hex and encoding routines 2021-01-14 11:13:24 +09:00
enum.c Rename "enum blacklist" to "uncommitted enums". 2021-01-05 12:38:48 +13:00
expandeddatum.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
expandedrecord.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
float.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
format_type.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
formatting.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
genfile.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
geo_ops.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
geo_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
geo_spgist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
inet_cidr_ntop.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
inet_net_pton.c Avoid conflicts with library versions of inet_net_ntop() and friends. 2019-08-18 19:27:23 -04:00
int.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
int8.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
json.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb_gin.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb_op.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonb_util.c Implementation of subscripting for jsonb 2021-01-31 23:50:40 +03:00
jsonbsubs.c Get rid of unnecessary memory allocation in jsonb_subscript_assign() 2021-02-01 14:06:02 +03:00
jsonfuncs.c Throw error when assigning jsonb scalar instead of a composite object 2021-01-31 23:51:06 +03:00
jsonpath.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonpath_exec.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonpath_gram.y Update copyright for 2021 2021-01-02 13:06:25 -05:00
jsonpath_scan.l Update copyright for 2021 2021-01-02 13:06:25 -05:00
levenshtein.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
like.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
like_match.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
like_support.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
lockfuncs.c Replace CLOBBER_CACHE_ALWAYS with run-time GUC 2021-01-06 10:46:44 +01:00
mac.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
mac8.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
mcxtfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
misc.c Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
multirangetypes.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
multirangetypes_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
name.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
network.c Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
network_gist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
network_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
network_spgist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
numeric.c Add an explicit cast to double when using fabs(). 2021-01-05 11:52:42 +00:00
numutils.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
oid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
oracle_compat.c Add bytea equivalents of ltrim() and rtrim(). 2021-01-18 15:11:32 -05:00
orderedsetaggs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
partitionfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_locale.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_lsn.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pg_upgrade_support.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
pgstatfuncs.c Add pg_stat_database counters for sessions and session time 2021-01-17 13:52:31 +01:00
pseudotypes.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
quote.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_gist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_selfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_spgist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rangetypes_typanalyze.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
regexp.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
regproc.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
ri_triggers.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
rowtypes.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
ruleutils.c SEARCH and CYCLE clauses 2021-02-01 14:32:51 +01:00
selfuncs.c Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar. 2021-01-21 15:37:23 -05:00
tid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
timestamp.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
trigfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsginidx.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsgistidx.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_cleanup.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_gist.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_op.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_rewrite.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsquery_util.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsrank.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsvector.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsvector_op.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
tsvector_parser.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
uuid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
varbit.c Fix integer-overflow corner cases in substring() functions. 2021-01-04 18:32:44 -05:00
varchar.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
varlena.c Rework refactoring of hex and encoding routines 2021-01-14 11:13:24 +09:00
version.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
windowfuncs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xid.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xid8funcs.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
xml.c Simplify some comments in xml.c 2021-01-04 19:47:58 +09:00