Commit ed72d2d2 authored by Olivier Bertrand's avatar Olivier Bertrand

- Add some new tests

added:
  storage/connect/mysql-test/connect/r/datest.result
  storage/connect/mysql-test/connect/r/mrr.result
  storage/connect/mysql-test/connect/r/updelx2.result
  storage/connect/mysql-test/connect/t/datest.test
  storage/connect/mysql-test/connect/t/mrr.test
  storage/connect/mysql-test/connect/t/updelx2.test
parent 8585a6b5
#
# Testing out of range dates as (var)char
#
CREATE TABLE t1 (
id INT NOT NULL,
dat CHAR(10) NOT NULL,
tim CHAR(8) DEFAULT '09:35:08',
datim CHAR(19) DEFAULT '1789-08-10 14:20:30')
ENGINE=CONNECT TABLE_TYPE=FIX;
Warnings:
Warning 1105 No file name. Table will use t1.fix
INSERT INTO t1(id,dat) VALUES(1,'1515-04-01'),(2,'2014-07-26'),(3,'2118-11-02');
SELECT * FROM t1;
id dat tim datim
1 1515-04-01 09:35:08 1789-08-10 14:20:30
2 2014-07-26 09:35:08 1789-08-10 14:20:30
3 2118-11-02 09:35:08 1789-08-10 14:20:30
SELECT id, DATE(datim) FROM t1 LIMIT 1;
id DATE(datim)
1 1789-08-10
SELECT id, DAYNAME(dat) FROM t1;
id DAYNAME(dat)
1 Thursday
2 Saturday
3 Wednesday
SELECT id, DAYNAME(datim) FROM t1 LIMIT 1;
id DAYNAME(datim)
1 Monday
SELECT id, TIME(tim) FROM t1 LIMIT 1;
id TIME(tim)
1 09:35:08.000000
DROP TABLE t1;
#
# Show MRR setting. The way it is done is because the t3 table cannot be directly based on
# the information_schema.session_variables table. Not being a CONNECT table, it would be
# read using an intermediate MYSQL table using the MySQL API and could not reflect the
# current session variable change (the call would create another session) This would be
# correct only for querying GLOBAL variables but is not what we want to do here.
#
CREATE TABLE t2 (
name VARCHAR(64) NOT NULL,
value VARCHAR(1024) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DOS;
Warnings:
Warning 1105 No file name. Table will use t2.dos
INSERT INTO t2 SELECT * FROM information_schema.session_variables WHERE variable_name = 'OPTIMIZER_SWITCH';
create table t3 (
name CHAR(32) NOT NULL,
value CHAR(64) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=XCOL TABNAME=t2 OPTION_LIST='Colname=value';
SELECT value FROM t3 WHERE value LIKE 'mrr%';
value
mrr=off
mrr_cost_based=off
mrr_sort_keys=off
#
# Testing indexing with MRR OFF
#
CREATE TABLE t1
(
matricule INT(4) KEY NOT NULL field_format='Z',
nom VARCHAR(16) NOT NULL,
prenom VARCHAR(20) NOT NULL,
sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F',
aanais INT(4) NOT NULL,
mmnais INT(2) NOT NULL,
ddentree DATE NOT NULL date_format='YYYYMM',
ddnom DATE NOT NULL date_format='YYYYMM',
brut INT(5) NOT NULL,
net DOUBLE(8,2) NOT NULL,
service INT(2) NOT NULL,
sitmat CHAR(1) NOT NULL,
formation CHAR(5) NOT NULL,
INDEX NP(nom,prenom)
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2;
SELECT * FROM t1 LIMIT 10;
matricule nom prenom sexe aanais mmnais ddentree ddnom brut net service sitmat formation
5745 ESCOURCHE BENEDICTE 2 1935 7 1962-12-01 1994-05-01 18345 14275.50 0 M TECHN
9692 VICENTE LAURENCE 2 1941 8 1967-10-01 1989-01-01 16212 13032.80 0 M ANGL
9146 NICOLAS ROGER 1 1941 6 1964-07-01 1995-02-01 34173 25098.65 0 M SANS
2985 TESSEREAU MARIE HELENE 2 1941 9 1967-01-01 1990-01-01 19323 14933.78 0 V SANS
3368 MOGADOR ALAIN 1 1941 1 1961-09-01 1993-11-01 43303 31420.55 0 C SANS
7394 CHAUSSEE ERIC DENIS 1 1944 9 1965-11-01 1983-12-01 32002 23583.86 0 M ANGL
4655 MAILLOT GEORGES 1 1945 5 1970-09-01 1986-12-01 24700 18541.64 0 C ANGL
2825 CAMILLE NADINE 2 1956 9 1994-01-01 1993-01-01 19494 15050.45 0 M SANS
1460 BRUYERES JEAN MARC 1 1958 8 1984-08-01 1988-05-01 20902 15980.07 0 M SANS
4974 LONES GERARD 1 1959 10 1979-01-01 1994-12-01 16081 12916.70 0 M SANS
# Without MRR, the rows are retrieved sorted by name
SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI');
matricule nom prenom sitmat net
5324 CERF CLAUDE M 9503.34
7703 CERF NICOLE M 12025.61
3110 CERF VALERIE M 10472.37
4454 ETANG BEATRICE M 11017.61
1022 ETANG GERARD L 8729.58
8222 ETANG LIONEL M 13497.90
2492 ETANG PASCAL VINCENT M 11986.62
1977 FOCH BERNADETTE . 8145.03
5707 FOCH DENIS C 7679.36
2552 FOCH FRANCK M 10745.81
2634 FOCH JOCELYNE M 10473.09
5765 FOCH ROBERT M 12916.32
4080 FOCH SERGE M 9658.24
5898 ITALIE DENIS M 9502.41
7606 ITALIE JACQUES C 7679.45
1067 ITALIE SVETLANA M 11713.61
5853 ROI CHANTAL . 8147.06
2995 ROI JEAN M 11715.50
2531 ROI MICHEL L 10240.44
5846 ROI PATRICIA M 15669.57
#
# Testing indexing with MRR ON
#
SET @@LOCAL.OPTIMIZER_SWITCH='mrr=on';
# Refresh the t2 table to reflect the change
UPDATE t2, information_schema.session_variables SET value = variable_value WHERE variable_name = 'OPTIMIZER_SWITCH';
# Check that MRR is ON for the session
SELECT value FROM t3 WHERE value LIKE 'mrr%';
value
mrr=on
mrr_cost_based=off
mrr_sort_keys=off
# With MRR, the rows are retrieved sorted by their position in the table
SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI');
matricule nom prenom sitmat net
1977 FOCH BERNADETTE . 8145.03
2995 ROI JEAN M 11715.50
3110 CERF VALERIE M 10472.37
5324 CERF CLAUDE M 9503.34
4080 FOCH SERGE M 9658.24
4454 ETANG BEATRICE M 11017.61
5898 ITALIE DENIS M 9502.41
2552 FOCH FRANCK M 10745.81
2531 ROI MICHEL L 10240.44
5853 ROI CHANTAL . 8147.06
8222 ETANG LIONEL M 13497.90
5707 FOCH DENIS C 7679.36
1067 ITALIE SVETLANA M 11713.61
7606 ITALIE JACQUES C 7679.45
7703 CERF NICOLE M 12025.61
2634 FOCH JOCELYNE M 10473.09
1022 ETANG GERARD L 8729.58
5846 ROI PATRICIA M 15669.57
2492 ETANG PASCAL VINCENT M 11986.62
5765 FOCH ROBERT M 12916.32
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
SET @@LOCAL.OPTIMIZER_SWITCH='mrr=off';
#
# Testing multiple indexed UPDATE and DELETE
#
CREATE TABLE t1 (
id INT(4) NOT NULL,
msg VARCHAR(16) NOT NULL,
INDEX IDM(id,msg))
ENGINE=CONNECT TABLE_TYPE=DOS;
Warnings:
Warning 1105 No file name. Table will use t1.dos
INSERT INTO t1 VALUES(1,'one'),(4, 'four'),(7,'seven'),(8,'eight'),(10,'ten'),(11,'eleven'),(40,'forty'),(35,'thirty five'),(60,'sixty'),(72,'seventy two'),(81,'eighty one');
INSERT INTO t1 VALUES(1,'un'),(4, 'quatre'),(7,'sept'),(8,'huit'),(10,'dix'),(11,'onze'),(40,'quarante'),(35,'trente cinq'),(60,'soixante'),(72,'soixante douze'),(81,'quatrevingt un');
SELECT * FROM t1 IGNORE INDEX (IDM);
id msg
1 one
4 four
7 seven
8 eight
10 ten
11 eleven
40 forty
35 thirty five
60 sixty
72 seventy two
81 eighty one
1 un
4 quatre
7 sept
8 huit
10 dix
11 onze
40 quarante
35 trente cinq
60 soixante
72 soixante douze
81 quatrevingt un
UPDATE t1 SET msg = 'dieci' WHERE id = 10;
SELECT * FROM t1 IGNORE INDEX (IDM);
id msg
1 one
4 four
7 seven
8 eight
10 dieci
11 eleven
40 forty
35 thirty five
60 sixty
72 seventy two
81 eighty one
1 un
4 quatre
7 sept
8 huit
10 dieci
11 onze
40 quarante
35 trente cinq
60 soixante
72 soixante douze
81 quatrevingt un
UPDATE t1 SET msg = 'septante deux' WHERE id = 72;
SELECT * FROM t1 IGNORE INDEX (IDM);
id msg
1 one
4 four
7 seven
8 eight
10 dieci
11 eleven
40 forty
35 thirty five
60 sixty
72 septante deux
81 eighty one
1 un
4 quatre
7 sept
8 huit
10 dieci
11 onze
40 quarante
35 trente cinq
60 soixante
72 septante deux
81 quatrevingt un
UPDATE t1 SET id=2, msg='deux' WHERE id=4 AND msg='quatre';
SELECT * FROM t1 IGNORE INDEX (IDM);
id msg
1 one
4 four
7 seven
8 eight
10 dieci
11 eleven
40 forty
35 thirty five
60 sixty
72 septante deux
81 eighty one
1 un
2 deux
7 sept
8 huit
10 dieci
11 onze
40 quarante
35 trente cinq
60 soixante
72 septante deux
81 quatrevingt un
DELETE FROM t1 WHERE id IN (8,40);
SELECT * FROM t1 IGNORE INDEX (IDM);
id msg
1 one
4 four
7 seven
10 dieci
11 eleven
35 thirty five
60 sixty
72 septante deux
81 eighty one
1 un
2 deux
7 sept
10 dieci
11 onze
35 trente cinq
60 soixante
72 septante deux
81 quatrevingt un
DROP TABLE t1;
--echo #
--echo # Testing out of range dates as (var)char
--echo #
CREATE TABLE t1 (
id INT NOT NULL,
dat CHAR(10) NOT NULL,
tim CHAR(8) DEFAULT '09:35:08',
datim CHAR(19) DEFAULT '1789-08-10 14:20:30')
ENGINE=CONNECT TABLE_TYPE=FIX;
INSERT INTO t1(id,dat) VALUES(1,'1515-04-01'),(2,'2014-07-26'),(3,'2118-11-02');
SELECT * FROM t1;
SELECT id, DATE(datim) FROM t1 LIMIT 1;
SELECT id, DAYNAME(dat) FROM t1;
SELECT id, DAYNAME(datim) FROM t1 LIMIT 1;
SELECT id, TIME(tim) FROM t1 LIMIT 1;
DROP TABLE t1;
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/emp.txt $MYSQLD_DATADIR/test/emp.txt
--echo #
--echo # Show MRR setting. The way it is done is because the t3 table cannot be directly based on
--echo # the information_schema.session_variables table. Not being a CONNECT table, it would be
--echo # read using an intermediate MYSQL table using the MySQL API and could not reflect the
--echo # current session variable change (the call would create another session) This would be
--echo # correct only for querying GLOBAL variables but is not what we want to do here.
--echo #
CREATE TABLE t2 (
name VARCHAR(64) NOT NULL,
value VARCHAR(1024) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DOS;
INSERT INTO t2 SELECT * FROM information_schema.session_variables WHERE variable_name = 'OPTIMIZER_SWITCH';
# Check that MRR is OFF by default
create table t3 (
name CHAR(32) NOT NULL,
value CHAR(64) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=XCOL TABNAME=t2 OPTION_LIST='Colname=value';
SELECT value FROM t3 WHERE value LIKE 'mrr%';
--echo #
--echo # Testing indexing with MRR OFF
--echo #
CREATE TABLE t1
(
matricule INT(4) KEY NOT NULL field_format='Z',
nom VARCHAR(16) NOT NULL,
prenom VARCHAR(20) NOT NULL,
sexe SMALLINT(1) NOT NULL COMMENT 'sexe 1:M 2:F',
aanais INT(4) NOT NULL,
mmnais INT(2) NOT NULL,
ddentree DATE NOT NULL date_format='YYYYMM',
ddnom DATE NOT NULL date_format='YYYYMM',
brut INT(5) NOT NULL,
net DOUBLE(8,2) NOT NULL,
service INT(2) NOT NULL,
sitmat CHAR(1) NOT NULL,
formation CHAR(5) NOT NULL,
INDEX NP(nom,prenom)
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='emp.txt' ENDING=2;
SELECT * FROM t1 LIMIT 10;
--echo # Without MRR, the rows are retrieved sorted by name
SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI');
--echo #
--echo # Testing indexing with MRR ON
--echo #
SET @@LOCAL.OPTIMIZER_SWITCH='mrr=on';
--echo # Refresh the t2 table to reflect the change
UPDATE t2, information_schema.session_variables SET value = variable_value WHERE variable_name = 'OPTIMIZER_SWITCH';
--echo # Check that MRR is ON for the session
SELECT value FROM t3 WHERE value LIKE 'mrr%';
--echo # With MRR, the rows are retrieved sorted by their position in the table
SELECT matricule, nom, prenom, sitmat, net FROM t1 WHERE nom IN ('ETANG','FOCH','CERF','ITALIE','ROI');
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
#
# Clean up
#
SET @@LOCAL.OPTIMIZER_SWITCH='mrr=off';
--remove_file $MYSQLD_DATADIR/test/emp.txt
-- source include/not_embedded.inc
--echo #
--echo # Testing multiple indexed UPDATE and DELETE
--echo #
CREATE TABLE t1 (
id INT(4) NOT NULL,
msg VARCHAR(16) NOT NULL,
INDEX IDM(id,msg))
ENGINE=CONNECT TABLE_TYPE=DOS;
INSERT INTO t1 VALUES(1,'one'),(4, 'four'),(7,'seven'),(8,'eight'),(10,'ten'),(11,'eleven'),(40,'forty'),(35,'thirty five'),(60,'sixty'),(72,'seventy two'),(81,'eighty one');
INSERT INTO t1 VALUES(1,'un'),(4, 'quatre'),(7,'sept'),(8,'huit'),(10,'dix'),(11,'onze'),(40,'quarante'),(35,'trente cinq'),(60,'soixante'),(72,'soixante douze'),(81,'quatrevingt un');
SELECT * FROM t1 IGNORE INDEX (IDM);
UPDATE t1 SET msg = 'dieci' WHERE id = 10;
SELECT * FROM t1 IGNORE INDEX (IDM);
UPDATE t1 SET msg = 'septante deux' WHERE id = 72;
SELECT * FROM t1 IGNORE INDEX (IDM);
UPDATE t1 SET id=2, msg='deux' WHERE id=4 AND msg='quatre';
SELECT * FROM t1 IGNORE INDEX (IDM);
DELETE FROM t1 WHERE id IN (8,40);
SELECT * FROM t1 IGNORE INDEX (IDM);
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment