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
|
|
|
*
|
|
|
|
*
|
2006-03-05 16:59:11 +01:00
|
|
|
* Portions Copyright (c) 1996-2006, 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
|
|
|
*
|
2006-07-13 18:49:20 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.63 2006/07/13 16:49:18 momjian 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 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
|
|
|
|
2006-05-11 01:18:39 +02:00
|
|
|
/*
|
|
|
|
* Struct for statistics returned by ambuild
|
|
|
|
*/
|
|
|
|
typedef struct IndexBuildResult
|
|
|
|
{
|
|
|
|
double heap_tuples; /* # of tuples seen in parent table */
|
|
|
|
double index_tuples; /* # of tuples inserted into index */
|
|
|
|
} IndexBuildResult;
|
|
|
|
|
2003-02-22 01:45:05 +01:00
|
|
|
/*
|
2006-05-03 00:25:10 +02:00
|
|
|
* Struct for input arguments passed to ambulkdelete and amvacuumcleanup
|
2003-02-22 01:45:05 +01:00
|
|
|
*
|
2006-05-03 00:25:10 +02:00
|
|
|
* Note that num_heap_tuples will not be valid during ambulkdelete,
|
|
|
|
* only amvacuumcleanup.
|
|
|
|
*/
|
|
|
|
typedef struct IndexVacuumInfo
|
|
|
|
{
|
|
|
|
Relation index; /* the index being vacuumed */
|
|
|
|
bool vacuum_full; /* VACUUM FULL (we have exclusive lock) */
|
|
|
|
int message_level; /* ereport level for progress messages */
|
|
|
|
double num_heap_tuples; /* tuples remaining in heap */
|
|
|
|
} IndexVacuumInfo;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Struct for statistics returned by ambulkdelete and amvacuumcleanup
|
|
|
|
*
|
|
|
|
* This struct is normally allocated by the first ambulkdelete call and then
|
|
|
|
* passed along through subsequent ones until amvacuumcleanup; however,
|
|
|
|
* amvacuumcleanup must be prepared to allocate it in the case where no
|
|
|
|
* ambulkdelete calls were made (because no tuples needed deletion).
|
|
|
|
* Note that an index AM could choose to return a larger struct
|
|
|
|
* of which this is just the first field; this provides a way for ambulkdelete
|
|
|
|
* to communicate additional private data to amvacuumcleanup.
|
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 */
|
2006-05-03 00:25:10 +02:00
|
|
|
BlockNumber pages_removed; /* # removed during vacuum operation */
|
2003-02-22 01:45:05 +01:00
|
|
|
double num_index_tuples; /* tuples remaining */
|
2006-05-03 00:25:10 +02:00
|
|
|
double tuples_removed; /* # removed during vacuum 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);
|
|
|
|
|
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);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void index_close(Relation relation);
|
2005-03-21 02:24:04 +01:00
|
|
|
extern bool index_insert(Relation indexRelation,
|
|
|
|
Datum *values, bool *isnull,
|
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,
|
2005-12-03 06:51:03 +01:00
|
|
|
bool need_index_lock,
|
2002-09-04 22:31:48 +02:00
|
|
|
Snapshot snapshot,
|
|
|
|
int nkeys, ScanKey key);
|
2005-03-28 01:53:05 +02:00
|
|
|
extern IndexScanDesc index_beginscan_multi(Relation indexRelation,
|
2005-12-03 06:51:03 +01:00
|
|
|
bool need_index_lock,
|
2005-10-15 04:49:52 +02:00
|
|
|
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);
|
2005-03-28 01:53:05 +02:00
|
|
|
extern bool index_getmulti(IndexScanDesc scan,
|
2005-10-15 04:49:52 +02:00
|
|
|
ItemPointer tids, int32 max_tids,
|
|
|
|
int32 *returned_tids);
|
2002-05-21 01:51:44 +02:00
|
|
|
|
2006-05-03 00:25:10 +02:00
|
|
|
extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info,
|
|
|
|
IndexBulkDeleteResult *stats,
|
2001-10-25 07:50:21 +02:00
|
|
|
IndexBulkDeleteCallback callback,
|
|
|
|
void *callback_state);
|
2006-05-03 00:25:10 +02:00
|
|
|
extern IndexBulkDeleteResult *index_vacuum_cleanup(IndexVacuumInfo *info,
|
2003-08-04 02:43:34 +02:00
|
|
|
IndexBulkDeleteResult *stats);
|
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);
|
2005-05-28 01:31:21 +02:00
|
|
|
extern 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,
|
2005-04-14 22:03:27 +02:00
|
|
|
Oid indexId,
|
2002-09-04 22:31:48 +02:00
|
|
|
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 */
|