@@ -2172,14 +2172,16 @@ get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
21722172 needComma = false;
21732173 for (i = 0 ; i < natts ; i ++ )
21742174 {
2175- if (tupdesc -> attrs [i ]-> attisdropped )
2175+ Form_pg_attribute att = TupleDescAttr (tupdesc , i );
2176+
2177+ if (att -> attisdropped )
21762178 continue ;
21772179
21782180 if (needComma )
21792181 appendStringInfoChar (& buf , ',' );
21802182
21812183 appendStringInfoString (& buf ,
2182- quote_ident_cstr (NameStr (tupdesc -> attrs [ i ] -> attname )));
2184+ quote_ident_cstr (NameStr (att -> attname )));
21832185 needComma = true;
21842186 }
21852187
@@ -2191,7 +2193,7 @@ get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
21912193 needComma = false;
21922194 for (i = 0 ; i < natts ; i ++ )
21932195 {
2194- if (tupdesc -> attrs [ i ] -> attisdropped )
2196+ if (TupleDescAttr ( tupdesc , i ) -> attisdropped )
21952197 continue ;
21962198
21972199 if (needComma )
@@ -2237,12 +2239,13 @@ get_sql_delete(Relation rel, int *pkattnums, int pknumatts, char **tgt_pkattvals
22372239 for (i = 0 ; i < pknumatts ; i ++ )
22382240 {
22392241 int pkattnum = pkattnums [i ];
2242+ Form_pg_attribute attr = TupleDescAttr (tupdesc , pkattnum );
22402243
22412244 if (i > 0 )
22422245 appendStringInfoString (& buf , " AND " );
22432246
22442247 appendStringInfoString (& buf ,
2245- quote_ident_cstr (NameStr (tupdesc -> attrs [ pkattnum ] -> attname )));
2248+ quote_ident_cstr (NameStr (attr -> attname )));
22462249
22472250 if (tgt_pkattvals [i ] != NULL )
22482251 appendStringInfo (& buf , " = %s" ,
@@ -2289,14 +2292,16 @@ get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
22892292 needComma = false;
22902293 for (i = 0 ; i < natts ; i ++ )
22912294 {
2292- if (tupdesc -> attrs [i ]-> attisdropped )
2295+ Form_pg_attribute attr = TupleDescAttr (tupdesc , i );
2296+
2297+ if (attr -> attisdropped )
22932298 continue ;
22942299
22952300 if (needComma )
22962301 appendStringInfoString (& buf , ", " );
22972302
22982303 appendStringInfo (& buf , "%s = " ,
2299- quote_ident_cstr (NameStr (tupdesc -> attrs [ i ] -> attname )));
2304+ quote_ident_cstr (NameStr (attr -> attname )));
23002305
23012306 key = get_attnum_pk_pos (pkattnums , pknumatts , i );
23022307
@@ -2320,12 +2325,13 @@ get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
23202325 for (i = 0 ; i < pknumatts ; i ++ )
23212326 {
23222327 int pkattnum = pkattnums [i ];
2328+ Form_pg_attribute attr = TupleDescAttr (tupdesc , pkattnum );
23232329
23242330 if (i > 0 )
23252331 appendStringInfoString (& buf , " AND " );
23262332
23272333 appendStringInfoString (& buf ,
2328- quote_ident_cstr (NameStr (tupdesc -> attrs [ pkattnum ] -> attname )));
2334+ quote_ident_cstr (NameStr (attr -> attname )));
23292335
23302336 val = tgt_pkattvals [i ];
23312337
@@ -2409,27 +2415,30 @@ get_tuple_of_interest(Relation rel, int *pkattnums, int pknumatts, char **src_pk
24092415
24102416 for (i = 0 ; i < natts ; i ++ )
24112417 {
2418+ Form_pg_attribute attr = TupleDescAttr (tupdesc , i );
2419+
24122420 if (i > 0 )
24132421 appendStringInfoString (& buf , ", " );
24142422
2415- if (tupdesc -> attrs [ i ] -> attisdropped )
2423+ if (attr -> attisdropped )
24162424 appendStringInfoString (& buf , "NULL" );
24172425 else
24182426 appendStringInfoString (& buf ,
2419- quote_ident_cstr (NameStr (tupdesc -> attrs [ i ] -> attname )));
2427+ quote_ident_cstr (NameStr (attr -> attname )));
24202428 }
24212429
24222430 appendStringInfo (& buf , " FROM %s WHERE " , relname );
24232431
24242432 for (i = 0 ; i < pknumatts ; i ++ )
24252433 {
24262434 int pkattnum = pkattnums [i ];
2435+ Form_pg_attribute attr = TupleDescAttr (tupdesc , pkattnum );
24272436
24282437 if (i > 0 )
24292438 appendStringInfoString (& buf , " AND " );
24302439
24312440 appendStringInfoString (& buf ,
2432- quote_ident_cstr (NameStr (tupdesc -> attrs [ pkattnum ] -> attname )));
2441+ quote_ident_cstr (NameStr (attr -> attname )));
24332442
24342443 if (src_pkattvals [i ] != NULL )
24352444 appendStringInfo (& buf , " = %s" ,
@@ -2894,7 +2903,7 @@ validate_pkattnums(Relation rel,
28942903 for (j = 0 ; j < natts ; j ++ )
28952904 {
28962905 /* dropped columns don't count */
2897- if (tupdesc -> attrs [ j ] -> attisdropped )
2906+ if (TupleDescAttr ( tupdesc , j ) -> attisdropped )
28982907 continue ;
28992908
29002909 if (++ lnum == pkattnum )
0 commit comments