Re: pg_dump emits ALTER TABLE ONLY partitioned_table

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_dump emits ALTER TABLE ONLY partitioned_table
Date: 2017-04-13 15:05:40
Message-ID: 20170413150540.GQ9812@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert,

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> So I think I was indeed confused before, and I think you're basically
> right here, but on one point I think you are not right -- ALTER TABLE
> ONLY .. CHECK () doesn't work on a table with inheritance children
> regardless of whether the children already have the matching
> constraint:

To be clear- I wasn't thinking about what's possible today with
inheiritance or partitioning or in PG at all, but rather focusing on
what a user is likely to expect and understand from the messaging.

> rhaas=# create table foo (a int, b text);
> CREATE TABLE
> rhaas=# create table bar () inherits (foo);
> CREATE TABLE
> rhaas=# alter table only foo add check (a = 1);
> ERROR: constraint must be added to child tables too
> rhaas=# alter table only bar add check (a = 1);
> ALTER TABLE
> rhaas=# alter table only foo add check (a = 1);
> ERROR: constraint must be added to child tables too

If that's the case then we should really change that error message, in
my view. I'd be happier if we did support adding the constraint after
child tables exist, but if we don't, we shouldn't imply to the user that
they can add it after adding it to the children.

> So, regarding Amit's 0001:
>
> - I think we should update the relevant hunk of the documentation
> rather than just removing it.

Alright.

> - Should we similarly allow TRUNCATE ONLY foo and ALTER TABLE ONLY foo
> .. to work on a partitioned table without partitions, or is that just
> pointless tinkering? That seems to be the only case where, after this
> patch, an ONLY operation will fail on a childless partitioned table.

I'm less sure about TRUNCATE ONLY because that really isn't meaningful
at all, is it? A partitioned table doesn't have any data to truncate
and truncating it doesn't have any impact on what happens later, does
it? Having a sensible error be reported if someone tries to do that
would be good though.

> Do you want to be responsible for committing these or should I do it?

Sure, though I won't be able to today and I've got some doubts about the
other patches. I'll have more time tomorrow though.

Thanks!

Stephen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2017-04-13 15:15:16 Re: xmltable doc fix and example for XMLNAMESPACES
Previous Message Alvaro Herrera 2017-04-13 14:39:38 Re: pg_stats_ext view does not seem all that useful