Below is the list of changes that have just been committed into a local
5.0 repository of monty. When monty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1904 05/04/30 03:14:42 monty@stripped +7 -0
Setting a variable to CAST(NULL as X) set the result type of the variable to X. (Bug
#6598)
sql/unireg.cc
1.54 05/04/30 03:14:38 monty@stripped +5 -2
Safety fix
sql/item_func.h
1.108 05/04/30 03:14:38 monty@stripped +1 -0
Detect setting a variable to NULL
sql/item_func.cc
1.183 05/04/30 03:14:38 monty@stripped +11 -4
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.
mysql-test/t/user_var.test
1.28 05/04/30 03:14:38 monty@stripped +26 -0
Test of CAST(NULL as SIGNED/UNSIGNED)
mysql-test/t/bigint.test
1.23 05/04/30 03:14:38 monty@stripped +10 -0
Test to show show that the parser threats big longlong values as unsigned
mysql-test/r/user_var.result
1.33 05/04/30 03:14:38 monty@stripped +41 -0
Test of CAST(NULL as SIGNED/UNSIGNED)
mysql-test/r/bigint.result
1.27 05/04/30 03:14:38 monty@stripped +17 -0
Test to show show that the parser threats big longlong values as unsigned
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: monty
# Host: narttu.mysql.com
# Root: /home/my/mysql-5.0
--- 1.182/sql/item_func.cc 2005-04-27 17:00:22 +03:00
+++ 1.183/sql/item_func.cc 2005-04-30 03:14:38 +03:00
@@ -3271,7 +3271,8 @@
from the argument if the argument is NULL
and the variable has previously been initialized.
*/
- if (!entry->collation.collation || !args[0]->null_value)
+ null_item= (args[0]->type() == NULL_ITEM);
+ if (!entry->collation.collation || !null_item)
entry->collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT);
collation.set(entry->collation.collation, DERIVATION_IMPLICIT);
cached_result_type= args[0]->result_type();
@@ -3315,8 +3316,8 @@
char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
if (entry->value && entry->value != pos)
my_free(entry->value,MYF(0));
- entry->value=0;
- entry->length=0;
+ entry->value= 0;
+ entry->length= 0;
}
else
{
@@ -3355,9 +3356,9 @@
if (type == DECIMAL_RESULT)
((my_decimal*)entry->value)->fix_buffer_pointer();
entry->length= length;
- entry->type=type;
entry->collation.set(cs, dv);
}
+ entry->type=type;
return 0;
}
@@ -3366,6 +3367,12 @@
Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type,
CHARSET_INFO *cs, Derivation dv)
{
+ /*
+ If we set a variable explicitely to NULL then keep the old
+ result type of the variable
+ */
+ if ((null_value= args[0]->null_value) && null_item)
+ type= entry->type; // Don't change type of item
if (::update_hash(entry, (null_value= args[0]->null_value),
ptr, length, type, cs, dv))
{
--- 1.107/sql/item_func.h 2005-04-27 14:54:36 +03:00
+++ 1.108/sql/item_func.h 2005-04-30 03:14:38 +03:00
@@ -1071,6 +1071,7 @@
char buffer[MAX_FIELD_WIDTH];
String value;
my_decimal decimal_buff;
+ bool null_item;
union
{
longlong vint;
--- 1.53/sql/unireg.cc 2005-04-05 11:40:28 +03:00
+++ 1.54/sql/unireg.cc 2005-04-30 03:14:38 +03:00
@@ -685,6 +685,9 @@
thd->count_cuted_fields= CHECK_FIELD_WARN; // To find wrong default values
while ((field=it++))
{
+ /*
+ regfield don't have to be deleted as it's allocated with sql_alloc()
+ */
Field *regfield=make_field((char*) buff+field->offset,field->length,
null_pos,
null_count & 7,
@@ -696,7 +699,8 @@
field->interval,
field->field_name,
&table);
- DBUG_ASSERT(regfield);
+ if (!regfield)
+ goto err; // End of memory
if (!(field->flags & NOT_NULL_FLAG))
null_count++;
@@ -730,7 +734,6 @@
regfield->store(ER(ER_NO), (uint) strlen(ER(ER_NO)),system_charset_info);
else
regfield->reset();
- delete regfield;
}
/* Fill not used startpos */
--- 1.26/mysql-test/r/bigint.result 2005-04-01 15:04:43 +03:00
+++ 1.27/mysql-test/r/bigint.result 2005-04-30 03:14:38 +03:00
@@ -128,3 +128,20 @@
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;
--- 1.22/mysql-test/t/bigint.test 2005-02-28 22:50:02 +02:00
+++ 1.23/mysql-test/t/bigint.test 2005-04-30 03:14:38 +03:00
@@ -104,3 +104,13 @@
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;
--- 1.32/mysql-test/r/user_var.result 2005-04-07 00:12:01 +03:00
+++ 1.33/mysql-test/r/user_var.result 2005-04-30 03:14:38 +03:00
@@ -182,3 +182,44 @@
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;
--- 1.27/mysql-test/t/user_var.test 2005-04-07 00:12:01 +03:00
+++ 1.28/mysql-test/t/user_var.test 2005-04-30 03:14:38 +03:00
@@ -119,3 +119,29 @@
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;
| Thread |
|---|
| • bk commit into 5.0 tree (monty:1.1904) BUG#6598 | monty | 30 Apr |