PreparedStatement *entry;
entry = FetchPreparedStatement(stmt->name, true);
- p = entry->plansource->query_string;
- target_query = (Query *) linitial (entry->plansource->query_list);
+
+ if (entry->plansource->is_valid)
+ {
+ p = entry->plansource->query_string;
+ target_query = (Query *) linitial (entry->plansource->query_list);
+ }
+ else
+ {
+ /* igonre the hint for EXECUTE if invalidated */
+ p = NULL;
+ target_query = NULL;
+ }
}
/* JumbleQuery accespts only a non-utility Query */
- if (!IsA(target_query, Query) ||
- target_query->utilityStmt != NULL)
+ if (target_query &&
+ (!IsA(target_query, Query) ||
+ target_query->utilityStmt != NULL))
target_query = NULL;
if (jumblequery)
current_hint_str = get_hints_from_comment(query_str);
MemoryContextSwitchTo(oldcontext);
}
+ else
+ {
+ /*
+ * Failed to get query. We would be in fetching invalidated
+ * plancache. Try the next chance.
+ */
+ current_hint_retrieved = false;
+ }
if (debug_level > 1)
{
int save_nestlevel;
PlannedStmt *result;
HintState *hstate;
- const char *prev_hint_str;
+ const char *prev_hint_str = NULL;
/*
* Use standard planner if pg_hint_plan is disabled or current nesting