~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/include/access/tupdesc.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * tupdesc.h
 
4
 *        POSTGRES tuple descriptor definitions.
 
5
 *
 
6
 *
 
7
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
8
 * Portions Copyright (c) 1994, Regents of the University of California
 
9
 *
 
10
 * $PostgreSQL: pgsql/src/include/access/tupdesc.h,v 1.46 2004-12-31 22:03:21 pgsql Exp $
 
11
 *
 
12
 *-------------------------------------------------------------------------
 
13
 */
 
14
#ifndef TUPDESC_H
 
15
#define TUPDESC_H
 
16
 
 
17
#include "access/attnum.h"
 
18
#include "catalog/pg_attribute.h"
 
19
#include "nodes/pg_list.h"
 
20
 
 
21
 
 
22
typedef struct attrDefault
 
23
{
 
24
        AttrNumber      adnum;
 
25
        char       *adbin;                      /* nodeToString representation of expr */
 
26
} AttrDefault;
 
27
 
 
28
typedef struct constrCheck
 
29
{
 
30
        char       *ccname;
 
31
        char       *ccbin;                      /* nodeToString representation of expr */
 
32
} ConstrCheck;
 
33
 
 
34
/* This structure contains constraints of a tuple */
 
35
typedef struct tupleConstr
 
36
{
 
37
        AttrDefault *defval;            /* array */
 
38
        ConstrCheck *check;                     /* array */
 
39
        uint16          num_defval;
 
40
        uint16          num_check;
 
41
        bool            has_not_null;
 
42
} TupleConstr;
 
43
 
 
44
/*
 
45
 * This structure contains all information (i.e. from Classes
 
46
 * pg_attribute, pg_attrdef, pg_constraint) for the structure of a tuple.
 
47
 *
 
48
 * Note that only user attributes, not system attributes, are mentioned in
 
49
 * TupleDesc; with the exception that tdhasoid indicates if OID is present.
 
50
 *
 
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.
 
56
 */
 
57
typedef struct tupleDesc
 
58
{
 
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.  */
 
62
        TupleConstr *constr;
 
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 */
 
66
}       *TupleDesc;
 
67
 
 
68
 
 
69
extern TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid);
 
70
 
 
71
extern TupleDesc CreateTupleDesc(int natts, bool hasoid,
 
72
                                Form_pg_attribute *attrs);
 
73
 
 
74
extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
 
75
 
 
76
extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
 
77
 
 
78
extern void FreeTupleDesc(TupleDesc tupdesc);
 
79
 
 
80
extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
 
81
 
 
82
extern void TupleDescInitEntry(TupleDesc desc,
 
83
                                   AttrNumber attributeNumber,
 
84
                                   const char *attributeName,
 
85
                                   Oid oidtypeid,
 
86
                                   int32 typmod,
 
87
                                   int attdim);
 
88
 
 
89
extern TupleDesc BuildDescForRelation(List *schema);
 
90
 
 
91
#endif   /* TUPDESC_H */