Re: Recording foreign key relationships for the system catalogs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joel Jacobson" <joel(at)compiler(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, "Peter Eisentraut" <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Re: Recording foreign key relationships for the system catalogs
Date: 2021-02-02 16:00:48
Message-ID: 3716490.1612281648@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Joel Jacobson" <joel(at)compiler(dot)org> writes:
> I could only find one minor error,
> found by running the regression-tests,
> and then using the query below to compare "is_opt"
> with my own "zero_values" in my tool
> that derives its value from pg_catalog content.
> ...
> I therefore think is_opt should be changed to true for this row:
> fktable | fkcols | pktable | pkcols | is_array | is_opt
> ---------------+---------------------+--------------+-------------------+----------+--------
> pg_constraint | {confrelid,confkey} | pg_attribute | {attrelid,attnum} | t | f

No, I think it's correct as-is (and this is one reason that I chose to
have two separate FK entries for cases like this). confrelid can be
zero in rows that are not FK constraints. However, such a row must
also have empty confkey. The above entry states that for each element
of confkey, the pair (confrelid,confkey[i]) must be nonzero and have
a match in pg_attribute. It creates no constraint if confkey is empty.

> If this is fixed, I also agree this is ready to be committed.

Appreciate the review! Please confirm if you agree with above
analysis.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2021-02-02 16:49:46 Re: adding wait_start column to pg_locks
Previous Message Bruce Momjian 2021-02-02 15:58:07 Re: Key management with tests