Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

pg_range.c File Reference

#include "postgres.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/htup_details.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_range.h"
#include "catalog/pg_type.h"
#include "utils/fmgroids.h"
#include "utils/rel.h"
#include "utils/tqual.h"
Include dependency graph for pg_range.c:

Go to the source code of this file.

Functions

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

Function Documentation

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, CatalogUpdateIndexes(), ObjectAddress::classId, DEPENDENCY_NORMAL, heap_close, heap_form_tuple(), heap_freetuple(), heap_open(), ObjectAddress::objectId, ObjectIdGetDatum, ObjectAddress::objectSubId, OidIsValid, RangeRelationId, recordDependencyOn(), RelationGetDescr, RowExclusiveLock, simple_heap_insert(), and values.

Referenced by DefineRange().

{
    Relation    pg_range;
    Datum       values[Natts_pg_range];
    bool        nulls[Natts_pg_range];
    HeapTuple   tup;
    ObjectAddress myself;
    ObjectAddress referenced;

    pg_range = heap_open(RangeRelationId, RowExclusiveLock);

    memset(nulls, 0, sizeof(nulls));

    values[Anum_pg_range_rngtypid - 1] = ObjectIdGetDatum(rangeTypeOid);
    values[Anum_pg_range_rngsubtype - 1] = ObjectIdGetDatum(rangeSubType);
    values[Anum_pg_range_rngcollation - 1] = ObjectIdGetDatum(rangeCollation);
    values[Anum_pg_range_rngsubopc - 1] = ObjectIdGetDatum(rangeSubOpclass);
    values[Anum_pg_range_rngcanonical - 1] = ObjectIdGetDatum(rangeCanonical);
    values[Anum_pg_range_rngsubdiff - 1] = ObjectIdGetDatum(rangeSubDiff);

    tup = heap_form_tuple(RelationGetDescr(pg_range), values, nulls);

    simple_heap_insert(pg_range, tup);
    CatalogUpdateIndexes(pg_range, tup);
    heap_freetuple(tup);

    /* record type's dependencies on range-related items */

    myself.classId = TypeRelationId;
    myself.objectId = rangeTypeOid;
    myself.objectSubId = 0;

    referenced.classId = TypeRelationId;
    referenced.objectId = rangeSubType;
    referenced.objectSubId = 0;
    recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);

    referenced.classId = OperatorClassRelationId;
    referenced.objectId = rangeSubOpclass;
    referenced.objectSubId = 0;
    recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);

    if (OidIsValid(rangeCollation))
    {
        referenced.classId = CollationRelationId;
        referenced.objectId = rangeCollation;
        referenced.objectSubId = 0;
        recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
    }

    if (OidIsValid(rangeCanonical))
    {
        referenced.classId = ProcedureRelationId;
        referenced.objectId = rangeCanonical;
        referenced.objectSubId = 0;
        recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
    }

    if (OidIsValid(rangeSubDiff))
    {
        referenced.classId = ProcedureRelationId;
        referenced.objectId = rangeSubDiff;
        referenced.objectSubId = 0;
        recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
    }

    heap_close(pg_range, RowExclusiveLock);
}

void RangeDelete ( Oid  rangeTypeOid  )