Re: ATSimpleRecursion() and inheritance foreign parents

From: David Fetter <david(at)fetter(dot)org>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ATSimpleRecursion() and inheritance foreign parents
Date: 2015-04-28 12:28:54
Message-ID: 20150428122854.GA31463@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 28, 2015 at 03:17:08PM +0900, Amit Langote wrote:
>
> Hi,
>
> Following ALTER TABLE actions are applied recursively to inheritance
> descendents via ATSimpleRecursion() -
>
> ALTER COLUMN DEFAULT
> ALTER COLUMN DROP NOT NULL
> ALTER COLUMN SET NOT NULL
> ALTER COLUMN SET STATISTICS
> ALTER COLUMN SET STORAGE
>
> The code at the beginning of ATSimpleRecursion() looks like -
>
> /*
> * Propagate to children if desired. Non-table relations never have
> * children, so no need to search in that case.
> */
> if (recurse && rel->rd_rel->relkind == RELKIND_RELATION)
>
> Not sure if it's great idea, but now that foreign tables can also have
> children, should above be changed to take that into account? Any inheritance
> related recursion performed without using ATSimpleRecursion() recurse as
> dictated by RangeVar.inhOpt; so even foreign inheritance parents expand for
> various ALTER TABLE actions like adding a column though that is not a
> meaningful operation on foreign tables anyway.
>
> An example,
> postgres=# alter foreign table fparent alter a type char;
> ALTER FOREIGN TABLE
>
> postgres=# select * from fparent;
> ERROR: attribute "a" of relation "fchild1" does not match parent's type
>
> Above error, AIUI, is hit much before it is determined that fparent is a
> foreign table, whereas the following is FDW-specific (waiting to happen) error,
>
> postgres=# alter foreign table fparent add b char;
> ALTER FOREIGN TABLE
>
> postgres=# SELECT * FROM fparent;
> ERROR: column "b" does not exist
> CONTEXT: Remote SQL command: SELECT a, b FROM public.parent

I'm pretty sure this is a bug. The way I see it, foreign tables can
either fully participate in table inheritance, or not at all, because
any inconsistencies here will cause confusion at best.

How big a deal would it be to fix it?

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-04-28 12:28:57 Re: Improving vacuum/VM/etc
Previous Message Amit Langote 2015-04-28 12:15:27 Re: ATSimpleRecursion() and inheritance foreign parents