@@ -175,8 +175,6 @@ aqo_planner(Query *parse,
175175 ParamListInfo boundParams )
176176{
177177 bool query_is_stored = false;
178- Datum query_params [5 ];
179- bool query_nulls [5 ] = {false, false, false, false, false};
180178 LOCKTAG tag ;
181179 MemoryContext oldCxt ;
182180
@@ -226,7 +224,7 @@ aqo_planner(Query *parse,
226224 boundParams );
227225 }
228226
229- elog (DEBUG1 , "AQO will be used for query '%s', class %ld" ,
227+ elog (DEBUG1 , "AQO will be used for query '%s', class " UINT64_FORMAT ,
230228 query_string ? query_string : "null string" , query_context .query_hash );
231229
232230 oldCxt = MemoryContextSwitchTo (AQOMemoryContext );
@@ -240,8 +238,7 @@ aqo_planner(Query *parse,
240238 goto ignore_query_settings ;
241239 }
242240
243- query_is_stored = find_query (query_context .query_hash , & query_params [0 ],
244- & query_nulls [0 ]);
241+ query_is_stored = find_query (query_context .query_hash , & query_context );
245242
246243 if (!query_is_stored )
247244 {
@@ -295,16 +292,12 @@ aqo_planner(Query *parse,
295292 else /* Query class exists in a ML knowledge base. */
296293 {
297294 query_context .adding_query = false;
298- query_context .learn_aqo = DatumGetBool (query_params [1 ]);
299- query_context .use_aqo = DatumGetBool (query_params [2 ]);
300- query_context .fspace_hash = DatumGetInt64 (query_params [3 ]);
301- query_context .auto_tuning = DatumGetBool (query_params [4 ]);
302- query_context .collect_stat = query_context .auto_tuning ;
295+
296+ /* Other query_context fields filled in the find_query() routine. */
303297
304298 /*
305299 * Deactivate query if no one reason exists for usage of an AQO machinery.
306300 */
307- Assert (query_context .query_hash >=0 );
308301 if (!query_context .learn_aqo && !query_context .use_aqo &&
309302 !query_context .auto_tuning && !force_collect_stat )
310303 add_deactivated_query (query_context .query_hash );
@@ -330,7 +323,6 @@ aqo_planner(Query *parse,
330323 * In this mode we want to learn with incoming query (if it is not
331324 * suppressed manually) and collect stats.
332325 */
333- Assert (query_context .query_hash >=0 );
334326 query_context .collect_stat = true;
335327 query_context .fspace_hash = query_context .query_hash ;
336328 break ;
@@ -354,15 +346,13 @@ aqo_planner(Query *parse,
354346 * find-add query and query text must be atomic operation to prevent
355347 * concurrent insertions.
356348 */
357- Assert (query_context .query_hash >=0 );
358- init_lock_tag (& tag , (uint32 ) query_context .query_hash , (uint32 ) 0 );//my code
349+ init_lock_tag (& tag , query_context .query_hash , 0 );
359350 LockAcquire (& tag , ExclusiveLock , false, false);
360351 /*
361352 * Add query into the AQO knowledge base. To process an error with
362353 * concurrent addition from another backend we will try to restart
363354 * preprocessing routine.
364355 */
365- Assert (query_context .query_hash >=0 );
366356 update_query (query_context .query_hash , query_context .fspace_hash ,
367357 query_context .learn_aqo , query_context .use_aqo ,
368358 query_context .auto_tuning );
@@ -371,7 +361,6 @@ aqo_planner(Query *parse,
371361 * Add query text into the ML-knowledge base. Just for further
372362 * analysis. In the case of cached plans we could have NULL query text.
373363 */
374- Assert (query_context .query_hash >=0 );
375364 if (query_string != NULL )
376365 add_query_text (query_context .query_hash , query_string );
377366
@@ -385,7 +374,6 @@ aqo_planner(Query *parse,
385374 * query execution statistics in any mode.
386375 */
387376 query_context .collect_stat = true;
388- Assert (query_context .query_hash >=0 );
389377 query_context .fspace_hash = query_context .query_hash ;
390378 }
391379
0 commit comments