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

Simplify API for initially hooking custom-path providers into the planner.

Instead of register_custom_path_provider and a CreateCustomScanPath
callback, let's just provide a standard function hook in set_rel_pathlist.
This is more flexible than what was previously committed, is more like the
usual conventions for planner hooks, and requires less support code in the
core.  We had discussed this design (including centralizing the
set_cheapest() calls) back in March or so, so I'm not sure why it wasn't
done like this already.
This commit is contained in:
Tom Lane
2014-11-21 14:05:46 -05:00
parent 4077fb4d1d
commit c2ea2285e9
5 changed files with 27 additions and 88 deletions

View File

@ -27,7 +27,6 @@
#include "optimizer/var.h"
#include "parser/parsetree.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/selfuncs.h"
@ -1927,50 +1926,3 @@ 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(const CustomPathMethods *cpp_methods)
{
MemoryContext oldcxt;
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
custom_path_providers = lappend(custom_path_providers,
(void *) 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);
}
}