diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-01-17 19:36:59 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-01-17 19:36:59 -0500 |
commit | 65c5fcd353a859da9e61bfb2b92a99f12937de3b (patch) | |
tree | 3d75be487f88d11a27fb0b96809e492838666d72 /src/include/access/spgist.h | |
parent | 8d290c8ec6c182a4df1d089c21fe84c7912f01fe (diff) | |
download | postgresql-65c5fcd353a859da9e61bfb2b92a99f12937de3b.tar.gz postgresql-65c5fcd353a859da9e61bfb2b92a99f12937de3b.zip |
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.
Diffstat (limited to 'src/include/access/spgist.h')
-rw-r--r-- | src/include/access/spgist.h | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/include/access/spgist.h b/src/include/access/spgist.h index 5936af6f4e7..1994f718eb1 100644 --- a/src/include/access/spgist.h +++ b/src/include/access/spgist.h @@ -14,7 +14,7 @@ #ifndef SPGIST_H #define SPGIST_H -#include "access/skey.h" +#include "access/amapi.h" #include "access/xlogreader.h" #include "fmgr.h" #include "lib/stringinfo.h" @@ -174,27 +174,37 @@ typedef struct spgLeafConsistentOut } spgLeafConsistentOut; +/* spgutils.c */ +extern Datum spghandler(PG_FUNCTION_ARGS); +extern bytea *spgoptions(Datum reloptions, bool validate); + /* spginsert.c */ -extern Datum spgbuild(PG_FUNCTION_ARGS); -extern Datum spgbuildempty(PG_FUNCTION_ARGS); -extern Datum spginsert(PG_FUNCTION_ARGS); +extern IndexBuildResult *spgbuild(Relation heap, Relation index, + struct IndexInfo *indexInfo); +extern void spgbuildempty(Relation index); +extern bool spginsert(Relation index, Datum *values, bool *isnull, + ItemPointer ht_ctid, Relation heapRel, + IndexUniqueCheck checkUnique); /* spgscan.c */ -extern Datum spgbeginscan(PG_FUNCTION_ARGS); -extern Datum spgendscan(PG_FUNCTION_ARGS); -extern Datum spgrescan(PG_FUNCTION_ARGS); -extern Datum spgmarkpos(PG_FUNCTION_ARGS); -extern Datum spgrestrpos(PG_FUNCTION_ARGS); -extern Datum spggetbitmap(PG_FUNCTION_ARGS); -extern Datum spggettuple(PG_FUNCTION_ARGS); -extern Datum spgcanreturn(PG_FUNCTION_ARGS); - -/* spgutils.c */ -extern Datum spgoptions(PG_FUNCTION_ARGS); +extern IndexScanDesc spgbeginscan(Relation rel, int keysz, int orderbysz); +extern void spgendscan(IndexScanDesc scan); +extern void spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, + ScanKey orderbys, int norderbys); +extern int64 spggetbitmap(IndexScanDesc scan, TIDBitmap *tbm); +extern bool spggettuple(IndexScanDesc scan, ScanDirection dir); +extern bool spgcanreturn(Relation index, int attno); /* spgvacuum.c */ -extern Datum spgbulkdelete(PG_FUNCTION_ARGS); -extern Datum spgvacuumcleanup(PG_FUNCTION_ARGS); +extern IndexBulkDeleteResult *spgbulkdelete(IndexVacuumInfo *info, + IndexBulkDeleteResult *stats, + IndexBulkDeleteCallback callback, + void *callback_state); +extern IndexBulkDeleteResult *spgvacuumcleanup(IndexVacuumInfo *info, + IndexBulkDeleteResult *stats); + +/* spgvalidate.c */ +extern bool spgvalidate(Oid opclassoid); /* spgxlog.c */ extern void spg_redo(XLogReaderState *record); |