@@ -493,11 +493,16 @@ CheckerInit(Checker *checker, Relation rel, TupleChecker *tchecker)
493493
494494 checker -> desc = CreateTupleDescCopy (desc );
495495 for (n = 0 ; n < desc -> natts ; n ++ )
496- #if PG_VERSION_NUM >= 110000
496+ {
497+ #if PG_VERSION_NUM >= 180000
498+ TupleDescAttr (checker -> desc , n )-> attnotnull = TupleDescAttr (desc , n )-> attnotnull ;
499+ populate_compact_attribute (checker -> desc , n );
500+ #elif PG_VERSION_NUM >= 110000
497501 checker -> desc -> attrs [n ].attnotnull = desc -> attrs [n ].attnotnull ;
498502#else
499503 checker -> desc -> attrs [n ]-> attnotnull = desc -> attrs [n ]-> attnotnull ;
500504#endif
505+ }
501506 }
502507}
503508
@@ -595,7 +600,10 @@ CheckerConstraints(Checker *checker, HeapTuple tuple, int *parsing_field)
595600
596601 for (i = 0 ; i < desc -> natts ; i ++ )
597602 {
598- #if PG_VERSION_NUM >= 110000
603+ #if PG_VERSION_NUM >= 180000
604+ if (TupleDescAttr (desc , i )-> attnotnull &&
605+ att_isnull (i , tuple -> t_data -> t_bits ))
606+ #elif PG_VERSION_NUM >= 110000
599607 if (desc -> attrs [i ].attnotnull &&
600608 att_isnull (i , tuple -> t_data -> t_bits ))
601609#else
@@ -608,7 +616,9 @@ CheckerConstraints(Checker *checker, HeapTuple tuple, int *parsing_field)
608616 ereport (ERROR ,
609617 (errcode (ERRCODE_NOT_NULL_VIOLATION ),
610618 errmsg ("null value in column \"%s\" violates not-null constraint" ,
611- #if PG_VERSION_NUM >= 110000
619+ #if PG_VERSION_NUM >= 180000
620+ NameStr (TupleDescAttr (desc , i )-> attname ))));
621+ #elif PG_VERSION_NUM >= 110000
612622 NameStr (desc -> attrs [i ].attname ))));
613623#else
614624 NameStr (desc -> attrs [i ]-> attname ))));
@@ -630,11 +640,16 @@ TupleFormerInit(TupleFormer *former, Filter *filter, TupleDesc desc)
630640
631641 former -> desc = CreateTupleDescCopy (desc );
632642 for (i = 0 ; i < desc -> natts ; i ++ )
633- #if PG_VERSION_NUM >= 110000
643+ {
644+ #if PG_VERSION_NUM >= 180000
645+ TupleDescAttr (former -> desc , i )-> attnotnull = TupleDescAttr (desc , i )-> attnotnull ;
646+ populate_compact_attribute (former -> desc , i );
647+ #elif PG_VERSION_NUM >= 110000
634648 former -> desc -> attrs [i ].attnotnull = desc -> attrs [i ].attnotnull ;
635649#else
636650 former -> desc -> attrs [i ]-> attnotnull = desc -> attrs [i ]-> attnotnull ;
637651#endif
652+ }
638653
639654 /*
640655 * allocate buffer to store columns or function arguments
@@ -689,7 +704,19 @@ TupleFormerInit(TupleFormer *former, Filter *filter, TupleDesc desc)
689704 former -> maxfields = 0 ;
690705 for (i = 0 ; i < natts ; i ++ )
691706 {
692- #if PG_VERSION_NUM >= 110000
707+ #if PG_VERSION_NUM >= 180000
708+ /* ignore dropped columns */
709+ if (TupleDescAttr (desc , i )-> attisdropped )
710+ continue ;
711+
712+ /* get type information and input function */
713+ getTypeInputInfo (TupleDescAttr (desc , i )-> atttypid ,
714+ & in_func_oid , & former -> typIOParam [i ]);
715+ fmgr_info (in_func_oid , & former -> typInput [i ]);
716+
717+ former -> typMod [i ] = TupleDescAttr (desc , i )-> atttypmod ;
718+ former -> typId [i ] = TupleDescAttr (desc , i )-> atttypid ;
719+ #elif PG_VERSION_NUM >= 110000
693720 /* ignore dropped columns */
694721 if (attrs [i ].attisdropped )
695722 continue ;
@@ -807,7 +834,19 @@ tupledesc_match(TupleDesc dst_tupdesc, TupleDesc src_tupdesc)
807834
808835 for (i = 0 ; i < dst_tupdesc -> natts ; i ++ )
809836 {
810- #if PG_VERSION_NUM >= 110000
837+ #if PG_VERSION_NUM >= 180000
838+ FormData_pg_attribute * dattr = TupleDescAttr (dst_tupdesc , i );
839+ FormData_pg_attribute * sattr = TupleDescAttr (src_tupdesc , i );
840+
841+ if (dattr -> atttypid == sattr -> atttypid )
842+ continue ; /* no worries */
843+ if (!dattr -> attisdropped )
844+ return false;
845+
846+ if (dattr -> attlen != sattr -> attlen ||
847+ dattr -> attalign != sattr -> attalign )
848+ return false;
849+ #elif PG_VERSION_NUM >= 110000
811850 FormData_pg_attribute dattr = dst_tupdesc -> attrs [i ];
812851 FormData_pg_attribute sattr = src_tupdesc -> attrs [i ];
813852
@@ -1262,7 +1301,19 @@ CoercionDeformTuple(TupleChecker *self, HeapTuple tuple, int *parsing_field)
12621301
12631302 for (i = 0 ; i < natts ; i ++ )
12641303 {
1265- #if PG_VERSION_NUM >= 110000
1304+ #if PG_VERSION_NUM >= 180000
1305+ if (TupleDescAttr (self -> sourceDesc , i )-> atttypid ==
1306+ TupleDescAttr (self -> targetDesc , i )-> atttypid )
1307+ continue ;
1308+
1309+ getTypeOutputInfo (TupleDescAttr (self -> sourceDesc , i )-> atttypid ,
1310+ & iofunc , & self -> typIsVarlena [i ]);
1311+ fmgr_info (iofunc , & self -> typOutput [i ]);
1312+
1313+ getTypeInputInfo (TupleDescAttr (self -> targetDesc , i )-> atttypid , & iofunc ,
1314+ & self -> typIOParam [i ]);
1315+ fmgr_info (iofunc , & self -> typInput [i ]);
1316+ #elif PG_VERSION_NUM >= 110000
12661317 if (self -> sourceDesc -> attrs [i ].atttypid ==
12671318 self -> targetDesc -> attrs [i ].atttypid )
12681319 continue ;
@@ -1298,7 +1349,33 @@ CoercionDeformTuple(TupleChecker *self, HeapTuple tuple, int *parsing_field)
12981349 {
12991350 * parsing_field = i + 1 ;
13001351
1301- #if PG_VERSION_NUM >= 110000
1352+ #if PG_VERSION_NUM >= 180000
1353+ /* Ignore dropped columns in datatype */
1354+ if (TupleDescAttr (self -> targetDesc , i )-> attisdropped )
1355+ continue ;
1356+
1357+ if (self -> nulls [i ])
1358+ {
1359+ /* emit nothing... */
1360+ continue ;
1361+ }
1362+ else if (TupleDescAttr (self -> sourceDesc , i )-> atttypid ==
1363+ TupleDescAttr (self -> targetDesc , i )-> atttypid )
1364+ {
1365+ continue ;
1366+ }
1367+ else
1368+ {
1369+ char * value ;
1370+
1371+ value = OutputFunctionCall (& self -> typOutput [i ], self -> values [i ]);
1372+ self -> values [i ] = InputFunctionCall (& self -> typInput [i ], value ,
1373+ self -> typIOParam [i ],
1374+ TupleDescAttr (self -> targetDesc , i )-> atttypmod );
1375+ pfree (value );
1376+ }
1377+ }
1378+ #elif PG_VERSION_NUM >= 110000
13021379 /* Ignore dropped columns in datatype */
13031380 if (self -> targetDesc -> attrs [i ].attisdropped )
13041381 continue ;
0 commit comments