⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type_newdecimal.test

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 TEST
📖 第 1 页 / 共 2 页
字号:
#select .7777777777777777777777777777777777777 *       1000000000000000000;#-- should return 777777777777777777.7777777777777777777 #select .7777777777777777777777777777777777777 - 0.1;#-- should return .6777777777777777777777777777777777777 #select .343434343434343434 + .343434343434343434;#-- should return .686868686868686868 ##-- 5. All arithmetic functions mentioned in the#MySQL Reference Manual should work.#select abs(9999999999999999999999);#-- should return 9999999999999999999999#select abs(-9999999999999999999999);#-- should return 9999999999999999999999#select ceiling(999999999999999999);select ceiling(99999999999999999999);#-- should return 99999999999999999999#select ceiling(9.9999999999999999999);#-- should return 10#select ceiling(-9.9999999999999999999);#-- should return 9#select floor(999999999999999999);select floor(9999999999999999999999);#-- should return 9999999999999999999999#select floor(9.999999999999999999999);#-- should return 9#select floor(-9.999999999999999999999);#-- should return -10#select floor(-999999999999999999999.999);select ceiling(999999999999999999999.999);##select 99999999999999999999999999999999999999 mod 3;#-- should return 0#select round(99999999999999999.999);#-- should return 100000000000000000#select round(-99999999999999999.999);#-- should return -100000000000000000#select round(99999999999999999.999,3);#-- should return 100000000000000000.000#select round(-99999999999999999.999,3);#-- should return -100000000000000000.000#select truncate(99999999999999999999999999999999999999,31);#-- should return 99999999999999999999999999999999999999.000#select truncate(99.999999999999999999999999999999999999,31);#-- should return 99.9999999999999999999999999999999#select truncate(99999999999999999999999999999999999999,-31);-- should return 90000000000000000000000000000000##-- 6. Set functions (AVG, SUM, COUNT) should work.##drop table if exists t1;##delimiter //##create procedure p1 () begin #  declare v1 int default 1; declare v2 decimal(0,38) default 0; #  create table t1 (col1 decimal(0,38)); #  while v1 <= 10000 do #    insert into t1 values (-v2); #    set v2 = v2 + 0.00000000000000000000000000000000000001; #    set v1 = v1 + 1; #  end while;#  select avg(col1),sum(col1),count(col1) from t1; end;//##call p1()//#-- should return#   -- avg(col1)=0.00000000000000000000000000000000000001 added 10,000 times, then divided by 10,000#   -- sum(col1)=0.00000000000000000000000000000000000001 added 10,000 times##   -- count(col1)=10000##delimiter ;//##drop procedure p1;#drop table t1;##-- When I say DECIMAL(x) I should be able to store x digits.#-- If I can't, there should be an error at CREATE time.##drop table if exists t1;##create table t1 (col1 decimal(254));#-- should return SQLSTATE 22003 numeric value out of range ##-- When I say DECIMAL(x,y) there should be no silent change of precision or#-- scale.##drop table if exists t1;##create table t1 (col1 decimal(0,38));##show create table t1;#-- should return:#+-------+--------------------------------+#| Table | Create Table                   |#+-------+--------------------------------+#| t9    | CREATE TABLE `t1` (            |#|`s1` decimal(0,38) default NULL         |#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |#+-------+--------------------------------+##drop table t1;##-- From WL#1612 "The future" point 2.:#-- The standard requires that we treat numbers like "0.5" as#-- DECIMAL or NUMERIC, not as floating-point.##drop table if exists t1;##create table t1 as select 0.5;#show create table t1;#-- should return:#+-------+-----------------------------------+#| Table | Create Table                      |#+-------+-----------------------------------+#| t7 | CREATE TABLE `t1` (                  |#| `0.5` decimal(3,1) NOT NULL default '0.0' |#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1    |#+-------+-----------------------------------+#drop table t1;##-- From WL#1612, "The future", point 3.: We have to start rounding correctly.#select round(1.5),round(2.5);#-- should return:#+------------+------------+#| round(1.5) | round(2.5) |#+------------+------------+#| 2          | 3          |#+------------+------------+##-- From WL#1612, "The future", point 4.: "select 0.07 * 0.07;" should return 0.0049, not 0.00.#-- If operand#1 has scale X and operand#2 has scale Y, then result should have scale (X+Y).#select 0.07 * 0.07;#-- should return 0.0049##-- From WL#1612, "The future", point 5.: Division by zero is an error.#set sql_mode='traditional';#select 1E-500 = 0;#-- should return 1 (true).#select 1 / 1E-500;##-- should return SQLSTATE 22012 division by zero.#select 1 / 0;#-- should return SQLSTATE 22012 division by zero.##+-------+#| 1 / 0 |#+-------+#| NULL  |#+-------+#1 row in set, 1 warning (0.00 sec)##-- From WL#1612 "The future" point 6.: Overflow is an error.##set sql_mode='';##select 1E300 * 1E300;#-- should return SQLSTATE 22003 numeric value out of range ##select 18446744073709551615 + 1;#-- should return SQLSTATE 22003 numeric value out of range ##-- 14. From WL#1612 "The future" point 7.:#-- If s1 is INTEGER and s2 is DECIMAL, then#-- "create table tk7 as select avg(s1),avg(s2) from tk;"#-- should not create a table with "double(17,4)" data types.#-- The result of AVG must still be exact numeric, with a#-- scale the same or greater than the operand's scale.#-- The result of SUM must still be exact numeric, with#-- a scale the same as the operand's scale.##drop table if exists t1;#drop table if exists t2;##create table t1 (col1 int, col2 decimal(5));##create table t2 as select avg(col1),avg(col2) from t1;###show create table t2;#-- should return:#+-------+---------------------------------+#| Table | Create Table                    |#+-------+---------------------------------+#| t2    | CREATE TABLE `t2` (             |#| `avg(col1)` decimal(17,4) default NULL, |#| `avg(col2)` decimal(17,5) default NULL  |#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1  |#+-------+---------------------------------+##drop table t2;#drop table t1;##-- From WL#1612 "The future" point 8.: Stop storing leading "+" signs and#   leading "0"s.##drop table if exists t1;##create table t1 (col1 decimal(5,2),col2 decimal(5) zerofill, col3 decimal(3,1));##insert into t1 values (1,1,1);##select col1 from t1 union select col2 from t1 union select col3 from t1;##drop table t1;##-- From WL#1612, The future" point 9.:#-- Accept the data type and precision and scale as the user#-- asks, or return an error, but don't change to something else.##drop table if exists t1;##create table t1 (col1 numeric(4,2));##show create table t1;##drop table t1;##-- The scripts in the following bugs should work:##BUG#559  Maximum precision for DECIMAL column ...#BUG#1499 INSERT/UPDATE into decimal field rounding problem#BUG#1845 Not correctly recognising value for decimal field#BUG#2493 Round function doesn't work correctly#BUG#2649 round(0.5) gives 0 (should be 1)#BUG#3612 impicite rounding of VARCHARS during aritchmetic operations...#BUG#3722 SELECT fails for certain values in Double(255,10) column.#BUG#4485 Floating point conversions are inconsistent#BUG#4891 MATH#BUG#5931 Out-of-range values are accepted#BUG#6048 Stored procedure causes operating system reboot#BUG#6053 DOUBLE PRECISION literal-- Tests from 'traditional' mode tests#set sql_mode='ansi,traditional';#CREATE TABLE Sow6_2f (col1 NUMERIC(4,2));#-- should return OKINSERT INTO Sow6_2f VALUES (10.55);#-- should return OKINSERT INTO Sow6_2f VALUES (10.5555);#-- should return OKINSERT INTO Sow6_2f VALUES (-10.55);#-- should return OKINSERT INTO Sow6_2f VALUES (-10.5555);#-- should return OKINSERT INTO Sow6_2f VALUES (11);#-- should return OK-- error 1264INSERT INTO Sow6_2f VALUES (101.55);#-- should return SQLSTATE 22003 numeric value out of range-- error 1264UPDATE Sow6_2f SET col1 = col1 * 50 WHERE col1 = 11;#-- should return SQLSTATE 22003 numeric value out of range-- error 1365UPDATE Sow6_2f SET col1 = col1 / 0 WHERE col1 > 0;#-- should return SQLSTATE 22012 division by zeroSELECT MOD(col1,0) FROM Sow6_2f;#-- should return SQLSTATE 22012 division by zero-- error 1366INSERT INTO Sow6_2f VALUES ('a59b');#-- should return SQLSTATE 22018 invalid character value for castdrop table Sow6_2f;## bug#9501#select 10.3330000000000/12.34500000;## Bug #10404#set sql_mode='';select 0/0;## bug #9546#--disable_ps_protocolselect 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 as x;select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;--enable_ps_protocol## Bug #10004#select 0.190287977636363637 + 0.040372670 * 0 -  0;## Bug #9527#select -0.123 * 0;## Bug #10232#CREATE TABLE t1 (f1 DECIMAL (12,9), f2 DECIMAL(2,2));INSERT INTO t1 VALUES (10.5, 0);UPDATE t1 SET f1 = 4.5;SELECT * FROM t1;DROP TABLE t1;CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2));INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0);SELECT * FROM t1;DROP TABLE t1;## Bug #10599: problem with NULL#select abs(10/0);select abs(NULL);## Bug #9894 (negative to unsigned column)#set @@sql_mode='traditional';create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned);--error 1264insert into t1 values(1,-1,-1);drop table t1;create table t1 (col1 decimal(5,2), col2 numeric(5,2));--error 1264insert into t1 values (999.999,999.999);--error 1264insert into t1 values (-999.999,-999.999);select * from t1;drop table t1;set sql_mode='';## Bug #8425 (insufficient precision of the division)#set @sav_dpi= @@div_precision_increment;set @@div_precision_increment=15;create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25));insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345);select col2/9999999999 from t1 where col1=1;select 9999999999/col2 from t1 where col1=1;select 77777777/7777777;drop table t1;set div_precision_increment= @sav_dpi;## Bug #10896 (0.00 > -0.00)#create table t1 (a decimal(4,2));insert into t1 values (0.00);select * from t1 where a > -0.00;select * from t1 where a = -0.00;drop table t1;## Bug #11215: a problem with LONGLONG_MIN#create table t1 (col1 bigint default -9223372036854775808);insert into t1 values (default);select * from t1;drop table t1;## Bug #10891 (converting to decimal crashes server)#select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));## Bug #11708 (conversion to decimal fails in decimal part)#select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;## Bug #8449 (Silent column changes)#--error 1426create table t1 (sl decimal(70,30));--error 1425create table t1 (sl decimal(32,31));--error 1425create table t1 (sl decimal(0,38));--error 1427create table t1 (sl decimal(0,30));create table t1 (sl decimal(5, 5));show create table t1;drop table t1;# Test limitscreate table t1 (sl decimal(65, 30));show create table t1;drop table t1;## Bug 11557 (DEFAULT values rounded improperly#create table t1 (       f1 decimal unsigned not null default 17.49,        f2 decimal unsigned not null default 17.68,        f3 decimal unsigned not null default 99.2,        f4 decimal unsigned not null default 99.7,        f5 decimal unsigned not null default 104.49,        f6 decimal unsigned not null default 199.91,        f7 decimal unsigned not null default 999.9,        f8 decimal unsigned not null default 9999.99);insert into t1 (f1) values (1);select * from t1;drop table t1;## Bug 12173 (show create table fails)#create table t1 (        f0 decimal (30,30) zerofill not null DEFAULT 0,        f1 decimal (0,0) zerofill not null default 0);show create table t1;drop table t1;## Bug 12938 (arithmetic loop's zero)#--disable-warningsdrop procedure if exists wg2;--enable-warningsdelimiter //;create procedure wg2()begin  declare v int default 1;  declare tdec decimal(5) default 0;  while v <= 9 do set tdec =tdec * 10;    select v, tdec;    set v = v + 1;  end while;end//call wg2()//delimiter ;//drop procedure wg2;## Bug #12979 Stored procedures: crash if inout decimal parameter# (not a SP bug in fact)#select cast(@non_existing_user_var/2 as DECIMAL);## Bug #13667 (Inconsistency for decimal(m,d) specification#--error 1427create table t (d decimal(0,10));## Bug #14268 (bad FLOAT->DECIMAL conversion)#CREATE TABLE t1 (   my_float   FLOAT,   my_double  DOUBLE,   my_varchar VARCHAR(50),   my_decimal DECIMAL(65,30));SHOW CREATE TABLE t1;let $max_power= 32;while ($max_power){   eval INSERT INTO t1 SET my_float = 1.175494345e-$max_power,                           my_double = 1.175494345e-$max_power,                           my_varchar = '1.175494345e-$max_power';   dec $max_power;}SELECT my_float, my_double, my_varchar FROM t1;# Expected result   0.000000000011754943372854760000# On windows we get 0.000000000011754943372854770000# use replace_result to correct it--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000SELECT CAST(my_float   AS DECIMAL(65,30)), my_float FROM t1;SELECT CAST(my_double  AS DECIMAL(65,30)), my_double FROM t1;SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;# We have to disable warnings here as the test in# Field_new_decimal::store(double):# if (nr2 != nr)# fails randomly depending on compiler options--disable_warningsUPDATE t1 SET my_decimal = my_float;# Expected result   0.000000000011754943372854760000# On windows we get 0.000000000011754943372854770000# use replace_result to correct it--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000SELECT my_decimal, my_float   FROM t1;UPDATE t1 SET my_decimal = my_double;SELECT my_decimal, my_double  FROM t1;--enable_warningsUPDATE t1 SET my_decimal = my_varchar;SELECT my_decimal, my_varchar FROM t1;DROP TABLE t1;## Bug #13573 (Wrong data inserted for too big values)#create table t1 (c1 decimal(64));--disable_ps_protocolinsert into t1 values(89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);insert into t1 values(99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);--enable_ps_protocolinsert into t1 values(1e100);select * from t1;drop table t1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -