aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-08-23 16:58:53 -0700
committerAndres Freund <andres@anarazel.de>2018-08-23 16:58:53 -0700
commit88ebd62fcc2ea7c55c0858f6dd4800d51383529f (patch)
tree652d1428bd6aeae154408c27e8725ff229162035 /src
parenta40631a920accbcca1a49a909d380308d95b4674 (diff)
downloadpostgresql-88ebd62fcc2ea7c55c0858f6dd4800d51383529f.tar.gz
postgresql-88ebd62fcc2ea7c55c0858f6dd4800d51383529f.zip
Deduplicate code between slot_getallattrs() and slot_getsomeattrs().
Code in slot_getallattrs() is the same as if slot_getsomeattrs() is called with number of attributes specified in the tuple descriptor. Implement it that way instead of duplicating the code between those two functions. This is part of a patchseries abstracting TupleTableSlots so they can store arbitrary forms of tuples, but is a nice enough cleanup on its own. Author: Ashutosh Bapat Reviewed-By: Andres Freund Discussion: https://postgr.es/m/20180220224318.gw4oe5jadhpmcdnm@alap3.anarazel.de
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/common/heaptuple.c45
-rw-r--r--src/include/executor/tuptable.h13
2 files changed, 12 insertions, 46 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 2ec7e6a4392..d8b06bca7e7 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -1602,51 +1602,6 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
}
/*
- * slot_getallattrs
- * This function forces all the entries of the slot's Datum/isnull
- * arrays to be valid. The caller may then extract data directly
- * from those arrays instead of using slot_getattr.
- */
-void
-slot_getallattrs(TupleTableSlot *slot)
-{
- int tdesc_natts = slot->tts_tupleDescriptor->natts;
- int attnum;
- HeapTuple tuple;
-
- /* Quick out if we have 'em all already */
- if (slot->tts_nvalid == tdesc_natts)
- return;
-
- /*
- * otherwise we had better have a physical tuple (tts_nvalid should equal
- * natts in all virtual-tuple cases)
- */
- tuple = slot->tts_tuple;
- if (tuple == NULL) /* internal error */
- elog(ERROR, "cannot extract attribute from empty tuple slot");
-
- /*
- * load up any slots available from physical tuple
- */
- attnum = HeapTupleHeaderGetNatts(tuple->t_data);
- attnum = Min(attnum, tdesc_natts);
-
- slot_deform_tuple(slot, attnum);
-
- attnum = slot->tts_nvalid;
-
- /*
- * If tuple doesn't have all the atts indicated by tupleDesc, read the
- * rest as NULLS or missing values.
- */
- if (attnum < tdesc_natts)
- slot_getmissingattrs(slot, attnum, tdesc_natts);
-
- slot->tts_nvalid = tdesc_natts;
-}
-
-/*
* slot_getsomeattrs
* This function forces the entries of the slot's Datum/isnull
* arrays to be valid at least up through the attnum'th entry.
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
index 0b874d97638..bb38aa655c0 100644
--- a/src/include/executor/tuptable.h
+++ b/src/include/executor/tuptable.h
@@ -174,11 +174,22 @@ extern TupleTableSlot *ExecCopySlot(TupleTableSlot *dstslot,
/* in access/common/heaptuple.c */
extern Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull);
-extern void slot_getallattrs(TupleTableSlot *slot);
extern void slot_getsomeattrs(TupleTableSlot *slot, int attnum);
extern bool slot_attisnull(TupleTableSlot *slot, int attnum);
extern bool slot_getsysattr(TupleTableSlot *slot, int attnum,
Datum *value, bool *isnull);
extern void slot_getmissingattrs(TupleTableSlot *slot, int startAttNum, int lastAttNum);
+/*
+ * slot_getallattrs
+ * This function forces all the entries of the slot's Datum/isnull
+ * arrays to be valid. The caller may then extract data directly
+ * from those arrays instead of using slot_getattr.
+ */
+static inline void
+slot_getallattrs(TupleTableSlot *slot)
+{
+ slot_getsomeattrs(slot, slot->tts_tupleDescriptor->natts);
+}
+
#endif /* TUPTABLE_H */