summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorBruce Momjian1998-01-31 04:39:26 +0000
committerBruce Momjian1998-01-31 04:39:26 +0000
commit726c3854cb133b7121c86347cefeb017c1f85226 (patch)
treefb73b51979c48e519dda627e5ee0d80b8a3d4ae1 /src/include
parent2df6bba3ca3343f8ed8283f0974e5c0089280cba (diff)
Inline fastgetattr and others so data access does not use function
calls.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/heapam.h105
-rw-r--r--src/include/access/htup.h4
-rw-r--r--src/include/access/itup.h84
-rw-r--r--src/include/access/valid.h4
-rw-r--r--src/include/parser/parse_node.h3
5 files changed, 182 insertions, 18 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index f3c7c55bda6..4e5fe7ca5b7 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -6,13 +6,14 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: heapam.h,v 1.26 1998/01/27 15:57:41 momjian Exp $
+ * $Id: heapam.h,v 1.27 1998/01/31 04:39:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef HEAPAM_H
#define HEAPAM_H
+#include <access/tupmacs.h>
#include <access/htup.h>
#include <access/relscan.h>
#include <storage/block.h>
@@ -80,6 +81,59 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
(heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
/* ----------------
+ * fastgetattr
+ *
+ * This gets called many times, so we macro the cacheable and NULL
+ * lookups, and call noncachegetattr() for the rest.
+ *
+ * ----------------
+ */
+#define fastgetattr(tup, attnum, tupleDesc, isnull) \
+( \
+ AssertMacro((attnum) > 0) ? \
+ ( \
+ ((isnull) ? (*(isnull) = false) : (dummyret)NULL), \
+ HeapTupleNoNulls(tup) ? \
+ ( \
+ ((tupleDesc)->attrs[(attnum)-1]->attcacheoff > 0) ? \
+ ( \
+ (Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]), \
+ (char *) (tup) + (tup)->t_hoff + (tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
+ ) \
+ : \
+ ( \
+ ((attnum)-1 == 0) ? \
+ ( \
+ (Datum)fetchatt(&((tupleDesc)->attrs[0]), (char *) (tup) + (tup)->t_hoff) \
+ ) \
+ : \
+ ( \
+ nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \
+ ) \
+ ) \
+ ) \
+ : \
+ ( \
+ att_isnull((attnum)-1, (tup)->t_bits) ? \
+ ( \
+ ((isnull) ? (*(isnull) = true) : (dummyret)NULL), \
+ (Datum)NULL \
+ ) \
+ : \
+ ( \
+ nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \
+ ) \
+ ) \
+ ) \
+ : \
+ ( \
+ (Datum)NULL \
+ ) \
+)
+
+
+
+/* ----------------
* heap_getattr
*
* Find a particular field in a row represented as a heap tuple.
@@ -97,15 +151,46 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
* Because this macro is often called with constants, it generates
* compiler warnings about 'left-hand comma expression has no effect.
*
- * ---------------- */
-#define heap_getattr(tup, b, attnum, tupleDesc, isnull) \
- (AssertMacro((tup) != NULL) ? \
+ * ----------------
+ */
+#define heap_getattr(tup, attnum, tupleDesc, isnull) \
+( \
+ AssertMacro((tup) != NULL && \
+ (attnum) > FirstLowInvalidHeapAttributeNumber && \
+ (attnum) != 0) ? \
+ ( \
((attnum) > (int) (tup)->t_natts) ? \
- (((isnull) ? (*(isnull) = true) : (dummyret)NULL), (Datum)NULL) : \
- ((attnum) > 0) ? \
- fastgetattr((tup), (attnum), (tupleDesc), (isnull)) : \
- (((isnull) ? (*(isnull) = false) : (dummyret)NULL), heap_getsysattr((tup), (b), (attnum))) : \
- (Datum)NULL)
+ ( \
+ ((isnull) ? (*(isnull) = true) : (dummyret)NULL), \
+ (Datum)NULL \
+ ) \
+ : \
+ ( \
+ ((attnum) > 0) ? \
+ ( \
+ fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
+ ) \
+ : \
+ ( \
+ ((isnull) ? (*(isnull) = false) : (dummyret)NULL), \
+ ((attnum) == SelfItemPointerAttributeNumber) ? \
+ ( \
+ (Datum)((char *)(tup) + \
+ heap_sysoffset[-SelfItemPointerAttributeNumber-1]) \
+ ) \
+ : \
+ ( \
+ (Datum)*(unsigned int *) \
+ ((char *)(tup) + heap_sysoffset[-(attnum)-1]) \
+ ) \
+ ) \
+ ) \
+ ) \
+ : \
+ ( \
+ (Datum)NULL \
+ ) \
+)
extern HeapAccessStatistics heap_access_stats; /* in stats.c */
@@ -143,7 +228,7 @@ extern int heap_attisnull(HeapTuple tup, int attnum);
extern int heap_sysattrlen(AttrNumber attno);
extern bool heap_sysattrbyval(AttrNumber attno);
extern Datum heap_getsysattr(HeapTuple tup, Buffer b, int attnum);
-extern Datum fastgetattr(HeapTuple tup, int attnum,
+extern Datum nocachegetattr(HeapTuple tup, int attnum,
TupleDesc att, bool *isnull);
extern HeapTuple heap_copytuple(HeapTuple tuple);
extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
diff --git a/src/include/access/htup.h b/src/include/access/htup.h
index 72fb5a8d314..6e7674ea7c8 100644
--- a/src/include/access/htup.h
+++ b/src/include/access/htup.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: htup.h,v 1.7 1997/11/02 15:26:42 vadim Exp $
+ * $Id: htup.h,v 1.8 1998/01/31 04:39:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -63,6 +63,8 @@ typedef HeapTupleData *HeapTuple;
#define MaxCommandIdAttributeNumber (-6)
#define FirstLowInvalidHeapAttributeNumber (-7)
+/* If you make any changes above, the order off offsets in this must change */
+extern long heap_sysoffset[];
/* ----------------
* support macros
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index 362dcce1fc2..1ace51fa44f 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -6,15 +6,18 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: itup.h,v 1.9 1998/01/24 22:48:06 momjian Exp $
+ * $Id: itup.h,v 1.10 1998/01/31 04:39:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef ITUP_H
#define ITUP_H
+#include <access/ibit.h>
+#include <access/tupmacs.h>
#include <access/tupdesc.h>
#include <storage/itemptr.h>
+#include <utils/memutils.h>
#define MaxIndexAttributeNumber 7
@@ -87,12 +90,87 @@ typedef struct PredInfo
#define IndexTupleHasMinHeader(itup) (IndexTupleNoNulls(itup))
+/*
+ * Takes an infomask as argument (primarily because this needs to be usable
+ * at index_formtuple time so enough space is allocated).
+ *
+ * Change me if adding an attribute to IndexTuples!!!!!!!!!!!
+ */
+#define IndexInfoFindDataOffset(t_info) \
+( \
+ (!((unsigned short)(t_info) & INDEX_NULL_MASK)) ? \
+ ( \
+ (Size)sizeof(IndexTupleData) \
+ ) \
+ : \
+ ( \
+ (Size)DOUBLEALIGN(sizeof(IndexTupleData) + sizeof(IndexAttributeBitMapData)) \
+ ) \
+)
+/* ----------------
+ * index_getattr
+ *
+ * This gets called many times, so we macro the cacheable and NULL
+ * lookups, and call noncachegetattr() for the rest.
+ *
+ * ----------------
+ */
+#define index_getattr(tup, attnum, tupleDesc, isnull) \
+( \
+ AssertMacro(PointerIsValid(isnull) && (attnum) > 0) ? \
+ ( \
+ *(isnull) = false, \
+ IndexTupleNoNulls(tup) ? \
+ ( \
+ ((tupleDesc)->attrs[(attnum)-1]->attcacheoff > 0) ? \
+ ( \
+ (Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]), \
+ (char *) (tup) + \
+ (IndexTupleHasMinHeader(tup) ? sizeof (*(tup)) : \
+ IndexInfoFindDataOffset((tup)->t_info)) + \
+ (tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
+ ) \
+ : \
+ ( \
+ ((attnum)-1 == 0) ? \
+ ( \
+ (Datum)fetchatt(&((tupleDesc)->attrs[0]), \
+ (char *) (tup) + \
+ (IndexTupleHasMinHeader(tup) ? sizeof (*(tup)) : \
+ IndexInfoFindDataOffset((tup)->t_info))) \
+ ) \
+ : \
+ ( \
+ nocache_index_getattr((tup), (attnum), (tupleDesc), (isnull)) \
+ ) \
+ ) \
+ ) \
+ : \
+ ( \
+ (att_isnull((attnum)-1, (char *)(tup) + sizeof(*(tup)))) ? \
+ ( \
+ *(isnull) = true, \
+ (Datum)NULL \
+ ) \
+ : \
+ ( \
+ nocache_index_getattr((tup), (attnum), (tupleDesc), (isnull)) \
+ ) \
+ ) \
+ ) \
+ : \
+ ( \
+ (Datum)NULL \
+ ) \
+)
+
+
/* indextuple.h */
extern IndexTuple index_formtuple(TupleDesc tupleDescriptor,
Datum value[], char null[]);
-extern Datum index_getattr(IndexTuple tuple, AttrNumber attNum,
- TupleDesc tupDesc, bool *isNullOutP);
+extern Datum nocache_index_getattr(IndexTuple tup, int attnum,
+ TupleDesc tupleDesc, bool *isnull);
extern RetrieveIndexResult FormRetrieveIndexResult(ItemPointer indexItemPointer,
ItemPointer heapItemPointer);
extern void CopyIndexTuple(IndexTuple source, IndexTuple *target);
diff --git a/src/include/access/valid.h b/src/include/access/valid.h
index 9a95d9c3329..fe874512694 100644
--- a/src/include/access/valid.h
+++ b/src/include/access/valid.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: valid.h,v 1.12 1998/01/15 19:46:18 pgsql Exp $
+ * $Id: valid.h,v 1.13 1998/01/31 04:39:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,7 +53,7 @@ do \
(result) = true; /* may change */ \
for (; __cur_nkeys--; __cur_keys++) \
{ \
- __atp = heap_getattr((tuple), InvalidBuffer, \
+ __atp = heap_getattr((tuple), \
__cur_keys->sk_attno, \
(tupdesc), \
&__isnull); \
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index 50580f10366..c92c2861816 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_node.h,v 1.7 1998/01/20 22:12:16 momjian Exp $
+ * $Id: parse_node.h,v 1.8 1998/01/31 04:39:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,7 +28,6 @@ typedef struct QueryTreeList
/* state information used during parse analysis */
typedef struct ParseState
{
- struct ParseState;
int p_last_resno;
List *p_rtable;
List *p_insert_columns;