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

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: ejberdecia(at)yahoo(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15954: Unable to alter partitioned table to set logged
Date: 2019-08-14 01:57:26
Message-ID: CAKJS1f8wUtYNh3KLrOB=+r6Bio-vUeeS_jyisumz_5V0yok_Pg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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 Michael Paquier 2019-08-14 02:48:22 Re: BUG #15954: Unable to alter partitioned table to set logged
Previous Message Amit Langote 2019-08-14 01:47:34 Re: BUG #15954: Unable to alter partitioned table to set logged