Debian Codegraph @

mysql-test/suite/sys_vars/r/div_precision_increment_func.result

raw
1 drop table if exists t1;
2 ## Creating new table ##
3 CREATE TABLE t1
4 (
5 id INT NOT NULL auto_increment,
6 PRIMARY KEY (id),
7 name VARCHAR(30),
8 salary INT
9 );
10 '#--------------------FN_DYNVARS_027_01-------------------------#'
11 ## Setting initial session value of variable to 3 ##
12 SET @@session.div_precision_increment = 3;
13 ## Inserting some rows in table ##
14 INSERT into t1(name, salary) values('Record_1', 100011);
15 INSERT into t1(name, salary) values('Record_2', 501);
16 INSERT into t1(name, salary) values('Record_3', 210);
17 SELECT name, salary, ((salary * 2.5)/1000) AS INCOME from t1;
18 name salary INCOME
19 Record_1 100011 250.0275
20 Record_2 501 1.2525
21 Record_3 210 0.5250
22 ## Verifying variable's behavior with direct division ##
23 SELECT 1/7;
24 1/7
25 0.143
26 '#--------------------FN_DYNVARS_027_02-------------------------#'
27 drop table if exists t1;
28 ## Creating new table ##
29 CREATE TABLE t1
30 (
31 id INT NOT NULL auto_increment,
32 PRIMARY KEY (id),
33 name VARCHAR(30),
34 salary INT,
35 income_tax FLOAT
36 );
37 connect test_con1, localhost, root,,;
38 connection test_con1;
39 ## Setting global & session scope value of variable ##
40 SET @@global.div_precision_increment = 2;
41 SET @@session.div_precision_increment = 1;
42 SELECT @@global.div_precision_increment;
43 @@global.div_precision_increment
44 2
45 SELECT @@session.div_precision_increment;
46 @@session.div_precision_increment
47 1
48 ## Inserting some data and verifying behavior of variable ##
49 INSERT into t1(name, salary, income_tax) values('Record_1', 100011, 100011*2.5/1000);
50 INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000);
51 INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000);
52 SELECT * from t1;
53 id name salary income_tax
54 1 Record_1 100011 250.027
55 2 Record_2 501 1.2525
56 3 Record_3 210 0.525
57 connect test_con2, localhost, root,,;
58 connection test_con2;
59 ## Verifying session & global value of variable ##
60 SELECT @@global.div_precision_increment = 2;
61 @@global.div_precision_increment = 2
62 1
63 SELECT @@session.div_precision_increment = 2;
64 @@session.div_precision_increment = 2
65 1
66 ## Verifying behavior of variable by inserting some rows in table ##
67 INSERT into t1(name, salary, income_tax) values('Record_4', 100011, 100011*2.5/1000);
68 INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000);
69 INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000);
70 SELECT * from t1;
71 id name salary income_tax
72 1 Record_1 100011 250.027
73 2 Record_2 501 1.2525
74 3 Record_3 210 0.525
75 4 Record_4 100011 250.027
76 5 Record_5 501 1.2525
77 6 Record_6 210 0.525
78 ## Dropping table t1 ##
79 drop table t1;
80 disconnect test_con1;
81 disconnect test_con2;
82 connection default;
83 SET @@global.div_precision_increment = 4;