diff options
author | Robert Haas <rhaas@postgresql.org> | 2014-11-07 17:26:02 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2014-11-07 17:34:36 -0500 |
commit | 0b03e5951bf0a1a8868db13f02049cf686a82165 (patch) | |
tree | 3495ca06369ec694e68ac84ed19c296a74521f26 /src/backend/optimizer/util/pathnode.c | |
parent | 7250d8535b11d6443a9b27299e586c3df0654302 (diff) | |
download | postgresql-0b03e5951bf0a1a8868db13f02049cf686a82165.tar.gz postgresql-0b03e5951bf0a1a8868db13f02049cf686a82165.zip |
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.
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 319e8b2c379..6f1c6cfb2aa 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -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); + } +} |