1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Introduce custom path and scan providers.

This allows extension modules to define their own methods for
scanning a relation, and get the core code to use them.  It's
unclear as yet how much use this capability will find, but we
won't find out if we never commit it.

KaiGai Kohei, reviewed at various times and in various levels
of detail by Shigeru Hanada, Tom Lane, Andres Freund, Álvaro
Herrera, and myself.
This commit is contained in:
Robert Haas
2014-11-07 17:26:02 -05:00
parent 7250d8535b
commit 0b03e5951b
22 changed files with 638 additions and 10 deletions

View File

@ -27,6 +27,7 @@
#include "optimizer/var.h"
#include "parser/parsetree.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/selfuncs.h"
@ -1926,3 +1927,49 @@ reparameterize_path(PlannerInfo *root, Path *path,
}
return NULL;
}
/*****************************************************************************
* creation of custom-plan paths
*****************************************************************************/
static List *custom_path_providers = NIL;
/*
* register_custom_path_provider
*
* Register a table of callback functions which implements a custom-path
* provider. This allows extension to provide additional (hopefully faster)
* methods of scanning a relation.
*/
void
register_custom_path_provider(CustomPathMethods *cpp_methods)
{
MemoryContext oldcxt;
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
custom_path_providers = lappend(custom_path_providers, cpp_methods);
MemoryContextSwitchTo(oldcxt);
}
/*
* create_customscan_paths
*
* Invoke custom path provider callbacks. If the callback determines that
* the custom-path provider can handle this relation, it can add one or more
* paths using add_path().
*/
void
create_customscan_paths(PlannerInfo *root,
RelOptInfo *baserel,
RangeTblEntry *rte)
{
ListCell *cell;
foreach (cell, custom_path_providers)
{
const CustomPathMethods *cpp_methods = lfirst(cell);
if (cpp_methods->CreateCustomScanPath)
cpp_methods->CreateCustomScanPath(root, baserel, rte);
}
}