1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* indexing.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* This file contains routines to support indices defined on system
|
|
|
|
* catalogs.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1999-11-01 05:00:57 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.50 1999/11/01 04:00:56 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-01-10 21:19:49 +01:00
|
|
|
|
1998-04-27 06:08:07 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
#include "access/genam.h"
|
|
|
|
#include "access/heapam.h"
|
|
|
|
#include "catalog/catalog.h"
|
|
|
|
#include "catalog/catname.h"
|
|
|
|
#include "catalog/index.h"
|
|
|
|
#include "catalog/indexing.h"
|
|
|
|
#include "catalog/pg_index.h"
|
|
|
|
#include "miscadmin.h"
|
|
|
|
#include "utils/syscache.h"
|
1996-11-04 00:27:08 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* Names of indices on the following system catalogs:
|
1999-07-20 19:14:08 +02:00
|
|
|
*
|
|
|
|
* pg_attribute
|
|
|
|
* pg_proc
|
|
|
|
* pg_type
|
|
|
|
* pg_naming
|
|
|
|
* pg_class
|
|
|
|
* pg_attrdef
|
|
|
|
* pg_relcheck
|
|
|
|
* pg_trigger
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
1999-11-01 03:29:27 +01:00
|
|
|
char *Name_pg_amop_indices[Num_pg_amop_indices] = {AccessMethodOpidIndex,
|
|
|
|
AccessMethodStrategyIndex};
|
1997-09-08 04:41:22 +02:00
|
|
|
char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex,
|
1999-11-01 03:29:27 +01:00
|
|
|
AttributeNumIndex, AttributeRelidIndex};
|
|
|
|
char *Name_pg_index_indices[Num_pg_index_indices] = {IndexRelidIndex};
|
1997-09-08 04:41:22 +02:00
|
|
|
char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex,
|
1999-11-01 03:29:27 +01:00
|
|
|
ProcedureOidIndex};
|
1997-09-08 04:41:22 +02:00
|
|
|
char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex,
|
1999-11-01 03:29:27 +01:00
|
|
|
TypeOidIndex};
|
1997-09-08 04:41:22 +02:00
|
|
|
char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex,
|
1999-11-01 03:29:27 +01:00
|
|
|
ClassOidIndex};
|
1997-09-08 04:41:22 +02:00
|
|
|
char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex};
|
|
|
|
char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
|
1999-09-29 18:06:40 +02:00
|
|
|
char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex,
|
1999-11-01 05:00:57 +01:00
|
|
|
TriggerConstrNameIndex, TriggerConstrRelidIndex};
|
This patch implements ORACLE's COMMENT SQL command.
>From the ORACLE 7 SQL Language Reference Manual:
-----------------------------------------------------
COMMENT
Purpose:
To add a comment about a table, view, snapshot, or
column into the data dictionary.
Prerequisites:
The table, view, or snapshot must be in your own
schema
or you must have COMMENT ANY TABLE system privilege.
Syntax:
COMMENT ON [ TABLE table ] |
[ COLUMN table.column] IS 'text'
You can effectively drop a comment from the database
by setting it to the empty string ''.
-----------------------------------------------------
Example:
COMMENT ON TABLE workorders IS
'Maintains base records for workorder information';
COMMENT ON COLUMN workorders.hours IS
'Number of hours the engineer worked on the task';
to drop a comment:
COMMENT ON COLUMN workorders.hours IS '';
The current patch will simply perform the insert into
pg_description, as per the TODO. And, of course, when
the table is dropped, any comments relating to it
or any of its attributes are also dropped. I haven't
looked at the ODBC source yet, but I do know from
an ODBC client standpoint that the standard does
support the notion of table and column comments.
Hopefully the ODBC driver is already fetching these
values from pg_description, but if not, it should be
trivial.
Hope this makes the grade,
Mike Mascari
(mascarim@yahoo.com)
1999-10-15 03:49:49 +02:00
|
|
|
char *Name_pg_description_indices[Num_pg_description_indices] = {DescriptionObjIndex};
|
|
|
|
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,
|
1999-11-01 05:00:57 +01:00
|
|
|
Relation idesc,
|
|
|
|
ScanKey skey,
|
|
|
|
int16 num_keys);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Changes (appends) to catalogs can (and does) happen at various places
|
|
|
|
* throughout the code. We need a generic routine that will open all of
|
|
|
|
* the indices defined on a given catalog a return the relation descriptors
|
|
|
|
* associated with them.
|
|
|
|
*/
|
|
|
|
void
|
1998-09-01 05:29:17 +02:00
|
|
|
CatalogOpenIndices(int nIndices, char **names, Relation *idescs)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < nIndices; i++)
|
|
|
|
idescs[i] = index_openr(names[i]);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the inverse routine to CatalogOpenIndices()
|
|
|
|
*/
|
|
|
|
void
|
1997-09-08 23:56:23 +02:00
|
|
|
CatalogCloseIndices(int nIndices, Relation *idescs)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < nIndices; i++)
|
|
|
|
index_close(idescs[i]);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For the same reasons outlined above CatalogOpenIndices() we need a routine
|
1997-09-07 07:04:48 +02:00
|
|
|
* that takes a new catalog tuple and inserts an associated index tuple into
|
1996-07-09 08:22:35 +02:00
|
|
|
* each catalog index.
|
|
|
|
*/
|
|
|
|
void
|
1997-09-08 23:56:23 +02:00
|
|
|
CatalogIndexInsert(Relation *idescs,
|
1997-09-07 07:04:48 +02:00
|
|
|
int nIndices,
|
|
|
|
Relation heapRelation,
|
|
|
|
HeapTuple heapTuple)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-09-01 18:21:47 +02:00
|
|
|
HeapTuple index_tup;
|
1997-09-08 04:41:22 +02:00
|
|
|
TupleDesc heapDescriptor;
|
1998-09-01 18:21:47 +02:00
|
|
|
Form_pg_index index_form;
|
1998-09-03 01:05:37 +02:00
|
|
|
Datum datum[INDEX_MAX_KEYS];
|
|
|
|
char nulls[INDEX_MAX_KEYS];
|
1997-09-08 04:41:22 +02:00
|
|
|
int natts;
|
|
|
|
AttrNumber *attnumP;
|
|
|
|
FuncIndexInfo finfo,
|
|
|
|
*finfoP;
|
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
heapDescriptor = RelationGetDescr(heapRelation);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < nIndices; i++)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
InsertIndexResult indexRes;
|
|
|
|
|
1998-09-01 18:21:47 +02:00
|
|
|
index_tup = SearchSysCacheTupleCopy(INDEXRELID,
|
1998-09-01 06:40:42 +02:00
|
|
|
ObjectIdGetDatum(idescs[i]->rd_id),
|
1999-05-25 18:15:34 +02:00
|
|
|
0, 0, 0);
|
1998-09-01 18:21:47 +02:00
|
|
|
Assert(index_tup);
|
|
|
|
index_form = (Form_pg_index) GETSTRUCT(index_tup);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 18:21:47 +02:00
|
|
|
if (index_form->indproc != InvalidOid)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
int fatts;
|
1998-09-07 07:35:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute the number of attributes we are indexing upon.
|
|
|
|
*/
|
|
|
|
for (attnumP = index_form->indkey, fatts = 0;
|
1998-09-23 06:22:14 +02:00
|
|
|
fatts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber;
|
1998-09-07 07:35:48 +02:00
|
|
|
attnumP++, fatts++)
|
|
|
|
;
|
|
|
|
FIgetnArgs(&finfo) = fatts;
|
1997-09-07 07:04:48 +02:00
|
|
|
natts = 1;
|
1998-09-01 18:21:47 +02:00
|
|
|
FIgetProcOid(&finfo) = index_form->indproc;
|
1997-09-07 07:04:48 +02:00
|
|
|
*(FIgetname(&finfo)) = '\0';
|
|
|
|
finfoP = &finfo;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
1998-09-07 07:35:48 +02:00
|
|
|
{
|
|
|
|
natts = RelationGetDescr(idescs[i])->natts;
|
1997-09-07 07:04:48 +02:00
|
|
|
finfoP = (FuncIndexInfo *) NULL;
|
1998-09-07 07:35:48 +02:00
|
|
|
}
|
1999-05-25 18:15:34 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
FormIndexDatum(natts,
|
1998-09-01 18:21:47 +02:00
|
|
|
(AttrNumber *) index_form->indkey,
|
1997-09-07 07:04:48 +02:00
|
|
|
heapTuple,
|
|
|
|
heapDescriptor,
|
1998-09-03 01:05:37 +02:00
|
|
|
datum,
|
1997-09-07 07:04:48 +02:00
|
|
|
nulls,
|
|
|
|
finfoP);
|
|
|
|
|
1998-09-03 01:05:37 +02:00
|
|
|
indexRes = index_insert(idescs[i], datum, nulls,
|
1998-11-27 20:52:36 +01:00
|
|
|
&heapTuple->t_self, heapRelation);
|
1997-09-07 07:04:48 +02:00
|
|
|
if (indexRes)
|
|
|
|
pfree(indexRes);
|
1998-09-07 07:35:48 +02:00
|
|
|
|
1998-09-01 18:21:47 +02:00
|
|
|
pfree(index_tup);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is needed at initialization when reldescs for some of the crucial
|
|
|
|
* system catalogs are created and nailed into the cache.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
CatalogHasIndex(char *catName, Oid catId)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation pg_class;
|
|
|
|
HeapTuple htup;
|
|
|
|
Form_pg_class pgRelP;
|
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
Assert(IsSystemRelationName(catName));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're bootstraping we don't have pg_class (or any indices).
|
|
|
|
*/
|
|
|
|
if (IsBootstrapProcessingMode())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (IsInitProcessingMode())
|
|
|
|
{
|
|
|
|
for (i = 0; IndexedCatalogNames[i] != NULL; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(IndexedCatalogNames[i], catName) == 0)
|
1998-09-01 05:29:17 +02:00
|
|
|
return true;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1998-09-01 05:29:17 +02:00
|
|
|
return false;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-09-18 21:08:25 +02:00
|
|
|
pg_class = heap_openr(RelationRelationName, AccessShareLock);
|
1997-09-07 07:04:48 +02:00
|
|
|
htup = ClassOidIndexScan(pg_class, catId);
|
1999-09-18 21:08:25 +02:00
|
|
|
heap_close(pg_class, AccessShareLock);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
if (!HeapTupleIsValid(htup))
|
|
|
|
{
|
1999-05-10 02:46:32 +02:00
|
|
|
elog(NOTICE, "CatalogHasIndex: no relation with oid %u", catId);
|
1997-09-07 07:04:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
pgRelP = (Form_pg_class) GETSTRUCT(htup);
|
1998-09-01 05:29:17 +02:00
|
|
|
return pgRelP->relhasindex;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* CatalogIndexFetchTuple() -- Get a tuple that satisfies a scan key
|
|
|
|
* from a catalog relation.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Since the index may contain pointers to dead tuples, we need to
|
|
|
|
* iterate until we find a tuple that's valid and satisfies the scan
|
|
|
|
* key.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static HeapTuple
|
1996-07-09 08:22:35 +02:00
|
|
|
CatalogIndexFetchTuple(Relation heapRelation,
|
1997-09-07 07:04:48 +02:00
|
|
|
Relation idesc,
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKey skey,
|
|
|
|
int16 num_keys)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
IndexScanDesc sd;
|
1997-09-07 07:04:48 +02:00
|
|
|
RetrieveIndexResult indexRes;
|
1999-05-25 18:15:34 +02:00
|
|
|
HeapTupleData tuple;
|
|
|
|
HeapTuple result = NULL;
|
|
|
|
Buffer buffer;
|
1998-09-01 06:40:42 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
sd = index_beginscan(idesc, false, num_keys, skey);
|
1998-11-27 20:52:36 +01:00
|
|
|
tuple.t_data = NULL;
|
1998-08-31 01:25:56 +02:00
|
|
|
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1998-11-27 20:52:36 +01:00
|
|
|
tuple.t_self = indexRes->heap_iptr;
|
|
|
|
heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
|
1998-08-31 01:25:56 +02:00
|
|
|
pfree(indexRes);
|
1998-11-27 20:52:36 +01:00
|
|
|
if (tuple.t_data != NULL)
|
1997-09-07 07:04:48 +02:00
|
|
|
break;
|
1998-09-01 06:40:42 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-11-27 20:52:36 +01:00
|
|
|
if (tuple.t_data != NULL)
|
1998-08-31 01:25:56 +02:00
|
|
|
{
|
1998-11-27 20:52:36 +01:00
|
|
|
result = heap_copytuple(&tuple);
|
1997-09-07 07:04:48 +02:00
|
|
|
ReleaseBuffer(buffer);
|
1998-08-31 01:25:56 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_endscan(sd);
|
|
|
|
pfree(sd);
|
1998-11-27 20:52:36 +01:00
|
|
|
return result;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1999-11-01 03:29:27 +01:00
|
|
|
/*---------------------------------------------------------------------
|
|
|
|
* Class-specific index lookups
|
|
|
|
*---------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* The remainder of the file is for individual index scan routines. Each
|
|
|
|
* index should be scanned according to how it was defined during bootstrap
|
|
|
|
* (that is, functional or normal) and what arguments the cache lookup
|
|
|
|
* requires. Each routine returns the heap tuple that qualifies.
|
|
|
|
*/
|
1999-11-01 03:29:27 +01:00
|
|
|
HeapTuple
|
|
|
|
AccessMethodOpidIndexScan(Relation heapRelation,
|
|
|
|
Oid claid,
|
|
|
|
Oid opopr,
|
|
|
|
Oid opid)
|
|
|
|
{
|
|
|
|
Relation idesc;
|
|
|
|
ScanKeyData skey[3];
|
|
|
|
HeapTuple tuple;
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
|
|
|
(RegProcedure) F_OIDEQ,
|
|
|
|
ObjectIdGetDatum(claid));
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[1],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 2,
|
|
|
|
(RegProcedure) F_OIDEQ,
|
|
|
|
ObjectIdGetDatum(opopr));
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[2],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 3,
|
|
|
|
(RegProcedure) F_OIDEQ,
|
|
|
|
ObjectIdGetDatum(opid));
|
|
|
|
|
|
|
|
idesc = index_openr(AccessMethodOpidIndex);
|
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
|
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapTuple
|
|
|
|
AccessMethodStrategyIndexScan(Relation heapRelation,
|
|
|
|
Oid opid,
|
|
|
|
Oid claid,
|
|
|
|
int2 opstrategy)
|
|
|
|
{
|
|
|
|
Relation idesc;
|
|
|
|
ScanKeyData skey[3];
|
|
|
|
HeapTuple tuple;
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
|
|
|
(RegProcedure) F_OIDEQ,
|
|
|
|
ObjectIdGetDatum(opid));
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[1],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 2,
|
|
|
|
(RegProcedure) F_OIDEQ,
|
|
|
|
ObjectIdGetDatum(claid));
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[2],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 3,
|
|
|
|
(RegProcedure) F_INT2EQ,
|
|
|
|
Int16GetDatum(opstrategy));
|
|
|
|
|
|
|
|
idesc = index_openr(AccessMethodStrategyIndex);
|
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
|
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
AttributeNameIndexScan(Relation heapRelation,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
char *attname)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[2];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-09-01 06:40:42 +02:00
|
|
|
(RegProcedure) F_OIDEQ,
|
1998-08-20 17:16:59 +02:00
|
|
|
ObjectIdGetDatum(relid));
|
1998-08-19 04:04:17 +02:00
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[1],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 2,
|
1998-09-01 06:40:42 +02:00
|
|
|
(RegProcedure) F_NAMEEQ,
|
1998-08-19 04:04:17 +02:00
|
|
|
NameGetDatum(attname));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(AttributeNameIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
AttributeNumIndexScan(Relation heapRelation,
|
1997-09-07 07:04:48 +02:00
|
|
|
Oid relid,
|
|
|
|
AttrNumber attnum)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[2];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-09-01 06:40:42 +02:00
|
|
|
(RegProcedure) F_OIDEQ,
|
1998-08-31 19:49:18 +02:00
|
|
|
ObjectIdGetDatum(relid));
|
1998-08-19 04:04:17 +02:00
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[1],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 2,
|
1998-09-01 06:40:42 +02:00
|
|
|
(RegProcedure) F_INT2EQ,
|
1998-08-19 04:04:17 +02:00
|
|
|
Int16GetDatum(attnum));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(AttributeNumIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1999-11-01 03:29:27 +01:00
|
|
|
HeapTuple
|
|
|
|
IndexRelidIndexScan(Relation heapRelation, Oid relid)
|
|
|
|
{
|
|
|
|
Relation idesc;
|
|
|
|
ScanKeyData skey[1];
|
|
|
|
HeapTuple tuple;
|
|
|
|
|
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
|
|
|
(RegProcedure) F_OIDEQ,
|
|
|
|
ObjectIdGetDatum(relid));
|
|
|
|
|
|
|
|
idesc = index_openr(IndexRelidIndex);
|
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
ProcedureOidIndexScan(Relation heapRelation, Oid procId)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[1];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-04-27 06:08:07 +02:00
|
|
|
(RegProcedure) F_OIDEQ,
|
1998-08-31 01:25:56 +02:00
|
|
|
ObjectIdGetDatum(procId));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(ProcedureOidIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1996-11-26 03:45:05 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
ProcedureNameIndexScan(Relation heapRelation,
|
1997-09-07 07:04:48 +02:00
|
|
|
char *procName,
|
1998-08-19 04:04:17 +02:00
|
|
|
int2 nargs,
|
1997-09-08 23:56:23 +02:00
|
|
|
Oid *argTypes)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[3];
|
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-04-27 06:08:07 +02:00
|
|
|
(RegProcedure) F_NAMEEQ,
|
1998-08-31 01:25:56 +02:00
|
|
|
PointerGetDatum(procName));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[1],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 2,
|
|
|
|
(RegProcedure) F_INT2EQ,
|
|
|
|
Int16GetDatum(nargs));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[2],
|
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 3,
|
|
|
|
(RegProcedure) F_OID8EQ,
|
1998-08-31 01:25:56 +02:00
|
|
|
PointerGetDatum(argTypes));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
idesc = index_openr(ProcedureNameIndex);
|
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1996-11-26 03:45:05 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
TypeOidIndexScan(Relation heapRelation, Oid typeId)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[1];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-04-27 06:08:07 +02:00
|
|
|
(RegProcedure) F_OIDEQ,
|
1998-08-31 01:25:56 +02:00
|
|
|
ObjectIdGetDatum(typeId));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(TypeOidIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
TypeNameIndexScan(Relation heapRelation, char *typeName)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[1];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-04-27 06:08:07 +02:00
|
|
|
(RegProcedure) F_NAMEEQ,
|
1998-08-31 01:25:56 +02:00
|
|
|
PointerGetDatum(typeName));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(TypeNameIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
ClassNameIndexScan(Relation heapRelation, char *relName)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[1];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1999-09-04 21:55:50 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-04-27 06:08:07 +02:00
|
|
|
(RegProcedure) F_NAMEEQ,
|
1998-08-20 17:16:59 +02:00
|
|
|
PointerGetDatum(relName));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(ClassNameIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-10-02 07:10:11 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
HeapTuple
|
|
|
|
ClassOidIndexScan(Relation heapRelation, Oid relId)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Relation idesc;
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyData skey[1];
|
1997-09-08 04:41:22 +02:00
|
|
|
HeapTuple tuple;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
ScanKeyEntryInitialize(&skey[0],
|
1997-09-07 07:04:48 +02:00
|
|
|
(bits16) 0x0,
|
|
|
|
(AttrNumber) 1,
|
1998-04-27 06:08:07 +02:00
|
|
|
(RegProcedure) F_OIDEQ,
|
1998-08-31 01:25:56 +02:00
|
|
|
ObjectIdGetDatum(relId));
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
idesc = index_openr(ClassOidIndex);
|
1998-08-19 04:04:17 +02:00
|
|
|
tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
index_close(idesc);
|
|
|
|
|
|
|
|
return tuple;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|