postgresql/src/include/catalog/pg_amproc.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

75 lines
2.6 KiB
C

/*-------------------------------------------------------------------------
*
* pg_amproc.h
* definition of the "access method procedure" system catalog (pg_amproc)
*
* The amproc table identifies support procedures associated with index
* operator families and classes. These procedures can't be listed in pg_amop
* since they are not the implementation of any indexable operator.
*
* The primary key for this table is <amprocfamily, amproclefttype,
* amprocrighttype, amprocnum>. The "default" support functions for a
* particular opclass within the family are those with amproclefttype =
* amprocrighttype = opclass's opcintype. These are the ones loaded into the
* relcache for an index and typically used for internal index operations.
* Other support functions are typically used to handle cross-type indexable
* operators with oprleft/oprright matching the entry's amproclefttype and
* amprocrighttype. The exact behavior depends on the index AM, however, and
* some don't pay attention to non-default functions at all.
*
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/catalog/pg_amproc.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
* information.
*
*-------------------------------------------------------------------------
*/
#ifndef PG_AMPROC_H
#define PG_AMPROC_H
#include "catalog/genbki.h"
#include "catalog/pg_amproc_d.h"
/* ----------------
* pg_amproc definition. cpp turns this into
* typedef struct FormData_pg_amproc
* ----------------
*/
CATALOG(pg_amproc,2603,AccessMethodProcedureRelationId)
{
Oid oid; /* oid */
/* the index opfamily this entry is for */
Oid amprocfamily BKI_LOOKUP(pg_opfamily);
/* procedure's left input data type */
Oid amproclefttype BKI_LOOKUP(pg_type);
/* procedure's right input data type */
Oid amprocrighttype BKI_LOOKUP(pg_type);
/* support procedure index */
int16 amprocnum;
/* OID of the proc */
regproc amproc BKI_LOOKUP(pg_proc);
} FormData_pg_amproc;
/* ----------------
* Form_pg_amproc corresponds to a pointer to a tuple with
* the format of pg_amproc relation.
* ----------------
*/
typedef FormData_pg_amproc *Form_pg_amproc;
DECLARE_UNIQUE_INDEX(pg_amproc_fam_proc_index, 2655, on pg_amproc using btree(amprocfamily oid_ops, amproclefttype oid_ops, amprocrighttype oid_ops, amprocnum int2_ops));
#define AccessMethodProcedureIndexId 2655
DECLARE_UNIQUE_INDEX_PKEY(pg_amproc_oid_index, 2757, on pg_amproc using btree(oid oid_ops));
#define AccessMethodProcedureOidIndexId 2757
#endif /* PG_AMPROC_H */