summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/r/innodb_stats_persistent.result
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-05-16 12:07:26 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-05-19 22:56:39 +0300
commit0bfa3dff8b95ed8b8bd133e434b47189857121ac (patch)
treed373281685d5f5b217838a05e774a9ec809c06fd /mysql-test/suite/innodb/r/innodb_stats_persistent.result
parent5e9d6511088e4435470b37bcc07825a77cc99539 (diff)
downloadmariadb-git-0bfa3dff8b95ed8b8bd133e434b47189857121ac.tar.gz
MDEV-12698 innodb.innodb_stats_del_mark test failure
In my merge of the MySQL fix for Oracle Bug#23333990 / WL#9513 I overlooked some subsequent revisions to the test, and I also failed to notice that the test is actually always failing. Oracle introduced the parameter innodb_stats_include_delete_marked but failed to consistently take it into account in FOREIGN KEY constraints that involve CASCADE or SET NULL. When innodb_stats_include_delete_marked=ON, obviously the purge of delete-marked records should update the statistics as well. One more omission was that statistics were never updated on ROLLBACK. We are fixing that as well, properly taking into account the parameter innodb_stats_include_delete_marked. dict_stats_analyze_index_level(): Simplify an expression. (Using the ternary operator with a constant operand is unnecessary obfuscation.) page_scan_method_t: Revert the change done by Oracle. Instead, examine srv_stats_include_delete_marked directly where it is needed. dict_stats_update_if_needed(): Renamed from row_update_statistics_if_needed(). row_update_for_mysql_using_upd_graph(): Assert that the table statistics are initialized, as guaranteed by ha_innobase::open(). Update the statistics in a consistent way, both for FOREIGN KEY triggers and for the main table. If FOREIGN KEY constraints exist, do not dereference a freed pointer, but cache the proper value of node->is_delete so that it matches prebuilt->table. row_purge_record_func(): Update statistics if innodb_stats_include_delete_marked=ON. row_undo_ins(): Update statistics (on ROLLBACK of a fresh INSERT). This is independent of the parameter; the record is not delete-marked. row_undo_mod(): Update statistics on the ROLLBACK of updating key columns, or (if innodb_stats_include_delete_marked=OFF) updating delete-marks. innodb.innodb_stats_persistent: Renamed and extended from innodb.innodb_stats_del_mark. Reduced the unnecessarily large dataset from 262,144 to 32 rows. Test both values of the configuration parameter innodb_stats_include_delete_marked. Test that purge is updating the statistics. innodb_fts.innodb_fts_multiple_index: Adjust the result. The test is performing a ROLLBACK of an INSERT, which now affects the statistics. include/wait_all_purged.inc: Moved from innodb.innodb_truncate_debug to its own file.
Diffstat (limited to 'mysql-test/suite/innodb/r/innodb_stats_persistent.result')
-rw-r--r--mysql-test/suite/innodb/r/innodb_stats_persistent.result116
1 files changed, 116 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/innodb_stats_persistent.result b/mysql-test/suite/innodb/r/innodb_stats_persistent.result
new file mode 100644
index 00000000000..f4de4b6b82e
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_stats_persistent.result
@@ -0,0 +1,116 @@
+SET @saved_include_delete_marked = @@GLOBAL.innodb_stats_include_delete_marked;
+SET GLOBAL innodb_stats_include_delete_marked = ON;
+SET @saved_traditional = @@GLOBAL.innodb_stats_traditional;
+SET GLOBAL innodb_stats_traditional=false;
+SET @saved_modified_counter = @@GLOBAL.innodb_stats_modified_counter;
+SET GLOBAL innodb_stats_modified_counter=1;
+CREATE TABLE t0 (id SERIAL, val INT UNSIGNED NOT NULL, KEY(val))
+ENGINE=INNODB STATS_PERSISTENT=1,STATS_AUTO_RECALC=1;
+CREATE TABLE t1 LIKE t0;
+CREATE TABLE t2 LIKE t0;
+INSERT INTO t0 (val) VALUES (4);
+INSERT INTO t0 (val) SELECT 4 FROM t0;
+INSERT INTO t0 (val) SELECT 4 FROM t0;
+INSERT INTO t0 (val) SELECT 4 FROM t0;
+INSERT INTO t0 (val) SELECT 4 FROM t0;
+INSERT INTO t1 SELECT * FROM t0;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+16
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+connect con1, localhost, root,,;
+START TRANSACTION;
+DELETE FROM t1;
+SELECT COUNT(*) FROM t1;
+connection default;
+# With innodb_stats_include_delete_marked=ON,
+# DELETE must not affect statistics before COMMIT.
+EXPLAIN SELECT * FROM t1 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref val val 4 const 16 Using index
+connection con1;
+COUNT(*)
+0
+ROLLBACK;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+16
+EXPLAIN SELECT * FROM t1 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref val val 4 const 16 Using index
+BEGIN;
+DELETE FROM t1;
+COMMIT;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+connection default;
+BEGIN;
+INSERT INTO t2 SELECT * FROM t0;
+# The INSERT will show up before COMMIT.
+EXPLAIN SELECT * FROM t2 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref val val 4 const 16 Using index
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+16
+# The ROLLBACK of the INSERT must affect the statistics.
+ROLLBACK;
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+0
+connection con1;
+EXPLAIN SELECT * FROM t2 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref val val 4 const 1 Using index
+SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+InnoDB 0 transactions not purged
+SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
+# After COMMIT and purge, the DELETE must show up.
+EXPLAIN SELECT * FROM t1 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref val val 4 const 1 Using index
+SET GLOBAL innodb_stats_include_delete_marked = OFF;
+BEGIN;
+INSERT INTO t1 SELECT * FROM t0;
+EXPLAIN SELECT * FROM t1 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref val val 4 const 16 Using index
+ROLLBACK;
+EXPLAIN SELECT * FROM t1 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref val val 4 const 1 Using index
+BEGIN;
+INSERT INTO t1 SELECT * FROM t0;
+COMMIT;
+EXPLAIN SELECT * FROM t1 WHERE val=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref val val 4 const 16 Using index
+BEGIN;
+DELETE FROM t1;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+# With innodb_stats_include_delete_marked=OFF,
+# DELETE must affect statistics even before COMMIT.
+# However, if there was a WHERE condition,
+# ha_innobase::records_in_range() would count the delete-marked records.
+EXPLAIN SELECT * FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL val 4 NULL 1 Using index
+ROLLBACK;
+EXPLAIN SELECT * FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL val 4 NULL 16 Using index
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+16
+disconnect con1;
+connection default;
+DROP TABLE t0,t1,t2;
+SET GLOBAL innodb_stats_include_delete_marked = @saved_include_delete_marked;
+SET GLOBAL innodb_stats_traditional = @saved_traditional;
+SET GLOBAL innodb_stats_modified_counter = @saved_modified_counter;