1
############## mysql-test\t\div_precision_increment_func.test #################
3
# Variable Name: div_precision_increment #
4
# Scope: GLOBAL & SESSION #
5
# Access Type: Dynamic #
11
# Creation Date: 2008-03-07 #
12
# Author: Salman Rawala #
14
# Description: Test Cases of Dynamic System Variable "div_precision_increment" #
15
# that checks functionality of this variable #
17
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
18
# server-system-variables.html#option_mysqld_div_precision_increment #
20
################################################################################
22
let $save_div_precision_increment = `SELECT @@global.div_precision_increment`
24
#SET @save_div_precision_increment = @@global.div_precision_increment;
27
drop table if exists t1;
30
#########################
31
# Creating new table #
32
#########################
34
--echo ## Creating new table ##
37
id INT NOT NULL auto_increment,
43
--echo '#--------------------FN_DYNVARS_027_01-------------------------#'
44
####################################################################
45
# Setting initial value of div_precision_increment to 1
46
# to check whether it is working with columns or not.
47
####################################################################
49
--echo ## Setting initial session value of variable to 3 ##
50
SET @@session.div_precision_increment = 3;
52
--echo ## Inserting some rows in table ##
53
INSERT into t1(name, salary) values('Record_1', 100011);
54
INSERT into t1(name, salary) values('Record_2', 501);
55
INSERT into t1(name, salary) values('Record_3', 210);
57
SELECT name, salary, ((salary * 2.5)/1000) AS INCOME from t1;
58
--echo 'Bug#35374: div_precision is not working with table column'
60
--echo ## Verifying variable's behavior with direct division ##
63
--echo '#--------------------FN_DYNVARS_027_02-------------------------#'
64
####################################################################
65
# Verifying div_precision_increment behavior by inserting rows
66
# to check whether it is working with columns or not.
67
####################################################################
70
drop table if exists t1;
73
#########################
74
# Creating new table #
75
#########################
77
--echo ## Creating new table ##
80
id INT NOT NULL auto_increment,
87
--echo ## Creating new connection test_con1 ##
88
connect (test_con1, localhost, root,,);
91
--echo ## Setting global & session scope value of variable ##
92
SET @@global.div_precision_increment = 2;
93
SET @@session.div_precision_increment = 1;
94
SELECT @@global.div_precision_increment;
95
SELECT @@session.div_precision_increment;
97
--echo ## Inserting some data and verifying behavior of variable ##
98
INSERT into t1(name, salary, income_tax) values('Record_1', 100011, 100011*2.5/1000);
99
INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000);
100
INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000);
103
--echo ## Creating new connection ##
104
connect (test_con2, localhost, root,,);
105
connection test_con2;
107
--echo ## Verifying session & global value of variable ##
108
SELECT @@global.div_precision_increment = 2;
109
SELECT @@session.div_precision_increment = 2;
111
--echo ## Verifying behavior of variable by inserting some rows in table ##
112
INSERT into t1(name, salary, income_tax) values('Record_4', 100011, 100011*2.5/1000);
113
INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000);
114
INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000);
117
--echo ## Dropping table t1 ##
120
--echo ## Disconnection both the connections ##
121
disconnect test_con1;
122
disconnect test_con2;
125
eval SET @@global.div_precision_increment = $save_div_precision_increment;