summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/sys_vars/t/myisam_stats_method_func.test
blob: 5cb01958aff397dc135cd2851b5fa70789aae278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
############## mysql-test\t\myisam_stats_method_func.test  ####################
#                                                                             #
# Variable Name: myisam_stats_method                                          #
# Scope: GLOBAL | SESSION                                                     #
# Access Type: Dynamic                                                        #
# Data Type: enumeration                                                      #
# Default Value: nulls_equal                                                  #
# Valid Values: nulls_equal, nulls_unequal                                    #
#                                                                             #
#                                                                             #
# Creation Date: 2008-03-08                                                   #
# Author:  Rizwan                                                             #
#                                                                             #
# Description: Test Cases of Dynamic System Variable myisam_stats_method      #
#              that checks the behavior of this variable                      #
#                                                                             #
# Reference:                                                                  #
#    http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html      #
#                                                                             #
###############################################################################

--echo '#--------------------FN_DYNVARS_097_01-------------------------#'
#####################################################################
# Check if Setting myisam_stats_method is changed in new connection #
#####################################################################

SET @start_value = @@global.myisam_stats_method;

SET @@global.myisam_stats_method = nulls_equal;
connect (con1,localhost,root,,,,);
connection con1;
SELECT @@global.myisam_stats_method;
SELECT @@session.myisam_stats_method;
disconnect con1;

--echo '#--------------------FN_DYNVARS_097_02-------------------------#'
###########################################################
# Begin the functionality Testing of myisam_stats_method  #
###########################################################

connection default;

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1 (a INT, KEY (a));
INSERT INTO t1 VALUES (0),(1),(2),(3),(4);
INSERT INTO t1 SELECT NULL FROM t1;

#=======================================
--echo 'default: NULLs considered unequal'
#=======================================
SET myisam_stats_method = nulls_unequal;

ANALYZE TABLE t1;
SHOW INDEX FROM t1;
INSERT INTO t1 VALUES (11);
DELETE FROM t1 WHERE a = 11;
CHECK TABLE t1;
SHOW INDEX FROM t1;


#=====================================
--echo 'Set nulls to be equal'
#=====================================
SET myisam_stats_method = nulls_equal;
set @save_use_stat_tables= @@use_stat_tables;
set @@use_stat_tables= COMPLEMENTARY;

INSERT INTO t1 VALUES (11);
DELETE FROM t1 WHERE a = 11;
ANALYZE TABLE t1;
SHOW INDEX FROM t1;
INSERT INTO t1 VALUES (11);
DELETE FROM t1 WHERE a = 11;
CHECK TABLE t1;
SHOW INDEX FROM t1;


#=====================================
--echo 'Set nulls to be ignored'
#=====================================

SET myisam_stats_method = nulls_ignored;
SHOW VARIABLES LIKE 'myisam_stats_method';
DROP TABLE t1;

CREATE TABLE t1 (
  a CHAR(3), b CHAR(4), c CHAR(5), d CHAR(6),
  KEY(a,b,c,d)
);
INSERT INTO t1 VALUES ('bcd','def1', NULL, 'zz');
INSERT INTO t1 VALUES ('bcd','def2', NULL, 'zz');
INSERT INTO t1 VALUES ('bce','def1', 'yuu', NULL);
INSERT INTO t1 VALUES ('bce','def2', NULL, 'quux');
ANALYZE TABLE t1;
SHOW INDEX FROM t1;
DELETE FROM t1;
ANALYZE TABLE t1;
SHOW INDEX FROM t1;

SET myisam_stats_method = DEFAULT;
set @@use_stat_tables= @save_use_stat_tables;
DROP TABLE t1;

SET @@global.myisam_stats_method= @start_value;

########################################################
# End of functionality Testing for myisam_stats_method #
########################################################