aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execPartition.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-12-01 10:01:50 -0500
committerRobert Haas <rhaas@postgresql.org>2017-12-01 10:05:00 -0500
commit59c8078744b5febf549c8b53171242cf667b87a1 (patch)
tree4f799e72d4f91958e60323cbe9122c624af89a2d /src/backend/executor/execPartition.c
parent86ab28fbd19a6a0742a7f66e69a595b61eb13d00 (diff)
downloadpostgresql-59c8078744b5febf549c8b53171242cf667b87a1.tar.gz
postgresql-59c8078744b5febf549c8b53171242cf667b87a1.zip
Fix uninitialized memory reference.
Without this, when partdesc->nparts == 0, we end up calling ExecBuildSlotPartitionKeyDescription without initializing values and isnull. Reported by Coverity via Michael Paquier. Patch by Michael Paquier, reviewed and revised by Amit Langote. Discussion: http://postgr.es/m/CAB7nPqQ3mwkdMoPY-ocgTpPnjd8TKOadMxdTtMLvEzF8480Zfg@mail.gmail.com
Diffstat (limited to 'src/backend/executor/execPartition.c')
-rw-r--r--src/backend/executor/execPartition.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index 59a0ca4597c..34875945e81 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -206,13 +206,6 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
slot = myslot;
}
- /* Quick exit */
- if (partdesc->nparts == 0)
- {
- result = -1;
- break;
- }
-
/*
* Extract partition key from tuple. Expression evaluation machinery
* that FormPartitionKeyDatum() invokes expects ecxt_scantuple to
@@ -223,6 +216,17 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
*/
ecxt->ecxt_scantuple = slot;
FormPartitionKeyDatum(parent, slot, estate, values, isnull);
+
+ /*
+ * Nothing for get_partition_for_tuple() to do if there are no
+ * partitions to begin with.
+ */
+ if (partdesc->nparts == 0)
+ {
+ result = -1;
+ break;
+ }
+
cur_index = get_partition_for_tuple(rel, values, isnull);
/*