Re: Internal error XX000 with enable_partition_pruning=on, pg 11 beta1 on Debian
Rushabh Lathia <rushabh.lathia@gmail.com>
From: Rushabh Lathia <rushabh.lathia@gmail.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Rowley <david.rowley@2ndquadrant.com>,
Robert Haas <robertmhaas@gmail.com>, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>,
Phil Florent <philflorent@hotmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2018-08-07T16:51:52Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Match RelOptInfos by relids not pointer equality.
- a3deecb1c9af 11.0 landed
- 11e22e486d8d 12.0 landed
-
Fix run-time partition pruning for appends with multiple source rels.
- 1b54e91faabf 11.0 landed
- 1c2cb2744bf3 12.0 landed
Hi,
Consider the below case:
CREATE TABLE pt (a INT, b INT, c INT) PARTITION BY RANGE(a);
CREATE TABLE pt_p1 PARTITION OF pt FOR VALUES FROM (1) to (6) PARTITION BY
RANGE (b);
CREATE TABLE pt_p1_p1 PARTITION OF pt_p1 FOR VALUES FROM (11) to (44);
CREATE TABLE pt_p1_p2 PARTITION OF pt_p1 FOR VALUES FROM (44) to (66);
INSERT INTO pt (a,b,c) VALUES
(1,11,111),(2,22,222),(3,33,333),(4,44,444),(5,55,555);
-- rule on root partition to first level child,
CREATE RULE pt_rule_ptp1 AS ON UPDATE TO pt DO INSTEAD UPDATE pt_p1 SET a =
new.a WHERE a = old.a;
-- Below command end up with error
UPDATE pt SET a = 3 WHERE a = 2;
ERROR: child rel 1 not found in append_rel_array
Here update on the partition table fail, if it has rule which is define on
partition table - to redirect record on the child table.
While looking further, I found the test started failing with below commit:
commit 1b54e91faabf3764b6786915881e514e42dccf89
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed Aug 1 19:42:46 2018 -0400
Fix run-time partition pruning for appends with multiple source rels.
Error coming from below code, where its try to adjust the appendrel
attribute and end up with error from find_appinfos_by_relids().
/*
* The prunequal is presented to us as a qual for 'parentrel'.
* Frequently this rel is the same as targetpart, so we can skip
* an adjust_appendrel_attrs step. But it might not be, and
then
* we have to translate. We update the prunequal parameter
here,
* because in later iterations of the loop for child partitions,
* we want to translate from parent to child variables.
*/
if (parentrel != subpart)
{
int nappinfos;
AppendRelInfo **appinfos = find_appinfos_by_relids(root,
subpart->relids,
&nappinfos);
prunequal = (List *) adjust_appendrel_attrs(root, (Node *)
prunequal,
nappinfos,
appinfos);
pfree(appinfos);
}
Regards,
On Thu, Aug 2, 2018 at 8:36 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> On 2018-Aug-01, Tom Lane wrote:
>
> > David Rowley <david.rowley@2ndquadrant.com> writes:
> > > On 20 July 2018 at 01:03, David Rowley <david.rowley@2ndquadrant.com>
> wrote:
> > >> I've attached a patch intended for master which is just v2 based on
> > >> post 5220bb7533.
> >
> > I've pushed the v3 patch with a lot of editorial work (e.g. cleaning
> > up comments you hadn't).
>
> Thanks Tom, much appreciated.
>
> --
> Álvaro Herrera https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
>
--
Rushabh Lathia
www.EnterpriseDB.com