
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.
66 lines
2.2 KiB
C
66 lines
2.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* genam.h
|
|
* POSTGRES general access method definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $Id: genam.h,v 1.26 2001/07/15 22:48:18 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef GENAM_H
|
|
#define GENAM_H
|
|
|
|
#include "access/itup.h"
|
|
#include "access/relscan.h"
|
|
#include "access/sdir.h"
|
|
|
|
|
|
/* Struct for statistics returned by bulk-delete operation */
|
|
typedef struct IndexBulkDeleteResult
|
|
{
|
|
BlockNumber num_pages; /* pages remaining in index */
|
|
double tuples_removed; /* # removed by bulk-delete operation */
|
|
double num_index_tuples; /* # remaining */
|
|
} IndexBulkDeleteResult;
|
|
|
|
/* Typedef for callback function to determine if a tuple is bulk-deletable */
|
|
typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
|
|
|
|
|
|
/* ----------------
|
|
* generalized index_ interface routines (in indexam.c)
|
|
* ----------------
|
|
*/
|
|
extern Relation index_open(Oid relationId);
|
|
extern Relation index_openr(char *relationName);
|
|
extern void index_close(Relation relation);
|
|
extern InsertIndexResult index_insert(Relation relation,
|
|
Datum *datum, char *nulls,
|
|
ItemPointer heap_t_ctid,
|
|
Relation heapRel);
|
|
extern IndexScanDesc index_beginscan(Relation relation, bool scanFromEnd,
|
|
uint16 numberOfKeys, ScanKey key);
|
|
extern void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key);
|
|
extern void index_endscan(IndexScanDesc scan);
|
|
extern void index_markpos(IndexScanDesc scan);
|
|
extern void index_restrpos(IndexScanDesc scan);
|
|
extern RetrieveIndexResult index_getnext(IndexScanDesc scan,
|
|
ScanDirection direction);
|
|
extern IndexBulkDeleteResult *index_bulk_delete(Relation relation,
|
|
IndexBulkDeleteCallback callback,
|
|
void *callback_state);
|
|
extern RegProcedure index_cost_estimator(Relation relation);
|
|
extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
|
|
uint16 procnum);
|
|
|
|
/* in genam.c */
|
|
extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd,
|
|
uint16 numberOfKeys, ScanKey key);
|
|
extern void IndexScanEnd(IndexScanDesc scan);
|
|
|
|
#endif /* GENAM_H */
|