1996-08-27 23:50:29 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* genam.h
|
2002-05-21 01:51:44 +02:00
|
|
|
* POSTGRES generalized index access method definitions.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2004-12-31 23:04:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2004-12-31 23:04:05 +01:00
|
|
|
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.47 2004/12/31 22:03:21 pgsql Exp $
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef GENAM_H
|
1996-08-27 23:50:29 +02:00
|
|
|
#define GENAM_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/itup.h"
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "access/relscan.h"
|
|
|
|
#include "access/sdir.h"
|
2002-03-26 20:17:02 +01:00
|
|
|
#include "nodes/primnodes.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
|
2003-02-22 01:45:05 +01:00
|
|
|
/*
|
|
|
|
* Struct for statistics returned by bulk-delete operation
|
|
|
|
*
|
|
|
|
* This is now also passed to the index AM's vacuum-cleanup operation,
|
|
|
|
* if it has one, which can modify the results as needed. Note that
|
|
|
|
* an index AM could choose to have bulk-delete return a larger struct
|
|
|
|
* of which this is just the first field; this provides a way for bulk-delete
|
|
|
|
* to communicate additional private data to vacuum-cleanup.
|
2004-12-01 20:00:56 +01:00
|
|
|
*
|
|
|
|
* Note: pages_removed is the amount by which the index physically shrank,
|
|
|
|
* if any (ie the change in its total size on disk). pages_deleted and
|
|
|
|
* pages_free refer to free space within the index file.
|
2003-02-22 01:45:05 +01:00
|
|
|
*/
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
typedef struct IndexBulkDeleteResult
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
BlockNumber num_pages; /* pages remaining in index */
|
2004-12-01 20:00:56 +01:00
|
|
|
BlockNumber pages_removed; /* # removed by bulk-delete operation */
|
2003-02-22 01:45:05 +01:00
|
|
|
double num_index_tuples; /* tuples remaining */
|
2001-10-25 07:50:21 +02:00
|
|
|
double tuples_removed; /* # removed by bulk-delete operation */
|
2003-08-04 02:43:34 +02:00
|
|
|
BlockNumber pages_deleted; /* # unused pages in index */
|
|
|
|
BlockNumber pages_free; /* # pages available for reuse */
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
} IndexBulkDeleteResult;
|
|
|
|
|
|
|
|
/* Typedef for callback function to determine if a tuple is bulk-deletable */
|
|
|
|
typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
|
|
|
|
|
2003-02-22 01:45:05 +01:00
|
|
|
/* Struct for additional arguments passed to vacuum-cleanup operation */
|
|
|
|
typedef struct IndexVacuumCleanupInfo
|
|
|
|
{
|
|
|
|
bool vacuum_full; /* VACUUM FULL (we have exclusive lock) */
|
2003-07-27 19:10:07 +02:00
|
|
|
int message_level; /* ereport level for progress messages */
|
2003-08-08 23:42:59 +02:00
|
|
|
} IndexVacuumCleanupInfo;
|
Restructure index AM interface for index building and index tuple deletion,
per previous discussion on pghackers. Most of the duplicate code in
different AMs' ambuild routines has been moved out to a common routine
in index.c; this means that all index types now do the right things about
inserting recently-dead tuples, etc. (I also removed support for EXTEND
INDEX in the ambuild routines, since that's about to go away anyway, and
it cluttered the code a lot.) The retail indextuple deletion routines have
been replaced by a "bulk delete" routine in which the indexscan is inside
the access method. I haven't pushed this change as far as it should go yet,
but it should allow considerable simplification of the internal bookkeeping
for deletions. Also, add flag columns to pg_am to eliminate various
hardcoded tests on AM OIDs, and remove unused pg_am columns.
Fix rtree and gist index types to not attempt to store NULLs; before this,
gist usually crashed, while rtree managed not to crash but computed wacko
bounding boxes for NULL entries (which might have had something to do with
the performance problems we've heard about occasionally).
Add AtEOXact routines to hash, rtree, and gist, all of which have static
state that needs to be reset after an error. We discovered this need long
ago for btree, but missed the other guys.
Oh, one more thing: concurrent VACUUM is now the default.
2001-07-16 00:48:19 +02:00
|
|
|
|
2002-02-19 21:11:20 +01:00
|
|
|
/* Struct for heap-or-index scans of system tables */
|
|
|
|
typedef struct SysScanDescData
|
|
|
|
{
|
|
|
|
Relation heap_rel; /* catalog being scanned */
|
|
|
|
Relation irel; /* NULL if doing heap scan */
|
|
|
|
HeapScanDesc scan; /* only valid in heap-scan case */
|
|
|
|
IndexScanDesc iscan; /* only valid in index-scan case */
|
|
|
|
} SysScanDescData;
|
|
|
|
|
|
|
|
typedef SysScanDescData *SysScanDesc;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* generalized index_ interface routines (in indexam.c)
|
1996-08-27 23:50:29 +02:00
|
|
|
*/
|
|
|
|
extern Relation index_open(Oid relationId);
|
2002-03-26 20:17:02 +01:00
|
|
|
extern Relation index_openrv(const RangeVar *relation);
|
|
|
|
extern Relation index_openr(const char *sysRelationName);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void index_close(Relation relation);
|
2002-05-21 01:51:44 +02:00
|
|
|
extern InsertIndexResult index_insert(Relation indexRelation,
|
|
|
|
Datum *datums, char *nulls,
|
1997-09-07 07:04:48 +02:00
|
|
|
ItemPointer heap_t_ctid,
|
2002-05-24 20:57:57 +02:00
|
|
|
Relation heapRelation,
|
|
|
|
bool check_uniqueness);
|
2002-05-21 01:51:44 +02:00
|
|
|
|
|
|
|
extern IndexScanDesc index_beginscan(Relation heapRelation,
|
2002-09-04 22:31:48 +02:00
|
|
|
Relation indexRelation,
|
|
|
|
Snapshot snapshot,
|
|
|
|
int nkeys, ScanKey key);
|
2002-05-21 01:51:44 +02:00
|
|
|
extern void index_rescan(IndexScanDesc scan, ScanKey key);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void index_endscan(IndexScanDesc scan);
|
1998-02-26 13:14:54 +01:00
|
|
|
extern void index_markpos(IndexScanDesc scan);
|
|
|
|
extern void index_restrpos(IndexScanDesc scan);
|
2002-05-21 01:51:44 +02:00
|
|
|
extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction);
|
|
|
|
extern bool index_getnext_indexitem(IndexScanDesc scan,
|
2002-09-04 22:31:48 +02:00
|
|
|
ScanDirection direction);
|
2002-05-21 01:51:44 +02:00
|
|
|
|
|
|
|
extern IndexBulkDeleteResult *index_bulk_delete(Relation indexRelation,
|
2001-10-25 07:50:21 +02:00
|
|
|
IndexBulkDeleteCallback callback,
|
|
|
|
void *callback_state);
|
2003-02-22 01:45:05 +01:00
|
|
|
extern IndexBulkDeleteResult *index_vacuum_cleanup(Relation indexRelation,
|
2003-08-08 23:42:59 +02:00
|
|
|
IndexVacuumCleanupInfo *info,
|
2003-08-04 02:43:34 +02:00
|
|
|
IndexBulkDeleteResult *stats);
|
2002-05-21 01:51:44 +02:00
|
|
|
extern RegProcedure index_cost_estimator(Relation indexRelation);
|
1998-09-01 06:40:42 +02:00
|
|
|
extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
|
1997-09-07 07:04:48 +02:00
|
|
|
uint16 procnum);
|
2001-10-07 01:21:45 +02:00
|
|
|
extern struct FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
|
2001-10-25 07:50:21 +02:00
|
|
|
uint16 procnum);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2002-02-19 21:11:20 +01:00
|
|
|
/*
|
|
|
|
* index access method support routines (in genam.c)
|
|
|
|
*/
|
2002-05-21 01:51:44 +02:00
|
|
|
extern IndexScanDesc RelationGetIndexScan(Relation indexRelation,
|
2002-09-04 22:31:48 +02:00
|
|
|
int nkeys, ScanKey key);
|
1999-12-30 06:05:13 +01:00
|
|
|
extern void IndexScanEnd(IndexScanDesc scan);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2002-02-19 21:11:20 +01:00
|
|
|
/*
|
|
|
|
* heap-or-index access to system catalogs (in genam.c)
|
|
|
|
*/
|
2002-05-21 01:51:44 +02:00
|
|
|
extern SysScanDesc systable_beginscan(Relation heapRelation,
|
2002-09-04 22:31:48 +02:00
|
|
|
const char *indexRelname,
|
|
|
|
bool indexOK,
|
|
|
|
Snapshot snapshot,
|
|
|
|
int nkeys, ScanKey key);
|
2002-02-19 21:11:20 +01:00
|
|
|
extern HeapTuple systable_getnext(SysScanDesc sysscan);
|
|
|
|
extern void systable_endscan(SysScanDesc sysscan);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* GENAM_H */
|