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