Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2ea228

Browse files
committed
Simplify API for initially hooking custom-path providers into the planner.
Instead of register_custom_path_provider and a CreateCustomScanPathcallback, let's just provide a standard function hook in set_rel_pathlist.This is more flexible than what was previously committed, is more like theusual conventions for planner hooks, and requires less support code in thecore. We had discussed this design (including centralizing theset_cheapest() calls) back in March or so, so I'm not sure why it wasn'tdone like this already.
1 parent4077fb4 commitc2ea228

File tree

5 files changed

+27
-88
lines changed

5 files changed

+27
-88
lines changed

‎src/backend/optimizer/path/allpaths.c

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ typedef struct pushdown_safety_info
5454
boolenable_geqo= false;/* just in case GUC doesn't set it */
5555
intgeqo_threshold;
5656

57+
/* Hook for plugins to get control in set_rel_pathlist() */
58+
set_rel_pathlist_hook_typeset_rel_pathlist_hook=NULL;
59+
5760
/* Hook for plugins to replace standard_join_search() */
5861
join_search_hook_typejoin_search_hook=NULL;
5962

@@ -355,6 +358,17 @@ set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
355358
}
356359
}
357360

361+
/*
362+
* Allow a plugin to editorialize on the set of Paths for this base
363+
* relation. It could add new paths (such as CustomPaths) by calling
364+
* add_path(), or delete or modify paths added by the core code.
365+
*/
366+
if (set_rel_pathlist_hook)
367+
(*set_rel_pathlist_hook) (root,rel,rti,rte);
368+
369+
/* Now find the cheapest of the paths for this rel */
370+
set_cheapest(rel);
371+
358372
#ifdefOPTIMIZER_DEBUG
359373
debug_print_rel(root,rel);
360374
#endif
@@ -401,12 +415,6 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
401415

402416
/* Consider TID scans */
403417
create_tidscan_paths(root,rel);
404-
405-
/* Consider custom scans, if any */
406-
create_customscan_paths(root,rel,rte);
407-
408-
/* Now find the cheapest of the paths for this rel */
409-
set_cheapest(rel);
410418
}
411419

412420
/*
@@ -432,9 +440,6 @@ set_foreign_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
432440
{
433441
/* Call the FDW's GetForeignPaths function to generate path(s) */
434442
rel->fdwroutine->GetForeignPaths(root,rel,rte->relid);
435-
436-
/* Select cheapest path */
437-
set_cheapest(rel);
438443
}
439444

440445
/*
@@ -857,9 +862,6 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
857862
add_path(rel, (Path*)
858863
create_append_path(rel,subpaths,required_outer));
859864
}
860-
861-
/* Select cheapest paths */
862-
set_cheapest(rel);
863865
}
864866

865867
/*
@@ -1087,7 +1089,12 @@ set_dummy_rel_pathlist(RelOptInfo *rel)
10871089

10881090
add_path(rel, (Path*)create_append_path(rel,NIL,NULL));
10891091

1090-
/* Select cheapest path (pretty easy in this case...) */
1092+
/*
1093+
* We set the cheapest path immediately, to ensure that IS_DUMMY_REL()
1094+
* will recognize the relation as dummy if anyone asks. This is redundant
1095+
* when we're called from set_rel_size(), but not when called from
1096+
* elsewhere, and doing it twice is harmless anyway.
1097+
*/
10911098
set_cheapest(rel);
10921099
}
10931100

@@ -1275,9 +1282,6 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel,
12751282

12761283
/* Generate appropriate path */
12771284
add_path(rel,create_subqueryscan_path(root,rel,pathkeys,required_outer));
1278-
1279-
/* Select cheapest path (pretty easy in this case...) */
1280-
set_cheapest(rel);
12811285
}
12821286

12831287
/*
@@ -1346,9 +1350,6 @@ set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
13461350
/* Generate appropriate path */
13471351
add_path(rel,create_functionscan_path(root,rel,
13481352
pathkeys,required_outer));
1349-
1350-
/* Select cheapest path (pretty easy in this case...) */
1351-
set_cheapest(rel);
13521353
}
13531354

13541355
/*
@@ -1369,9 +1370,6 @@ set_values_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
13691370

13701371
/* Generate appropriate path */
13711372
add_path(rel,create_valuesscan_path(root,rel,required_outer));
1372-
1373-
/* Select cheapest path (pretty easy in this case...) */
1374-
set_cheapest(rel);
13751373
}
13761374

