diff options
| author | Tom Lane | 2016-01-18 00:36:59 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-01-18 00:36:59 +0000 |
| commit | 65c5fcd353a859da9e61bfb2b92a99f12937de3b (patch) | |
| tree | 3d75be487f88d11a27fb0b96809e492838666d72 /src/include/nodes | |
| parent | 8d290c8ec6c182a4df1d089c21fe84c7912f01fe (diff) | |
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/nodes')
| -rw-r--r-- | src/include/nodes/nodes.h | 1 | ||||
| -rw-r--r-- | src/include/nodes/relation.h | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 2b734830988..cf09db4e5fe 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -454,6 +454,7 @@ typedef enum NodeTag T_TIDBitmap, /* in nodes/tidbitmap.h */ T_InlineCodeBlock, /* in nodes/parsenodes.h */ T_FdwRoutine, /* in foreign/fdwapi.h */ + T_IndexAmRoutine, /* in access/amapi.h */ T_TsmRoutine /* in access/tsmapi.h */ } NodeTag; diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 61519bb6fae..6deda54c143 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -554,8 +554,6 @@ typedef struct IndexOptInfo * index-only scan? */ Oid relam; /* OID of the access method (in pg_am) */ - RegProcedure amcostestimate; /* OID of the access method's cost fcn */ - List *indexprs; /* expressions for non-simple index columns */ List *indpred; /* predicate if a partial index, else NIL */ @@ -565,12 +563,16 @@ typedef struct IndexOptInfo bool unique; /* true if a unique index */ bool immediate; /* is uniqueness enforced immediately? */ bool hypothetical; /* true if index doesn't really exist */ + + /* Remaining fields are copied from the index AM's API struct: */ bool amcanorderbyop; /* does AM support order by operator result? */ bool amoptionalkey; /* can query omit key for the first column? */ bool amsearcharray; /* can AM handle ScalarArrayOpExpr quals? */ bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */ bool amhasgettuple; /* does AM have amgettuple interface? */ bool amhasgetbitmap; /* does AM have amgetbitmap interface? */ + /* Rather than include amapi.h here, we declare amcostestimate like this */ + void (*amcostestimate) (); /* AM's cost estimator */ } IndexOptInfo; |
