postgres/contrib/test_decoding/expected
Álvaro Herrera 14e87ffa5c
Add pg_constraint rows for not-null constraints
We now create contype='n' pg_constraint rows for not-null constraints on
user tables.  Only one such constraint is allowed for a column.

We propagate these constraints to other tables during operations such as
adding inheritance relationships, creating and attaching partitions and
creating tables LIKE other tables.  These related constraints mostly
follow the well-known rules of conislocal and coninhcount that we have
for CHECK constraints, with some adaptations: for example, as opposed to
CHECK constraints, we don't match not-null ones by name when descending
a hierarchy to alter or remove it, instead matching by the name of the
column that they apply to.  This means we don't require the constraint
names to be identical across a hierarchy.

The inheritance status of these constraints can be controlled: now we
can be sure that if a parent table has one, then all children will have
it as well.  They can optionally be marked NO INHERIT, and then children
are free not to have one.  (There's currently no support for altering a
NO INHERIT constraint into inheriting down the hierarchy, but that's a
desirable future feature.)

This also opens the door for having these constraints be marked NOT
VALID, as well as allowing UNIQUE+NOT NULL to be used for functional
dependency determination, as envisioned by commit e49ae8d3bc.  It's
likely possible to allow DEFERRABLE constraints as followup work, as
well.

psql shows these constraints in \d+, though we may want to reconsider if
this turns out to be too noisy.  Earlier versions of this patch hid
constraints that were on the same columns of the primary key, but I'm
not sure that that's very useful.  If clutter is a problem, we might be
better off inventing a new \d++ command and not showing the constraints
in \d+.

For now, we omit these constraints on system catalog columns, because
they're unlikely to achieve anything.

The main difference to the previous attempt at this (b0e96f3119) is
that we now require that such a constraint always exists when a primary
key is in the column; we didn't require this previously which had a
number of unpalatable consequences.  With this requirement, the code is
easier to reason about.  For example:

- We no longer have "throwaway constraints" during pg_dump.  We needed
  those for the case where a table had a PK without a not-null
  underneath, to prevent a slow scan of the data during restore of the
  PK creation, which was particularly problematic for pg_upgrade.

- We no longer have to cope with attnotnull being set spuriously in
  case a primary key is dropped indirectly (e.g., via DROP COLUMN).

Some bits of code in this patch were authored by Jian He.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Author: Bernd Helmle <mailings@oopsware.de>
Reviewed-by: 何建 (jian he) <jian.universality@gmail.com>
Reviewed-by: 王刚 (Tender Wang) <tndrwang@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/202408310358.sdhumtyuy2ht@alvherre.pgsql
2024-11-08 13:28:48 +01:00
..
binary.out Message style improvements 2015-10-28 20:38:36 -04:00
catalog_change_snapshot.out Fix assertion failures while processing NEW_CID record in logical decoding. 2022-10-20 08:49:48 +05:30
concurrent_ddl_dml.out Improve display of query results in isolation tests. 2021-06-23 11:13:00 -04:00
concurrent_stream.out Remove incidental md5() function uses from several tests 2023-07-04 14:31:57 +02:00
ddl.out Add pg_constraint rows for not-null constraints 2024-11-08 13:28:48 +01:00
decoding_in_xact.out Make RelationFlushRelation() work without ResourceOwner during abort 2024-06-06 18:56:28 +03:00
decoding_into_rel.out Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
delayed_startup.out Improve display of query results in isolation tests. 2021-06-23 11:13:00 -04:00
messages.out Add flush option to pg_logical_emit_message() 2023-10-18 11:24:59 +09:00
mxact.out Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
oldest_xmin.out Improve display of query results in isolation tests. 2021-06-23 11:13:00 -04:00
ondisk_startup.out Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
permissions.out Add a slot synchronization function. 2024-02-14 09:45:36 +05:30
prepared.out Add skip-empty-xacts option to test_decoding for use in the regression tests. 2014-09-01 15:59:44 +02:00
replorigin.out Fix the misuse of origin filter across multiple pg_logical_slot_get_changes() calls. 2023-09-27 14:32:51 +05:30
rewrite.out Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
skip_snapshot_restore.out Fix possibility of logical decoding partial transaction changes. 2024-07-11 22:48:23 +09:00
slot.out Revise GUC names quoting in messages again 2024-05-17 11:44:26 +02:00
slot_creation_error.out Close race condition in slot_creation_error.spec. 2022-03-18 18:18:00 -07:00
snapshot_transfer.out Improve display of query results in isolation tests. 2021-06-23 11:13:00 -04:00
spill.out Make contrib/test_decoding regression tests safe for CZ locale. 2016-11-21 20:39:28 -05:00
stats.out pgstat: add/extend tests for resetting various kinds of stats. 2022-04-07 15:43:43 -07:00
stream.out Stabilize the test added by commit 022564f60c. 2024-10-08 12:25:52 +05:30
subxact_without_top.out Improve display of query results in isolation tests. 2021-06-23 11:13:00 -04:00
time.out logical decoding: fix decoding of a commit's commit time. 2016-03-02 23:42:21 -08:00
toast.out Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
truncate.out Revert "Logical decoding of sequences" 2022-04-07 20:06:36 +02:00
twophase.out Stabilize the test added by commit 022564f60c. 2024-10-08 12:25:52 +05:30
twophase_snapshot.out Improve display of query results in isolation tests. 2021-06-23 11:13:00 -04:00
twophase_stream.out Add STREAM_START/STREAM_STOP for transactional messages during decoding. 2023-10-30 14:36:21 +05:30
xact.out Don't propagate a null subtransaction snapshot up to parent transaction. 2016-08-07 13:15:55 -04:00