Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxjPO-00074l-Sn for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Aug 2019 02:53:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxjPN-0007Gb-Oc for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Aug 2019 02:53:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxjNz-0008AC-92 for pgsql-bugs@lists.postgresql.org; Wed, 14 Aug 2019 02:51:40 +0000 Received: from sonic304-22.consmr.mail.ne1.yahoo.com ([66.163.191.148]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxjNv-00042o-D9 for pgsql-bugs@lists.postgresql.org; Wed, 14 Aug 2019 02:51:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1565751090; bh=LS3pHBqWABvuy2Jakc2UaR9Jw0lfhgS+K976Idpo1Mg=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=DK4gFHh4J7J8GacDGCiCMfUVVHAQjNVJeLsDJqjuw8U6ymsDOwXCiSq7aqvdQviTNXupML+RwcC41JECBFu5l+StxeEmTEXUSTmzGlqO4mBWH7+04kcjqNhclnKUBN03rWTyuBYqROfboi+rijRTeBL0J2NkS4RoDRm/gmpBW3hUMrRSBo3qvjQ7AR6dncwyvCiZgEyNTmM9AtoxyDdL364nkFqF+2L4jcQFjD/kjRw4BqlEehYZfCNvuuK9GQju95ShLGNSXtFSzfWKkQ5QdeS5KeW8KxTm19lN+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JKkJtH3PyTJ3eFBmKEU3lnZn3jIWY6FPD CdrUEtevDLB5ZmiX2_IbyIaAP.WIgtDH43bJyr8udMeWUep0JoMQVleRRUzjLzMslBOLdH84ihpz pECMJDAxibFjFim4Qmx_KhJQ3qLP9Jnx3z2ZXKTZOXsSoUDdaZzlfq5qUbGIi_Tx6pbj9CzIPOYm tgfBXlrdixXDcrWiOrGADN4X3vrMOE2msv5edSbRj71FjHb_3MR7r4603f73bbHdr4AOzlLMe0t9 p.aZC8z3yOhw5iVWkiSKgMM2Z4jigl5WYgcQa3NXhh.kCeKIQKqxDgH5J9gJlvZbiigmJTlrnWFW ASkVvKiI- Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Wed, 14 Aug 2019 02:51:30 +0000 Date: Wed, 14 Aug 2019 02:51:27 +0000 (UTC) From: "Efrain J. Berdecia" Reply-To: "ejberdecia@yahoo.com" To: "david.rowley@2ndquadrant.com" , Amit Langote Cc: PostgreSQL mailing lists Message-ID: <950396924.5108495.1565751087812@mail.yahoo.com> In-Reply-To: References: <15954-b61523bed4b110c4@postgresql.org> Subject: Re: BUG #15954: Unable to alter partitioned table to set log MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5108494_1099353425.1565751087811" X-Mailer: WebService/1.1.14097 YahooMailAndroidMobile YMobile/1.0 (com.yahoo.mobile.client.android.mail/5.43.1; Android/9; PPR1.180610.011; crownqltesq; samsung; SM-N960U; 6.05; 1396x720;) Content-Length: 6730 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_5108494_1099353425.1565751087811 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Is there any way to check in the code whether the table is a parent and the= n allow the execution of the alter accordingly? Or are you saying that any empty table we would not be able to change the u= nlogged state? Should the logic to alter the table just ignore whether the table is empty = or not? Sent from Yahoo Mail on Android=20 =20 On Tue, Aug 13, 2019 at 9:57 PM, David Rowley wrote: On Wed, 14 Aug 2019 at 13:47, Amit Langote 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.=C2=A0 A workaround is to perform ALTER TABLE SET LOGGED > individually on each partition.=C2=A0 Specifying LOGGED / UNLOGGED for th= e > 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.=C2=A0 I think that should have been blocked. As for why ALTER 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 =3D 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... --=20 David Rowley=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services =20 ------=_Part_5108494_1099353425.1565751087811 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Is there any way to check in the code whether the table is a parent and the= n 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?

S= hould the logic to alter the table just ignore whether the table is empty o= r not?


On Tue, Aug 13,= 2019 at 9:57 PM, David Rowley
<david.rowley@2ndquadrant.com&g= t; 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 reporti= ng form
> > I have a partition table that I created= unlogged. I'm using pg_partman to
> > manage the p= artition. I then proceeded to load data into it with a COPY
> > command.
> >
> &g= t; Afterwards, I ran an alter table set logged on the parent table but the<= br clear=3D"none">> > table still shows as UNLOGGED along with all it= s 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<= br clear=3D"none">> 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 pla= ce.  I think that should have been
blocked.

As for why ALTER TABLE <partitioned_table&g= t; SET LOGGED; does not work,
that's due to ATRewriteTabl= es() 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 =3D tab->chgPersist= ence ?
tab->newrelpersistence : OldHeap->rd_rel->= ;relpersistence;

I'm not too sure what= we can do to fix this though. Ideally, we'd just
block U= NLOGGED 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  &n= bsp;               http://www.2ndQuadrant= .com/
PostgreSQL Development, 24x7 Support, Training= & Services

------=_Part_5108494_1099353425.1565751087811--