summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-09-08 19:04:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-09-08 19:04:32 -0400
commit1377b40965b257e228ae8faf45c6ce145ce357e5 (patch)
tree889af3dd46a2b5c4effaf141c467d5d167e44b1b
parent5f0ac02d7f8ded730c27a5197f8c594302c5d7e0 (diff)
Fix uninitialized-variable bug.
map_partition_varattnos() failed to set its found_whole_row output parameter if the given expression list was NIL. This seems to be a pre-existing bug that chanced to be exposed by commit 6f6b99d13. It might be unreachable in v10, but I have little faith in that proposition, so back-patch. Per buildfarm.
-rw-r--r--src/backend/catalog/partition.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c
index 21901380cb2..c2f304ec338 100644
--- a/src/backend/catalog/partition.c
+++ b/src/backend/catalog/partition.c
@@ -916,21 +916,23 @@ map_partition_varattnos(List *expr, int target_varno,
Relation partrel, Relation parent,
bool *found_whole_row)
{
- AttrNumber *part_attnos;
- bool my_found_whole_row;
+ bool my_found_whole_row = false;
- if (expr == NIL)
- return NIL;
+ if (expr != NIL)
+ {
+ AttrNumber *part_attnos;
+
+ part_attnos = convert_tuples_by_name_map(RelationGetDescr(partrel),
+ RelationGetDescr(parent),
+ gettext_noop("could not convert row type"));
+ expr = (List *) map_variable_attnos((Node *) expr,
+ target_varno, 0,
+ part_attnos,
+ RelationGetDescr(parent)->natts,
+ RelationGetForm(partrel)->reltype,
+ &my_found_whole_row);
+ }
- part_attnos = convert_tuples_by_name_map(RelationGetDescr(partrel),
- RelationGetDescr(parent),
- gettext_noop("could not convert row type"));
- expr = (List *) map_variable_attnos((Node *) expr,
- target_varno, 0,
- part_attnos,
- RelationGetDescr(parent)->natts,
- RelationGetForm(partrel)->reltype,
- &my_found_whole_row);
if (found_whole_row)
*found_whole_row = my_found_whole_row;