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 ## Creating new connection test_con1 ##
38 ## Setting global & session scope value of variable ##
39 SET @@global.div_precision_increment = 2;
40 SET @@session.div_precision_increment = 1;
41 SELECT @@global.div_precision_increment;
42 @@global.div_precision_increment
43 2
44 SELECT @@session.div_precision_increment;
45 @@session.div_precision_increment
46 1
47 ## Inserting some data and verifying behavior of variable ##
48 INSERT into t1(name, salary, income_tax) values('Record_1', 100011, 100011*2.5/1000);
49 INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000);
50 INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000);
51 SELECT * from t1;
52 id name salary income_tax
53 1 Record_1 100011 250.027
54 2 Record_2 501 1.2525
55 3 Record_3 210 0.525
56 ## Creating new connection ##
57 ## Verifying session & global value of variable ##
58 SELECT @@global.div_precision_increment = 2;
59 @@global.div_precision_increment = 2
60 1
61 SELECT @@session.div_precision_increment = 2;
62 @@session.div_precision_increment = 2
63 1
64 ## Verifying behavior of variable by inserting some rows in table ##
65 INSERT into t1(name, salary, income_tax) values('Record_4', 100011, 100011*2.5/1000);
66 INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000);
67 INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000);
68 SELECT * from t1;
69 id name salary income_tax
70 1 Record_1 100011 250.027
71 2 Record_2 501 1.2525
72 3 Record_3 210 0.525
73 4 Record_4 100011 250.027
74 5 Record_5 501 1.2525
75 6 Record_6 210 0.525
76 ## Dropping table t1 ##
77 drop table t1;
78 ## Disconnection both the connections ##
79 SET @@global.div_precision_increment = 4;