PostgreSQL Source Code  git master
pg_amop.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_amop.h
4  * definition of the "access method operator" system catalog (pg_amop)
5  *
6  * The amop table identifies the operators associated with each index operator
7  * family and operator class (classes are subsets of families). An associated
8  * operator can be either a search operator or an ordering operator, as
9  * identified by amoppurpose.
10  *
11  * The primary key for this table is <amopfamily, amoplefttype, amoprighttype,
12  * amopstrategy>. amoplefttype and amoprighttype are just copies of the
13  * operator's oprleft/oprright, ie its declared input data types. The
14  * "default" operators for a particular opclass within the family are those
15  * with amoplefttype = amoprighttype = opclass's opcintype. An opfamily may
16  * also contain other operators, typically cross-data-type operators. All the
17  * operators within a family are supposed to be compatible, in a way that is
18  * defined by each individual index AM.
19  *
20  * We also keep a unique index on <amopopr, amoppurpose, amopfamily>, so that
21  * we can use a syscache to quickly answer questions of the form "is this
22  * operator in this opfamily, and if so what are its semantics with respect to
23  * the family?" This implies that the same operator cannot be listed for
24  * multiple strategy numbers within a single opfamily, with the exception that
25  * it's possible to list it for both search and ordering purposes (with
26  * different strategy numbers for the two purposes).
27  *
28  * amopmethod is a copy of the owning opfamily's opfmethod field. This is an
29  * intentional denormalization of the catalogs to buy lookup speed.
30  *
31  *
32  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
33  * Portions Copyright (c) 1994, Regents of the University of California
34  *
35  * src/include/catalog/pg_amop.h
36  *
37  * NOTES
38  * The Catalog.pm module reads this file and derives schema
39  * information.
40  *
41  *-------------------------------------------------------------------------
42  */
43 #ifndef PG_AMOP_H
44 #define PG_AMOP_H
45 
46 #include "catalog/genbki.h"
47 #include "catalog/pg_amop_d.h"
48 
49 /* ----------------
50  * pg_amop definition. cpp turns this into
51  * typedef struct FormData_pg_amop
52  * ----------------
53  */
54 CATALOG(pg_amop,2602,AccessMethodOperatorRelationId)
55 {
56  Oid oid; /* oid */
57 
58  /* the index opfamily this entry is for */
59  Oid amopfamily BKI_LOOKUP(pg_opfamily);
60 
61  /* operator's left input data type */
62  Oid amoplefttype BKI_LOOKUP(pg_type);
63 
64  /* operator's right input data type */
65  Oid amoprighttype BKI_LOOKUP(pg_type);
66 
67  /* operator strategy number */
68  int16 amopstrategy;
69 
70  /* is operator for 's'earch or 'o'rdering? */
71  char amoppurpose BKI_DEFAULT(s);
72 
73  /* the operator's pg_operator OID */
74  Oid amopopr BKI_LOOKUP(pg_operator);
75 
76  /* the index access method this entry is for */
77  Oid amopmethod BKI_LOOKUP(pg_am);
78 
79  /* ordering opfamily OID, or 0 if search op */
80  Oid amopsortfamily BKI_DEFAULT(0) BKI_LOOKUP_OPT(pg_opfamily);
82 
83 /* ----------------
84  * Form_pg_amop corresponds to a pointer to a tuple with
85  * the format of pg_amop relation.
86  * ----------------
87  */
89 
90 DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, pg_amop, btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops));
91 DECLARE_UNIQUE_INDEX(pg_amop_opr_fam_index, 2654, AccessMethodOperatorIndexId, pg_amop, btree(amopopr oid_ops, amoppurpose char_ops, amopfamily oid_ops));
92 DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, pg_amop, btree(oid oid_ops));
93 
94 MAKE_SYSCACHE(AMOPSTRATEGY, pg_amop_fam_strat_index, 64);
95 MAKE_SYSCACHE(AMOPOPID, pg_amop_opr_fam_index, 64);
96 
97 #ifdef EXPOSE_TO_CLIENT_CODE
98 
99 /* allowed values of amoppurpose: */
100 #define AMOP_SEARCH 's' /* operator is for search */
101 #define AMOP_ORDER 'o' /* operator is for ordering */
102 
103 #endif /* EXPOSE_TO_CLIENT_CODE */
104 
105 #endif /* PG_AMOP_H */
signed short int16
Definition: c.h:493
#define BKI_LOOKUP(catalog)
Definition: genbki.h:46
#define BKI_DEFAULT(value)
Definition: genbki.h:35
#define BKI_LOOKUP_OPT(catalog)
Definition: genbki.h:47
DECLARE_UNIQUE_INDEX(pg_amop_fam_strat_index, 2653, AccessMethodStrategyIndexId, pg_amop, btree(amopfamily oid_ops, amoplefttype oid_ops, amoprighttype oid_ops, amopstrategy int2_ops))
MAKE_SYSCACHE(AMOPSTRATEGY, pg_amop_fam_strat_index, 64)
CATALOG(pg_amop, 2602, AccessMethodOperatorRelationId)
Definition: pg_amop.h:54
DECLARE_UNIQUE_INDEX_PKEY(pg_amop_oid_index, 2756, AccessMethodOperatorOidIndexId, pg_amop, btree(oid oid_ops))
FormData_pg_amop
Definition: pg_amop.h:81
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
unsigned int Oid
Definition: postgres_ext.h:31