1
/*-------------------------------------------------------------------------
4
* POSTGRES tuple descriptor definitions.
7
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8
* Portions Copyright (c) 1994, Regents of the University of California
10
* $PostgreSQL: pgsql/src/include/access/tupdesc.h,v 1.46 2004-12-31 22:03:21 pgsql Exp $
12
*-------------------------------------------------------------------------
17
#include "access/attnum.h"
18
#include "catalog/pg_attribute.h"
19
#include "nodes/pg_list.h"
22
typedef struct attrDefault
25
char *adbin; /* nodeToString representation of expr */
28
typedef struct constrCheck
31
char *ccbin; /* nodeToString representation of expr */
34
/* This structure contains constraints of a tuple */
35
typedef struct tupleConstr
37
AttrDefault *defval; /* array */
38
ConstrCheck *check; /* array */
45
* This structure contains all information (i.e. from Classes
46
* pg_attribute, pg_attrdef, pg_constraint) for the structure of a tuple.
48
* Note that only user attributes, not system attributes, are mentioned in
49
* TupleDesc; with the exception that tdhasoid indicates if OID is present.
51
* If the tuple is known to correspond to a named rowtype (such as a table's
52
* rowtype) then tdtypeid identifies that type and tdtypmod is -1. Otherwise
53
* tdtypeid is RECORDOID, and tdtypmod can be either -1 for a fully anonymous
54
* row type, or a value >= 0 to allow the rowtype to be looked up in the
55
* typcache.c type cache.
57
typedef struct tupleDesc
59
int natts; /* Number of attributes in the tuple */
60
Form_pg_attribute *attrs;
61
/* attrs[N] is a pointer to the description of Attribute Number N+1. */
63
Oid tdtypeid; /* composite type ID for tuple type */
64
int32 tdtypmod; /* typmod for tuple type */
65
bool tdhasoid; /* Tuple has oid attribute in its header */
69
extern TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid);
71
extern TupleDesc CreateTupleDesc(int natts, bool hasoid,
72
Form_pg_attribute *attrs);
74
extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
76
extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
78
extern void FreeTupleDesc(TupleDesc tupdesc);
80
extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
82
extern void TupleDescInitEntry(TupleDesc desc,
83
AttrNumber attributeNumber,
84
const char *attributeName,
89
extern TupleDesc BuildDescForRelation(List *schema);
91
#endif /* TUPDESC_H */