@@ -710,6 +710,7 @@ ha_innopart::ha_innopart(
710
710
Partition_helper(this ),
711
711
m_ins_node_parts(),
712
712
m_upd_node_parts(),
713
+ m_blob_heap_parts(),
713
714
m_trx_id_parts(),
714
715
m_row_read_type_parts(),
715
716
m_sql_stat_start_parts(),
@@ -1223,6 +1224,9 @@ ha_innopart::open(
1223
1224
ut_malloc (sizeof (*m_upd_node_parts)
1224
1225
* m_tot_parts,
1225
1226
mem_key_partitioning));
1227
+
1228
+ alloc_blob_heap_array ();
1229
+
1226
1230
m_trx_id_parts = static_cast <trx_id_t *>(
1227
1231
ut_malloc (sizeof (*m_trx_id_parts)
1228
1232
* m_tot_parts,
@@ -1236,6 +1240,7 @@ ha_innopart::open(
1236
1240
mem_key_partitioning));
1237
1241
if (m_ins_node_parts == NULL
1238
1242
|| m_upd_node_parts == NULL
1243
+ || m_blob_heap_parts == NULL
1239
1244
|| m_trx_id_parts == NULL
1240
1245
|| m_row_read_type_parts == NULL
1241
1246
|| m_sql_stat_start_parts == NULL ) {
@@ -1356,6 +1361,7 @@ ha_innopart::close()
1356
1361
m_part_share = NULL ;
1357
1362
}
1358
1363
clear_ins_upd_nodes ();
1364
+ free_blob_heap_array ();
1359
1365
1360
1366
/* Prevent double close of m_prebuilt->table. The real one was done
1361
1367
done in m_part_share->close_table_parts(). */
@@ -1408,9 +1414,13 @@ void
1408
1414
ha_innopart::set_partition (
1409
1415
uint part_id)
1410
1416
{
1417
+ DBUG_ENTER (" ha_innopart::set_partition" );
1418
+
1419
+ DBUG_PRINT (" ha_innopart" , (" partition id: %u" , part_id));
1420
+
1411
1421
if (part_id >= m_tot_parts) {
1412
1422
ut_ad (0 );
1413
- return ;
1423
+ DBUG_VOID_RETURN ;
1414
1424
}
1415
1425
if (m_pcur_parts != NULL ) {
1416
1426
m_prebuilt->pcur = &m_pcur_parts[m_pcur_map[part_id]];
@@ -1421,11 +1431,23 @@ ha_innopart::set_partition(
1421
1431
}
1422
1432
m_prebuilt->ins_node = m_ins_node_parts[part_id];
1423
1433
m_prebuilt->upd_node = m_upd_node_parts[part_id];
1434
+
1435
+ #ifdef UNIV_DEBUG
1436
+ if (m_blob_heap_parts[part_id] != NULL ) {
1437
+ DBUG_PRINT (" ha_innopart" , (" validating blob_heap: %p" ,
1438
+ m_blob_heap_parts[part_id]));
1439
+ mem_heap_validate (m_blob_heap_parts[part_id]);
1440
+ }
1441
+ #endif
1442
+
1443
+ m_prebuilt->blob_heap = m_blob_heap_parts[part_id];
1424
1444
m_prebuilt->trx_id = m_trx_id_parts[part_id];
1425
1445
m_prebuilt->row_read_type = m_row_read_type_parts[part_id];
1426
1446
m_prebuilt->sql_stat_start = get_bit (m_sql_stat_start_parts, part_id);
1427
1447
m_prebuilt->table = m_part_share->get_table_part (part_id);
1428
1448
m_prebuilt->index = innopart_get_index (part_id, active_index);
1449
+
1450
+ DBUG_VOID_RETURN;
1429
1451
}
1430
1452
1431
1453
/* * Update active partition.
@@ -1435,17 +1457,31 @@ void
1435
1457
ha_innopart::update_partition (
1436
1458
uint part_id)
1437
1459
{
1460
+ DBUG_ENTER (" ha_innopart::update_partition" );
1461
+ DBUG_PRINT (" ha_innopart" , (" partition id: %u" , part_id));
1462
+
1438
1463
if (part_id >= m_tot_parts) {
1439
1464
ut_ad (0 );
1440
- return ;
1465
+ DBUG_VOID_RETURN ;
1441
1466
}
1442
1467
m_ins_node_parts[part_id] = m_prebuilt->ins_node ;
1443
1468
m_upd_node_parts[part_id] = m_prebuilt->upd_node ;
1469
+
1470
+ #ifdef UNIV_DEBUG
1471
+ if (m_prebuilt->blob_heap != NULL ) {
1472
+ DBUG_PRINT (" ha_innopart" , (" validating blob_heap: %p" ,
1473
+ m_prebuilt->blob_heap ));
1474
+ mem_heap_validate (m_prebuilt->blob_heap );
1475
+ }
1476
+ #endif
1477
+
1478
+ m_blob_heap_parts[part_id] = m_prebuilt->blob_heap ;
1444
1479
m_trx_id_parts[part_id] = m_prebuilt->trx_id ;
1445
1480
m_row_read_type_parts[part_id] = m_prebuilt->row_read_type ;
1446
1481
update_bit (m_sql_stat_start_parts, part_id,
1447
1482
m_prebuilt->sql_stat_start == 0 ? false : true );
1448
1483
m_last_part = part_id;
1484
+ DBUG_VOID_RETURN;
1449
1485
}
1450
1486
1451
1487
/* * Save currently highest auto increment value.
@@ -1640,13 +1676,15 @@ ha_innopart::index_end()
1640
1676
{
1641
1677
uint part_id = m_part_info->get_first_used_partition ();
1642
1678
DBUG_ENTER (" ha_innopart::index_end" );
1679
+
1643
1680
if (part_id == MY_BIT_NONE) {
1644
1681
/* Never initialized any index. */
1645
1682
DBUG_RETURN (0 );
1646
1683
}
1647
1684
if (m_ordered) {
1648
1685
destroy_record_priority_queue ();
1649
1686
}
1687
+
1650
1688
DBUG_RETURN (ha_innobase::index_end ());
1651
1689
}
1652
1690
@@ -1943,10 +1981,13 @@ ha_innopart::index_first_in_part(
1943
1981
uchar* record)
1944
1982
{
1945
1983
int error;
1984
+ DBUG_ENTER (" ha_innopart::index_first_in_part" );
1985
+
1946
1986
set_partition (part);
1947
1987
error = ha_innobase::index_first (record);
1948
1988
update_partition (part);
1949
- return (error);
1989
+
1990
+ DBUG_RETURN (error);
1950
1991
}
1951
1992
1952
1993
/* * Return next record in index from a partition.
@@ -1958,7 +1999,11 @@ ha_innopart::index_next_in_part(
1958
1999
uint part,
1959
2000
uchar* record)
1960
2001
{
2002
+ DBUG_ENTER (" ha_innopart::index_next_in_part" );
2003
+
1961
2004
int error;
2005
+
2006
+ clear_blob_heap_part (part);
1962
2007
set_partition (part);
1963
2008
error = ha_innobase::index_next (record);
1964
2009
update_partition (part);
@@ -1980,7 +2025,7 @@ ha_innopart::index_next_in_part(
1980
2025
m_prebuilt->n_rows_fetched = 0 ;
1981
2026
}
1982
2027
1983
- return (error);
2028
+ DBUG_RETURN (error);
1984
2029
}
1985
2030
1986
2031
/* * Return next same record in index from a partition.
@@ -1999,6 +2044,9 @@ ha_innopart::index_next_same_in_part(
1999
2044
uint length)
2000
2045
{
2001
2046
int error;
2047
+
2048
+ clear_blob_heap_part (part);
2049
+
2002
2050
set_partition (part);
2003
2051
error = ha_innobase::index_next_same (record, key, length);
2004
2052
update_partition (part);
@@ -2015,6 +2063,7 @@ ha_innopart::index_last_in_part(
2015
2063
uchar* record)
2016
2064
{
2017
2065
int error;
2066
+
2018
2067
set_partition (part);
2019
2068
error = ha_innobase::index_last (record);
2020
2069
update_partition (part);
@@ -2031,6 +2080,9 @@ ha_innopart::index_prev_in_part(
2031
2080
uchar* record)
2032
2081
{
2033
2082
int error;
2083
+
2084
+ clear_blob_heap_part (part);
2085
+
2034
2086
set_partition (part);
2035
2087
error = ha_innobase::index_prev (record);
2036
2088
update_partition (part);
@@ -2072,6 +2124,7 @@ ha_innopart::index_read_map_in_part(
2072
2124
enum ha_rkey_function find_flag)
2073
2125
{
2074
2126
int error;
2127
+
2075
2128
set_partition (part);
2076
2129
error = ha_innobase::index_read_map (
2077
2130
record,
@@ -2102,6 +2155,7 @@ ha_innopart::index_read_idx_map_in_part(
2102
2155
enum ha_rkey_function find_flag)
2103
2156
{
2104
2157
int error;
2158
+
2105
2159
set_partition (part);
2106
2160
error = ha_innobase::index_read_idx_map (
2107
2161
record,
@@ -2200,6 +2254,8 @@ ha_innopart::read_range_next_in_part(
2200
2254
{
2201
2255
int error;
2202
2256
uchar* read_record = record;
2257
+
2258
+ clear_blob_heap_part (part);
2203
2259
set_partition (part);
2204
2260
if (read_record == NULL ) {
2205
2261
read_record = table->record [0 ];
@@ -2253,6 +2309,8 @@ ha_innopart::rnd_init_in_part(
2253
2309
{
2254
2310
int err;
2255
2311
2312
+ clear_blob_heap_part (part_id);
2313
+
2256
2314
if (m_prebuilt->clust_index_was_generated ) {
2257
2315
err = change_active_index (part_id, MAX_KEY);
2258
2316
} else {
@@ -2280,6 +2338,9 @@ ha_innopart::rnd_end_in_part(
2280
2338
uint part_id,
2281
2339
bool scan)
2282
2340
{
2341
+
2342
+ m_prebuilt->blob_heap = NULL ;
2343
+
2283
2344
return (index_end ());
2284
2345
}
2285
2346
@@ -2298,6 +2359,7 @@ ha_innopart::rnd_next_in_part(
2298
2359
2299
2360
DBUG_ENTER (" ha_innopart::rnd_next_in_part" );
2300
2361
2362
+ clear_blob_heap_part (part_id);
2301
2363
set_partition (part_id);
2302
2364
if (m_start_of_scan) {
2303
2365
error = ha_innobase::index_first (buf);
@@ -2338,6 +2400,7 @@ ha_innopart::rnd_pos(
2338
2400
2339
2401
/* Restore used partition. */
2340
2402
part_id = uint2korr (pos);
2403
+
2341
2404
set_partition (part_id);
2342
2405
2343
2406
/* Note that we assume the length of the row reference is fixed
@@ -4166,6 +4229,96 @@ ha_innopart::write_row_in_new_part(
4166
4229
DBUG_RETURN (result);
4167
4230
}
4168
4231
4232
+ /* * Allocate the array to hold blob heaps for all partitions */
4233
+ mem_heap_t **
4234
+ ha_innopart::alloc_blob_heap_array ()
4235
+ {
4236
+ DBUG_ENTER (" ha_innopart::alloc_blob_heap_array" );
4237
+
4238
+ const ulint len = sizeof (mem_heap_t *) * m_tot_parts;
4239
+ m_blob_heap_parts = static_cast <mem_heap_t **>(
4240
+ ut_malloc (len, mem_key_partitioning));
4241
+ if (m_blob_heap_parts == NULL ) {
4242
+ DBUG_RETURN (NULL );
4243
+ }
4244
+ memset (m_blob_heap_parts, 0 , len);
4245
+
4246
+ DBUG_RETURN (m_blob_heap_parts);
4247
+ }
4248
+
4249
+ /* * Free the array that holds blob heaps for all partitions */
4250
+ void
4251
+ ha_innopart::free_blob_heap_array ()
4252
+ {
4253
+ DBUG_ENTER (" ha_innopart::free_blob_heap_array" );
4254
+
4255
+ if (m_blob_heap_parts != NULL ) {
4256
+ clear_blob_heaps ();
4257
+ ut_free (m_blob_heap_parts);
4258
+ m_blob_heap_parts = NULL ;
4259
+ }
4260
+
4261
+ DBUG_VOID_RETURN;
4262
+ }
4263
+
4264
+ /* * Clear the blob heap for the given partition */
4265
+ void
4266
+ ha_innopart::clear_blob_heap_part (uint part_id)
4267
+ {
4268
+ DBUG_ENTER (" ha_innopart::clear_blob_heap_part" );
4269
+ DBUG_PRINT (" ha_innopart" , (" partition id: %u" , part_id));
4270
+
4271
+
4272
+ if (m_blob_heap_parts != NULL
4273
+ && m_blob_heap_parts[part_id] != NULL ) {
4274
+
4275
+ DBUG_PRINT (" ha_innopart" , (" freeing blob_heap: %p" ,
4276
+ m_blob_heap_parts[part_id]));
4277
+ mem_heap_free (m_blob_heap_parts[part_id]);
4278
+ m_blob_heap_parts[part_id] = NULL ;
4279
+
4280
+ }
4281
+
4282
+ m_prebuilt->blob_heap = NULL ;
4283
+
4284
+ DBUG_VOID_RETURN;
4285
+ }
4286
+
4287
+ void
4288
+ ha_innopart::clear_blob_heaps ()
4289
+ {
4290
+ DBUG_ENTER (" ha_innopart::clear_blob_heaps" );
4291
+
4292
+ if (m_blob_heap_parts == NULL ) {
4293
+ DBUG_VOID_RETURN;
4294
+ }
4295
+
4296
+ for (uint i = 0 ; i < m_tot_parts; i++) {
4297
+ if (m_blob_heap_parts[i] != NULL ) {
4298
+ DBUG_PRINT (" ha_innopart" , (" freeing blob_heap: %p" ,
4299
+ m_blob_heap_parts[i]));
4300
+ mem_heap_free (m_blob_heap_parts[i]);
4301
+ m_blob_heap_parts[i] = NULL ;
4302
+ }
4303
+ }
4304
+
4305
+ m_prebuilt->blob_heap = NULL ;
4306
+
4307
+ DBUG_VOID_RETURN;
4308
+ }
4309
+
4310
+ /* * Reset state of file to after 'open'. This function is called
4311
+ after every statement for all tables used by that statement. */
4312
+ int
4313
+ ha_innopart::reset ()
4314
+ {
4315
+ DBUG_ENTER (" ha_innopart::reset" );
4316
+
4317
+ clear_blob_heaps ();
4318
+
4319
+ DBUG_RETURN (ha_innobase::reset ());
4320
+ }
4321
+
4169
4322
/* ***************************************************************************
4170
4323
* DS-MRR implementation
4171
4324
***************************************************************************/
0 commit comments