| 1 |
############## mysql-test\t\div_precision_increment_func.test ################# |
| 2 |
# # |
| 3 |
# Variable Name: div_precision_increment # |
| 4 |
# Scope: GLOBAL & SESSION # |
| 5 |
# Access Type: Dynamic # |
| 6 |
# Data Type: Numeric # |
| 7 |
# Default Value: 4 # |
| 8 |
# Range: 0 - 30 # |
| 9 |
# # |
| 10 |
# # |
| 11 |
# Creation Date: 2008-03-07 # |
| 12 |
# Author: Salman Rawala # |
| 13 |
# # |
| 14 |
# Description: Test Cases of Dynamic System Variable "div_precision_increment" # |
| 15 |
# that checks functionality of this variable # |
| 16 |
# # |
| 17 |
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # |
| 18 |
# server-system-variables.html#option_mysqld_div_precision_increment # |
| 19 |
# # |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
let $save_div_precision_increment = `SELECT @@global.div_precision_increment`; |
| 23 |
|
| 24 |
#SET @save_div_precision_increment = @@global.div_precision_increment; |
| 25 |
|
| 26 |
--disable_warnings |
| 27 |
drop table if exists t1; |
| 28 |
--enable_warnings |
| 29 |
|
| 30 |
######################### |
| 31 |
# Creating new table # |
| 32 |
######################### |
| 33 |
|
| 34 |
--echo ## Creating new table ## |
| 35 |
CREATE TABLE t1 |
| 36 |
( |
| 37 |
id INT NOT NULL auto_increment, |
| 38 |
PRIMARY KEY (id), |
| 39 |
name VARCHAR(30), |
| 40 |
salary INT |
| 41 |
); |
| 42 |
|
| 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 |
#################################################################### |
| 48 |
|
| 49 |
--echo ## Setting initial session value of variable to 3 ## |
| 50 |
SET @@session.div_precision_increment = 3; |
| 51 |
|
| 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); |
| 56 |
|
| 57 |
SELECT name, salary, ((salary * 2.5)/1000) AS INCOME from t1; |
| 58 |
|
| 59 |
--echo ## Verifying variable's behavior with direct division ## |
| 60 |
SELECT 1/7; |
| 61 |
|
| 62 |
--echo '#--------------------FN_DYNVARS_027_02-------------------------#' |
| 63 |
#################################################################### |
| 64 |
# Verifying div_precision_increment behavior by inserting rows |
| 65 |
# to check whether it is working with columns or not. |
| 66 |
#################################################################### |
| 67 |
|
| 68 |
--disable_warnings |
| 69 |
drop table if exists t1; |
| 70 |
--enable_warnings |
| 71 |
|
| 72 |
######################### |
| 73 |
# Creating new table # |
| 74 |
######################### |
| 75 |
|
| 76 |
--echo ## Creating new table ## |
| 77 |
CREATE TABLE t1 |
| 78 |
( |
| 79 |
id INT NOT NULL auto_increment, |
| 80 |
PRIMARY KEY (id), |
| 81 |
name VARCHAR(30), |
| 82 |
salary INT, |
| 83 |
income_tax FLOAT |
| 84 |
); |
| 85 |
|
| 86 |
--echo ## Creating new connection test_con1 ## |
| 87 |
connect (test_con1, localhost, root,,); |
| 88 |
connection test_con1; |
| 89 |
|
| 90 |
--echo ## Setting global & session scope value of variable ## |
| 91 |
SET @@global.div_precision_increment = 2; |
| 92 |
SET @@session.div_precision_increment = 1; |
| 93 |
SELECT @@global.div_precision_increment; |
| 94 |
SELECT @@session.div_precision_increment; |
| 95 |
|
| 96 |
--echo ## Inserting some data and verifying behavior of variable ## |
| 97 |
INSERT into t1(name, salary, income_tax) values('Record_1', 100011, 100011*2.5/1000); |
| 98 |
INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000); |
| 99 |
INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000); |
| 100 |
SELECT * from t1; |
| 101 |
|
| 102 |
--echo ## Creating new connection ## |
| 103 |
connect (test_con2, localhost, root,,); |
| 104 |
connection test_con2; |
| 105 |
|
| 106 |
--echo ## Verifying session & global value of variable ## |
| 107 |
SELECT @@global.div_precision_increment = 2; |
| 108 |
SELECT @@session.div_precision_increment = 2; |
| 109 |
|
| 110 |
--echo ## Verifying behavior of variable by inserting some rows in table ## |
| 111 |
INSERT into t1(name, salary, income_tax) values('Record_4', 100011, 100011*2.5/1000); |
| 112 |
INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000); |
| 113 |
INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000); |
| 114 |
SELECT * from t1; |
| 115 |
|
| 116 |
--echo ## Dropping table t1 ## |
| 117 |
drop table t1; |
| 118 |
|
| 119 |
--echo ## Disconnection both the connections ## |
| 120 |
disconnect test_con1; |
| 121 |
disconnect test_con2; |
| 122 |
|
| 123 |
connection default; |
| 124 |
eval SET @@global.div_precision_increment = $save_div_precision_increment; |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|