@@ -149,7 +149,7 @@ int tile::mytile_group_by_handler::end_scan() {
149
149
150
150
this ->pushdown_ranges .clear ();
151
151
this ->pushdown_in_ranges .clear ();
152
- delete this ->aggr_array ;
152
+ this ->aggr_array . reset () ;
153
153
DBUG_RETURN (0 );
154
154
}
155
155
@@ -170,7 +170,7 @@ int tile::mytile_group_by_handler::init_scan() {
170
170
tile::build_subarray (thd, this ->valid_ranges , this ->valid_in_ranges ,
171
171
empty_read, domain, this ->pushdown_ranges ,
172
172
this ->pushdown_in_ranges , this ->tiledb_sub ,
173
- this ->ctx .get (), this ->aggr_array );
173
+ this ->ctx .get (), this ->aggr_array . get () );
174
174
} catch (const tiledb::TileDBError &e) {
175
175
// Log errors
176
176
my_printf_error (ER_UNKNOWN_ERROR, " [init_scan] error for table %s : %s" ,
@@ -641,41 +641,35 @@ static group_by_handler *mytile_create_group_by_handler(THD *thd,
641
641
642
642
// open array here before init scan because we need to check if the aggregate
643
643
// requested can be processed by TileDB.
644
- tiledb::Array * aggr_array;
644
+ std::unique_ptr< tiledb::Array> aggr_array;
645
645
std::shared_ptr<tiledb::Config> cfg;
646
646
std::shared_ptr<tiledb::Context> ctx;
647
647
648
648
cfg = std::make_shared<tiledb::Config>(tile::build_config (thd));
649
649
ctx = std::make_shared<tiledb::Context>(tile::build_context (*cfg));
650
+ tiledb_encryption_type_t encryption_type =
651
+ encryption_key.empty () ? TILEDB_NO_ENCRYPTION : TILEDB_AES_256_GCM;
650
652
651
653
if (open_at != UINT64_MAX) {
652
654
#if TILEDB_VERSION_MAJOR >= 2 && TILEDB_VERSION_MINOR >= 15
653
- aggr_array = new tiledb::Array (
655
+ aggr_array = std::make_unique< tiledb::Array> (
654
656
*ctx, uri, TILEDB_READ,
655
657
tiledb::TemporalPolicy (tiledb::TimeTravel, open_at),
656
- tiledb::EncryptionAlgorithm (
657
- encryption_key.empty () ? TILEDB_NO_ENCRYPTION : TILEDB_AES_256_GCM,
658
- encryption_key.c_str ()));
658
+ tiledb::EncryptionAlgorithm (encryption_type, encryption_key.c_str ()));
659
659
#else
660
- aggr_array = new tiledb::Array (*ctx, uri, TILEDB_READ,
661
- encryption_key.empty () ? TILEDB_NO_ENCRYPTION
662
- : TILEDB_AES_256_GCM,
663
- encryption_key, open_at);
660
+ aggr_array = std::make_unique<tiledb::Array>(
661
+ *ctx, uri, TILEDB_READ, encryption_type, encryption_key, open_at);
664
662
#endif
665
663
666
664
} else {
667
665
668
666
#if TILEDB_VERSION_MAJOR >= 2 && TILEDB_VERSION_MINOR >= 15
669
- aggr_array = new tiledb::Array (
667
+ aggr_array = std::make_unique< tiledb::Array> (
670
668
*ctx, uri, TILEDB_READ, tiledb::TemporalPolicy (),
671
- tiledb::EncryptionAlgorithm (
672
- encryption_key.empty () ? TILEDB_NO_ENCRYPTION : TILEDB_AES_256_GCM,
673
- encryption_key.c_str ()));
669
+ tiledb::EncryptionAlgorithm (encryption_type, encryption_key.c_str ()));
674
670
#else
675
- aggr_array = new tiledb::Array (*ctx, uri, TILEDB_READ,
676
- encryption_key.empty () ? TILEDB_NO_ENCRYPTION
677
- : TILEDB_AES_256_GCM,
678
- encryption_key);
671
+ aggr_array = std::make_unique<tiledb::Array>(
672
+ *ctx, uri, TILEDB_READ, encryption_type, encryption_key);
679
673
#endif
680
674
}
681
675
@@ -696,10 +690,10 @@ static group_by_handler *mytile_create_group_by_handler(THD *thd,
696
690
}
697
691
698
692
if (isp && !aggregate_is_supported (column_with_aggregate, isp->sum_func (),
699
- aggr_array)) {
693
+ aggr_array. get () )) {
700
694
if (aggr_array != nullptr && aggr_array->is_open ()) {
701
695
aggr_array->close ();
702
- delete aggr_array;
696
+ aggr_array. reset () ;
703
697
}
704
698
return 0 ;
705
699
}
@@ -708,9 +702,14 @@ static group_by_handler *mytile_create_group_by_handler(THD *thd,
708
702
709
703
/* Create handler and return it */
710
704
handler = new tile::mytile_group_by_handler (
711
- thd, aggr_array, ctx, qc, valid_ranges, valid_in_ranges, ranges ,
712
- in_ranges, encryption_key, open_at);
705
+ thd, std::move ( aggr_array) , ctx, qc, valid_ranges, valid_in_ranges,
706
+ ranges, in_ranges, encryption_key, open_at);
713
707
return handler;
708
+ } else {
709
+ if (aggr_array != nullptr && aggr_array->is_open ()) {
710
+ aggr_array->close ();
711
+ aggr_array.reset ();
712
+ }
714
713
}
715
714
return 0 ;
716
715
}
@@ -763,17 +762,18 @@ tile::mytile::mytile(handlerton *hton, TABLE_SHARE *table_arg)
763
762
: handler(hton, table_arg){};
764
763
765
764
tile::mytile_group_by_handler::mytile_group_by_handler (
766
- THD *thd_arg, tiledb::Array * array,
765
+ THD *thd_arg, std::unique_ptr< tiledb::Array> array,
767
766
std::shared_ptr<tiledb::Context> &context,
768
767
std::shared_ptr<tiledb::QueryCondition> &qc, bool val_ranges,
769
768
bool val_in_ranges,
770
769
std::vector<std::vector<std::shared_ptr<tile::range>>> &ranges,
771
770
std::vector<std::vector<std::shared_ptr<tile::range>>> &in_ranges,
772
771
const std::string encryption_key, const uint64_t open_at)
773
- : group_by_handler(thd_arg, mytile_hton), aggr_array(array), ctx(context),
774
- tiledb_qc(qc), valid_ranges(val_ranges), valid_in_ranges(val_in_ranges),
775
- pushdown_ranges(ranges), pushdown_in_ranges(in_ranges),
776
- encryption_key(encryption_key), open_at(open_at){};
772
+ : group_by_handler(thd_arg, mytile_hton), aggr_array(std::move(array)),
773
+ ctx(context), tiledb_qc(qc), valid_ranges(val_ranges),
774
+ valid_in_ranges(val_in_ranges), pushdown_ranges(ranges),
775
+ pushdown_in_ranges(in_ranges), encryption_key(encryption_key),
776
+ open_at(open_at){};
777
777
778
778
int tile::mytile::create (const char *name, TABLE *table_arg,
779
779
HA_CREATE_INFO *create_info) {
@@ -1231,8 +1231,8 @@ int tile::mytile::create_array(const char *name, TABLE *table_arg,
1231
1231
tiledb::FilterList filter_list (context);
1232
1232
if (field->option_struct ->filters != nullptr ) {
1233
1233
filter_list =
1234
- tile::parse_filter_list (context, field->option_struct ->filters );
1235
- }
1234
+ tile::parse_filter_list (context, field->option_struct ->filters );
1235
+ }
1236
1236
1237
1237
auto dim = create_field_dimension (context, field, arrayType);
1238
1238
if (filter_list.nfilters () > 0 ) {
@@ -1281,7 +1281,7 @@ int tile::mytile::create_array(const char *name, TABLE *table_arg,
1281
1281
tiledb::FilterList filter_list (context);
1282
1282
if (field->option_struct ->filters != nullptr ) {
1283
1283
filter_list =
1284
- tile::parse_filter_list (context, field->option_struct ->filters );
1284
+ tile::parse_filter_list (context, field->option_struct ->filters );
1285
1285
}
1286
1286
1287
1287
auto dim = create_field_dimension (context, field, arrayType);
@@ -4378,7 +4378,7 @@ mysql_declare_plugin(mytile){
4378
4378
PLUGIN_LICENSE_PROPRIETARY, /* the plugin license (PLUGIN_LICENSE_XXX) */
4379
4379
mytile_init_func, /* Plugin Init */
4380
4380
NULL , /* Plugin Deinit */
4381
- 0x0341 , /* version number (0.34.1 ) */
4381
+ 0x0340 , /* version number (0.34.0 ) */
4382
4382
tile::statusvars::mytile_status_variables, /* status variables */
4383
4383
tile::sysvars::mytile_system_variables, /* system variables */
4384
4384
NULL , /* config options */
@@ -4395,9 +4395,9 @@ maria_declare_plugin(mytile){
4395
4395
PLUGIN_LICENSE_PROPRIETARY, /* the plugin license (PLUGIN_LICENSE_XXX) */
4396
4396
mytile_init_func, /* Plugin Init */
4397
4397
NULL , /* Plugin Deinit */
4398
- 0x0341 , /* version number (0.34.1 ) */
4398
+ 0x0340 , /* version number (0.34.0 ) */
4399
4399
tile::statusvars::mytile_status_variables, /* status variables */
4400
4400
tile::sysvars::mytile_system_variables, /* system variables */
4401
- " 0.34.1 " , /* string version */
4401
+ " 0.34.0 " , /* string version */
4402
4402
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
4403
4403
} maria_declare_plugin_end;
0 commit comments