postgresql/src/include/catalog/pg_range.h
Peter Eisentraut dfb75e478c Add primary keys and unique constraints to system catalogs
For those system catalogs that have a unique indexes, make a primary
key and unique constraint, using ALTER TABLE ... PRIMARY KEY/UNIQUE
USING INDEX.

This can be helpful for GUI tools that look for a primary key, and it
might in the future allow declaring foreign keys, for making schema
diagrams.

The constraint creation statements are automatically created by
genbki.pl from DECLARE_UNIQUE_INDEX directives.  To specify which one
of the available unique indexes is the primary key, use the new
directive DECLARE_UNIQUE_INDEX_PKEY instead.  By convention, we
usually make a catalog's OID column its primary key, if it has one.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/dc5f44d9-5ec1-a596-0251-dadadcdede98@2ndquadrant.com
2021-01-30 19:44:29 +01:00

76 lines
2.1 KiB
C

/*-------------------------------------------------------------------------
*
* pg_range.h
* definition of the "range type" system catalog (pg_range)
*
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/catalog/pg_range.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
* information.
*
*-------------------------------------------------------------------------
*/
#ifndef PG_RANGE_H
#define PG_RANGE_H
#include "catalog/genbki.h"
#include "catalog/pg_range_d.h"
/* ----------------
* pg_range definition. cpp turns this into
* typedef struct FormData_pg_range
* ----------------
*/
CATALOG(pg_range,3541,RangeRelationId)
{
/* OID of owning range type */
Oid rngtypid BKI_LOOKUP(pg_type);
/* OID of range's element type (subtype) */
Oid rngsubtype BKI_LOOKUP(pg_type);
/* OID of the range's multirange type */
Oid rngmultitypid BKI_LOOKUP(pg_type);
/* collation for this range type, or 0 */
Oid rngcollation BKI_DEFAULT(0);
/* subtype's btree opclass */
Oid rngsubopc BKI_LOOKUP(pg_opclass);
/* canonicalize range, or 0 */
regproc rngcanonical BKI_LOOKUP(pg_proc);
/* subtype difference as a float8, or 0 */
regproc rngsubdiff BKI_LOOKUP(pg_proc);
} FormData_pg_range;
/* ----------------
* Form_pg_range corresponds to a pointer to a tuple with
* the format of pg_range relation.
* ----------------
*/
typedef FormData_pg_range *Form_pg_range;
DECLARE_UNIQUE_INDEX_PKEY(pg_range_rngtypid_index, 3542, on pg_range using btree(rngtypid oid_ops));
#define RangeTypidIndexId 3542
DECLARE_UNIQUE_INDEX(pg_range_rngmultitypid_index, 2228, on pg_range using btree(rngmultitypid oid_ops));
#define RangeMultirangeTypidIndexId 2228
/*
* prototypes for functions in pg_range.c
*/
extern void RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation,
Oid rangeSubOpclass, RegProcedure rangeCanonical,
RegProcedure rangeSubDiff, Oid multirangeTypeOid);
extern void RangeDelete(Oid rangeTypeOid);
#endif /* PG_RANGE_H */