From: | Robert Haas <rhaas(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix a bug in how we generate partition constraints. |
Date: | 2017-01-13 19:07:02 |
Message-ID: | E1cS7Bm-0005BQ-CE@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
Fix a bug in how we generate partition constraints.
Move the code for doing parent attnos to child attnos mapping for Vars
in partition constraint expressions to a separate function
map_partition_varattnos() and call it from the appropriate places.
Doing it in get_qual_from_partbound(), as is now, would produce wrong
result in certain multi-level partitioning cases, because it only
considers the current pair of parent-child relations. In certain
multi-level partitioning cases, attnums for the same key attribute(s)
might differ between various levels causing the same attribute to be
numbered differently in different instances of the Var corresponding
to a given attribute.
With this commit, in generate_partition_qual(), we first generate the
the whole partition constraint (considering all levels of partitioning)
and then do the mapping, so that Vars in the final expression are
numbered according the leaf relation (to which it is supposed to apply).
Amit Langote, reviewed by me.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/0563a3a8b59150bf3cc8b2b7077f684e0eaf8aff
Modified Files
--------------
src/backend/catalog/partition.c | 99 +++++++++++++++----------------
src/backend/commands/tablecmds.c | 7 ++-
src/include/catalog/partition.h | 1 +
src/test/regress/expected/alter_table.out | 30 ++++++++++
src/test/regress/sql/alter_table.sql | 25 ++++++++
5 files changed, 110 insertions(+), 52 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2017-01-13 19:18:28 | Re: [COMMITTERS] pgsql: Fix a bug in how we generate partition constraints. |
Previous Message | Robert Haas | 2017-01-13 18:37:58 | pgsql: Fix cardinality estimates for parallel joins. |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2017-01-13 19:11:29 | Re: Packages: Again |
Previous Message | Tom Lane | 2017-01-13 19:06:04 | Re: BUG: pg_stat_statements query normalization issues with combined queries |