[HACKERS] pg_dump emits ALTER TABLE ONLY partitioned_table

Поиск
Список
Период
Сортировка
От Amit Langote
Тема [HACKERS] pg_dump emits ALTER TABLE ONLY partitioned_table
Дата
Msg-id 7682253a-6f79-6a92-00aa-267c4c412870@lab.ntt.co.jp
обсуждение исходный текст
Ответы Re: [HACKERS] pg_dump emits ALTER TABLE ONLY partitioned_table  (Stephen Frost <sfrost@snowman.net>)
Re: pg_dump emits ALTER TABLE ONLY partitioned_table  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
In certain cases, pg_dump's dumpTableSchema() emits a separate ALTER TABLE
command for those schema elements of a table that could not be included
directly in the CREATE TABLE command for the table.

For example:

create table p (a int, b int) partition by range (a);
create table p1 partition of p for values from (1) to (10) partition by
range (b);
create table p11 partition of p1 for values from (1) to (10);

pg_dump -s gives:

CREATE TABLE p (
    a integer NOT NULL,
    b integer
)
PARTITION BY RANGE (a);

CREATE TABLE p1 PARTITION OF p
FOR VALUES FROM (1) TO (10)
PARTITION BY RANGE (b);
ALTER TABLE ONLY p1 ALTER COLUMN a SET NOT NULL;
ALTER TABLE ONLY p1 ALTER COLUMN b SET NOT NULL;

<snip>

Note the ONLY in the above emitted command.  Now if I run the above
commands in another database, the following error occurs:

ERROR:  constraint must be added to child tables too

That's because specifying ONLY for the AT commands on partitioned tables
that must recurse causes an error.

Attached patch fixes that - it prevents emitting ONLY for those ALTER
TABLE commands, which if run, would cause an error like the one above.

Thanks,
Amit

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: [HACKERS] Measuring replay lag
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: [HACKERS] Help text for pg_basebackup -R