Re: BUG #15954: Unable to alter partitioned table to set log

From: "Efrain J(dot) Berdecia" <ejberdecia(at)yahoo(dot)com>
To: "david(dot)rowley(at)2ndquadrant(dot)com" <david(dot)rowley(at)2ndquadrant(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15954: Unable to alter partitioned table to set log
Date: 2019-08-14 02:51:27
Message-ID: 950396924.5108495.1565751087812@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Is there any way to check in the code whether the table is a parent and then allow the execution of the alter accordingly?
Or are you saying that any empty table we would not be able to change the unlogged state?
Should the logic to alter the table just ignore whether the table is empty or not?

Sent from Yahoo Mail on Android

On Tue, Aug 13, 2019 at 9:57 PM, David Rowley<david(dot)rowley(at)2ndquadrant(dot)com> wrote: On Wed, 14 Aug 2019 at 13:47, Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
>
> On Wed, Aug 14, 2019 at 3:06 AM PG Bug reporting form
> > I have a partition table that I created unlogged. I'm using pg_partman to
> > manage the partition. I then proceeded to load data into it with a COPY
> > command.
> >
> > Afterwards, I ran an alter table set logged on the parent table but the
> > table still shows as UNLOGGED along with all its children.
> >
> > Is this broken?
>
> It is somewhat.  A workaround is to perform ALTER TABLE SET LOGGED
> individually on each partition.  Specifying LOGGED / UNLOGGED for the
> parent table is useless as things stand now.

I'd say it's broken in a sense that we can create an unlogged
partitioned table in the first place.  I think that should have been
blocked.

As for why ALTER TABLE <partitioned_table> SET LOGGED; does not work,
that's due to ATRewriteTables() skipping relations without storage in:

/* Relations without storage may be ignored here */
if (!RELKIND_HAS_STORAGE(tab->relkind))
continue;

meaning we never get to:

/*
* Select persistence of transient table (same as original unless
* user requested a change)
*/
persistence = tab->chgPersistence ?
tab->newrelpersistence : OldHeap->rd_rel->relpersistence;

I'm not too sure what we can do to fix this though. Ideally, we'd just
block UNLOGGED partitioned tables, but we can't really do that as a
bug fix in back branches since it might break someone's code.

We could maybe just fix it in master...

--
David Rowley                  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2019-08-14 03:17:18 Re: BUG #15954: Unable to alter partitioned table to set logged
Previous Message Michael Paquier 2019-08-14 02:48:22 Re: BUG #15954: Unable to alter partitioned table to set logged