mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Setting a variable to CAST(NULL as X) set the result type of the variable to X. (Bug #6598)
mysql-test/r/bigint.result: Test to show show that the parser threats big longlong values as unsigned mysql-test/r/user_var.result: Test of CAST(NULL as SIGNED/UNSIGNED) mysql-test/t/bigint.test: Test to show show that the parser threats big longlong values as unsigned mysql-test/t/user_var.test: Test of CAST(NULL as SIGNED/UNSIGNED) sql/item_func.cc: Setting a variable to CAST(NULL as X) set the result type of the variable to X. (Bug #6598) Setting a variable to NULL doesn't change the old result type. sql/item_func.h: Detect setting a variable to NULL sql/unireg.cc: Safety fix
This commit is contained in:
@ -128,3 +128,20 @@ t2.value64=t1.value64;
|
||||
value64 value32 value64 value32
|
||||
9223372036854775807 2 9223372036854775807 4
|
||||
drop table t1, t2;
|
||||
create table t1 select 1 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(1) NOT NULL default '0'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 select 9223372036854775809 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bigint(19) unsigned NOT NULL default '0'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
a
|
||||
9223372036854775809
|
||||
drop table t1;
|
||||
|
@ -182,3 +182,44 @@ coercibility(@v1) coercibility(@v2) coercibility(@v3) coercibility(@v4)
|
||||
set session @honk=99;
|
||||
set one_shot @honk=99;
|
||||
ERROR HY000: The 'SET ONE_SHOT' syntax is reserved for purposes internal to the MySQL server
|
||||
set @first_var= NULL;
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`@first_var` longblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
set @first_var= cast(NULL as signed integer);
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`@first_var` bigint(20) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
set @first_var= NULL;
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`@first_var` bigint(20) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
set @first_var= concat(NULL);
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`@first_var` longblob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
set @first_var=1;
|
||||
set @first_var= cast(NULL as CHAR);
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`@first_var` longtext
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
|
@ -104,3 +104,13 @@ t2.value64=t1.value64;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# Test of CREATE ... SELECT and unsigned integers
|
||||
#
|
||||
create table t1 select 1 as 'a';
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
create table t1 select 9223372036854775809 as 'a';
|
||||
show create table t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
@ -119,3 +119,29 @@ select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
|
||||
set session @honk=99;
|
||||
--error 1382
|
||||
set one_shot @honk=99;
|
||||
|
||||
#
|
||||
# Bug #6598: problem with cast(NULL as signed integer);
|
||||
#
|
||||
|
||||
set @first_var= NULL;
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
set @first_var= cast(NULL as signed integer);
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
set @first_var= NULL;
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
set @first_var= concat(NULL);
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
set @first_var=1;
|
||||
set @first_var= cast(NULL as CHAR);
|
||||
create table t1 select @first_var;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user