summaryrefslogtreecommitdiff
path: root/mysql-test/suite/sys_vars/t/div_precision_increment_func.test
blob: ba7bc65eb48ed4c713eed0abb55b1169dddfa4e6 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
############## mysql-test\t\div_precision_increment_func.test #################
#                                                                              #
# Variable Name: div_precision_increment                                       #
# Scope: GLOBAL & SESSION                                                      #
# Access Type: Dynamic                                                         #
# Data Type: Numeric                                                           #
# Default Value: 4                                                             #
# Range: 0 - 30                                                                # 
#                                                                              #
#                                                                              #
# Creation Date: 2008-03-07                                                    #
# Author:  Salman Rawala                                                       #
#                                                                              #
# Description: Test Cases of Dynamic System Variable "div_precision_increment" #
#              that checks functionality of this variable                      #
#                                                                              #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                           #
#   server-system-variables.html#option_mysqld_div_precision_increment         #
#                                                                              #
################################################################################

let $save_div_precision_increment = `SELECT @@global.div_precision_increment`;
 
#SET @save_div_precision_increment = @@global.div_precision_increment;

--disable_warnings
drop table if exists t1;
--enable_warnings

#########################
#   Creating new table  #
#########################

--echo ## Creating new table ##
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name VARCHAR(30),
salary LONG
);

--echo '#--------------------FN_DYNVARS_027_01-------------------------#'
####################################################################
#    Setting initial value of div_precision_increment to 1  
#    to check whether it is working with columns or not.
####################################################################

--echo ## Setting initial session value of variable to 3 ##
SET @@session.div_precision_increment = 3;

--echo ## Inserting some rows in table ##
INSERT into t1(name, salary) values('Record_1', 100011);
INSERT into t1(name, salary) values('Record_2', 501);	
INSERT into t1(name, salary) values('Record_3', 210);

SELECT name, salary, ((salary * 2.5)/1000) AS INCOME from t1;
--echo 'Bug#35374: div_precision is not working with table column'

--echo ## Verifying variable's behavior with direct division ##
SELECT 1/7;

--echo '#--------------------FN_DYNVARS_027_02-------------------------#'
####################################################################
#    Verifying div_precision_increment behavior by inserting rows 
#    to check whether it is working with columns or not.
####################################################################

--disable_warnings
drop table if exists t1;
--enable_warnings

#########################
#   Creating new table  #
#########################

--echo ## Creating new table ##
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name VARCHAR(30),
salary LONG,
income_tax FLOAT
);

--echo ## Creating new connection test_con1 ##
connect (test_con1, localhost, root,,);
connection test_con1;

--echo ## Setting global & session scope value of variable ##
SET @@global.div_precision_increment = 2;
SET @@session.div_precision_increment = 1;
SELECT @@global.div_precision_increment;
SELECT @@session.div_precision_increment;

--echo ## Inserting some data and verifying behavior of variable ##
INSERT into t1(name, salary, income_tax) values('Record_1', 100011, 100011*2.5/1000);
INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000);	
INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000);
SELECT * from t1;

--echo ## Creating new connection ## 
connect (test_con2, localhost, root,,);
connection test_con2;

--echo ## Verifying session & global value of variable ##
SELECT @@global.div_precision_increment = 2;
SELECT @@session.div_precision_increment = 2;

--echo ## Verifying behavior of variable by inserting some rows in table ##
INSERT into t1(name, salary, income_tax) values('Record_4', 100011, 100011*2.5/1000);
INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000);	
INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000);
SELECT * from t1;

--echo ## Dropping table t1 ##
drop table t1;

--echo ## Disconnection both the connections ##
disconnect test_con1;
disconnect test_con2;

connection default;
eval SET @@global.div_precision_increment = $save_div_precision_increment;