adjust_partition_colnos mustn't be called if not needed
authorAlvaro Herrera <[email protected]>
Tue, 12 Apr 2022 13:19:57 +0000 (15:19 +0200)
committerAlvaro Herrera <[email protected]>
Tue, 12 Apr 2022 13:19:57 +0000 (15:19 +0200)
Add an assert to make this very explicit, as well as a code comment.
The former should silence Coverity complaining about this.

Introduced by 7103ebb7aae8.

Reported-by: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqTTAOzXiYybab+1DQOb3ZUuK99=p_KD+yrRFhcDbd0jg@mail.gmail.com

src/backend/executor/execPartition.c

index 615bd80973539691f6248298fb4a102b92f21ccc..e03ea27299c8ee929b96e07673e41d6b64cf83ee 100644 (file)
@@ -1530,12 +1530,16 @@ ExecBuildSlotPartitionKeyDescription(Relation rel,
  * adjust_partition_colnos
  *             Adjust the list of UPDATE target column numbers to account for
  *             attribute differences between the parent and the partition.
+ *
+ * Note: mustn't be called if no adjustment is required.
  */
 static List *
 adjust_partition_colnos(List *colnos, ResultRelInfo *leaf_part_rri)
 {
        TupleConversionMap *map = ExecGetChildToRootMap(leaf_part_rri);
 
+       Assert(map != NULL);
+
        return adjust_partition_colnos_using_map(colnos, map->attrMap);
 }
 
@@ -1543,6 +1547,8 @@ adjust_partition_colnos(List *colnos, ResultRelInfo *leaf_part_rri)
  * adjust_partition_colnos_using_map
  *             Like adjust_partition_colnos, but uses a caller-supplied map instead
  *             of assuming to map from the "root" result relation.
+ *
+ * Note: mustn't be called if no adjustment is required.
  */
 static List *
 adjust_partition_colnos_using_map(List *colnos, AttrMap *attrMap)