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 14e87ffa5c54. 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+hfquzjbqourz...@mail.gmail.com Author: Ashutosh Bapat <ashutosh.bapat....@gmail.com> Reported-by: Ashutosh Bapat <ashutosh.bapat....@gmail.com> Reviewed-by: Alvaro Herrera <alvhe...@alvh.no-ip.org> Discussion: https://postgr.es/m/caexhw5tbdgakdfqjdj-7fk6pjthg8d4zuf6fq4h2pq8zk38...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/fd41ba93e4630921a72ed5127cd0d552a8f3f8fc Modified Files -------------- src/bin/pg_dump/pg_dump.c | 55 +++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 23 deletions(-)