@@ -2295,6 +2295,7 @@ make_attrmap_ext(int maplen)
2295
2295
res = (AttrMapExt * ) palloc0 (sizeof (AttrMapExt ));
2296
2296
res -> maplen = maplen ;
2297
2297
res -> attnums = (AttrNumber * ) palloc0 (sizeof (AttrNumber ) * maplen );
2298
+ res -> dropped_attr = false;
2298
2299
res -> coerceExprs = palloc0_array (Node * , maplen );
2299
2300
return res ;
2300
2301
}
@@ -2382,7 +2383,10 @@ build_attrmap_by_name_ext(TupleDesc indesc,
2382
2383
int j ;
2383
2384
2384
2385
if (outatt -> attisdropped )
2386
+ {
2387
+ attrMap -> dropped_attr = true;
2385
2388
continue ; /* attrMap->attnums[i] is already 0 */
2389
+ }
2386
2390
attname = NameStr (outatt -> attname );
2387
2391
atttypid = outatt -> atttypid ;
2388
2392
atttypmod = outatt -> atttypmod ;
@@ -2408,7 +2412,10 @@ build_attrmap_by_name_ext(TupleDesc indesc,
2408
2412
2409
2413
inatt = TupleDescAttr (indesc , nextindesc );
2410
2414
if (inatt -> attisdropped )
2415
+ {
2416
+ attrMap -> dropped_attr = true;
2411
2417
continue ;
2418
+ }
2412
2419
if (strcmp (attname , NameStr (inatt -> attname )) == 0 )
2413
2420
{
2414
2421
/* Found it, check type */
@@ -2476,6 +2483,14 @@ check_attrmap_match_ext(TupleDesc indesc,
2476
2483
{
2477
2484
int i ;
2478
2485
2486
+ /*
2487
+ * Dropped attribute in either descriptor makes the function return false,
2488
+ * even if it appears in both descriptors and at the same position. Thus
2489
+ * we (mis)use the map to get rid of the values of the dropped columns.
2490
+ */
2491
+ if (attrMap -> dropped_attr )
2492
+ return false;
2493
+
2479
2494
/* no match if attribute numbers are not the same */
2480
2495
if (indesc -> natts != outdesc -> natts )
2481
2496
return false;
0 commit comments