Skip to content

Commit d3e490a

Browse files
committed
handle inlined SQL functions in pathman_post_parse_analysis_hook()
1 parent fc9d807 commit d3e490a

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/hooks.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,7 @@ pathman_post_parse_analysis_hook(ParseState *pstate, Query *query)
516516
if (query->commandType == CMD_UTILITY &&
517517
(xact_is_transaction_stmt(query->utilityStmt) ||
518518
xact_is_set_transaction_stmt(query->utilityStmt)))
519-
{
520519
return;
521-
}
522520

523521
/* Finish delayed invalidation jobs */
524522
if (IsPathmanReady())
@@ -532,6 +530,28 @@ pathman_post_parse_analysis_hook(ParseState *pstate, Query *query)
532530
{
533531
load_config(); /* perform main cache initialization */
534532
}
533+
534+
/* Process inlined SQL functions (we've already entered planning stage) */
535+
if (IsPathmanReady() && get_refcount_parenthood_statuses() > 0)
536+
{
537+
/* Check that pg_pathman is the last extension loaded */
538+
if (post_parse_analyze_hook != pathman_post_parse_analysis_hook)
539+
{
540+
char *spl_value; /* value of "shared_preload_libraries" GUC */
541+
542+
spl_value = GetConfigOptionByName("shared_preload_libraries", NULL, false);
543+
544+
ereport(ERROR,
545+
(errmsg("extension conflict has been detected"),
546+
errdetail("shared_preload_libraries = \"%s\"", spl_value),
547+
errhint("pg_pathman should be the last extension listed in "
548+
"\"shared_preload_libraries\" GUC in order to "
549+
"prevent possible conflicts with other extensions")));
550+
}
551+
552+
/* Modify query tree if needed */
553+
pathman_transform_query(query);
554+
}
535555
}
536556

537557
/*

src/planner_tree_modification.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,14 @@ incr_refcount_parenthood_statuses(void)
598598
per_table_parenthood_mapping_refcount++;
599599
}
600600

601+
/* Return current value of usage counter */
602+
uint32
603+
get_refcount_parenthood_statuses(void)
604+
{
605+
/* incr_refcount_parenthood_statuses() is called by pathman_planner_hook() */
606+
return per_table_parenthood_mapping_refcount;
607+
}
608+
601609
/* Reset all cached statuses if needed (query end) */
602610
void
603611
decr_refcount_parenthood_statuses(bool entirely)

src/planner_tree_modification.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void assign_rel_parenthood_status(uint32 query_id, Oid relid,
4545
rel_parenthood_status new_status);
4646
rel_parenthood_status get_rel_parenthood_status(uint32 query_id, Oid relid);
4747
void incr_refcount_parenthood_statuses(void);
48+
uint32 get_refcount_parenthood_statuses(void);
4849
void decr_refcount_parenthood_statuses(bool entirely);
4950

5051

0 commit comments

Comments
 (0)