pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Joe Conway <mail@joeconway.com>
Cc: pgsql-committers@postgresql.org
Subject: Re: pgsql: Apply RLS policies to partitioned tables.
Date: Sun, 11 Jun 2017 22:51:25 -0400
Message-ID: <25990.1497235885@sss.pgh.pa.us> (raw)
In-Reply-To: <bea1642d-2791-fe5f-e9cf-df12ea5cf162@lab.ntt.co.jp>
References: <E1dK59q-0005XI-2U@gemulon.postgresql.org>
	<10974.1497227727@sss.pgh.pa.us>
	<0c5b8b18-262d-de09-50e1-6cf4815d74ab@joeconway.com>
	<bea1642d-2791-fe5f-e9cf-df12ea5cf162@lab.ntt.co.jp>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> 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 well.

> 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 
$1 = 0x11b6220 "INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_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 ----
  
        Assert(operation == CMD_INSERT);
        resultRelInfo = mtstate->mt_partitions;
+       Assert(mtstate->mt_num_partitions == mtstate->mt_nplans);
        wcoList = linitial(node->withCheckOptionLists);
        for (i = 0; i < mtstate->mt_num_partitions; i++)
        {

			regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



view thread (8+ messages)  latest in thread

Message-ID: <25990.1497235885@sss.pgh.pa.us>
Permalink:  ../25990.1497235885@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25990.1497235885@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Langote_Amit_f8@lab.ntt.co.jp, mail@joeconway.com
  Subject: Re: pgsql: Apply RLS policies to partitioned tables.
  In-Reply-To: <25990.1497235885@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox