From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: pgsql: Fix restore of not-null constraints with inheritance |
Date: | 2024-04-21 01:25:48 |
Message-ID: | ZiRrHLZzwfukSf-v@pryzbyj2023 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
On Fri, Apr 19, 2024 at 01:59:31PM +0200, Alvaro Herrera wrote:
> BTW because of a concern from Justin that the NO INHERIT stuff will
> cause errors in old server versions, I started to wonder if it wouldn't
> be better to add these constraints in a separate line for compatibility,
> so for example in the table above it'd be
>
> CREATE TABLE public.rule_and_refint_t2 (
> id2a integer,
> id2c integer
> );
> ALTER TABLE public.rule_and_refint_t2 ADD CONSTRAINT pgdump_throwaway_notnull_0 NOT NULL id2a NO INHERIT;
> ALTER TABLE public.rule_and_refint_t2 ADD CONSTRAINT pgdump_throwaway_notnull_1 NOT NULL id2c NO INHERIT;
>
> which might be less problematic in terms of compatibility: you still end
> up having the table, it's only the ALTER TABLE that would error out.
Under pg_restore -d, those would all be run in a single transactional
command, so it would *still* fail to create the table...
It seems like the workaround to restore into an old server version would
be to run:
| pg_restore -f- |sed 's/ NO INHERIT//' |psql
Putting them on separate lines makes that a tiny bit better, since you
could do:
| pg_restore -f- |sed '/^ALTER TABLE .* ADD CONSTRAINT .* NOT NULL/{ s/ NO INHERIT// }' |psql
But I'm not sure whether that's enough of an improvement to warrant the
effort.
--
Justin
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2024-04-21 07:57:26 | pgsql: createdb: Correct parameter name in SGML docs |
Previous Message | Justin Pryzby | 2024-04-21 01:25:02 | Re: pgsql: createdb: Correct parameter name in SGML docs |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2024-04-21 07:26:38 | Re: Support a wildcard in backtrace_functions |
Previous Message | Tom Lane | 2024-04-20 22:19:15 | Re: createdb compares strategy as case-sensitive |