mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +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:
@ -10,7 +10,7 @@
|
||||
#ifndef GIN_PRIVATE_H
|
||||
#define GIN_PRIVATE_H
|
||||
|
||||
#include "access/genam.h"
|
||||
#include "access/amapi.h"
|
||||
#include "access/gin.h"
|
||||
#include "access/itup.h"
|
||||
#include "fmgr.h"
|
||||
@ -593,7 +593,8 @@ typedef struct ginxlogDeleteListPages
|
||||
|
||||
|
||||
/* ginutil.c */
|
||||
extern Datum ginoptions(PG_FUNCTION_ARGS);
|
||||
extern Datum ginhandler(PG_FUNCTION_ARGS);
|
||||
extern bytea *ginoptions(Datum reloptions, bool validate);
|
||||
extern void initGinState(GinState *state, Relation index);
|
||||
extern Buffer GinNewBuffer(Relation index);
|
||||
extern void GinInitBuffer(Buffer b, uint32 f);
|
||||
@ -614,9 +615,12 @@ extern Datum gintuple_get_key(GinState *ginstate, IndexTuple tuple,
|
||||
GinNullCategory *category);
|
||||
|
||||
/* gininsert.c */
|
||||
extern Datum ginbuild(PG_FUNCTION_ARGS);
|
||||
extern Datum ginbuildempty(PG_FUNCTION_ARGS);
|
||||
extern Datum gininsert(PG_FUNCTION_ARGS);
|
||||
extern IndexBuildResult *ginbuild(Relation heap, Relation index,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern void ginbuildempty(Relation index);
|
||||
extern bool gininsert(Relation index, Datum *values, bool *isnull,
|
||||
ItemPointer ht_ctid, Relation heapRel,
|
||||
IndexUniqueCheck checkUnique);
|
||||
extern void ginEntryInsert(GinState *ginstate,
|
||||
OffsetNumber attnum, Datum key, GinNullCategory category,
|
||||
ItemPointerData *items, uint32 nitem,
|
||||
@ -867,26 +871,32 @@ typedef struct GinScanOpaqueData
|
||||
|
||||
typedef GinScanOpaqueData *GinScanOpaque;
|
||||
|
||||
extern Datum ginbeginscan(PG_FUNCTION_ARGS);
|
||||
extern Datum ginendscan(PG_FUNCTION_ARGS);
|
||||
extern Datum ginrescan(PG_FUNCTION_ARGS);
|
||||
extern Datum ginmarkpos(PG_FUNCTION_ARGS);
|
||||
extern Datum ginrestrpos(PG_FUNCTION_ARGS);
|
||||
extern IndexScanDesc ginbeginscan(Relation rel, int nkeys, int norderbys);
|
||||
extern void ginendscan(IndexScanDesc scan);
|
||||
extern void ginrescan(IndexScanDesc scan, ScanKey key, int nscankeys,
|
||||
ScanKey orderbys, int norderbys);
|
||||
extern void ginNewScanKey(IndexScanDesc scan);
|
||||
extern void ginFreeScanKeys(GinScanOpaque so);
|
||||
|
||||
/* ginget.c */
|
||||
extern Datum gingetbitmap(PG_FUNCTION_ARGS);
|
||||
extern int64 gingetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
|
||||
|
||||
/* ginlogic.c */
|
||||
extern void ginInitConsistentFunction(GinState *ginstate, GinScanKey key);
|
||||
|
||||
/* ginvacuum.c */
|
||||
extern Datum ginbulkdelete(PG_FUNCTION_ARGS);
|
||||
extern Datum ginvacuumcleanup(PG_FUNCTION_ARGS);
|
||||
extern IndexBulkDeleteResult *ginbulkdelete(IndexVacuumInfo *info,
|
||||
IndexBulkDeleteResult *stats,
|
||||
IndexBulkDeleteCallback callback,
|
||||
void *callback_state);
|
||||
extern IndexBulkDeleteResult *ginvacuumcleanup(IndexVacuumInfo *info,
|
||||
IndexBulkDeleteResult *stats);
|
||||
extern ItemPointer ginVacuumItemPointers(GinVacuumState *gvs,
|
||||
ItemPointerData *items, int nitem, int *nremaining);
|
||||
|
||||
/* ginvalidate.c */
|
||||
extern bool ginvalidate(Oid opclassoid);
|
||||
|
||||
/* ginbulk.c */
|
||||
typedef struct GinEntryAccumulator
|
||||
{
|
||||
|
Reference in New Issue
Block a user