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

Commit006850e

Browse files
committed
Load configuration in post_parse_analyze hook
1 parent5ee80cc commit006850e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

‎pg_pathman.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include"optimizer/planner.h"
2323
#include"optimizer/restrictinfo.h"
2424
#include"optimizer/cost.h"
25+
#include"parser/analyze.h"
2526
#include"parser/parsetree.h"
2627
#include"utils/hsearch.h"
2728
#include"utils/tqual.h"
@@ -56,6 +57,7 @@ typedef struct
5657
/* Original hooks */
5758
staticset_rel_pathlist_hook_typeset_rel_pathlist_hook_original=NULL;
5859
staticshmem_startup_hook_typeshmem_startup_hook_original=NULL;
60+
staticpost_parse_analyze_hook_typepost_parse_analyze_hook_original=NULL;
5961
staticplanner_hook_typeplanner_hook_original=NULL;
6062

6163
/* pg module functions */
@@ -65,6 +67,7 @@ void _PG_fini(void);
6567
/* Hook functions */
6668
staticvoidpathman_shmem_startup(void);
6769
staticvoidpathman_set_rel_pathlist_hook(PlannerInfo*root,RelOptInfo*rel,Indexrti,RangeTblEntry*rte);
70+
voidpathman_post_parse_analysis_hook(ParseState*pstate,Query*query);
6871
staticPlannedStmt*pathman_planner_hook(Query*parse,intcursorOptions,ParamListInfoboundParams);
6972

7073
/* Utility functions */
@@ -135,6 +138,8 @@ _PG_init(void)
135138
set_rel_pathlist_hook=pathman_set_rel_pathlist_hook;
136139
shmem_startup_hook_original=shmem_startup_hook;
137140
shmem_startup_hook=pathman_shmem_startup;
141+
post_parse_analyze_hook_original=post_parse_analyze_hook;
142+
post_parse_analyze_hook=pathman_post_parse_analysis_hook;
138143
planner_hook_original=planner_hook;
139144
planner_hook=pathman_planner_hook;
140145
}
@@ -144,6 +149,7 @@ _PG_fini(void)
144149
{
145150
set_rel_pathlist_hook=set_rel_pathlist_hook_original;
146151
shmem_startup_hook=shmem_startup_hook_original;
152+
post_parse_analyze_hook=post_parse_analyze_hook_original;
147153
planner_hook=planner_hook_original;
148154
}
149155

@@ -186,6 +192,20 @@ get_cmp_func(Oid type1, Oid type2)
186192
returncmp_func;
187193
}
188194

195+
/*
196+
* Post parse analysis hook. It makes sure the config is loaded before executing
197+
* any statement, including utility commands
198+
*/
199+
void
200+
pathman_post_parse_analysis_hook(ParseState*pstate,Query*query)
201+
{
202+
if (initialization_needed)
203+
load_config();
204+
205+
if (post_parse_analyze_hook_original)
206+
post_parse_analyze_hook_original(pstate,query);
207+
}
208+
189209
/*
190210
* Planner hook. It disables inheritance for tables that have been partitioned
191211
* by pathman to prevent standart PostgreSQL partitioning mechanism from
@@ -197,11 +217,6 @@ pathman_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
197217
PlannedStmt*result;
198218
ListCell*lc;
199219

200-
if (initialization_needed)
201-
{
202-
load_config();
203-
}
204-
205220
inheritance_disabled= false;
206221
switch(parse->commandType)
207222
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp