mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Restructure index access method API to hide most of it at the C level.
This patch reduces pg_am to just two columns, a name and a handler function. All the data formerly obtained from pg_am is now provided in a C struct returned by the handler function. This is similar to the designs we've adopted for FDWs and tablesample methods. There are multiple advantages. For one, the index AM's support functions are now simple C functions, making them faster to call and much less error-prone, since the C compiler can now check function signatures. For another, this will make it far more practical to define index access methods in installable extensions. A disadvantage is that SQL-level code can no longer see attributes of index AMs; in particular, some of the crosschecks in the opr_sanity regression test are no longer possible from SQL. We've addressed that by adding a facility for the index AM to perform such checks instead. (Much more could be done in that line, but for now we're content if the amvalidate functions more or less replace what opr_sanity used to do.) We might also want to expose some sort of reporting functionality, but this patch doesn't do that. Alexander Korotkov, reviewed by Petr Jelínek, and rather heavily editorialized on by me.
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
#ifndef NBTREE_H
|
||||
#define NBTREE_H
|
||||
|
||||
#include "access/genam.h"
|
||||
#include "access/amapi.h"
|
||||
#include "access/itup.h"
|
||||
#include "access/sdir.h"
|
||||
#include "access/xlogreader.h"
|
||||
@ -654,20 +654,28 @@ typedef BTScanOpaqueData *BTScanOpaque;
|
||||
/*
|
||||
* prototypes for functions in nbtree.c (external entry points for btree)
|
||||
*/
|
||||
extern Datum btbuild(PG_FUNCTION_ARGS);
|
||||
extern Datum btbuildempty(PG_FUNCTION_ARGS);
|
||||
extern Datum btinsert(PG_FUNCTION_ARGS);
|
||||
extern Datum btbeginscan(PG_FUNCTION_ARGS);
|
||||
extern Datum btgettuple(PG_FUNCTION_ARGS);
|
||||
extern Datum btgetbitmap(PG_FUNCTION_ARGS);
|
||||
extern Datum btrescan(PG_FUNCTION_ARGS);
|
||||
extern Datum btendscan(PG_FUNCTION_ARGS);
|
||||
extern Datum btmarkpos(PG_FUNCTION_ARGS);
|
||||
extern Datum btrestrpos(PG_FUNCTION_ARGS);
|
||||
extern Datum btbulkdelete(PG_FUNCTION_ARGS);
|
||||
extern Datum btvacuumcleanup(PG_FUNCTION_ARGS);
|
||||
extern Datum btcanreturn(PG_FUNCTION_ARGS);
|
||||
extern Datum btoptions(PG_FUNCTION_ARGS);
|
||||
extern Datum bthandler(PG_FUNCTION_ARGS);
|
||||
extern IndexBuildResult *btbuild(Relation heap, Relation index,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern void btbuildempty(Relation index);
|
||||
extern bool btinsert(Relation rel, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique);
|
||||
extern IndexScanDesc btbeginscan(Relation rel, int nkeys, int norderbys);
|
||||
extern bool btgettuple(IndexScanDesc scan, ScanDirection dir);
|
||||
extern int64 btgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
|
||||
extern void btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
||||
ScanKey orderbys, int norderbys);
|
||||
extern void btendscan(IndexScanDesc scan);
|
||||
extern void btmarkpos(IndexScanDesc scan);
|
||||
extern void btrestrpos(IndexScanDesc scan);
|
||||
extern IndexBulkDeleteResult *btbulkdelete(IndexVacuumInfo *info,
|
||||
IndexBulkDeleteResult *stats,
|
||||
IndexBulkDeleteCallback callback,
|
||||
void *callback_state);
|
||||
extern IndexBulkDeleteResult *btvacuumcleanup(IndexVacuumInfo *info,
|
||||
IndexBulkDeleteResult *stats);
|
||||
extern bool btcanreturn(Relation index, int attno);
|
||||
|
||||
/*
|
||||
* prototypes for functions in nbtinsert.c
|
||||
@ -738,6 +746,12 @@ extern void _bt_end_vacuum(Relation rel);
|
||||
extern void _bt_end_vacuum_callback(int code, Datum arg);
|
||||
extern Size BTreeShmemSize(void);
|
||||
extern void BTreeShmemInit(void);
|
||||
extern bytea *btoptions(Datum reloptions, bool validate);
|
||||
|
||||
/*
|
||||
* prototypes for functions in nbtvalidate.c
|
||||
*/
|
||||
extern bool btvalidate(Oid opclassoid);
|
||||
|
||||
/*
|
||||
* prototypes for functions in nbtsort.c
|
||||
|
Reference in New Issue
Block a user