1- /* Copyright (C) 2008-2018 Kentoku Shiba
1+ /* Copyright (C) 2008-2019 Kentoku Shiba
2+ Copyright (C) 2019 MariaDB corp
23
34 This program is free software; you can redistribute it and/or modify
45 it under the terms of the GNU General Public License as published by
@@ -116,7 +117,7 @@ ha_spider::ha_spider(
116117 use_fields = FALSE ;
117118#endif
118119 use_pre_call = FALSE ;
119- use_pre_records = FALSE ;
120+ use_pre_action = FALSE ;
120121#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
121122 do_direct_update = FALSE ;
122123#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -228,7 +229,7 @@ ha_spider::ha_spider(
228229 use_fields = FALSE ;
229230#endif
230231 use_pre_call = FALSE ;
231- use_pre_records = FALSE ;
232+ use_pre_action = FALSE ;
232233#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
233234 do_direct_update = FALSE ;
234235#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -1805,7 +1806,7 @@ int ha_spider::reset()
18051806 high_priority = FALSE ;
18061807 insert_delayed = FALSE ;
18071808 use_pre_call = FALSE ;
1808- use_pre_records = FALSE ;
1809+ use_pre_action = FALSE ;
18091810 pre_bitmap_checked = FALSE ;
18101811 bulk_insert = FALSE ;
18111812 clone_bitmap_init = FALSE ;
@@ -8760,22 +8761,24 @@ int ha_spider::info(
87608761 }
87618762
87628763 if (flag & HA_STATUS_TIME)
8763- stats.update_time = (ulong) share->update_time ;
8764+ stats.update_time = (ulong) share->stat . update_time ;
87648765 if (flag & (HA_STATUS_CONST | HA_STATUS_VARIABLE))
87658766 {
8766- stats.max_data_file_length = share->max_data_file_length ;
8767- stats.create_time = (ulong) share->create_time ;
8767+ stats.max_data_file_length = share->stat . max_data_file_length ;
8768+ stats.create_time = share->stat . create_time ;
87688769 stats.block_size = spider_param_block_size (thd);
87698770 }
87708771 if (flag & HA_STATUS_VARIABLE)
87718772 {
8772- stats.data_file_length = share->data_file_length ;
8773- stats.index_file_length = share->index_file_length ;
8774- stats.records = share->records ;
8775- stats.mean_rec_length = share->mean_rec_length ;
8776- stats.check_time = (ulong) share->check_time ;
8773+ stats.data_file_length = share->stat . data_file_length ;
8774+ stats.index_file_length = share->stat . index_file_length ;
8775+ stats.records = share->stat . records ;
8776+ stats.mean_rec_length = share->stat . mean_rec_length ;
8777+ stats.check_time = share->stat . check_time ;
87778778 if (stats.records <= 1 /* && (flag & HA_STATUS_NO_LOCK) */ )
87788779 stats.records = 2 ;
8780+ stats.checksum = share->stat .checksum ;
8781+ stats.checksum_null = share->stat .checksum_null ;
87798782 }
87808783 if (flag & HA_STATUS_AUTO)
87818784 {
@@ -9014,7 +9017,7 @@ ha_rows ha_spider::records_in_range(
90149017 key_part_map tgt_key_part_map;
90159018 KEY_PART_INFO *key_part;
90169019 Field *field = NULL ;
9017- double rows = (double ) share->records ;
9020+ double rows = (double ) share->stat . records ;
90189021 double weight, rate;
90199022 DBUG_PRINT (" info" ,(" spider rows1=%f" , rows));
90209023 if (start_key)
@@ -9323,11 +9326,12 @@ int ha_spider::pre_records()
93239326 result_list.casual_read [search_link_idx] =
93249327 spider_param_casual_read (thd, share->casual_read );
93259328 }
9326- if ((error_num = spider_db_show_records (this , search_link_idx, TRUE )))
9329+ if ((error_num = spider_db_simple_action (SPIDER_SIMPLE_RECORDS, this ,
9330+ search_link_idx, TRUE )))
93279331 {
93289332 DBUG_RETURN (check_error_mode (error_num));
93299333 }
9330- use_pre_records = TRUE ;
9334+ use_pre_action = TRUE ;
93319335 DBUG_RETURN (0 );
93329336}
93339337
@@ -9339,14 +9343,14 @@ ha_rows ha_spider::records()
93399343 DBUG_PRINT (" info" ,(" spider this=%p" , this ));
93409344 if (sql_command == SQLCOM_ALTER_TABLE)
93419345 {
9342- use_pre_records = FALSE ;
9346+ use_pre_action = FALSE ;
93439347 DBUG_RETURN (0 );
93449348 }
93459349 if (!(share->additional_table_flags & HA_HAS_RECORDS) && !this ->result_list .direct_limit_offset )
93469350 {
93479351 DBUG_RETURN (handler::records ());
93489352 }
9349- if (!use_pre_records && !this ->result_list .direct_limit_offset )
9353+ if (!use_pre_action && !this ->result_list .direct_limit_offset )
93509354 {
93519355 THD *thd = trx->thd ;
93529356 if (
@@ -9357,17 +9361,84 @@ ha_rows ha_spider::records()
93579361 spider_param_casual_read (thd, share->casual_read );
93589362 }
93599363 }
9360- if ((error_num = spider_db_show_records (this , search_link_idx, FALSE )))
9364+ if ((error_num = spider_db_simple_action (SPIDER_SIMPLE_RECORDS, this ,
9365+ search_link_idx, FALSE )))
93619366 {
9362- use_pre_records = FALSE ;
9367+ use_pre_action = FALSE ;
93639368 check_error_mode (error_num);
93649369 DBUG_RETURN (HA_POS_ERROR);
93659370 }
9366- use_pre_records = FALSE ;
9367- share->records = table_rows;
9371+ use_pre_action = FALSE ;
9372+ share->stat . records = table_rows;
93689373 DBUG_RETURN (table_rows);
93699374}
93709375
9376+ #ifdef HA_HAS_CHECKSUM_EXTENDED
9377+ int ha_spider::pre_calculate_checksum ()
9378+ {
9379+ int error_num;
9380+ backup_error_status ();
9381+ DBUG_ENTER (" ha_spider::pre_calculate_checksum" );
9382+ DBUG_PRINT (" info" ,(" spider this=%p" , this ));
9383+ THD *thd = trx->thd ;
9384+ if (
9385+ spider_param_sync_autocommit (thd) &&
9386+ (!thd_test_options (thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
9387+ ) {
9388+ result_list.casual_read [search_link_idx] =
9389+ spider_param_casual_read (thd, share->casual_read );
9390+ }
9391+ action_flags = T_EXTEND;
9392+ if ((error_num = spider_db_simple_action (SPIDER_SIMPLE_CHECKSUM_TABLE, this ,
9393+ search_link_idx, TRUE )))
9394+ {
9395+ DBUG_RETURN (check_error_mode (error_num));
9396+ }
9397+ use_pre_action = TRUE ;
9398+ DBUG_RETURN (0 );
9399+ }
9400+
9401+ int ha_spider::calculate_checksum ()
9402+ {
9403+ int error_num;
9404+ backup_error_status ();
9405+ DBUG_ENTER (" ha_spider::calculate_checksum" );
9406+ DBUG_PRINT (" info" ,(" spider this=%p" , this ));
9407+ if (!use_pre_action && !this ->result_list .direct_limit_offset )
9408+ {
9409+ THD *thd = trx->thd ;
9410+ if (
9411+ spider_param_sync_autocommit (thd) &&
9412+ (!thd_test_options (thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
9413+ ) {
9414+ result_list.casual_read [search_link_idx] =
9415+ spider_param_casual_read (thd, share->casual_read );
9416+ }
9417+ }
9418+ action_flags = T_EXTEND;
9419+ if ((error_num = spider_db_simple_action (SPIDER_SIMPLE_CHECKSUM_TABLE, this ,
9420+ search_link_idx, FALSE )))
9421+ {
9422+ use_pre_action = FALSE ;
9423+ DBUG_RETURN (check_error_mode (error_num));
9424+ }
9425+ use_pre_action = FALSE ;
9426+ if (checksum_null)
9427+ {
9428+ share->stat .checksum_null = TRUE ;
9429+ share->stat .checksum = 0 ;
9430+ stats.checksum_null = TRUE ;
9431+ stats.checksum = 0 ;
9432+ } else {
9433+ share->stat .checksum_null = FALSE ;
9434+ share->stat .checksum = checksum_val;
9435+ stats.checksum_null = FALSE ;
9436+ stats.checksum = checksum_val;
9437+ }
9438+ DBUG_RETURN (0 );
9439+ }
9440+ #endif
9441+
93719442const char *ha_spider::table_type () const
93729443{
93739444 DBUG_ENTER (" ha_spider::table_type" );
@@ -11172,8 +11243,9 @@ double ha_spider::scan_time()
1117211243 DBUG_ENTER (" ha_spider::scan_time" );
1117311244 DBUG_PRINT (" info" ,(" spider this=%p" , this ));
1117411245 DBUG_PRINT (" info" ,(" spider scan_time = %.6f" ,
11175- share->scan_rate * share->records * share->mean_rec_length + 2 ));
11176- DBUG_RETURN (share->scan_rate * share->records * share->mean_rec_length + 2 );
11246+ share->scan_rate * share->stat .records * share->stat .mean_rec_length + 2 ));
11247+ DBUG_RETURN (share->scan_rate * share->stat .records *
11248+ share->stat .mean_rec_length + 2 );
1117711249}
1117811250
1117911251double ha_spider::read_time (
@@ -11192,8 +11264,8 @@ double ha_spider::read_time(
1119211264 rows / 2 + 2 );
1119311265 } else {
1119411266 DBUG_PRINT (" info" ,(" spider read_time = %.6f" ,
11195- share->read_rate * share->mean_rec_length * rows + 2 ));
11196- DBUG_RETURN (share->read_rate * share->mean_rec_length * rows + 2 );
11267+ share->read_rate * share->stat . mean_rec_length * rows + 2 ));
11268+ DBUG_RETURN (share->read_rate * share->stat . mean_rec_length * rows + 2 );
1119711269 }
1119811270}
1119911271
0 commit comments