Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKFSH-0001J8-4i for pgsql-committers@arkaria.postgresql.org; Mon, 12 Jun 2017 02:51:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dKFSG-0002QM-K6 for pgsql-committers@arkaria.postgresql.org; Mon, 12 Jun 2017 02:51:48 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dKFS2-00020x-0H for pgsql-committers@postgresql.org; Mon, 12 Jun 2017 02:51:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dKFRy-0006Jh-TM for pgsql-committers@postgresql.org; Mon, 12 Jun 2017 02:51:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v5C2pPjk025991; Sun, 11 Jun 2017 22:51:25 -0400 From: Tom Lane To: Amit Langote cc: Joe Conway , pgsql-committers@postgresql.org Subject: Re: pgsql: Apply RLS policies to partitioned tables. In-reply-to: References: <10974.1497227727@sss.pgh.pa.us> <0c5b8b18-262d-de09-50e1-6cf4815d74ab@joeconway.com> Comments: In-reply-to Amit Langote message dated "Mon, 12 Jun 2017 11:26:24 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25989.1497235885.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 11 Jun 2017 22:51:25 -0400 Message-ID: <25990.1497235885@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org Amit Langote writes: > On 2017/06/12 11:09, Joe Conway wrote: >> On 06/11/2017 05:35 PM, Tom Lane wrote: >>> First guess is that map_partition_varattnos has forgotten to handle >>> WithCheckOption.qual. >> Drat. I'll take a look, but it would probably be good if someone >> generally familiar with the partitioned tables patches have a look as we= ll. > I am looking too. Commit 587cda35ca3 which added that code did add a test > in updatable_views.sql, but tests added by this commit have perhaps > exposed something not previously covered. My first guess above is wrong -- the undefined reference is actually "mtstate->mt_plans[i]". This is because mtstate->mt_num_partitions is more than mtstate->mt_nplans in the failing case, so that the blithe assumption that we can use the partition number to index into mtstate->mt_plans is certainly wrong. Don't know how this should be corrected, offhand, but do we really have more than one plan for a partitioned query? The specific query that's failing is (gdb) p debug_query_string=20 $1 =3D 0x11b6220 "INSERT INTO part_document VALUES (100, 11, 5, 'regress_rl= s_dave', 'testing pp1');" and you can get a crash without all the valgrind effort by adding diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/= nodeModifyTable.c index bf26488..5013a6d 100644 *** a/src/backend/executor/nodeModifyTable.c --- b/src/backend/executor/nodeModifyTable.c *************** ExecInitModifyTable(ModifyTable *node, E *** 1844,1849 **** --- 1844,1850 ---- =20=20 Assert(operation =3D=3D CMD_INSERT); resultRelInfo =3D mtstate->mt_partitions; + Assert(mtstate->mt_num_partitions =3D=3D mtstate->mt_nplans); wcoList =3D linitial(node->withCheckOptionLists); for (i =3D 0; i < mtstate->mt_num_partitions; i++) { regards, tom lane --=20 Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers