Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TUPDESC_H
00015 #define TUPDESC_H
00016
00017 #include "access/attnum.h"
00018 #include "catalog/pg_attribute.h"
00019 #include "nodes/pg_list.h"
00020
00021
00022 typedef struct attrDefault
00023 {
00024 AttrNumber adnum;
00025 char *adbin;
00026 } AttrDefault;
00027
00028 typedef struct constrCheck
00029 {
00030 char *ccname;
00031 char *ccbin;
00032 bool ccvalid;
00033 bool ccnoinherit;
00034 } ConstrCheck;
00035
00036
00037 typedef struct tupleConstr
00038 {
00039 AttrDefault *defval;
00040 ConstrCheck *check;
00041 uint16 num_defval;
00042 uint16 num_check;
00043 bool has_not_null;
00044 } TupleConstr;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 typedef struct tupleDesc
00072 {
00073 int natts;
00074 Form_pg_attribute *attrs;
00075
00076 TupleConstr *constr;
00077 Oid tdtypeid;
00078 int32 tdtypmod;
00079 bool tdhasoid;
00080 int tdrefcount;
00081 } *TupleDesc;
00082
00083
00084 extern TupleDesc CreateTemplateTupleDesc(int natts, bool hasoid);
00085
00086 extern TupleDesc CreateTupleDesc(int natts, bool hasoid,
00087 Form_pg_attribute *attrs);
00088
00089 extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
00090
00091 extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
00092
00093 extern void FreeTupleDesc(TupleDesc tupdesc);
00094
00095 extern void IncrTupleDescRefCount(TupleDesc tupdesc);
00096 extern void DecrTupleDescRefCount(TupleDesc tupdesc);
00097
00098 #define PinTupleDesc(tupdesc) \
00099 do { \
00100 if ((tupdesc)->tdrefcount >= 0) \
00101 IncrTupleDescRefCount(tupdesc); \
00102 } while (0)
00103
00104 #define ReleaseTupleDesc(tupdesc) \
00105 do { \
00106 if ((tupdesc)->tdrefcount >= 0) \
00107 DecrTupleDescRefCount(tupdesc); \
00108 } while (0)
00109
00110 extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
00111
00112 extern void TupleDescInitEntry(TupleDesc desc,
00113 AttrNumber attributeNumber,
00114 const char *attributeName,
00115 Oid oidtypeid,
00116 int32 typmod,
00117 int attdim);
00118
00119 extern void TupleDescInitEntryCollation(TupleDesc desc,
00120 AttrNumber attributeNumber,
00121 Oid collationid);
00122
00123 extern TupleDesc BuildDescForRelation(List *schema);
00124
00125 extern TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations);
00126
00127 #endif