forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Rows_examined and Rows_sent implementation from 5.6
Summary: These two fields were added to 5.6 but missing in 8.0. I noticed previous implementation was buggy so added a new implementation which is capturing more rows_examine operations. There were also no MTR tests so I added new tests to cover these fields. Differential Revision: D15999862
- Loading branch information
Showing
6 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Executes sql command and validates the values of Rows_examined and Rows_sent | ||
# values from status table. | ||
# The following variables should be set before invoking this inc file | ||
|
||
# Start counters | ||
--let $start_rows_examined = query_get_value(show status like "Rows_examined", Value, 1) | ||
--let $start_rows_sent = query_get_value(show status like "Rows_sent", Value, 1) | ||
|
||
--eval $sql | ||
|
||
# Get counters | ||
--let $end_rows_examined = query_get_value(show status like "Rows_examined", Value, 1) | ||
--let $end_rows_sent = query_get_value(show status like "Rows_sent", Value, 1) | ||
|
||
# Check sanity | ||
--let $assert_text= Rows_examined should be increased by $expected_rows_examined. | ||
--let $assert_cond= $end_rows_examined - $start_rows_examined = $expected_rows_examined | ||
--source include/assert.inc | ||
|
||
--let $assert_text= Rows_sent should be increased by $expected_rows_sent. | ||
--let $assert_cond= $end_rows_sent - $start_rows_sent = $expected_rows_sent | ||
--source include/assert.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
flush status; | ||
Variation 0: Return constant value. | ||
select 1;; | ||
1 | ||
1 | ||
include/assert.inc [Rows_examined should be increased by 1.] | ||
include/assert.inc [Rows_sent should be increased by 1.] | ||
Variation 1: Create Table. | ||
CREATE TABLE t1 (a INT) ENGINE=InnoDB;; | ||
include/assert.inc [Rows_examined should be increased by 0.] | ||
include/assert.inc [Rows_sent should be increased by 0.] | ||
Variation 2: Insert one row into Table. | ||
INSERT INTO t1 VALUES (1);; | ||
include/assert.inc [Rows_examined should be increased by 0.] | ||
include/assert.inc [Rows_sent should be increased by 0.] | ||
Variation 3: Select one row from Table. | ||
SELECT * FROM t1;; | ||
a | ||
1 | ||
include/assert.inc [Rows_examined should be increased by 1.] | ||
include/assert.inc [Rows_sent should be increased by 1.] | ||
Variation 4: Update one row. | ||
UPDATE t1 SET a = 1;; | ||
include/assert.inc [Rows_examined should be increased by 1.] | ||
include/assert.inc [Rows_sent should be increased by 0.] | ||
Variation 5: SELECT with JOIN | ||
SELECT * FROM t1 AS a1 JOIN t1 AS a2 ON a1.a = a2.a;; | ||
a a | ||
1 1 | ||
include/assert.inc [Rows_examined should be increased by 2.] | ||
include/assert.inc [Rows_sent should be increased by 1.] | ||
Variation 6: UNION | ||
SELECT * FROM t1 AS a1 LEFT JOIN t1 AS a2 ON a1.a = a2.a UNION SELECT * FROM t1 AS a1 RIGHT JOIN t1 AS a2 ON a1.a = a2.a;; | ||
a a | ||
1 1 | ||
include/assert.inc [Rows_examined should be increased by 5.] | ||
include/assert.inc [Rows_sent should be increased by 1.] | ||
Variation 7: DELETE rows from Table. | ||
DELETE FROM t1;; | ||
include/assert.inc [Rows_examined should be increased by 1.] | ||
include/assert.inc [Rows_sent should be increased by 0.] | ||
Variation 8: Drop Table. | ||
DROP TABLE t1;; | ||
include/assert.inc [Rows_examined should be increased by 0.] | ||
include/assert.inc [Rows_sent should be increased by 0.] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#Set all to zero | ||
flush status; | ||
|
||
# | ||
--echo Variation 0: Return constant value. | ||
# | ||
|
||
--let $sql = select 1; | ||
--let $expected_rows_examined = 1 | ||
--let $expected_rows_sent = 1 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 1: Create Table. | ||
# | ||
|
||
--let $sql = CREATE TABLE t1 (a INT) ENGINE=InnoDB; | ||
--let $expected_rows_examined = 0 | ||
--let $expected_rows_sent = 0 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 2: Insert one row into Table. | ||
# | ||
|
||
--let $sql = INSERT INTO t1 VALUES (1); | ||
--let $expected_rows_examined = 0 | ||
--let $expected_rows_sent = 0 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 3: Select one row from Table. | ||
# | ||
|
||
--let $sql = SELECT * FROM t1; | ||
--let $expected_rows_examined = 1 | ||
--let $expected_rows_sent = 1 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 4: Update one row. | ||
# | ||
|
||
--let $sql = UPDATE t1 SET a = 1; | ||
--let $expected_rows_examined = 1 | ||
--let $expected_rows_sent = 0 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 5: SELECT with JOIN | ||
# | ||
|
||
--let $sql = SELECT * FROM t1 AS a1 JOIN t1 AS a2 ON a1.a = a2.a; | ||
--let $expected_rows_examined = 2 | ||
--let $expected_rows_sent = 1 | ||
--source include/counter_rows.inc | ||
|
||
# | ||
--echo Variation 6: UNION | ||
# | ||
|
||
--let $sql = SELECT * FROM t1 AS a1 LEFT JOIN t1 AS a2 ON a1.a = a2.a UNION SELECT * FROM t1 AS a1 RIGHT JOIN t1 AS a2 ON a1.a = a2.a; | ||
--let $expected_rows_examined = 5 | ||
--let $expected_rows_sent = 1 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 7: DELETE rows from Table. | ||
# | ||
|
||
--let $sql = DELETE FROM t1; | ||
--let $expected_rows_examined = 1 | ||
--let $expected_rows_sent = 0 | ||
--source include/counter_rows.inc | ||
|
||
|
||
# | ||
--echo Variation 8: Drop Table. | ||
# | ||
|
||
--let $sql = DROP TABLE t1; | ||
--let $expected_rows_examined = 0 | ||
--let $expected_rows_sent = 0 | ||
--source include/counter_rows.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters