2727#include "learn_cache.h"
2828
2929
30+ #define AQO_DATA_COLUMNS (7)
3031HTAB * deactivated_queries = NULL ;
3132
3233static ArrayType * form_matrix (double * * matrix ,int nrows ,int ncols );
@@ -403,8 +404,8 @@ load_fss(uint64 fs, int fss, OkNNrdata *data, List **relids)
403404bool find_ok = false;
404405IndexScanDesc scan ;
405406ScanKeyData key [2 ];
406- Datum values [6 ];
407- bool isnull [6 ];
407+ Datum values [AQO_DATA_COLUMNS ];
408+ bool isnull [AQO_DATA_COLUMNS ];
408409bool success = true;
409410
410411if (!open_aqo_relation ("public" ,"aqo_data" ,
@@ -435,6 +436,7 @@ load_fss(uint64 fs, int fss, OkNNrdata *data, List **relids)
435436deform_matrix (values [3 ],data -> matrix );
436437
437438deform_vector (values [4 ],data -> targets ,& (data -> rows ));
439+ deform_vector (values [6 ],data -> rfactors ,& (data -> rows ));
438440
439441if (relids != NULL )
440442* relids = deform_oids_vector (values [5 ]);
@@ -488,9 +490,9 @@ update_fss(uint64 fhash, int fsshash, OkNNrdata *data, List *relids)
488490TupleDesc tupDesc ;
489491HeapTuple tuple ,
490492nw_tuple ;
491- Datum values [6 ];
492- bool isnull [6 ] = { false, false, false, false, false, false } ;
493- bool replace [6 ]= { false, false, false, true, true, false };
493+ Datum values [AQO_DATA_COLUMNS ];
494+ bool isnull [AQO_DATA_COLUMNS ] ;
495+ bool replace [AQO_DATA_COLUMNS ]= { false, false, false, true, true, false, true };
494496bool shouldFree ;
495497bool find_ok = false;
496498bool update_indexes ;
@@ -507,6 +509,7 @@ update_fss(uint64 fhash, int fsshash, OkNNrdata *data, List *relids)
507509RowExclusiveLock ,& hrel ,& irel ))
508510return false;
509511
512+ memset (isnull ,0 ,sizeof (bool )* AQO_DATA_COLUMNS );
510513tupDesc = RelationGetDescr (hrel );
511514InitDirtySnapshot (snap );
512515scan = index_beginscan (hrel ,irel ,& snap ,2 ,0 );
@@ -536,6 +539,7 @@ update_fss(uint64 fhash, int fsshash, OkNNrdata *data, List *relids)
536539values [5 ]= PointerGetDatum (form_oids_vector (relids ));
537540if ((void * )values [5 ]== NULL )
538541isnull [5 ]= true;
542+ values [6 ]= PointerGetDatum (form_vector (data -> rfactors ,data -> rows ));
539543tuple = heap_form_tuple (tupDesc ,values ,isnull );
540544
541545/*
@@ -559,8 +563,8 @@ update_fss(uint64 fhash, int fsshash, OkNNrdata *data, List *relids)
559563isnull [3 ]= true;
560564
561565values [4 ]= PointerGetDatum (form_vector (data -> targets ,data -> rows ));
562- nw_tuple = heap_modify_tuple ( tuple , tupDesc ,
563- values ,isnull ,replace );
566+ values [ 6 ] = PointerGetDatum ( form_vector ( data -> rfactors , data -> rows ));
567+ nw_tuple = heap_modify_tuple ( tuple , tupDesc , values ,isnull ,replace );
564568if (my_simple_heap_update (hrel ,& (nw_tuple -> t_self ),nw_tuple ,
565569& update_indexes ))
566570{