mirror of
https://github.com/MariaDB/server.git
synced 2025-05-05 16:59:35 +03:00
CAST() now produces warnings when casting a wrong INTEGER or CHAR values. This also applies to implicite string to number casts. (Bug #5912) ALTER TABLE now fails in STRICT mode if it generates warnings. Inserting a zero date in a DATE, DATETIME or TIMESTAMP column during TRADITIONAL mode now produces an error. (Bug #5933) mysql-test/r/bigint.result: New warning added mysql-test/r/cast.result: Added testing of wrong CAST's of strings to numbers and numbers to strings mysql-test/r/create.result: Added test for wrong default values (#5902) mysql-test/r/func_if.result: Changed tests to produce less warnings mysql-test/r/func_misc.result: New warning mysql-test/r/func_str.result: Added missing drop table Changed test to produce less warnings New warnings mysql-test/r/ndb_index_unique.result: Removed wrong default usage mysql-test/r/ps_1general.result: Changed tests to produce less warnings mysql-test/r/row.result: New warnings mysql-test/r/rpl_session_var.result: Changed tests to produce less warnings mysql-test/r/strict.result: New tests for CAST() and zero date handling mysql-test/r/subselect.result: Changed tests to produce less warnings mysql-test/r/type_ranges.result: Changed tests to produce less warnings mysql-test/t/cast.test: Added testing of wrong CAST's of strings to numbers and numbers to strings mysql-test/t/create.test: Added test for wrong default values (#5902) mysql-test/t/func_if.test: Changed tests to produce less warnings mysql-test/t/func_str.test: Added missing drop table Changed test to produce less warnings New warnings mysql-test/t/ndb_index_unique.test: Removed wrong default usage mysql-test/t/ps_1general.test: Changed tests to produce less warnings mysql-test/t/rpl_session_var.test: Changed tests to produce less warnings mysql-test/t/strict.test: New tests for CAST() and zero date handling mysql-test/t/subselect.test: Changed tests to produce less warnings mysql-test/t/type_ranges.test: Changed tests to produce less warnings sql/Makefile.am: Added new include file sql/field.cc: Added warnings for zero dates for DATE, DATETIME and TIMESTAMP Moved Field_blob::max_length() to a more appropriate position Changed type for 'level' in set_warning() to avoid casts sql/field.h: Changed type for 'level' in set_warning() to avoid casts sql/field_conv.cc: Copy date and datetime fields through string in 'traditional' mode to detect zero dates sql/item.cc: Removed compiler warnings Give warnings for wrong CAST of strings -> number sql/item.h: Moved Item_string::val_real() and ::val_int() to item.cc sql/item_row.cc: Better detection of null values (which doesn't produce warnings) sql/item_sum.cc: Better detection of null values (which doesn't produce warnings) sql/item_timefunc.cc: Give warnings for wrong CAST of number -> string sql/my_decimal.cc: Fixed typo in comment sql/mysql_priv.h: Removed prototype for static function Moved defines for error handling to sql_error.h (to be able to use these in field.h) sql/mysqld.cc: Simplify code sql/sql_class.h: Moved to sql_error.h sql/sql_load.cc: Removed wrong cast sql/sql_parse.cc: Fixed wrong printf() sql/sql_table.cc: Made mysql_prepare_table() static Changed references to pointers to make code more readable ALTER TABLE now aborts if one gets warnings in STRICT mode sql/time.cc: Fixed possible wrong call sql/unireg.cc: Removed one call to current_thd Give errors if one uses a wrong DEFAULT value
131 lines
4.5 KiB
Plaintext
131 lines
4.5 KiB
Plaintext
drop table if exists t1;
|
|
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
|
|
0 256 00000000000000065536 2147483647 -2147483648 2147483648 4294967296
|
|
0 256 65536 2147483647 -2147483648 2147483648 4294967296
|
|
select 9223372036854775807,-009223372036854775808;
|
|
9223372036854775807 -009223372036854775808
|
|
9223372036854775807 -9223372036854775808
|
|
select +9999999999999999999,-9999999999999999999;
|
|
9999999999999999999 -9999999999999999999
|
|
9999999999999999999 -9999999999999999999
|
|
select cast(9223372036854775808 as unsigned)+1;
|
|
cast(9223372036854775808 as unsigned)+1
|
|
9223372036854775809
|
|
select 9223372036854775808+1;
|
|
9223372036854775808+1
|
|
9223372036854775809
|
|
select -(0-3),round(-(0-3)), round(9999999999999999999);
|
|
-(0-3) round(-(0-3)) round(9999999999999999999)
|
|
3 3 9999999999999999999
|
|
create table t1 (a bigint unsigned not null, primary key(a));
|
|
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
|
|
select * from t1;
|
|
a
|
|
18446744073709551612
|
|
18446744073709551613
|
|
18446744073709551614
|
|
18446744073709551615
|
|
select * from t1 where a=18446744073709551615;
|
|
a
|
|
18446744073709551615
|
|
delete from t1 where a=18446744073709551615;
|
|
select * from t1;
|
|
a
|
|
18446744073709551612
|
|
18446744073709551613
|
|
18446744073709551614
|
|
drop table t1;
|
|
create table t1 ( a int not null default 1, big bigint );
|
|
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
|
|
select min(big),max(big),max(big)-1 from t1;
|
|
min(big) max(big) max(big)-1
|
|
-1 9223372036854775807 9223372036854775806
|
|
select min(big),max(big),max(big)-1 from t1 group by a;
|
|
min(big) max(big) max(big)-1
|
|
-1 9223372036854775807 9223372036854775806
|
|
alter table t1 modify big bigint unsigned not null;
|
|
select min(big),max(big),max(big)-1 from t1;
|
|
min(big) max(big) max(big)-1
|
|
12345678901234567 18446744073709551615 18446744073709551614
|
|
select min(big),max(big),max(big)-1 from t1 group by a;
|
|
min(big) max(big) max(big)-1
|
|
12345678901234567 18446744073709551615 18446744073709551614
|
|
alter table t1 add key (big);
|
|
select min(big),max(big),max(big)-1 from t1;
|
|
min(big) max(big) max(big)-1
|
|
12345678901234567 18446744073709551615 18446744073709551614
|
|
select min(big),max(big),max(big)-1 from t1 group by a;
|
|
min(big) max(big) max(big)-1
|
|
12345678901234567 18446744073709551615 18446744073709551614
|
|
alter table t1 modify big bigint not null;
|
|
select min(big),max(big),max(big)-1 from t1;
|
|
min(big) max(big) max(big)-1
|
|
-1 9223372036854775807 9223372036854775806
|
|
select min(big),max(big),max(big)-1 from t1 group by a;
|
|
min(big) max(big) max(big)-1
|
|
-1 9223372036854775807 9223372036854775806
|
|
drop table t1;
|
|
create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
|
|
insert into t1 values (null,1);
|
|
select * from t1;
|
|
id a
|
|
9999999999 1
|
|
select * from t1 limit 9999999999;
|
|
id a
|
|
9999999999 1
|
|
drop table t1;
|
|
CREATE TABLE t1 ( quantity decimal(60,0));
|
|
insert into t1 values (10000000000000000000);
|
|
insert into t1 values (10000000000000000000.0);
|
|
insert into t1 values ('10000000000000000000');
|
|
select * from t1;
|
|
quantity
|
|
-8446744073709551616
|
|
10000000000000000000
|
|
10000000000000000000
|
|
drop table t1;
|
|
SELECT '0x8000000000000001'+0;
|
|
'0x8000000000000001'+0
|
|
0
|
|
Warnings:
|
|
Warning 1292 Truncated incorrect DOUBLE value: '0x8000000000000001'
|
|
create table t1 (
|
|
value64 bigint unsigned not null,
|
|
value32 integer not null,
|
|
primary key(value64, value32)
|
|
);
|
|
create table t2 (
|
|
value64 bigint unsigned not null,
|
|
value32 integer not null,
|
|
primary key(value64, value32)
|
|
);
|
|
insert into t1 values(17156792991891826145, 1);
|
|
insert into t1 values( 9223372036854775807, 2);
|
|
insert into t2 values(17156792991891826145, 3);
|
|
insert into t2 values( 9223372036854775807, 4);
|
|
select * from t1;
|
|
value64 value32
|
|
9223372036854775807 2
|
|
17156792991891826145 1
|
|
select * from t2;
|
|
value64 value32
|
|
9223372036854775807 4
|
|
17156792991891826145 3
|
|
select * from t1, t2 where t1.value64=17156792991891826145 and
|
|
t2.value64=17156792991891826145;
|
|
value64 value32 value64 value32
|
|
17156792991891826145 1 17156792991891826145 3
|
|
select * from t1, t2 where t1.value64=17156792991891826145 and
|
|
t2.value64=t1.value64;
|
|
value64 value32 value64 value32
|
|
17156792991891826145 1 17156792991891826145 3
|
|
select * from t1, t2 where t1.value64= 9223372036854775807 and
|
|
t2.value64=9223372036854775807;
|
|
value64 value32 value64 value32
|
|
9223372036854775807 2 9223372036854775807 4
|
|
select * from t1, t2 where t1.value64= 9223372036854775807 and
|
|
t2.value64=t1.value64;
|
|
value64 value32 value64 value32
|
|
9223372036854775807 2 9223372036854775807 4
|
|
drop table t1, t2;
|