|
| 1 | +/*------------------------------------------------------------------------- |
| 2 | + * |
| 3 | + * indexing.h-- |
| 4 | + * This include provides some definitions to support indexing |
| 5 | + * on system catalogs |
| 6 | + * |
| 7 | + * |
| 8 | + * Copyright (c) 1994, Regents of the University of California |
| 9 | + * |
| 10 | + * $Id: indexing.h,v 1.1 1996/08/28 01:56:29 scrappy Exp $ |
| 11 | + * |
| 12 | + *------------------------------------------------------------------------- |
| 13 | + */ |
| 14 | +#ifndef INDEXING_H |
| 15 | +#define INDEXING_H |
| 16 | + |
| 17 | +#include "utils/rel.h" |
| 18 | + |
| 19 | +/* |
| 20 | + * Some definitions for indices on pg_attribute |
| 21 | + */ |
| 22 | +#define Num_pg_attr_indices 3 |
| 23 | +#define Num_pg_proc_indices 3 |
| 24 | +#define Num_pg_type_indices 2 |
| 25 | +#define Num_pg_class_indices 2 |
| 26 | + |
| 27 | + |
| 28 | +/* |
| 29 | + * Names of indices on system catalogs |
| 30 | + */ |
| 31 | +#define AttributeNameIndex "pg_attnameind" |
| 32 | +#define AttributeNumIndex "pg_attnumind" |
| 33 | +#define AttributeRelidIndex "pg_attrelidind" |
| 34 | +#define ProcedureNameIndex "pg_procnameind" |
| 35 | +#define ProcedureOidIndex "pg_procidind" |
| 36 | +#define ProcedureSrcIndex "pg_procsrcind" |
| 37 | +#define TypeNameIndex "pg_typenameind" |
| 38 | +#define TypeOidIndex "pg_typeidind" |
| 39 | +#define ClassNameIndex "pg_classnameind" |
| 40 | +#define ClassOidIndex "pg_classoidind" |
| 41 | + |
| 42 | +extern char *Name_pg_attr_indices[]; |
| 43 | +extern char *Name_pg_proc_indices[]; |
| 44 | +extern char *Name_pg_type_indices[]; |
| 45 | +extern char *Name_pg_class_indices[]; |
| 46 | + |
| 47 | +extern char *IndexedCatalogNames[]; |
| 48 | + |
| 49 | +/* |
| 50 | + * indexing.c prototypes |
| 51 | + * |
| 52 | + * Functions for each index to perform the necessary scan on a cache miss. |
| 53 | + */ |
| 54 | +extern void CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]); |
| 55 | +extern void CatalogCloseIndices(int nIndices, Relation *idescs); |
| 56 | +extern void CatalogIndexInsert(Relation *idescs, |
| 57 | + int nIndices, |
| 58 | + Relation heapRelation, |
| 59 | + HeapTuple heapTuple); |
| 60 | +extern bool CatalogHasIndex(char *catName, Oid catId); |
| 61 | + |
| 62 | +extern HeapTuple AttributeNameIndexScan(Relation heapRelation, |
| 63 | + Oid relid, |
| 64 | + char *attname); |
| 65 | + |
| 66 | +extern HeapTuple AttributeNumIndexScan(Relation heapRelation, |
| 67 | + Oid relid, |
| 68 | + AttrNumber attnum); |
| 69 | +extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId); |
| 70 | +extern HeapTuple ProcedureNameIndexScan(Relation heapRelation, |
| 71 | + char *procName, int nargs, Oid *argTypes); |
| 72 | +extern HeapTuple ProcedureSrcIndexScan(Relation heapRelation, text *procSrc); |
| 73 | +extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId); |
| 74 | +extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName); |
| 75 | +extern HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName); |
| 76 | +extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId); |
| 77 | + |
| 78 | + |
| 79 | +/* |
| 80 | + * What follows are lines processed by genbki.sh to create the statements |
| 81 | + * the bootstrap parser will turn into DefineIndex commands. |
| 82 | + * |
| 83 | + * The keyword is DECLARE_INDEX every thing after that is just like in a |
| 84 | + * normal specification of the 'define index' POSTQUEL command. |
| 85 | + */ |
| 86 | +DECLARE_INDEX(pg_attnameind on pg_attribute using btree (mkoidname(attrelid, attname) oidname_ops)); |
| 87 | +DECLARE_INDEX(pg_attnumind on pg_attribute using btree (mkoidint2(attrelid, attnum) oidint2_ops)); |
| 88 | +DECLARE_INDEX(pg_attrelidind on pg_attribute using btree (attrelid oid_ops)); |
| 89 | + |
| 90 | +DECLARE_INDEX(pg_procidind on pg_proc using btree (Oid oid_ops)); |
| 91 | +DECLARE_INDEX(pg_procnameind on pg_proc using btree (proname name_ops)); |
| 92 | +DECLARE_INDEX(pg_procsrcind on pg_proc using btree (prosrc text_ops)); |
| 93 | + |
| 94 | +DECLARE_INDEX(pg_typeidind on pg_type using btree (Oid oid_ops)); |
| 95 | +DECLARE_INDEX(pg_typenameind on pg_type using btree (typname name_ops)); |
| 96 | + |
| 97 | +DECLARE_INDEX(pg_classnameind on pg_class using btree (relname name_ops)); |
| 98 | +DECLARE_INDEX(pg_classoidind on pg_class using btree (Oid oid_ops)); |
| 99 | + |
| 100 | +/* now build indices in the initialization scripts */ |
| 101 | +BUILD_INDICES |
| 102 | + |
| 103 | +#endif /* INDEXING_H */ |
0 commit comments