postgresql/src
Álvaro Herrera fd41ba93e4
Dump not-null constraints on inherited columns correctly
With not-null constraints defined in child tables for columns that are
coming from their parent tables, we were printing ALTER TABLE SET NOT
NULL commands that were missing the constraint name, so the original
constraint name was being lost, which is bogus.  Fix by instead adding
a table-constraint constraint declaration with the correct constraint
name in the CREATE TABLE instead.

Oversight in commit 14e87ffa5c.

We could have fixed it by changing the ALTER TABLE SET NOT NULL to ALTER
TABLE ADD CONSTRAINT, but I'm not sure that's any better.  A potential
problem here might be that if sent to a non-Postgres server, the new
pg_dump output would fail because the "CONSTRAINT foo NOT NULL colname"
syntax isn't SQL-conforming.  However, Postgres' implementation of
inheritance is already non-SQL-conforming, so that'd likely fail anyway.

This problem was only noticed by Ashutosh's proposed test framework for
pg_dump, https://postgr.es/m/CAExHW5uF5V=Cjecx3_Z=7xfh4rg2Wf61PT+hfquzjBqouRzQJQ@mail.gmail.com

Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reported-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/CAExHW5tbdgAKDfqjDJ-7Fk6PJtHg8D4zUF6FQ4H2Pq8zK38Nyw@mail.gmail.com
2024-12-13 07:38:49 +01:00
..
backend Revert "Don't truncate database and user names in startup packets." 2024-12-12 15:52:04 -06:00
bin Dump not-null constraints on inherited columns correctly 2024-12-13 07:38:49 +01:00
common Fix outdated comment of scram_build_secret() 2024-12-10 12:54:09 +09:00
fe_utils Remove unused #include's from bin .c files 2024-11-06 11:11:52 +01:00
include Adjust some comments about structure properties in pg_stat.h 2024-12-12 16:59:22 +09:00
interfaces Fix printf format string warning on MinGW. 2024-12-06 12:44:30 +13:00
makefiles Use __attribute__((target(...))) for AVX-512 support. 2024-11-07 13:58:43 -06:00
pl Remove useless casts to (void *) 2024-11-28 08:27:20 +01:00
port Fix elog(FATAL) before PostmasterMain() or just after fork(). 2024-12-10 13:51:59 -08:00
template thread-safety: gmtime_r(), localtime_r() 2024-08-23 07:43:04 +02:00
test Detect redundant GROUP BY columns using UNIQUE indexes 2024-12-12 15:28:38 +13:00
timezone Update time zone data files to tzdata release 2024b. 2024-10-29 11:49:38 -04:00
tools Provide a better error message for misplaced dispatch options. 2024-12-04 15:04:15 -06:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00