mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Restructure some header files a bit, in particular heapam.h, by removing some
unnecessary #include lines in it. Also, move some tuple routine prototypes and macros to htup.h, which allows removal of heapam.h inclusion from some .c files. For this to work, a new header file access/sysattr.h needed to be created, initially containing attribute numbers of system columns, for pg_dump usage. While at it, make contrib ltree, intarray and hstore header files more consistent with our header style.
This commit is contained in:
@@ -7,13 +7,15 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.98 2008/01/01 19:45:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/htup.h,v 1.99 2008/05/12 00:00:53 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef HTUP_H
|
||||
#define HTUP_H
|
||||
|
||||
#include "access/tupdesc.h"
|
||||
#include "access/tupmacs.h"
|
||||
#include "storage/itemptr.h"
|
||||
#include "storage/relfilenode.h"
|
||||
|
||||
@@ -392,19 +394,6 @@ do { \
|
||||
#define MaxAttrSize (10 * 1024 * 1024)
|
||||
|
||||
|
||||
/*
|
||||
* Attribute numbers for the system-defined attributes
|
||||
*/
|
||||
#define SelfItemPointerAttributeNumber (-1)
|
||||
#define ObjectIdAttributeNumber (-2)
|
||||
#define MinTransactionIdAttributeNumber (-3)
|
||||
#define MinCommandIdAttributeNumber (-4)
|
||||
#define MaxTransactionIdAttributeNumber (-5)
|
||||
#define MaxCommandIdAttributeNumber (-6)
|
||||
#define TableOidAttributeNumber (-7)
|
||||
#define FirstLowInvalidHeapAttributeNumber (-8)
|
||||
|
||||
|
||||
/*
|
||||
* MinimalTuple is an alternative representation that is used for transient
|
||||
* tuples inside the executor, in places where transaction status information
|
||||
@@ -725,4 +714,132 @@ extern void HeapTupleHeaderAdjustCmax(HeapTupleHeader tup,
|
||||
CommandId *cmax,
|
||||
bool *iscombo);
|
||||
|
||||
/* ----------------
|
||||
* fastgetattr
|
||||
*
|
||||
* Fetch a user attribute's value as a Datum (might be either a
|
||||
* value, or a pointer into the data area of the tuple).
|
||||
*
|
||||
* This must not be used when a system attribute might be requested.
|
||||
* Furthermore, the passed attnum MUST be valid. Use heap_getattr()
|
||||
* instead, if in doubt.
|
||||
*
|
||||
* This gets called many times, so we macro the cacheable and NULL
|
||||
* lookups, and call nocachegetattr() for the rest.
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
#if !defined(DISABLE_COMPLEX_MACRO)
|
||||
|
||||
#define fastgetattr(tup, attnum, tupleDesc, isnull) \
|
||||
( \
|
||||
AssertMacro((attnum) > 0), \
|
||||
(((isnull) != NULL) ? (*(isnull) = false) : (dummyret)NULL), \
|
||||
HeapTupleNoNulls(tup) ? \
|
||||
( \
|
||||
(tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
|
||||
( \
|
||||
fetchatt((tupleDesc)->attrs[(attnum)-1], \
|
||||
(char *) (tup)->t_data + (tup)->t_data->t_hoff + \
|
||||
(tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
|
||||
) \
|
||||
: \
|
||||
nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \
|
||||
) \
|
||||
: \
|
||||
( \
|
||||
att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
|
||||
( \
|
||||
(((isnull) != NULL) ? (*(isnull) = true) : (dummyret)NULL), \
|
||||
(Datum)NULL \
|
||||
) \
|
||||
: \
|
||||
( \
|
||||
nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
#else /* defined(DISABLE_COMPLEX_MACRO) */
|
||||
|
||||
extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
|
||||
bool *isnull);
|
||||
#endif /* defined(DISABLE_COMPLEX_MACRO) */
|
||||
|
||||
|
||||
/* ----------------
|
||||
* heap_getattr
|
||||
*
|
||||
* Extract an attribute of a heap tuple and return it as a Datum.
|
||||
* This works for either system or user attributes. The given attnum
|
||||
* is properly range-checked.
|
||||
*
|
||||
* If the field in question has a NULL value, we return a zero Datum
|
||||
* and set *isnull == true. Otherwise, we set *isnull == false.
|
||||
*
|
||||
* <tup> is the pointer to the heap tuple. <attnum> is the attribute
|
||||
* number of the column (field) caller wants. <tupleDesc> is a
|
||||
* pointer to the structure describing the row and all its fields.
|
||||
* ----------------
|
||||
*/
|
||||
#define heap_getattr(tup, attnum, tupleDesc, isnull) \
|
||||
( \
|
||||
AssertMacro((tup) != NULL), \
|
||||
( \
|
||||
((attnum) > 0) ? \
|
||||
( \
|
||||
((attnum) > (int) HeapTupleHeaderGetNatts((tup)->t_data)) ? \
|
||||
( \
|
||||
(((isnull) != NULL) ? (*(isnull) = true) : (dummyret)NULL), \
|
||||
(Datum)NULL \
|
||||
) \
|
||||
: \
|
||||
fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
|
||||
) \
|
||||
: \
|
||||
heap_getsysattr((tup), (attnum), (tupleDesc), (isnull)) \
|
||||
) \
|
||||
)
|
||||
|
||||
/* prototypes for functions in common/heaptuple.c */
|
||||
extern Size heap_compute_data_size(TupleDesc tupleDesc,
|
||||
Datum *values, bool *isnull);
|
||||
extern void heap_fill_tuple(TupleDesc tupleDesc,
|
||||
Datum *values, bool *isnull,
|
||||
char *data, Size data_size,
|
||||
uint16 *infomask, bits8 *bit);
|
||||
extern bool heap_attisnull(HeapTuple tup, int attnum);
|
||||
extern Datum nocachegetattr(HeapTuple tup, int attnum,
|
||||
TupleDesc att, bool *isnull);
|
||||
extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
|
||||
bool *isnull);
|
||||
extern HeapTuple heap_copytuple(HeapTuple tuple);
|
||||
extern void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest);
|
||||
extern HeapTuple heap_form_tuple(TupleDesc tupleDescriptor,
|
||||
Datum *values, bool *isnull);
|
||||
extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
|
||||
Datum *values, char *nulls);
|
||||
extern HeapTuple heap_modify_tuple(HeapTuple tuple,
|
||||
TupleDesc tupleDesc,
|
||||
Datum *replValues,
|
||||
bool *replIsnull,
|
||||
bool *doReplace);
|
||||
extern HeapTuple heap_modifytuple(HeapTuple tuple,
|
||||
TupleDesc tupleDesc,
|
||||
Datum *replValues,
|
||||
char *replNulls,
|
||||
char *replActions);
|
||||
extern void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
|
||||
Datum *values, bool *isnull);
|
||||
extern void heap_deformtuple(HeapTuple tuple, TupleDesc tupleDesc,
|
||||
Datum *values, char *nulls);
|
||||
extern void heap_freetuple(HeapTuple htup);
|
||||
extern MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor,
|
||||
Datum *values, bool *isnull);
|
||||
extern void heap_free_minimal_tuple(MinimalTuple mtup);
|
||||
extern MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup);
|
||||
extern HeapTuple heap_tuple_from_minimal_tuple(MinimalTuple mtup);
|
||||
extern MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup);
|
||||
extern HeapTuple heap_addheader(int natts, bool withoid,
|
||||
Size structlen, void *structure);
|
||||
|
||||
#endif /* HTUP_H */
|
||||
|
||||
Reference in New Issue
Block a user