diff options
author | Robert Haas <rhaas@postgresql.org> | 2018-02-05 17:31:57 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2018-02-05 17:31:57 -0500 |
commit | f069c91a5793ff6b7884120de748b2005ee7756f (patch) | |
tree | 2b5125e6ba39362e8eafa0f34e6b3f023432f801 /src/include/nodes/relation.h | |
parent | 1eb5d43beed9d8cdc61377867f0a53eb2cfba0c4 (diff) | |
download | postgresql-f069c91a5793ff6b7884120de748b2005ee7756f.tar.gz postgresql-f069c91a5793ff6b7884120de748b2005ee7756f.zip |
Fix possible crash in partition-wise join.
The previous code assumed that we'd always succeed in creating
child-joins for a joinrel for which partition-wise join was considered,
but that's not guaranteed, at least in the case where dummy rels
are involved.
Ashutosh Bapat, with some wordsmithing by me.
Discussion: http://postgr.es/m/CAFjFpRf8=uyMYYfeTBjWDMs1tR5t--FgOe2vKZPULxxdYQ4RNw@mail.gmail.com
Diffstat (limited to 'src/include/nodes/relation.h')
-rw-r--r-- | src/include/nodes/relation.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 6bf68f31da1..b1c63173c22 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -666,13 +666,17 @@ typedef struct RelOptInfo /* * Is given relation partitioned? * - * A join between two partitioned relations with same partitioning scheme - * without any matching partitions will not have any partition in it but will - * have partition scheme set. So a relation is deemed to be partitioned if it - * has a partitioning scheme, bounds and positive number of partitions. + * It's not enough to test whether rel->part_scheme is set, because it might + * be that the basic partitioning properties of the input relations matched + * but the partition bounds did not. + * + * We treat dummy relations as unpartitioned. We could alternatively + * treat them as partitioned, but it's not clear whether that's a useful thing + * to do. */ #define IS_PARTITIONED_REL(rel) \ - ((rel)->part_scheme && (rel)->boundinfo && (rel)->nparts > 0) + ((rel)->part_scheme && (rel)->boundinfo && (rel)->nparts > 0 && \ + (rel)->part_rels && !(IS_DUMMY_REL(rel))) /* * Convenience macro to make sure that a partitioned relation has all the |