8000 [PGPRO-5321] post_parse_analyze_hook and query_text variable removed … · postgrespro/aqo@c8f6a2c · GitHub
[go: up one dir, main page]

Skip to content

Commit c8f6a2c

Browse files
Maxim BelovAndrey Lepikhov
authored andcommitted
[PGPRO-5321] post_parse_analyze_hook and query_text variable removed from aqo
Tags: aqo
1 parent 3595294 commit c8f6a2c

File tree

4 files changed

+6
-42
lines changed

4 files changed

+6
-42
lines changed

aqo.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ QueryContextData query_context;
8989
/* Additional plan info */
9090
int njoins;
9191

92-
char *query_text = NULL;
93-
9492
/* Saved hook values */
9593
post_parse_analyze_hook_type prev_post_parse_analyze_hook;
9694
planner_hook_type prev_planner_hook;
@@ -120,12 +118,6 @@ aqo_free_callback(ResourceReleasePhase phase,
120118
if (phase != RESOURCE_RELEASE_AFTER_LOCKS)
121119
return;
122120

123-
if (query_text != NULL)
124-
{
125-
pfree(query_text);
126-
query_text = NULL;
127-
}
128-
129121
if (isTopLevel)
130122
{
131123
list_free(cur_classes);
@@ -203,8 +195,6 @@ _PG_init(void)
203195

204196
prev_planner_hook = planner_hook;
205197
planner_hook = aqo_planner;
206-
prev_post_parse_analyze_hook = post_parse_analyze_hook;
207-
post_parse_analyze_hook = get_query_text;
208198
prev_ExecutorStart_hook = ExecutorStart_hook;
209199
ExecutorStart_hook = aqo_ExecutorStart;
210200
prev_ExecutorEnd_hook = ExecutorEnd_hook;

aqo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ extern double log_selectivity_lower_bound;
245245
/* Parameters for current query */
246246
extern QueryContextData query_context;
247247
extern int njoins;
248-
extern char *query_text;
249248

250249
/* Memory context for long-live data */
251250
extern MemoryContext AQOMemoryContext;
@@ -285,7 +284,7 @@ int get_clause_hash(Expr *clause, int nargs, int *args_hash, int *eclass_hash);
285284
extern bool find_query(int qhash, Datum *search_values, bool *search_nulls);
286285
extern bool update_query(int qhash, int fhash,
287286
bool learn_aqo, bool use_aqo, bool auto_tuning);
288-
extern bool add_query_text(int query_hash);
287+
extern bool add_query_text(int query_hash, const char *query_string);
289288
extern bool load_fss(int fhash, int fss_hash,
290289
int ncols, double **matrix, double *targets, int *rows);
291290
extern bool update_fss(int fhash, int fss_hash, int nrows, int ncols,

preprocessing.c

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,6 @@ List *cur_classes = NIL;
6767
static bool isQueryUsingSystemRelation(Query *query);
6868
static bool isQueryUsingSystemRelation_walker(Node *node, void *context);
6969

70-
/*
71-
* Saves query text into query_text variable.
72-
* Query text field in aqo_queries table is for user.
73-
*/
74-
void
75-
get_query_text(ParseState *pstate, Query *query, JumbleState *jstate)
76-
{
77-
/*
78-
* Duplicate query string into private AQO memory context for guard
79-
* from possible memory context switching.
80-
*/
81-
if (pstate)
82-
{
83-
MemoryContext oldCxt = MemoryContextSwitchTo(AQOMemoryContext);
84-
query_text = pstrdup(pstate->p_sourcetext);
85-
MemoryContextSwitchTo(oldCxt);
86-
}
87-
else
88-
/* Can't imagine such case. Still, throw an error. */
89-
elog(ERROR, "[AQO]: Query text is not found in post-parse step");
90-
91-
if (prev_post_parse_analyze_hook)
92-
prev_post_parse_analyze_hook(pstate, query, jstate);
93-
}
94-
9570
/*
9671
* Calls standard query planner or its previous hook.
9772
*/
@@ -158,7 +133,7 @@ aqo_planner(Query *parse,
158133
boundParams);
159134
}
160135

161-
query_context.query_hash = get_query_hash(parse, query_text);
136+
query_context.query_hash = get_query_hash(parse, query_string);
162137

163138
if (query_is_deactivated(query_context.query_hash) ||
164139
list_member_int(cur_classes, query_context.query_hash))
@@ -256,8 +231,8 @@ aqo_planner(Query *parse,
256231
* Add query text into the ML-knowledge base. Just for further
257232
* analysis. In the case of cached plans we could have NULL query text.
258233
*/
259-
if (query_text != NULL)
260-
add_query_text(query_context.query_hash);
234+
if (query_string != NULL)
235+
add_query_text(query_context.query_hash, query_string);
261236
}
262237
}
263238
else

storage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ update_query(int qhash, int fhash,
219219
* Returns false if the operation failed, true otherwise.
220220
*/
221221
bool
222-
add_query_text(int qhash)
222+
add_query_text(int qhash, const char *query_string)
223223
{
224224
RangeVar *rv;
225225
Relation hrel;
@@ -230,7 +230,7 @@ add_query_text(int qhash)
230230
Oid reloid;
231231

232232
values[0] = Int32GetDatum(qhash);
233-
values[1] = CStringGetTextDatum(query_text);
233+
values[1] = CStringGetTextDatum(query_string);
234234

235235
/* Couldn't allow to write if xact must be read-only. */
236236
if (XactReadOnly)

0 commit comments

Comments
 (0)
0