PostgreSQL Source Code  git master
pg_range.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_range_d.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.

Typedefs

typedef FormData_pg_rangeForm_pg_range
 

Functions

 CATALOG (pg_range, 3541, RangeRelationId) BKI_WITHOUT_OIDS
 
void RangeCreate (Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation, Oid rangeSubOpclass, RegProcedure rangeCanonical, RegProcedure rangeSubDiff)
 
void RangeDelete (Oid rangeTypeOid)
 

Variables

 FormData_pg_range
 

Typedef Documentation

◆ Form_pg_range

Definition at line 55 of file pg_range.h.

Function Documentation

◆ CATALOG()

CATALOG ( pg_range  ,
3541  ,
RangeRelationId   
)

Definition at line 29 of file pg_range.h.

References BKI_DEFAULT, and BKI_LOOKUP.

30 {
31  /* OID of owning range type */
32  Oid rngtypid BKI_LOOKUP(pg_type);
33 
34  /* OID of range's element type (subtype) */
35  Oid rngsubtype BKI_LOOKUP(pg_type);
36 
37  /* collation for this range type, or 0 */
38  Oid rngcollation BKI_DEFAULT(0);
39 
40  /* subtype's btree opclass */
41  Oid rngsubopc BKI_LOOKUP(pg_opclass);
42 
43  /* canonicalize range, or 0 */
44  regproc rngcanonical BKI_LOOKUP(pg_proc);
45 
46  /* subtype difference as a float8, or 0 */
47  regproc rngsubdiff BKI_LOOKUP(pg_proc);
FormData_pg_range
Definition: pg_range.h:48
unsigned int Oid
Definition: postgres_ext.h:31
#define BKI_DEFAULT(value)
Definition: genbki.h:36
#define BKI_LOOKUP(catalog)
Definition: genbki.h:38
Oid regproc
Definition: c.h:471

◆ RangeCreate()

void RangeCreate ( Oid  rangeTypeOid,
Oid  rangeSubType,
Oid  rangeCollation,
Oid  rangeSubOpclass,
RegProcedure  rangeCanonical,
RegProcedure  rangeSubDiff 
)

Definition at line 37 of file pg_range.c.

References CatalogTupleInsert(), ObjectAddress::classId, DEPENDENCY_NORMAL, heap_close, heap_form_tuple(), heap_freetuple(), heap_open(), ObjectAddress::objectId, ObjectIdGetDatum, ObjectAddress::objectSubId, OidIsValid, recordDependencyOn(), RelationGetDescr, RowExclusiveLock, and values.

Referenced by DefineRange().

40 {
41  Relation pg_range;
42  Datum values[Natts_pg_range];
43  bool nulls[Natts_pg_range];
44  HeapTuple tup;
45  ObjectAddress myself;
46  ObjectAddress referenced;
47 
48  pg_range = heap_open(RangeRelationId, RowExclusiveLock);
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:433
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:1074
#define heap_close(r, l)
Definition: heapam.h:97
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1773
#define OidIsValid(objectId)
Definition: c.h:605
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
Oid CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:163
#define RowExclusiveLock
Definition: lockdefs.h:38
uintptr_t Datum
Definition: postgres.h:367
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1294
static Datum values[MAXATTR]
Definition: bootstrap.c:164

◆ RangeDelete()

void RangeDelete ( Oid  rangeTypeOid)

Definition at line 113 of file pg_range.c.

References BTEqualStrategyNumber, CatalogTupleDelete(), heap_close, heap_open(), HeapTupleIsValid, ObjectIdGetDatum, 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 
120  pg_range = heap_open(RangeRelationId, RowExclusiveLock);
121 
122  ScanKeyInit(&key[0],
123  Anum_pg_range_rngtypid,
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:502
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
Definition: indexing.c:256
#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:331
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:419
#define ObjectIdGetDatum(X)
Definition: postgres.h:492
ItemPointerData t_self
Definition: htup.h:65
#define RowExclusiveLock
Definition: lockdefs.h:38
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1294
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define RangeTypidIndexId
Definition: indexing.h:325
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

FormData_pg_range

Definition at line 48 of file pg_range.h.