@@ -346,6 +346,8 @@ aqo_query_stat(PG_FUNCTION_ARGS)
346346hash_seq_init (& hash_seq ,stat_htab );
347347while ((entry = hash_seq_search (& hash_seq ))!= NULL )
348348{
349+ memset (nulls ,0 ,TOTAL_NCOLS + 1 );
350+
349351values [QUERYID ]= Int64GetDatum (entry -> queryid );
350352values [NEXECS ]= Int64GetDatum (entry -> execs_without_aqo );
351353values [NEXECS_AQO ]= Int64GetDatum (entry -> execs_with_aqo );
@@ -1263,7 +1265,7 @@ _fill_knn_data(const DataEntry *entry, List **reloids)
12631265ptr = (char * )dsa_get_address (data_dsa ,entry -> data_dp );
12641266
12651267/* Check invariants */
1266- Assert (entry -> rows < aqo_K );
1268+ Assert (entry -> rows <= aqo_K );
12671269Assert (ptr != NULL );
12681270Assert (entry -> key .fss == ((data_key * )ptr )-> fss );
12691271
@@ -1438,13 +1440,14 @@ aqo_data(PG_FUNCTION_ARGS)
14381440MemoryContextSwitchTo (oldcontext );
14391441
14401442dsa_init ();
1441- memset (nulls ,0 ,AD_TOTAL_NCOLS );
14421443LWLockAcquire (& aqo_state -> data_lock ,LW_SHARED );
14431444hash_seq_init (& hash_seq ,data_htab );
14441445while ((entry = hash_seq_search (& hash_seq ))!= NULL )
14451446{
14461447char * ptr ;
14471448
1449+ memset (nulls ,0 ,AD_TOTAL_NCOLS );
1450+
14481451values [AD_FS ]= Int64GetDatum (entry -> key .fs );
14491452values [AD_FSS ]= Int64GetDatum (entry -> key .fss );
14501453values [AD_NFEATURES ]= Int32GetDatum (entry -> cols );
@@ -1632,11 +1635,12 @@ aqo_queries(PG_FUNCTION_ARGS)
16321635
16331636MemoryContextSwitchTo (oldcontext );
16341637
1635- memset (nulls ,0 ,AQ_TOTAL_NCOLS + 1 );
16361638LWLockAcquire (& aqo_state -> queries_lock ,LW_SHARED );
16371639hash_seq_init (& hash_seq ,queries_htab );
16381640while ((entry = hash_seq_search (& hash_seq ))!= NULL )
16391641{
1642+ memset (nulls ,0 ,AQ_TOTAL_NCOLS + 1 );
1643+
16401644values [AQ_QUERYID ]= Int64GetDatum (entry -> queryid );
16411645values [AQ_FS ]= Int64GetDatum (entry -> fs );
16421646values [AQ_LEARN_AQO ]= BoolGetDatum (entry -> learn_aqo );