Re: BUG #15954: Unable to alter partitioned table to set log - Mailing list pgsql-bugs

From Efrain J. Berdecia
Subject Re: BUG #15954: Unable to alter partitioned table to set log
Date
Msg-id 950396924.5108495.1565751087812@mail.yahoo.com
Whole thread Raw
In response to Re: BUG #15954: Unable to alter partitioned table to set logged  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: BUG #15954: Unable to alter partitioned table to set log  (David Rowley <david.rowley@2ndquadrant.com>)
List 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?


On Tue, Aug 13, 2019 at 9:57 PM, David Rowley
<david.rowley@2ndquadrant.com> wrote:
On Wed, 14 Aug 2019 at 13:47, Amit Langote <amitlangote09@gmail.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

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15954: Unable to alter partitioned table to set logged
Next
From: David Rowley
Date:
Subject: Re: BUG #15954: Unable to alter partitioned table to set logged