postgresql/src/bin
Alvaro Herrera 0cd711271d
Better handle indirect constraint drops
It is possible for certain cases to remove not-null constraints without
maintaining the attnotnull in its correct state; for example if you drop
a column that's part of the primary key, and the other columns of the PK don't
have not-null constraints, then we should reset the attnotnull flags for
those other columns; up to this commit, we didn't.  Handle those cases
better by doing the attnotnull reset in RemoveConstraintById() instead
of in dropconstraint_internal().

However, there are some cases where we must not do so.  For example if
those other columns are in replica identity indexes or are generated
identity columns, we must keep attnotnull set, even though it results in
the catalog inconsistency that no not-null constraint supports that.

Because the attnotnull reset now happens in more places than before, for
instance when a column of the primary key changes type, we need an
additional trick to reinstate it as necessary.  Introduce a new
alter-table pass that does this, which needs simply reschedule some
AT_SetAttNotNull subcommands that were already being generated and
ignored.

Because of the exceptions in which attnotnull is not reset noted above,
we also include a pg_dump hack to include a not-null constraint when the
attnotnull flag is set even if no pg_constraint row exists.  This part
is undesirable but necessary, because failing to handle the case can
result in unrestorable dumps.

Reported-by: Tender Wang <tndrwang@gmail.com>
Co-authored-by: Tender Wang <tndrwang@gmail.com>
Reviewed-by: jian he <jian.universality@gmail.com>
Discussion: https://postgr.es/m/CAHewXN=hMbNa3d43NOR=OCgdgpTt18S-1fmueCoEGesyeK4bqw@mail.gmail.com
2024-04-19 12:37:33 +02:00
..
initdb Fix test failures when language environment is not UTF-8. 2024-04-04 16:10:12 -07:00
pg_amcheck Support retrieval of results in chunks with libpq. 2024-04-06 20:45:11 -04:00
pg_archivecleanup Activate perlcritic InputOutput::RequireCheckedSyscalls and fix resulting warnings 2024-03-19 07:09:31 +01:00
pg_basebackup Fix typos and duplicate words 2024-04-18 21:28:07 +02:00
pg_checksums Skip .DS_Store files in server side utils 2024-02-13 13:47:12 +01:00
pg_combinebackup Fix typos and duplicate words 2024-04-18 21:28:07 +02:00
pg_config Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_controldata Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_ctl Activate perlcritic InputOutput::RequireCheckedSyscalls and fix resulting warnings 2024-03-19 07:09:31 +01:00
pg_dump Better handle indirect constraint drops 2024-04-19 12:37:33 +02:00
pg_resetwal Activate perlcritic InputOutput::RequireCheckedSyscalls and fix resulting warnings 2024-03-19 07:09:31 +01:00
pg_rewind Convert uses of hash_string_pointer to fasthash equivalent 2024-04-06 12:20:40 +07:00
pg_test_fsync Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_test_timing Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_upgrade Fix typos and duplicate words 2024-04-18 21:28:07 +02:00
pg_verifybackup Don't allocate large buffer on the stack in pg_verifybackup 2024-04-12 10:52:25 -04:00
pg_waldump Update copyright for 2024 2024-01-03 20:49:05 -05:00
pg_walsummary Add missing set_pglocale_pgservice() for pg_walsummary and pg_combinebackup 2024-04-09 14:01:33 +09:00
pgbench Adjust pgbench option for debug mode. 2024-03-25 11:08:53 -05:00
pgevent Update copyright for 2024 2024-01-03 20:49:05 -05:00
psql psql: Make output of \dD more stable 2024-04-15 09:28:48 +02:00
scripts Fix test failures when language environment is not UTF-8. 2024-04-04 16:10:12 -07:00
Makefile Add new pg_walsummary tool. 2024-01-11 12:48:27 -05:00
meson.build Add new pg_walsummary tool. 2024-01-11 12:48:27 -05:00