Skip to content

Commit cc14415

Browse files
committed
Avoid some code duplication in map_partition_varattnos().
Code to map attribute numbers in map_partition_varattnos() duplicates what convert_tuples_by_name_map() does. Avoid that. Amit Langote, per a report from Álvaro Herrera. Discussion: http://postgr.es/m/9ce97382-54c8-deb3-9ee9-a2ec271d866b%40lab.ntt.co.jp
1 parent 8a8afe2 commit cc14415

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/backend/catalog/partition.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -917,32 +917,19 @@ List *
917917
map_partition_varattnos(List *expr, int target_varno,
918918
Relation partrel, Relation parent)
919919
{
920-
TupleDesc tupdesc = RelationGetDescr(parent);
921-
AttrNumber attno;
922920
AttrNumber *part_attnos;
923921
bool found_whole_row;
924922

925923
if (expr == NIL)
926924
return NIL;
927925

928-
part_attnos = (AttrNumber *) palloc0(tupdesc->natts * sizeof(AttrNumber));
929-
for (attno = 1; attno <= tupdesc->natts; attno++)
930-
{
931-
Form_pg_attribute attribute = tupdesc->attrs[attno - 1];
932-
char *attname = NameStr(attribute->attname);
933-
AttrNumber part_attno;
934-
935-
if (attribute->attisdropped)
936-
continue;
937-
938-
part_attno = get_attnum(RelationGetRelid(partrel), attname);
939-
part_attnos[attno - 1] = part_attno;
940-
}
941-
926+
part_attnos = convert_tuples_by_name_map(RelationGetDescr(partrel),
927+
RelationGetDescr(parent),
928+
gettext_noop("could not convert row type"));
942929
expr = (List *) map_variable_attnos((Node *) expr,
943930
target_varno, 0,
944931
part_attnos,
945-
tupdesc->natts,
932+
RelationGetDescr(parent)->natts,
946933
&found_whole_row);
947934
/* There can never be a whole-row reference here */
948935
if (found_whole_row)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy