PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_range.h File Reference
#include "catalog/genbki.h"
Include dependency graph for pg_range.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RangeRelationId   3541
 
#define Natts_pg_range   6
 
#define Anum_pg_range_rngtypid   1
 
#define Anum_pg_range_rngsubtype   2
 
#define Anum_pg_range_rngcollation   3
 
#define Anum_pg_range_rngsubopc   4
 
#define Anum_pg_range_rngcanonical   5
 
#define Anum_pg_range_rngsubdiff   6
 

Typedefs

typedef FormData_pg_rangeForm_pg_range
 

Functions

 CATALOG (pg_range, 3541) BKI_WITHOUT_OIDS
 
 DATA (insert(3904 23 0 1978 int4range_canonical int4range_subdiff))
 
 DATA (insert(3906 1700 0 3125-numrange_subdiff))
 
 DATA (insert(3908 1114 0 3128-tsrange_subdiff))
 
 DATA (insert(3910 1184 0 3127-tstzrange_subdiff))
 
 DATA (insert(3912 1082 0 3122 daterange_canonical daterange_subdiff))
 
 DATA (insert(3926 20 0 3124 int8range_canonical int8range_subdiff))
 
void RangeCreate (Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation, Oid rangeSubOpclass, RegProcedure rangeCanonical, RegProcedure rangeSubDiff)
 
void RangeDelete (Oid rangeTypeOid)
 

Variables

 FormData_pg_range
 

Macro Definition Documentation

#define Anum_pg_range_rngcanonical   5

Definition at line 60 of file pg_range.h.

Referenced by RangeCreate().

#define Anum_pg_range_rngcollation   3

Definition at line 58 of file pg_range.h.

Referenced by RangeCreate().

#define Anum_pg_range_rngsubdiff   6

Definition at line 61 of file pg_range.h.

Referenced by RangeCreate().

#define Anum_pg_range_rngsubopc   4

Definition at line 59 of file pg_range.h.

Referenced by RangeCreate().

#define Anum_pg_range_rngsubtype   2

Definition at line 57 of file pg_range.h.

Referenced by RangeCreate().

#define Anum_pg_range_rngtypid   1

Definition at line 56 of file pg_range.h.

Referenced by RangeCreate(), and RangeDelete().

#define Natts_pg_range   6

Definition at line 55 of file pg_range.h.

Referenced by RangeCreate().

#define RangeRelationId   3541

Definition at line 32 of file pg_range.h.

Referenced by RangeCreate(), and RangeDelete().

Typedef Documentation

Definition at line 49 of file pg_range.h.

Function Documentation

CATALOG ( pg_range  ,
3541   
)

Definition at line 34 of file pg_range.h.

35 {
36  Oid rngtypid; /* OID of owning range type */
37  Oid rngsubtype; /* OID of range's element type (subtype) */
38  Oid rngcollation; /* collation for this range type, or 0 */
39  Oid rngsubopc; /* subtype's btree opclass */
40  regproc rngcanonical; /* canonicalize range, or 0 */
41  regproc rngsubdiff; /* subtype difference as a float8, or 0 */
FormData_pg_range
Definition: pg_range.h:42
unsigned int Oid
Definition: postgres_ext.h:31
Oid regproc
Definition: c.h:394
DATA ( insert(3904 23 0 1978 int4range_canonical int4range_subdiff )
DATA ( insert(3906 1700 0 3125-numrange_subdiff )
DATA ( insert(3908 1114 0 3128-tsrange_subdiff )
DATA ( insert(3910 1184 0 3127-tstzrange_subdiff )
DATA ( insert(3912 1082 0 3122 daterange_canonical daterange_subdiff )
DATA ( insert(3926 20 0 3124 int8range_canonical int8range_subdiff )
void RangeCreate ( Oid  rangeTypeOid,
Oid  rangeSubType,
Oid  rangeCollation,
Oid  rangeSubOpclass,
RegProcedure  rangeCanonical,
RegProcedure  rangeSubDiff 
)

Definition at line 37 of file pg_range.c.

References Anum_pg_range_rngcanonical, Anum_pg_range_rngcollation, Anum_pg_range_rngsubdiff, Anum_pg_range_rngsubopc, Anum_pg_range_rngsubtype, Anum_pg_range_rngtypid, CatalogTupleInsert(), ObjectAddress::classId, CollationRelationId, DEPENDENCY_NORMAL, heap_close, heap_form_tuple(), heap_freetuple(), heap_open(), Natts_pg_range, ObjectAddress::objectId, ObjectIdGetDatum, ObjectAddress::objectSubId, OidIsValid, OperatorClassRelationId, ProcedureRelationId, RangeRelationId, recordDependencyOn(), RelationGetDescr, RowExclusiveLock, TypeRelationId, and values.

Referenced by DefineRange().

40 {
41  Relation pg_range;
43  bool nulls[Natts_pg_range];
44  HeapTuple tup;
45  ObjectAddress myself;
46  ObjectAddress referenced;
47 
49 
50  memset(nulls, 0, sizeof(nulls));
51 
52  values[Anum_pg_range_rngtypid - 1] = ObjectIdGetDatum(rangeTypeOid);
53  values[Anum_pg_range_rngsubtype - 1] = ObjectIdGetDatum(rangeSubType);
54  values[Anum_pg_range_rngcollation - 1] = ObjectIdGetDatum(rangeCollation);
55  values[Anum_pg_range_rngsubopc - 1] = ObjectIdGetDatum(rangeSubOpclass);
56  values[Anum_pg_range_rngcanonical - 1] = ObjectIdGetDatum(rangeCanonical);
57  values[Anum_pg_range_rngsubdiff - 1] = ObjectIdGetDatum(rangeSubDiff);
58 
59  tup = heap_form_tuple(RelationGetDescr(pg_range), values, nulls);
60 
61  CatalogTupleInsert(pg_range, tup);
62  heap_freetuple(tup);
63 
64  /* record type's dependencies on range-related items */
65 
66  myself.classId = TypeRelationId;
67  myself.objectId = rangeTypeOid;
68  myself.objectSubId = 0;
69 
70  referenced.classId = TypeRelationId;
71  referenced.objectId = rangeSubType;
72  referenced.objectSubId = 0;
73  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
74 
75  referenced.classId = OperatorClassRelationId;
76  referenced.objectId = rangeSubOpclass;
77  referenced.objectSubId = 0;
78  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
79 
80  if (OidIsValid(rangeCollation))
81  {
82  referenced.classId = CollationRelationId;
83  referenced.objectId = rangeCollation;
84  referenced.objectSubId = 0;
85  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
86  }
87 
88  if (OidIsValid(rangeCanonical))
89  {
90  referenced.classId = ProcedureRelationId;
91  referenced.objectId = rangeCanonical;
92  referenced.objectSubId = 0;
93  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
94  }
95 
96  if (OidIsValid(rangeSubDiff))
97  {
98  referenced.classId = ProcedureRelationId;
99  referenced.objectId = rangeSubDiff;
100  referenced.objectSubId = 0;
101  recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
102  }
103 
104  heap_close(pg_range, RowExclusiveLock);
105 }
#define RelationGetDescr(relation)
Definition: rel.h:428
#define ProcedureRelationId
Definition: pg_proc.h:33
#define OperatorClassRelationId
Definition: pg_opclass.h:49
#define Anum_pg_range_rngcollation
Definition: pg_range.h:58
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
Definition: pg_depend.c:44
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:692
#define heap_close(r, l)
Definition: heapam.h:97
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1372
#define TypeRelationId
Definition: pg_type.h:34
#define OidIsValid(objectId)
Definition: c.h:538
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
Oid CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:162
#define Anum_pg_range_rngsubdiff
Definition: pg_range.h:61
#define RowExclusiveLock
Definition: lockdefs.h:38
#define Anum_pg_range_rngsubopc
Definition: pg_range.h:59
#define Anum_pg_range_rngtypid
Definition: pg_range.h:56
uintptr_t Datum
Definition: postgres.h:372
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1284
#define CollationRelationId
Definition: pg_collation.h:30
#define Natts_pg_range
Definition: pg_range.h:55
#define Anum_pg_range_rngcanonical
Definition: pg_range.h:60
static Datum values[MAXATTR]
Definition: bootstrap.c:163
#define RangeRelationId
Definition: pg_range.h:32
#define Anum_pg_range_rngsubtype
Definition: pg_range.h:57
void RangeDelete ( Oid  rangeTypeOid)

Definition at line 113 of file pg_range.c.

References Anum_pg_range_rngtypid, BTEqualStrategyNumber, CatalogTupleDelete(), heap_close, heap_open(), HeapTupleIsValid, NULL, ObjectIdGetDatum, RangeRelationId, RangeTypidIndexId, RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), and HeapTupleData::t_self.

Referenced by RemoveTypeById().

114 {
115  Relation pg_range;
116  ScanKeyData key[1];
117  SysScanDesc scan;
118  HeapTuple tup;
119 
121 
122  ScanKeyInit(&key[0],
124  BTEqualStrategyNumber, F_OIDEQ,
125  ObjectIdGetDatum(rangeTypeOid));
126 
127  scan = systable_beginscan(pg_range, RangeTypidIndexId, true,
128  NULL, 1, key);
129 
130  while (HeapTupleIsValid(tup = systable_getnext(scan)))
131  {
132  CatalogTupleDelete(pg_range, &tup->t_self);
133  }
134 
135  systable_endscan(scan);
136 
137  heap_close(pg_range, RowExclusiveLock);
138 }
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:499
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
Definition: indexing.c:255
#define heap_close(r, l)
Definition: heapam.h:97
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:328
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:416
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
ItemPointerData t_self
Definition: htup.h:65
#define RowExclusiveLock
Definition: lockdefs.h:38
#define Anum_pg_range_rngtypid
Definition: pg_range.h:56
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1284
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
#define RangeTypidIndexId
Definition: indexing.h:324
#define RangeRelationId
Definition: pg_range.h:32
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
#define BTEqualStrategyNumber
Definition: stratnum.h:31

Variable Documentation

FormData_pg_range

Definition at line 42 of file pg_range.h.