@@ -18,6 +18,11 @@ static ArrayType *form_vector(double *vector, int nrows);
18
18
static bool my_simple_heap_update (Relation relation ,
19
19
ItemPointer otid ,
20
20
HeapTuple tup );
21
+ static bool my_index_insert (Relation indexRelation ,
22
+ Datum * values , bool * isnull ,
23
+ ItemPointer heap_t_ctid ,
24
+ Relation heapRelation ,
25
+ IndexUniqueCheck checkUnique );
21
26
22
27
23
28
/*
@@ -125,11 +130,11 @@ add_query(int query_hash, bool learn_aqo, bool use_aqo,
125
130
PG_TRY ();
126
131
{
127
132
simple_heap_insert (aqo_queries_heap , tuple );
128
- index_insert (query_index_rel ,
129
- values , nulls ,
130
- & (tuple -> t_self ),
131
- aqo_queries_heap ,
132
- UNIQUE_CHECK_YES );
133
+ my_index_insert (query_index_rel ,
134
+ values , nulls ,
135
+ & (tuple -> t_self ),
136
+ aqo_queries_heap ,
137
+ UNIQUE_CHECK_YES );
133
138
}
134
139
PG_CATCH ();
135
140
{
@@ -206,8 +211,8 @@ update_query(int query_hash, bool learn_aqo, bool use_aqo,
206
211
values , nulls , do_replace );
207
212
if (my_simple_heap_update (aqo_queries_heap , & (nw_tuple -> t_self ), nw_tuple ))
208
213
{
209
- index_insert (query_index_rel , values , nulls , & (nw_tuple -> t_self ),
210
- aqo_queries_heap , UNIQUE_CHECK_YES );
214
+ my_index_insert (query_index_rel , values , nulls , & (nw_tuple -> t_self ),
215
+ aqo_queries_heap , UNIQUE_CHECK_YES );
211
216
}
212
217
else
213
218
{
@@ -270,11 +275,11 @@ add_query_text(int query_hash, const char *query_text)
270
275
PG_TRY ();
271
276
{
272
277
simple_heap_insert (aqo_query_texts_heap , tuple );
273
- index_insert (query_index_rel ,
274
- values , nulls ,
275
- & (tuple -> t_self ),
276
- aqo_query_texts_heap ,
277
- UNIQUE_CHECK_YES );
278
+ my_index_insert (query_index_rel ,
279
+ values , nulls ,
280
+ & (tuple -> t_self ),
281
+ aqo_query_texts_heap ,
282
+ UNIQUE_CHECK_YES );
278
283
}
279
284
PG_CATCH ();
280
285
{
@@ -475,8 +480,8 @@ update_fss(int fss_hash, int nrows, int ncols, double **matrix, double *targets,
475
480
PG_TRY ();
476
481
{
477
482
simple_heap_insert (aqo_data_heap , tuple );
478
- index_insert (data_index_rel , values , nulls , & (tuple -> t_self ),
479
- aqo_data_heap , UNIQUE_CHECK_YES );
483
+ my_index_insert (data_index_rel , values , nulls , & (tuple -> t_self ),
484
+ aqo_data_heap , UNIQUE_CHECK_YES );
480
485
}
481
486
PG_CATCH ();
482
487
{
@@ -494,8 +499,8 @@ update_fss(int fss_hash, int nrows, int ncols, double **matrix, double *targets,
494
499
values , nulls , do_replace );
495
500
if (my_simple_heap_update (aqo_data_heap , & (nw_tuple -> t_self ), nw_tuple ))
496
501
{
497
- index_insert (data_index_rel , values , nulls , & (nw_tuple -> t_self ),
498
- aqo_data_heap , UNIQUE_CHECK_YES );
502
+ my_index_insert (data_index_rel , values , nulls , & (nw_tuple -> t_self ),
503
+ aqo_data_heap , UNIQUE_CHECK_YES );
499
504
}
500
505
else
501
506
{
@@ -680,8 +685,8 @@ update_aqo_stat(int query_hash, QueryStat * stat)
680
685
PG_TRY ();
681
686
{
682
687
simple_heap_insert (aqo_stat_heap , tuple );
683
- index_insert (stat_index_rel , values , nulls , & (tuple -> t_self ),
684
- aqo_stat_heap , UNIQUE_CHECK_YES );
688
+ my_index_insert (stat_index_rel , values , nulls , & (tuple -> t_self ),
689
+ aqo_stat_heap , UNIQUE_CHECK_YES );
685
690
}
686
691
PG_CATCH ();
687
692
{
@@ -696,8 +701,8 @@ update_aqo_stat(int query_hash, QueryStat * stat)
696
701
values , nulls , do_replace );
697
702
if (my_simple_heap_update (aqo_stat_heap , & (nw_tuple -> t_self ), nw_tuple ))
698
703
{
699
- index_insert (stat_index_rel , values , nulls , & (nw_tuple -> t_self ),
700
- aqo_stat_heap , UNIQUE_CHECK_YES );
704
+ my_index_insert (stat_index_rel , values , nulls , & (nw_tuple -> t_self ),
705
+ aqo_stat_heap , UNIQUE_CHECK_YES );
701
706
}
702
707
else
703
708
{
@@ -855,6 +860,24 @@ my_simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
855
860
}
856
861
}
857
862
863
+
864
+ /* Provides correct insert in both PostgreQL 9.6.X and 10.X.X */
865
+ static bool
866
+ my_index_insert (Relation indexRelation ,
867
+ Datum * values , bool * isnull ,
868
+ ItemPointer heap_t_ctid ,
869
+ Relation heapRelation ,
870
+ IndexUniqueCheck checkUnique )
871
+ {
872
+ #if PG_VERSION_NUM < 100000
873
+ return index_insert (indexRelation , values , isnull , heap_t_ctid ,
874
+ heapRelation , checkUnique );
875
+ #else
876
+ return index_insert (indexRelation , values , isnull , heap_t_ctid ,
877
+ heapRelation , checkUnique , NULL );
878
+ #endif
879
+ }
880
+
858
881
/* Creates a storage for hashes of deactivated queries */
859
882
void
860
883
init_deactivated_queries_storage (void )
0 commit comments