pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Noah Misch <noah@leadboat.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: pg_dump emits ALTER TABLE ONLY partitioned_table
Date: Thu, 13 Apr 2017 11:05:40 -0400
Message-ID: <20170413150540.GQ9812@tamriel.snowman.net> (raw)
In-Reply-To: <CA+TgmoY7d=Tr4pYKnvqG4c174dXazwtQeNm6FJCj1y0oqvBofA@mail.gmail.com>
References: <20170409235057.GA2842536@tornado.leadboat.com>
	<CA+Tgmoba3SDoSyPJ5b4-n1S8fd+_vhKmKBpfwUenH_+=PUgQDg@mail.gmail.com>
	<7227.1491790247@sss.pgh.pa.us>
	<CA+TgmoaqY_UTX0CyBsM_h8YfFmxT7G+T-6GT2gU99Vx_MWLqNg@mail.gmail.com>
	<637efb89-0bef-1474-f28e-7e40e1f6d0a6@lab.ntt.co.jp>
	<20170411131233.GQ9812@tamriel.snowman.net>
	<4c4c2400-430b-2e78-3ce2-e7fede4353b4@lab.ntt.co.jp>
	<CA+Tgmob=xywPTSnok_aObFW7OssZi0VV-ke-MSN4hfaz437_3w@mail.gmail.com>
	<20170412192930.GJ9812@tamriel.snowman.net>
	<CA+TgmoY7d=Tr4pYKnvqG4c174dXazwtQeNm6FJCj1y0oqvBofA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Robert,

* Robert Haas (robertmhaas@gmail.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

Attachments:

  [application/pgp-signature] signature.asc (818B, ../20170413150540.GQ9812@tamriel.snowman.net/2-signature.asc)
  download

view thread (64+ messages)  latest in thread

Message-ID: <20170413150540.GQ9812@tamriel.snowman.net>
Permalink:  ../20170413150540.GQ9812@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20170413150540.GQ9812@tamriel.snowman.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: sfrost@snowman.net, robertmhaas@gmail.com, Langote_Amit_f8@lab.ntt.co.jp, tgl@sss.pgh.pa.us, noah@leadboat.com
  Subject: Re: pg_dump emits ALTER TABLE ONLY partitioned_table
  In-Reply-To: <20170413150540.GQ9812@tamriel.snowman.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox