@@ -690,88 +690,6 @@ struct MinimalTupleData
690690#define HeapTupleClearHeapOnly (tuple ) \
691691HeapTupleHeaderClearHeapOnly((tuple)->t_data)
692692
693-
694- /* ----------------
695- *fastgetattr
696- *
697- *Fetch a user attribute's value as a Datum (might be either a
698- *value, or a pointer into the data area of the tuple).
699- *
700- *This must not be used when a system attribute might be requested.
701- *Furthermore, the passed attnum MUST be valid. Use heap_getattr()
702- *instead, if in doubt.
703- *
704- *This gets called many times, so we macro the cacheable and NULL
705- *lookups, and call nocachegetattr() for the rest.
706- * ----------------
707- */
708-
709- #if !defined(DISABLE_COMPLEX_MACRO )
710-
711- #define fastgetattr (tup ,attnum ,tupleDesc ,isnull )\
712- (\
713- AssertMacro((attnum) > 0),\
714- (*(isnull) = false),\
715- HeapTupleNoNulls(tup) ?\
716- (\
717- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff >= 0 ?\
718- (\
719- fetchatt(TupleDescAttr((tupleDesc), (attnum)-1),\
720- (char *) (tup)->t_data + (tup)->t_data->t_hoff +\
721- TupleDescAttr((tupleDesc), (attnum)-1)->attcacheoff)\
722- )\
723- :\
724- nocachegetattr((tup), (attnum), (tupleDesc))\
725- )\
726- :\
727- (\
728- att_isnull((attnum)-1, (tup)->t_data->t_bits) ?\
729- (\
730- (*(isnull) = true),\
731- (Datum)NULL\
732- )\
733- :\
734- (\
735- nocachegetattr((tup), (attnum), (tupleDesc))\
736- )\
737- )\
738- )
739- #else /* defined(DISABLE_COMPLEX_MACRO) */
740-
741- extern Datum fastgetattr (HeapTuple tup ,int attnum ,TupleDesc tupleDesc ,
742- bool * isnull );
743- #endif /* defined(DISABLE_COMPLEX_MACRO) */
744-
745-
746- /* ----------------
747- *heap_getattr
748- *
749- *Extract an attribute of a heap tuple and return it as a Datum.
750- *This works for either system or user attributes. The given attnum
751- *is properly range-checked.
752- *
753- *If the field in question has a NULL value, we return a zero Datum
754- *and set *isnull == true. Otherwise, we set *isnull == false.
755- *
756- *<tup> is the pointer to the heap tuple. <attnum> is the attribute
757- *number of the column (field) caller wants. <tupleDesc> is a
758- *pointer to the structure describing the row and all its fields.
759- * ----------------
760- */
761- #define heap_getattr (tup ,attnum ,tupleDesc ,isnull ) \
762- ( \
763- ((attnum) > 0) ? \
764- ( \
765- ((attnum) > (int) HeapTupleHeaderGetNatts((tup)->t_data)) ? \
766- getmissingattr((tupleDesc), (attnum), (isnull)) \
767- : \
768- fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
769- ) \
770- : \
771- heap_getsysattr((tup), (attnum), (tupleDesc), (isnull)) \
772- )
773-
774-
775693/* prototypes for functions in common/heaptuple.c */
776694extern Size heap_compute_data_size (TupleDesc tupleDesc ,
777695Datum * values ,bool * isnull );
@@ -815,4 +733,73 @@ extern size_t varsize_any(void *p);
815733extern HeapTuple heap_expand_tuple (HeapTuple sourceTuple ,TupleDesc tupleDesc );
816734extern MinimalTuple minimal_expand_tuple (HeapTuple sourceTuple ,TupleDesc tupleDesc );
817735
736+ /*
737+ *fastgetattr
738+ *Fetch a user attribute's value as a Datum (might be either a
739+ *value, or a pointer into the data area of the tuple).
740+ *
741+ *This must not be used when a system attribute might be requested.
742+ *Furthermore, the passed attnum MUST be valid. Use heap_getattr()
743+ *instead, if in doubt.
744+ *
745+ *This gets called many times, so we macro the cacheable and NULL
746+ *lookups, and call nocachegetattr() for the rest.
747+ */
748+ static inline Datum
749+ fastgetattr (HeapTuple tup ,int attnum ,TupleDesc tupleDesc ,bool * isnull )
750+ {
751+ AssertMacro (attnum > 0 );
752+
753+ * isnull = false;
754+ if (HeapTupleNoNulls (tup ))
755+ {
756+ Form_pg_attribute att ;
757+
758+ att = TupleDescAttr (tupleDesc ,attnum - 1 );
759+ if (att -> attcacheoff >=0 )
760+ return fetchatt (att , (char * )tup -> t_data + tup -> t_data -> t_hoff +
761+ att -> attcacheoff );
762+ else
763+ return nocachegetattr (tup ,attnum ,tupleDesc );
764+ }
765+ else
766+ {
767+ if (att_isnull (attnum - 1 ,tup -> t_data -> t_bits ))
768+ {
769+ * isnull = true;
770+ return (Datum )NULL ;
771+ }
772+ else
773+ return nocachegetattr (tup ,attnum ,tupleDesc );
774+ }
775+ }
776+
777+ /*
778+ *heap_getattr
779+ *Extract an attribute of a heap tuple and return it as a Datum.
780+ *This works for either system or user attributes. The given attnum
781+ *is properly range-checked.
782+ *
783+ *If the field in question has a NULL value, we return a zero Datum
784+ *and set *isnull == true. Otherwise, we set *isnull == false.
785+ *
786+ *<tup> is the pointer to the heap tuple. <attnum> is the attribute
787+ *number of the column (field) caller wants. <tupleDesc> is a
788+ *pointer to the structure describing the row and all its fields.
789+ *
790+ */
791+ static inline Datum
792+ heap_getattr (HeapTuple tup ,int attnum ,TupleDesc tupleDesc ,bool * isnull )
793+ {
794+ if (attnum > 0 )
795+ {
796+ if (attnum > (int )HeapTupleHeaderGetNatts (tup -> t_data ))
797+ return getmissingattr (tupleDesc ,attnum ,isnull );
798+ else
799+ return fastgetattr (tup ,attnum ,tupleDesc ,isnull );
800+ }
801+ else
802+ return heap_getsysattr (tup ,attnum ,tupleDesc ,isnull );
803+ }
804+
818805#endif /* HTUP_DETAILS_H */