13771375
/*
@@ -1438,9 +1436,6 @@ set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
14381436

14391437
/* Generate appropriate path */
14401438
add_path(rel,create_ctescan_path(root,rel,required_outer));
1441-
1442-
/* Select cheapest path (pretty easy in this case...) */
1443-
set_cheapest(rel);
14441439
}
14451440

14461441
/*
@@ -1491,9 +1486,6 @@ set_worktable_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
14911486

14921487
/* Generate appropriate path */
14931488
add_path(rel,create_worktablescan_path(root,rel,required_outer));
1494-
1495-
/* Select cheapest path (pretty easy in this case...) */
1496-
set_cheapest(rel);
14971489
}
14981490

14991491
/*

‎src/backend/optimizer/util/pathnode.c

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include"optimizer/var.h"
2828
#include"parser/parsetree.h"
2929
#include"utils/lsyscache.h"
30-
#include"utils/memutils.h"
3130
#include"utils/selfuncs.h"
3231

3332

@@ -1927,50 +1926,3 @@ reparameterize_path(PlannerInfo *root, Path *path,
19271926
}
19281927
returnNULL;
19291928
}
1930-
1931-
/*****************************************************************************
1932-
* creation of custom-plan paths
1933-
*****************************************************************************/
1934-
1935-
staticList*custom_path_providers=NIL;
1936-
1937-
/*
1938-
* register_custom_path_provider
1939-
*
1940-
* Register a table of callback functions which implements a custom-path
1941-
* provider. This allows extension to provide additional (hopefully faster)
1942-
* methods of scanning a relation.
1943-
*/
1944-
void
1945-
register_custom_path_provider(constCustomPathMethods*cpp_methods)
1946-
{
1947-
MemoryContextoldcxt;
1948-
1949-
oldcxt=MemoryContextSwitchTo(TopMemoryContext);
1950-
custom_path_providers=lappend(custom_path_providers,
1951-
(void*)cpp_methods);
1952-
MemoryContextSwitchTo(oldcxt);
1953-
}
1954-
1955-
/*
1956-
* create_customscan_paths
1957-
*
1958-
* Invoke custom path provider callbacks. If the callback determines that
1959-
* the custom-path provider can handle this relation, it can add one or more
1960-
* paths using add_path().
1961-
*/
1962-
void
1963-
create_customscan_paths(PlannerInfo*root,
1964-
RelOptInfo*baserel,
1965-
RangeTblEntry*rte)
1966-
{
1967-
ListCell*cell;
1968-
1969-
foreach(cell,custom_path_providers)
1970-
{
1971-
constCustomPathMethods*cpp_methods=lfirst(cell);
1972-
1973-
if (cpp_methods->CreateCustomScanPath)
1974-
cpp_methods->CreateCustomScanPath(root,baserel,rte);
1975-
}
1976-
}

‎src/include/nodes/relation.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,6 @@ typedef struct CustomPathMethods
906906
{
907907
constchar*CustomName;
908908

909-
void(*CreateCustomScanPath) (PlannerInfo*root,
910-
RelOptInfo*baserel,
911-
RangeTblEntry*rte);
912909
structPlan*(*PlanCustomPath) (PlannerInfo*root,
913910
RelOptInfo*rel,
914911
structCustomPath*best_path,

‎src/include/optimizer/pathnode.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@ extern Path *reparameterize_path(PlannerInfo *root, Path *path,
128128
Relidsrequired_outer,
129129
doubleloop_count);
130130

131-
/*
132-
* Interface definition of custom-scan providers
133-
*/
134-
externvoidregister_custom_path_provider(constCustomPathMethods*cpp_methods);
135-
136-
externvoidcreate_customscan_paths(PlannerInfo*root,
137-
RelOptInfo*baserel,
138-
RangeTblEntry*rte);
139-
140131
/*
141132
* prototypes for relnode.c
142133
*/

‎src/include/optimizer/paths.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
externboolenable_geqo;
2424
externintgeqo_threshold;
2525

26+
/* Hook for plugins to get control in set_rel_pathlist() */
27+
typedefvoid (*set_rel_pathlist_hook_type) (PlannerInfo*root,
28+
RelOptInfo*rel,
29+
Indexrti,
30+
RangeTblEntry*rte);
31+
externPGDLLIMPORTset_rel_pathlist_hook_typeset_rel_pathlist_hook;
32+
2633
/* Hook for plugins to replace standard_join_search() */
2734
typedefRelOptInfo*(*join_search_hook_type) (PlannerInfo*root,
2835
intlevels_needed,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp