~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/r/type_decimal.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
DROP TABLE IF EXISTS t1, t2;
 
2
SET SQL_WARNINGS=1;
 
3
CREATE TABLE t1 (
 
4
id int(11) NOT NULL auto_increment,
 
5
datatype_id int(11) DEFAULT '0' NOT NULL,
 
6
minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
 
7
maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
 
8
valuename varchar(20),
 
9
forecolor int(11),
 
10
backcolor int(11),
 
11
PRIMARY KEY (id),
 
12
UNIQUE datatype_id (datatype_id, minvalue, maxvalue)
 
13
);
 
14
INSERT INTO t1 VALUES ( '1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960');
 
15
INSERT INTO t1 VALUES ( '2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255');
 
16
INSERT INTO t1 VALUES ( '3', '1', '2.0000000000', '49.0000000000', '', '0', '16777215');
 
17
INSERT INTO t1 VALUES ( '60', '11', '0.0000000000', '0.0000000000', 'Rikkis', '16777215', '16711680');
 
18
INSERT INTO t1 VALUES ( '4', '12', '1.0000000000', '1.0000000000', 'nork sadu', '65280', '14474460');
 
19
INSERT INTO t1 VALUES ( '5', '12', '2.0000000000', '2.0000000000', 'keskmine sadu', '255', '14474460');
 
20
INSERT INTO t1 VALUES ( '6', '12', '3.0000000000', '3.0000000000', 'tugev sadu', '127', '14474460');
 
21
INSERT INTO t1 VALUES ( '43', '39', '6.0000000000', '6.0000000000', 'lobjakas', '13107327', '16763080');
 
22
INSERT INTO t1 VALUES ( '40', '39', '2.0000000000', '2.0000000000', 'vihm', '8355839', '16777215');
 
23
INSERT INTO t1 VALUES ( '53', '1', '-35.0000000000', '-5.0000000000', '', '0', '16777215');
 
24
INSERT INTO t1 VALUES ( '41', '39', '3.0000000000', '3.0000000000', 'kļæ½lm vihm', '120', '16763080');
 
25
INSERT INTO t1 VALUES ( '12', '21', '21.0000000000', '21.0000000000', 'Kuiv', '13158600', '16777215');
 
26
INSERT INTO t1 VALUES ( '13', '21', '13.0000000000', '13.0000000000', 'Mļæ½rg', '5263615', '16777215');
 
27
INSERT INTO t1 VALUES ( '14', '21', '22.0000000000', '22.0000000000', 'Niiske', '9869055', '16777215');
 
28
INSERT INTO t1 VALUES ( '19', '21', '33.0000000000', '33.0000000000', 'Mļæ½rg', '5263615', '16777215');
 
29
INSERT INTO t1 VALUES ( '15', '21', '23.0000000000', '23.0000000000', 'Mļæ½rg', '5263615', '16777215');
 
30
INSERT INTO t1 VALUES ( '16', '21', '31.0000000000', '31.0000000000', 'Kuiv', '13158600', '16777215');
 
31
INSERT INTO t1 VALUES ( '17', '21', '12.0000000000', '12.0000000000', 'Niiske', '9869055', '16777215');
 
32
INSERT INTO t1 VALUES ( '18', '21', '32.0000000000', '32.0000000000', 'Niiske', '9869055', '16777215');
 
33
INSERT INTO t1 VALUES ( '20', '21', '331.0000000000', '331.0000000000', 'Hļæ½rmatise hoiatus!', '14448840', '13158600');
 
34
INSERT INTO t1 VALUES ( '21', '21', '11.0000000000', '11.0000000000', 'Kuiv', '13158600', '16777215');
 
35
INSERT INTO t1 VALUES ( '22', '33', '21.0000000000', '21.0000000000', 'Pilves, kuiv', '8355711', '12632256');
 
36
INSERT INTO t1 VALUES ( '23', '33', '13.0000000000', '13.0000000000', 'Sajab, mļæ½rg', '0', '8355839');
 
37
INSERT INTO t1 VALUES ( '24', '33', '22.0000000000', '22.0000000000', 'Pilves, niiske', '8355711', '12632319');
 
38
INSERT INTO t1 VALUES ( '29', '33', '33.0000000000', '33.0000000000', 'Selge, mļæ½rg', '16777215', '8355839');
 
39
INSERT INTO t1 VALUES ( '25', '33', '23.0000000000', '23.0000000000', 'Pilves, mļæ½rg', '8355711', '8355839');
 
40
INSERT INTO t1 VALUES ( '26', '33', '31.0000000000', '31.0000000000', 'Selge, kuiv', '16777215', '12632256');
 
41
INSERT INTO t1 VALUES ( '27', '33', '12.0000000000', '12.0000000000', 'Sajab, niiske', '0', '12632319');
 
42
INSERT INTO t1 VALUES ( '28', '33', '32.0000000000', '32.0000000000', 'Selge, niiske', '16777215', '12632319');
 
43
INSERT INTO t1 VALUES ( '30', '33', '331.0000000000', '331.0000000000', 'Hļæ½rmatis! selge,kuiv', '16711680', '12632256');
 
44
INSERT INTO t1 VALUES ( '31', '33', '11.0000000000', '11.0000000000', 'Sajab, kuiv', '0', '12632256');
 
45
INSERT INTO t1 VALUES ( '32', '11', '1.0000000000', '1.0000000000', 'Korras', '16777215', '49152');
 
46
INSERT INTO t1 VALUES ( '33', '21', '335.0000000000', '335.0000000000', 'Hļæ½rmatis!', '14448840', '11842740');
 
47
INSERT INTO t1 VALUES ( '34', '21', '134.0000000000', '134.0000000000', 'Hoiatus, M+S!', '255', '13158600');
 
48
INSERT INTO t1 VALUES ( '35', '21', '133.0000000000', '133.0000000000', 'Hoiatus, mļæ½rg!', '5263615', '13158600');
 
49
INSERT INTO t1 VALUES ( '36', '21', '135.0000000000', '135.0000000000', 'Hļæ½rmatis!', '14448840', '11842740');
 
50
INSERT INTO t1 VALUES ( '37', '21', '334.0000000000', '334.0000000000', 'Hļæ½rmatise hoiatus!', '14448840', '13158600');
 
51
INSERT INTO t1 VALUES ( '38', '21', '132.0000000000', '132.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
 
52
INSERT INTO t1 VALUES ( '39', '39', '1.0000000000', '1.0000000000', 'ei saja', '11206570', '16777215');
 
53
INSERT INTO t1 VALUES ( '44', '39', '4.0000000000', '5.0000000000', 'lumi', '16711680', '16763080');
 
54
INSERT INTO t1 VALUES ( '45', '12', '0.0000000000', '0.0000000000', '', '16777215', '14474460');
 
55
INSERT INTO t1 VALUES ( '46', '39', '8.0000000000', '8.0000000000', 'rahe', '9830400', '16763080');
 
56
INSERT INTO t1 VALUES ( '47', '39', '9.0000000000', '9.0000000000', 'tļæ½ļæ½p ebaselge', '12582912', '16777215');
 
57
INSERT INTO t1 VALUES ( '48', '39', '7.0000000000', '7.0000000000', 'lumetuisk', '7209070', '16763080');
 
58
INSERT INTO t1 VALUES ( '142', '15', '2.0000000000', '49.0000000000', '', '0', '16777215');
 
59
INSERT INTO t1 VALUES ( '52', '1', '-4.9000000000', '-0.1000000000', '', '0', '15774720');
 
60
INSERT INTO t1 VALUES ( '141', '15', '-4.9000000000', '-0.1000000000', '', '0', '15774720');
 
61
INSERT INTO t1 VALUES ( '55', '8', '0.0000000000', '0.0000000000', '', '0', '16777215');
 
62
INSERT INTO t1 VALUES ( '56', '8', '0.0100000000', '0.1000000000', '', '0', '16770560');
 
63
INSERT INTO t1 VALUES ( '57', '8', '0.1100000000', '25.0000000000', '', '0', '15774720');
 
64
INSERT INTO t1 VALUES ( '58', '2', '90.0000000000', '94.9000000000', '', NULL, '16770560');
 
65
INSERT INTO t1 VALUES ( '59', '6', '0.0000000000', '360.0000000000', '', NULL, '16777215');
 
66
INSERT INTO t1 VALUES ( '61', '21', '38.0000000000', '38.0000000000', 'Niiske', '9869055', '16777215');
 
67
INSERT INTO t1 VALUES ( '62', '38', '500.0000000000', '999.0000000000', '', '0', '16770560');
 
68
INSERT INTO t1 VALUES ( '63', '38', '1000.0000000000', '2000.0000000000', '', '0', '16777215');
 
69
INSERT INTO t1 VALUES ( '64', '17', '0.0000000000', '0.0000000000', '', NULL, '16777215');
 
70
INSERT INTO t1 VALUES ( '65', '17', '0.1000000000', '10.0000000000', '', NULL, '16770560');
 
71
INSERT INTO t1 VALUES ( '67', '21', '412.0000000000', '412.0000000000', 'Niiske', '9869055', '16777215');
 
72
INSERT INTO t1 VALUES ( '68', '21', '413.0000000000', '413.0000000000', 'Mļæ½rg', '5263615', '16777215');
 
73
INSERT INTO t1 VALUES ( '69', '21', '113.0000000000', '113.0000000000', 'Mļæ½rg', '5263615', '16777215');
 
74
INSERT INTO t1 VALUES ( '70', '21', '416.0000000000', '416.0000000000', 'Lumine!', '16711680', '11842740');
 
75
INSERT INTO t1 VALUES ( '71', '38', '0.0000000000', '499.0000000000', '', NULL, '16711680');
 
76
INSERT INTO t1 VALUES ( '72', '22', '-49.0000000000', '49.0000000000', '', NULL, '16777215');
 
77
INSERT INTO t1 VALUES ( '73', '13', '0.0000000000', '9.9000000000', '', NULL, '16777215');
 
78
INSERT INTO t1 VALUES ( '74', '13', '10.0000000000', '14.9000000000', '', NULL, '16770560');
 
79
INSERT INTO t1 VALUES ( '75', '7', '0.0000000000', '50.0000000000', '', NULL, '16777215');
 
80
INSERT INTO t1 VALUES ( '76', '18', '0.0000000000', '0.0000000000', '', NULL, '16777215');
 
81
INSERT INTO t1 VALUES ( '77', '18', '0.1000000000', '10.0000000000', '', NULL, '16770560');
 
82
INSERT INTO t1 VALUES ( '78', '19', '300.0000000000', '400.0000000000', '', NULL, '16777215');
 
83
INSERT INTO t1 VALUES ( '79', '19', '0.0000000000', '299.0000000000', '', NULL, '16770560');
 
84
INSERT INTO t1 VALUES ( '80', '23', '0.0000000000', '100.0000000000', '', NULL, '16777215');
 
85
INSERT INTO t1 VALUES ( '81', '24', '0.0000000000', '200.0000000000', '', NULL, '16777215');
 
86
INSERT INTO t1 VALUES ( '82', '26', '0.0000000000', '0.0000000000', '', NULL, '16777215');
 
87
INSERT INTO t1 VALUES ( '83', '26', '0.1000000000', '5.0000000000', '', NULL, '16776960');
 
88
INSERT INTO t1 VALUES ( '84', '21', '422.0000000000', '422.0000000000', 'Niiske', '9869055', '16777215');
 
89
INSERT INTO t1 VALUES ( '85', '21', '411.0000000000', '411.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600');
 
90
INSERT INTO t1 VALUES ( '86', '21', '423.0000000000', '423.0000000000', 'Mļæ½rg', '5263615', '16777215');
 
91
INSERT INTO t1 VALUES ( '144', '16', '-49.0000000000', '-5.0000000000', '', NULL, '16777215');
 
92
INSERT INTO t1 VALUES ( '88', '16', '2.0000000000', '49.0000000000', '', NULL, '16777215');
 
93
INSERT INTO t1 VALUES ( '89', '21', '338.0000000000', '338.0000000000', 'Hļæ½rm.hoiatus, N+S!', '16744319', '13158600');
 
94
INSERT INTO t1 VALUES ( '90', '21', '332.0000000000', '332.0000000000', 'Hļæ½rm.hoiat., niiske!', '16744319', '13158600');
 
95
INSERT INTO t1 VALUES ( '91', '21', '114.0000000000', '114.0000000000', 'Hoiatus, M+S!', '255', '13158600');
 
96
INSERT INTO t1 VALUES ( '92', '21', '117.0000000000', '117.0000000000', 'Hoiatus, Jļæ½ļæ½!', '14448840', '16711680');
 
97
INSERT INTO t1 VALUES ( '93', '21', '116.0000000000', '116.0000000000', 'Lumine!', '16711680', '11842740');
 
98
INSERT INTO t1 VALUES ( '94', '21', '414.0000000000', '414.0000000000', 'Hoiatus, M+S!', '255', '13158600');
 
99
INSERT INTO t1 VALUES ( '95', '21', '325.0000000000', '325.0000000000', 'Hļæ½rmatis!', '14448840', '11842740');
 
100
INSERT INTO t1 VALUES ( '96', '21', '321.0000000000', '321.0000000000', 'Hļæ½rmatise hoiatus!', '14448840', '13158600');
 
101
INSERT INTO t1 VALUES ( '97', '21', '328.0000000000', '328.0000000000', 'Hļæ½rm.hoiatus, N+S!', '16744319', '13158600');
 
102
INSERT INTO t1 VALUES ( '98', '21', '28.0000000000', '28.0000000000', 'Niiske ja sool', '9869055', '16777215');
 
103
INSERT INTO t1 VALUES ( '99', '21', '118.0000000000', '118.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
 
104
INSERT INTO t1 VALUES ( '100', '21', '418.0000000000', '418.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
 
105
INSERT INTO t1 VALUES ( '101', '21', '322.0000000000', '322.0000000000', 'Hļæ½rm.hoiat., niiske!', '16744319', '13158600');
 
106
INSERT INTO t1 VALUES ( '102', '21', '428.0000000000', '428.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
 
107
INSERT INTO t1 VALUES ( '103', '21', '432.0000000000', '432.0000000000', 'Hoiatus, niiske!', '7895240', '13158600');
 
108
INSERT INTO t1 VALUES ( '104', '21', '421.0000000000', '421.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600');
 
109
INSERT INTO t1 VALUES ( '105', '21', '24.0000000000', '24.0000000000', 'Mļæ½rg ja sool', '255', '16777215');
 
110
INSERT INTO t1 VALUES ( '106', '21', '438.0000000000', '438.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
 
111
INSERT INTO t1 VALUES ( '107', '21', '112.0000000000', '112.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
 
112
INSERT INTO t1 VALUES ( '108', '21', '34.0000000000', '34.0000000000', 'Mļæ½rg ja sool', '255', '16777215');
 
113
INSERT INTO t1 VALUES ( '109', '21', '434.0000000000', '434.0000000000', 'Hoiatus, M+S!', '255', '13158600');
 
114
INSERT INTO t1 VALUES ( '110', '21', '124.0000000000', '124.0000000000', 'Hoiatus, M+S!', '255', '13158600');
 
115
INSERT INTO t1 VALUES ( '111', '21', '424.0000000000', '424.0000000000', 'Hoiatus, M+S!', '255', '13158600');
 
116
INSERT INTO t1 VALUES ( '112', '21', '123.0000000000', '123.0000000000', 'Hoiatus, mļæ½rg!', '5263615', '13158600');
 
117
INSERT INTO t1 VALUES ( '140', '15', '-49.0000000000', '-5.0000000000', '', '0', '16777215');
 
118
INSERT INTO t1 VALUES ( '114', '21', '18.0000000000', '18.0000000000', 'Niiske ja sool', '9869055', '16777215');
 
119
INSERT INTO t1 VALUES ( '115', '21', '122.0000000000', '122.0000000000', 'Hoiatus, niiske!', '9869055', '13158600');
 
120
INSERT INTO t1 VALUES ( '116', '21', '14.0000000000', '14.0000000000', 'Mļæ½rg ja sool', '255', '16777215');
 
121
INSERT INTO t1 VALUES ( '117', '21', '311.0000000000', '311.0000000000', 'Hļæ½rmatise hoiatus!', '14448840', '13158600');
 
122
INSERT INTO t1 VALUES ( '121', '2', '95.0000000000', '100.0000000000', '', NULL, '15774720');
 
123
INSERT INTO t1 VALUES ( '118', '2', '0.0000000000', '89.9000000000', '', NULL, '16777215');
 
124
INSERT INTO t1 VALUES ( '119', '21', '16.0000000000', '16.0000000000', 'Lumine!', '16711680', '11842740');
 
125
INSERT INTO t1 VALUES ( '120', '21', '26.0000000000', '26.0000000000', 'Lumine!', '16711680', '11842740');
 
126
INSERT INTO t1 VALUES ( '122', '13', '15.0000000000', '50.0000000000', '', NULL, '15774720');
 
127
INSERT INTO t1 VALUES ( '123', '5', '0.0000000000', '9.9000000000', '', NULL, '16777215');
 
128
INSERT INTO t1 VALUES ( '124', '5', '10.0000000000', '14.9000000000', '', NULL, '16770560');
 
129
INSERT INTO t1 VALUES ( '125', '5', '15.0000000000', '50.0000000000', '', NULL, '15774720');
 
130
INSERT INTO t1 VALUES ( '126', '21', '128.0000000000', '128.0000000000', 'Hoiatus, N+S!', '9869055', '13158600');
 
131
INSERT INTO t1 VALUES ( '127', '21', '318.0000000000', '318.0000000000', 'Hļæ½rm.hoiatus, N+S!', '16744319', '13158600');
 
132
INSERT INTO t1 VALUES ( '128', '21', '312.0000000000', '312.0000000000', 'Hļæ½rm.hoiat., niiske!', '16744319', '13158600');
 
133
INSERT INTO t1 VALUES ( '129', '21', '126.0000000000', '126.0000000000', 'Lumine!', '16711680', '11842740');
 
134
INSERT INTO t1 VALUES ( '130', '21', '324.0000000000', '324.0000000000', 'Hļæ½rmatise hoiatus!', '14448840', '13158600');
 
135
INSERT INTO t1 VALUES ( '131', '21', '316.0000000000', '316.0000000000', 'Lumine!', '16711680', '11842740');
 
136
INSERT INTO t1 VALUES ( '132', '1', '0.0000000000', '1.9000000000', '', NULL, '16769024');
 
137
INSERT INTO t1 VALUES ( '134', '3', '-50.0000000000', '50.0000000000', '', NULL, '16777215');
 
138
INSERT INTO t1 VALUES ( '135', '8', '26.0000000000', '2000.0000000000', '', '9868950', '15774720');
 
139
INSERT INTO t1 VALUES ( '136', '21', '426.0000000000', '426.0000000000', 'Lumine!', '16711680', '11842740');
 
140
INSERT INTO t1 VALUES ( '137', '21', '127.0000000000', '127.0000000000', 'Hoiatus, Jļæ½ļæ½!', '14448840', '16711680');
 
141
INSERT INTO t1 VALUES ( '138', '21', '121.0000000000', '121.0000000000', 'Kuiv', '13158600', '16777215');
 
142
INSERT INTO t1 VALUES ( '139', '21', '326.0000000000', '326.0000000000', 'Lumine!', '16711680', '11842740');
 
143
INSERT INTO t1 VALUES ( '143', '16', '-4.9000000000', '-0.1000000000', '', NULL, '15774720');
 
144
INSERT INTO t1 VALUES ( '145', '15', '0.0000000000', '1.9000000000', '', '0', '16769024');
 
145
INSERT INTO t1 VALUES ( '146', '16', '0.0000000000', '1.9000000000', '', '0', '16769024');
 
146
select * from t1 where minvalue<=1 and maxvalue>=-1 and datatype_id=16;
 
147
id      datatype_id     minvalue        maxvalue        valuename       forecolor       backcolor
 
148
143     16      -4.9000000000   -0.1000000000           NULL    15774720
 
149
146     16      0.0000000000    1.9000000000            0       16769024
 
150
select * from t1 where minvalue<=-1 and maxvalue>=-1 and datatype_id=16;
 
151
id      datatype_id     minvalue        maxvalue        valuename       forecolor       backcolor
 
152
143     16      -4.9000000000   -0.1000000000           NULL    15774720
 
153
drop table t1;
 
154
create table t1 (a decimal(10,2));
 
155
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
 
156
insert into t1 values ("-.1"),("+.1"),(".1");
 
157
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
 
158
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
 
159
Warnings:
 
160
Warning 1264    Out of range value for column 'a' at row 1
 
161
Warning 1264    Out of range value for column 'a' at row 2
 
162
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
 
163
Warnings:
 
164
Warning 1264    Out of range value for column 'a' at row 1
 
165
Warning 1264    Out of range value for column 'a' at row 2
 
166
Warning 1264    Out of range value for column 'a' at row 3
 
167
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
 
168
Warnings:
 
169
Warning 1264    Out of range value for column 'a' at row 1
 
170
Note    1265    Data truncated for column 'a' at row 2
 
171
Warning 1264    Out of range value for column 'a' at row 3
 
172
insert into t1 values ("1e+4294967296"),("1e-4294967296");
 
173
Warnings:
 
174
Warning 1264    Out of range value for column 'a' at row 1
 
175
Note    1265    Data truncated for column 'a' at row 2
 
176
insert into t1 values ("1e+18446744073709551615"),("1e+18446744073709551616"),("1e-9223372036854775807"),("1e-9223372036854775809");
 
177
Warnings:
 
178
Warning 1264    Out of range value for column 'a' at row 1
 
179
Warning 1366    Incorrect decimal value: '1e+18446744073709551616' for column 'a' at row 2
 
180
Note    1265    Data truncated for column 'a' at row 3
 
181
Warning 1366    Incorrect decimal value: '1e-9223372036854775809' for column 'a' at row 4
 
182
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
 
183
Warnings:
 
184
Note    1265    Data truncated for column 'a' at row 1
 
185
Note    1265    Data truncated for column 'a' at row 3
 
186
select * from t1;
 
187
a
 
188
0.00
 
189
0.00
 
190
0.00
 
191
1.00
 
192
1.00
 
193
-1.00
 
194
-0.10
 
195
0.10
 
196
0.10
 
197
1.00
 
198
1.00
 
199
-1.00
 
200
99999999.99
 
201
99999999.99
 
202
-11111111.11
 
203
-99999999.99
 
204
99999999.99
 
205
99999999.99
 
206
99999999.99
 
207
0.00
 
208
-99999999.99
 
209
99999999.99
 
210
0.00
 
211
99999999.99
 
212
0.00
 
213
0.00
 
214
0.00
 
215
123.40
 
216
12340.00
 
217
1.23
 
218
1230.00
 
219
123.00
 
220
drop  table t1;
 
221
create table t1 (a decimal(10,2) unsigned);
 
222
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
 
223
Warnings:
 
224
Warning 1264    Out of range value for column 'a' at row 2
 
225
Warning 1264    Out of range value for column 'a' at row 6
 
226
insert into t1 values ("-.1"),("+.1"),(".1");
 
227
Warnings:
 
228
Warning 1264    Out of range value for column 'a' at row 1
 
229
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
 
230
Warnings:
 
231
Warning 1264    Out of range value for column 'a' at row 3
 
232
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
 
233
Warnings:
 
234
Warning 1264    Out of range value for column 'a' at row 1
 
235
Warning 1264    Out of range value for column 'a' at row 2
 
236
Warning 1264    Out of range value for column 'a' at row 3
 
237
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
 
238
Warnings:
 
239
Warning 1264    Out of range value for column 'a' at row 1
 
240
Warning 1264    Out of range value for column 'a' at row 2
 
241
Warning 1264    Out of range value for column 'a' at row 3
 
242
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
 
243
Warnings:
 
244
Warning 1264    Out of range value for column 'a' at row 1
 
245
Note    1265    Data truncated for column 'a' at row 2
 
246
Warning 1264    Out of range value for column 'a' at row 3
 
247
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
 
248
Warnings:
 
249
Note    1265    Data truncated for column 'a' at row 1
 
250
Note    1265    Data truncated for column 'a' at row 3
 
251
select * from t1;
 
252
a
 
253
0.00
 
254
0.00
 
255
0.00
 
256
1.00
 
257
1.00
 
258
0.00
 
259
0.00
 
260
0.10
 
261
0.10
 
262
1.00
 
263
1.00
 
264
0.00
 
265
99999999.99
 
266
99999999.99
 
267
0.00
 
268
0.00
 
269
99999999.99
 
270
99999999.99
 
271
99999999.99
 
272
0.00
 
273
0.00
 
274
123.40
 
275
12340.00
 
276
1.23
 
277
1230.00
 
278
123.00
 
279
drop  table t1;
 
280
create table t1 (a decimal(10,2) zerofill);
 
281
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
 
282
Warnings:
 
283
Warning 1264    Out of range value for column 'a' at row 2
 
284
Warning 1264    Out of range value for column 'a' at row 6
 
285
insert into t1 values ("-.1"),("+.1"),(".1");
 
286
Warnings:
 
287
Warning 1264    Out of range value for column 'a' at row 1
 
288
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
 
289
Warnings:
 
290
Warning 1264    Out of range value for column 'a' at row 3
 
291
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
 
292
Warnings:
 
293
Warning 1264    Out of range value for column 'a' at row 1
 
294
Warning 1264    Out of range value for column 'a' at row 2
 
295
Warning 1264    Out of range value for column 'a' at row 3
 
296
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
 
297
Warnings:
 
298
Warning 1264    Out of range value for column 'a' at row 1
 
299
Warning 1264    Out of range value for column 'a' at row 2
 
300
Warning 1264    Out of range value for column 'a' at row 3
 
301
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
 
302
Warnings:
 
303
Warning 1264    Out of range value for column 'a' at row 1
 
304
Note    1265    Data truncated for column 'a' at row 2
 
305
Warning 1264    Out of range value for column 'a' at row 3
 
306
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
 
307
Warnings:
 
308
Note    1265    Data truncated for column 'a' at row 1
 
309
Note    1265    Data truncated for column 'a' at row 3
 
310
select * from t1;
 
311
a
 
312
00000000.00
 
313
00000000.00
 
314
00000000.00
 
315
00000001.00
 
316
00000001.00
 
317
00000000.00
 
318
00000000.00
 
319
00000000.10
 
320
00000000.10
 
321
00000001.00
 
322
00000001.00
 
323
00000000.00
 
324
99999999.99
 
325
99999999.99
 
326
00000000.00
 
327
00000000.00
 
328
99999999.99
 
329
99999999.99
 
330
99999999.99
 
331
00000000.00
 
332
00000000.00
 
333
00000123.40
 
334
00012340.00
 
335
00000001.23
 
336
00001230.00
 
337
00000123.00
 
338
drop  table t1;
 
339
create table t1 (a decimal(10,2));
 
340
insert into t1 values (0.0),("-0.0"),(+0.0),(01.0),(+01.0),(-01.0);
 
341
insert into t1 values (-.1),(+.1),(.1);
 
342
insert into t1 values (00000000000001),(+0000000000001),(-0000000000001);
 
343
insert into t1 values (+111111111.11),(111111111.11),(-11111111.11);
 
344
Warnings:
 
345
Warning 1264    Out of range value for column 'a' at row 1
 
346
Warning 1264    Out of range value for column 'a' at row 2
 
347
insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
 
348
Warnings:
 
349
Warning 1264    Out of range value for column 'a' at row 1
 
350
Warning 1264    Out of range value for column 'a' at row 2
 
351
Warning 1264    Out of range value for column 'a' at row 3
 
352
insert into t1 values (1e+100),(1e-100),(-1e+100);
 
353
Warnings:
 
354
Warning 1264    Out of range value for column 'a' at row 1
 
355
Note    1265    Data truncated for column 'a' at row 2
 
356
Warning 1264    Out of range value for column 'a' at row 3
 
357
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
 
358
Warnings:
 
359
Note    1265    Data truncated for column 'a' at row 3
 
360
insert into t1 values (MID("987",1,2)),("987 "),("987.6e+2 ");
 
361
select * from t1;
 
362
a
 
363
0.00
 
364
0.00
 
365
0.00
 
366
1.00
 
367
1.00
 
368
-1.00
 
369
-0.10
 
370
0.10
 
371
0.10
 
372
1.00
 
373
1.00
 
374
-1.00
 
375
99999999.99
 
376
99999999.99
 
377
-11111111.11
 
378
-99999999.99
 
379
99999999.99
 
380
99999999.99
 
381
99999999.99
 
382
0.00
 
383
-99999999.99
 
384
123.40
 
385
12340.00
 
386
1.23
 
387
1230.00
 
388
123.00
 
389
98.00
 
390
987.00
 
391
98760.00
 
392
drop  table t1;
 
393
create table t1 (a decimal);
 
394
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
 
395
Warnings:
 
396
Warning 1264    Out of range value for column 'a' at row 1
 
397
Warning 1264    Out of range value for column 'a' at row 6
 
398
Warning 1264    Out of range value for column 'a' at row 7
 
399
select * from t1;
 
400
a
 
401
-9999999999
 
402
-1
 
403
1
 
404
1
 
405
1
 
406
9999999999
 
407
9999999999
 
408
drop  table t1;
 
409
create table t1 (a decimal unsigned);
 
410
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
 
411
Warnings:
 
412
Warning 1264    Out of range value for column 'a' at row 1
 
413
Warning 1264    Out of range value for column 'a' at row 2
 
414
Warning 1264    Out of range value for column 'a' at row 7
 
415
select * from t1;
 
416
a
 
417
0
 
418
0
 
419
1
 
420
1
 
421
1
 
422
1234567890
 
423
9999999999
 
424
drop  table t1;
 
425
create table t1 (a decimal zerofill);
 
426
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
 
427
Warnings:
 
428
Warning 1264    Out of range value for column 'a' at row 1
 
429
Warning 1264    Out of range value for column 'a' at row 2
 
430
Warning 1264    Out of range value for column 'a' at row 7
 
431
select * from t1;
 
432
a
 
433
0000000000
 
434
0000000000
 
435
0000000001
 
436
0000000001
 
437
0000000001
 
438
1234567890
 
439
9999999999
 
440
drop  table t1;
 
441
create table t1 (a decimal unsigned zerofill);
 
442
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
 
443
Warnings:
 
444
Warning 1264    Out of range value for column 'a' at row 1
 
445
Warning 1264    Out of range value for column 'a' at row 2
 
446
Warning 1264    Out of range value for column 'a' at row 7
 
447
select * from t1;
 
448
a
 
449
0000000000
 
450
0000000000
 
451
0000000001
 
452
0000000001
 
453
0000000001
 
454
1234567890
 
455
9999999999
 
456
drop  table t1;
 
457
create table t1(a decimal(10,0));
 
458
insert into t1 values ("1e4294967295");
 
459
Warnings:
 
460
Warning 1264    Out of range value for column 'a' at row 1
 
461
select * from t1;
 
462
a
 
463
9999999999
 
464
delete from t1;
 
465
insert into t1 values("1e4294967297");
 
466
Warnings:
 
467
Warning 1264    Out of range value for column 'a' at row 1
 
468
select * from t1;
 
469
a
 
470
9999999999
 
471
drop table t1;
 
472
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
 
473
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,0))' at line 1
 
474
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
 
475
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2,1))' at line 1
 
476
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
 
477
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,1))' at line 1
 
478
CREATE TABLE t1 (a_dec DECIMAL(0,11));
 
479
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'a_dec').
 
480
create table t1(a decimal(7,3));
 
481
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
 
482
select * from t1;
 
483
a
 
484
1.000
 
485
1.000
 
486
-1.000
 
487
1.000
 
488
1.000
 
489
-1.000
 
490
10.000
 
491
10.000
 
492
-10.000
 
493
10.000
 
494
10.000
 
495
-10.000
 
496
100.000
 
497
100.000
 
498
-100.000
 
499
100.000
 
500
100.000
 
501
-100.000
 
502
1000.000
 
503
1000.000
 
504
-1000.000
 
505
1000.000
 
506
1000.000
 
507
-1000.000
 
508
9999.999
 
509
9999.999
 
510
-9999.999
 
511
9999.999
 
512
9999.999
 
513
-9999.999
 
514
9999.999
 
515
9999.999
 
516
-9999.999
 
517
9999.999
 
518
9999.999
 
519
-9999.999
 
520
9999.999
 
521
9999.999
 
522
-9999.999
 
523
9999.999
 
524
9999.999
 
525
-9999.999
 
526
9999.999
 
527
9999.999
 
528
-9999.999
 
529
9999.999
 
530
9999.999
 
531
-9999.999
 
532
9999.999
 
533
9999.999
 
534
-9999.999
 
535
9999.999
 
536
9999.999
 
537
-9999.999
 
538
9999.999
 
539
9999.999
 
540
-9999.999
 
541
9999.999
 
542
9999.999
 
543
-9999.999
 
544
drop table t1;
 
545
create table t1(a decimal(7,3) unsigned);
 
546
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
 
547
select * from t1;
 
548
a
 
549
1.000
 
550
1.000
 
551
0.000
 
552
1.000
 
553
1.000
 
554
0.000
 
555
10.000
 
556
10.000
 
557
0.000
 
558
10.000
 
559
10.000
 
560
0.000
 
561
100.000
 
562
100.000
 
563
0.000
 
564
100.000
 
565
100.000
 
566
0.000
 
567
1000.000
 
568
1000.000
 
569
0.000
 
570
1000.000
 
571
1000.000
 
572
0.000
 
573
9999.999
 
574
9999.999
 
575
0.000
 
576
9999.999
 
577
9999.999
 
578
0.000
 
579
9999.999
 
580
9999.999
 
581
0.000
 
582
9999.999
 
583
9999.999
 
584
0.000
 
585
9999.999
 
586
9999.999
 
587
0.000
 
588
9999.999
 
589
9999.999
 
590
0.000
 
591
9999.999
 
592
9999.999
 
593
0.000
 
594
9999.999
 
595
9999.999
 
596
0.000
 
597
9999.999
 
598
9999.999
 
599
0.000
 
600
9999.999
 
601
9999.999
 
602
0.000
 
603
9999.999
 
604
9999.999
 
605
0.000
 
606
9999.999
 
607
9999.999
 
608
0.000
 
609
drop table t1;
 
610
create table t1(a decimal(7,3) zerofill);
 
611
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
 
612
select * from t1;
 
613
a
 
614
0001.000
 
615
0001.000
 
616
0000.000
 
617
0001.000
 
618
0001.000
 
619
0000.000
 
620
0010.000
 
621
0010.000
 
622
0000.000
 
623
0010.000
 
624
0010.000
 
625
0000.000
 
626
0100.000
 
627
0100.000
 
628
0000.000
 
629
0100.000
 
630
0100.000
 
631
0000.000
 
632
1000.000
 
633
1000.000
 
634
0000.000
 
635
1000.000
 
636
1000.000
 
637
0000.000
 
638
9999.999
 
639
9999.999
 
640
0000.000
 
641
9999.999
 
642
9999.999
 
643
0000.000
 
644
9999.999
 
645
9999.999
 
646
0000.000
 
647
9999.999
 
648
9999.999
 
649
0000.000
 
650
9999.999
 
651
9999.999
 
652
0000.000
 
653
9999.999
 
654
9999.999
 
655
0000.000
 
656
9999.999
 
657
9999.999
 
658
0000.000
 
659
9999.999
 
660
9999.999
 
661
0000.000
 
662
9999.999
 
663
9999.999
 
664
0000.000
 
665
9999.999
 
666
9999.999
 
667
0000.000
 
668
9999.999
 
669
9999.999
 
670
0000.000
 
671
9999.999
 
672
9999.999
 
673
0000.000
 
674
drop table t1;
 
675
create table t1(a decimal(10,5), b decimal(10,1));
 
676
insert into t1 values(123.12345, 123.12345);
 
677
Warnings:
 
678
Note    1265    Data truncated for column 'b' at row 1
 
679
update t1 set b=a;
 
680
Warnings:
 
681
Note    1265    Data truncated for column 'b' at row 1
 
682
select * from t1;
 
683
a       b
 
684
123.12345       123.1
 
685
drop table t1;
 
686
End of 4.1 tests
 
687
CREATE TABLE t1
 
688
(EMPNUM   CHAR(3) NOT NULL,
 
689
HOURS    DECIMAL(5));
 
690
CREATE TABLE t2
 
691
(EMPNUM   CHAR(3) NOT NULL,
 
692
HOURS    BIGINT);
 
693
INSERT INTO t1 VALUES ('E1',40);
 
694
INSERT INTO t1 VALUES ('E8',NULL);
 
695
INSERT INTO t2 VALUES ('E1',40);
 
696
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t2);
 
697
EMPNUM
 
698
E1
 
699
SELECT EMPNUM FROM t1 WHERE HOURS IN (SELECT HOURS FROM t1);
 
700
EMPNUM
 
701
E1
 
702
DROP TABLE t1,t2;
 
703
create table t1 (d decimal(64,0));
 
704
insert into t1 values (1);
 
705
select * from t1;
 
706
d
 
707
1
 
708
drop table t1;
 
709
create table t1 (d decimal(5));
 
710
show create table t1;
 
711
Table   Create Table
 
712
t1      CREATE TABLE `t1` (
 
713
  `d` decimal(5,0) DEFAULT NULL
 
714
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
715
drop table t1;
 
716
create table t1 (d decimal);
 
717
show create table t1;
 
718
Table   Create Table
 
719
t1      CREATE TABLE `t1` (
 
720
  `d` decimal(10,0) DEFAULT NULL
 
721
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
722
drop table t1;
 
723
create table t1 (d decimal(66,0));
 
724
ERROR 42000: Too big precision 66 specified for column 'd'. Maximum is 65.
 
725
CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2));
 
726
INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00),
 
727
(2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
 
728
(2, 30.40, 30.40), (3, 37.00, 7.40), (3, -29.60, 0.00),
 
729
(4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00),
 
730
(5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20),
 
731
(6, 0.00, 0.00), (6, -51.40, 0.00);
 
732
SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b;
 
733
i       a       b
 
734
6       -51.40  0.00
 
735
SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i
 
736
HAVING a <> b;
 
737
i       a       b
 
738
6       -51.40  0.00
 
739
drop table t1;
 
740
create table t1 (c1 varchar(100), c2 longtext);
 
741
insert into t1 set c1= 'non PS, 1.0 as constant', c2=1.0;
 
742
prepare stmt from "insert into t1 set c1='PS, 1.0 as constant    ', c2=1.0";
 
743
execute stmt;
 
744
set @a=1.0;
 
745
insert into t1 set c1='non PS, 1.0 in parameter', c2=@a;
 
746
prepare stmt from "insert into t1 set c1='PS, 1.0 in parameter    ', c2=?";
 
747
execute stmt using @a;
 
748
select * from t1;
 
749
c1      c2
 
750
non PS, 1.0 as constant 1.0
 
751
PS, 1.0 as constant     1.0
 
752
non PS, 1.0 in parameter        1.0
 
753
PS, 1.0 in parameter            1.0
 
754
deallocate prepare stmt;
 
755
drop table t1;
 
756
create table t1 (
 
757
strippedproductid char(15) not null default '',
 
758
zlevelprice decimal(10,2) default null,
 
759
primary key (strippedproductid)
 
760
);
 
761
create table t2 (
 
762
productid char(15) not null default '',
 
763
zlevelprice char(21) default null,
 
764
primary key (productid)
 
765
);
 
766
insert into t1 values ('002trans','49.99');
 
767
insert into t1 values ('003trans','39.98');
 
768
insert into t1 values ('004trans','31.18');
 
769
insert INTO t2 SELECT * FROM t1;
 
770
select * from t2;
 
771
productid       zlevelprice
 
772
002trans        49.99
 
773
003trans        39.98
 
774
004trans        31.18
 
775
drop table t1, t2;
 
776
create table t1 (f1 decimal(5));
 
777
insert into t1 values (40);
 
778
flush tables;
 
779
select f1 from t1 where f1 in (select f1 from t1);
 
780
f1
 
781
40
 
782
drop table t1;
 
783
create table t1 as
 
784
select from_days(s) as date,t
 
785
from (select 1 as s,'t' as t union select null, null ) as sub1;
 
786
select group_concat(t) from t1 group by week(date)/10;
 
787
group_concat(t)
 
788
t
 
789
drop table t1;
 
790
CREATE TABLE t1 (
 
791
qty decimal(16,6) default NULL, 
 
792
dps tinyint(3) unsigned default NULL 
 
793
);
 
794
INSERT INTO t1 VALUES (1.1325,3);
 
795
SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
 
796
ROUND(qty,3)    dps     ROUND(qty,dps)
 
797
1.133   3       1.133000
 
798
DROP TABLE t1;
 
799
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
 
800
%
 
801
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
 
802
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
 
803
MOD()
 
804
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
 
805
create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill);
 
806
insert into t1 values (-0.123456,0.123456);
 
807
select group_concat(f1),group_concat(f2) from t1;
 
808
group_concat(f1)        group_concat(f2)
 
809
-0.123456       0.123456
 
810
drop table t1;
 
811
create table t1 (
 
812
ua_id decimal(22,0) not null,
 
813
ua_invited_by_id decimal(22,0) default NULL,
 
814
primary key(ua_id)
 
815
);
 
816
insert into t1 values (123, NULL), (456, NULL);
 
817
this must not produce error 1048: 
 
818
select * from t1 where ua_invited_by_id not in (select ua_id from t1);
 
819
ua_id   ua_invited_by_id
 
820
drop table t1;
 
821
DROP TABLE IF EXISTS t3;
 
822
DROP TABLE IF EXISTS t4;
 
823
CREATE TABLE t1( a NUMERIC, b INT );
 
824
INSERT INTO t1 VALUES (123456, 40), (123456, 40);
 
825
SELECT TRUNCATE( a, b ) AS c FROM t1 ORDER BY c;
 
826
c
 
827
123456
 
828
123456
 
829
SELECT ROUND( a, b ) AS c FROM t1 ORDER BY c;
 
830
c
 
831
123456
 
832
123456
 
833
SELECT ROUND( a, 100 ) AS c FROM t1 ORDER BY c;
 
834
c
 
835
123456.000000000000000000000000000000
 
836
123456.000000000000000000000000000000
 
837
CREATE TABLE t2( a NUMERIC, b INT );
 
838
INSERT INTO t2 VALUES (123456, 100);
 
839
SELECT TRUNCATE( a, b ) AS c FROM t2 ORDER BY c;
 
840
c
 
841
123456
 
842
SELECT ROUND( a, b ) AS c FROM t2 ORDER BY c;
 
843
c
 
844
123456
 
845
CREATE TABLE t3( a DECIMAL, b INT );
 
846
INSERT INTO t3 VALUES (123456, 40), (123456, 40);
 
847
SELECT TRUNCATE( a, b ) AS c FROM t3 ORDER BY c;
 
848
c
 
849
123456
 
850
123456
 
851
SELECT ROUND( a, b ) AS c FROM t3 ORDER BY c;
 
852
c
 
853
123456
 
854
123456
 
855
SELECT ROUND( a, 100 ) AS c FROM t3 ORDER BY c;
 
856
c
 
857
123456.000000000000000000000000000000
 
858
123456.000000000000000000000000000000
 
859
CREATE TABLE t4( a DECIMAL, b INT );
 
860
INSERT INTO t4 VALUES (123456, 40), (123456, 40);
 
861
SELECT TRUNCATE( a, b ) AS c FROM t4 ORDER BY c;
 
862
c
 
863
123456
 
864
123456
 
865
SELECT ROUND( a, b ) AS c FROM t4 ORDER BY c;
 
866
c
 
867
123456
 
868
123456
 
869
SELECT ROUND( a, 100 ) AS c FROM t4 ORDER BY c;
 
870
c
 
871
123456.000000000000000000000000000000
 
872
123456.000000000000000000000000000000
 
873
delete from t1;
 
874
INSERT INTO t1 VALUES (1234567890, 20), (999.99, 5);
 
875
Warnings:
 
876
Note    1265    Data truncated for column 'a' at row 2
 
877
show create table t1;
 
878
Table   Create Table
 
879
t1      CREATE TABLE `t1` (
 
880
  `a` decimal(10,0) DEFAULT NULL,
 
881
  `b` int(11) DEFAULT NULL
 
882
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
883
select round(a,b) as c from t1 order by c;
 
884
c
 
885
1000
 
886
1234567890
 
887
DROP TABLE t1, t2, t3, t4;
 
888
CREATE TABLE t1( a DECIMAL(4, 3), b INT );
 
889
INSERT INTO t1 VALUES ( 1, 5 ), ( 2, 4 ), ( 3, 3 ), ( 4, 2 ), ( 5, 1 );
 
890
SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c;
 
891
a       b       c
 
892
1.000   5       1.000
 
893
2.000   4       2.000
 
894
3.000   3       3.000
 
895
4.000   2       4.000
 
896
5.000   1       5.000
 
897
SELECT a, b, ROUND( a, b ) AS c FROM t1 ORDER BY c DESC;
 
898
a       b       c
 
899
5.000   1       5.000
 
900
4.000   2       4.000
 
901
3.000   3       3.000
 
902
2.000   4       2.000
 
903
1.000   5       1.000
 
904
CREATE TABLE t2 ( a INT, b INT, c DECIMAL(5, 4) );
 
905
INSERT INTO t2 VALUES ( 0, 1, 1.2345 ), ( 1, 2, 1.2345 ),
 
906
( 3, 3, 1.2345 ), ( 2, 4, 1.2345 );
 
907
SELECT a, b, MAX(ROUND(c, a)) 
 
908
FROM t2 
 
909
GROUP BY a, b 
 
910
ORDER BY b;
 
911
a       b       MAX(ROUND(c, a))
 
912
0       1       1.0000
 
913
1       2       1.2000
 
914
3       3       1.2350
 
915
2       4       1.2300
 
916
SELECT a, b, ROUND(c, a) 
 
917
FROM t2;
 
918
a       b       ROUND(c, a)
 
919
0       1       1.0000
 
920
1       2       1.2000
 
921
3       3       1.2350
 
922
2       4       1.2300
 
923
CREATE TABLE t3( a INT, b DECIMAL(6, 3) );
 
924
INSERT INTO t3 VALUES( 0, 1.5 );
 
925
SELECT ROUND( b, a ) FROM t3;
 
926
ROUND( b, a )
 
927
2.000
 
928
CREATE TABLE t4( a INT, b DECIMAL( 12, 0) );
 
929
INSERT INTO t4 VALUES( -9, 1.5e9 );
 
930
SELECT ROUND( b, a ) FROM t4;
 
931
ROUND( b, a )
 
932
2000000000
 
933
CREATE TABLE t5( a INT, b DECIMAL( 13, 12 ) );
 
934
INSERT INTO t5 VALUES( 0, 1.5 );
 
935
INSERT INTO t5 VALUES( 9, 1.5e-9 );
 
936
SELECT ROUND( b, a ) FROM t5;
 
937
ROUND( b, a )
 
938
2.000000000000
 
939
0.000000002000
 
940
CREATE TABLE t6( a INT );
 
941
INSERT INTO t6 VALUES( 6 / 8 );
 
942
SELECT * FROM t6;
 
943
a
 
944
1
 
945
SELECT ROUND(20061108085411.000002);
 
946
ROUND(20061108085411.000002)
 
947
20061108085411
 
948
DROP TABLE t1, t2, t3, t4, t5, t6;
 
949
create table t1(`c` decimal(9,2));
 
950
insert into t1 values (300),(201.11);
 
951
select max(case 1 when 1 then c else null end) from t1 group by c;
 
952
max(case 1 when 1 then c else null end)
 
953
201.11
 
954
300.00
 
955
drop table t1;
 
956
End of 5.0 tests