Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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@stripped, 2007-11-17 23:01:35+04:00, gshchepa@stripped +3 -0
Fixed bug #32335.
Comparison of a BIGINT NOT NULL column with a constant arithmetical
expression containing NULL leaded to the error 1048: Column '...'
cannot be null.
Order of the constant expression evaluation during query preparation
has been modified to check an expression result for NULL value _before_
conversion to the target column type, because that type may be declared
as NOT NULL.
mysql-test/r/select.result@stripped, 2007-11-17 22:59:36+04:00, gshchepa@stripped +6 -0
Added test case for bug #32335.
mysql-test/t/select.test@stripped, 2007-11-17 22:59:36+04:00, gshchepa@stripped +11 -0
Added test case for bug #32335.
sql/item_cmpfunc.cc@stripped, 2007-11-17 22:59:35+04:00, gshchepa@stripped +15 -13
Fixed bug #32335.
1. The convert_constant_item function has been modified to determine
nullness of constant expression before storing to a field, because
the target field may be declared as NOT NULL.
2. Also minor bug has been fixed: the thd->count_cuted_fields value
was not restored in case of successful conversion.
diff -Nrup a/mysql-test/r/select.result b/mysql-test/r/select.result
--- a/mysql-test/r/select.result 2007-11-14 17:26:21 +04:00
+++ b/mysql-test/r/select.result 2007-11-17 22:59:36 +04:00
@@ -4322,4 +4322,10 @@ c3
DROP TABLE t1;
DROP TABLE t2;
+CREATE TABLE t1 (c1 BIGINT NOT NULL);
+INSERT INTO t1 (c1) VALUES (1);
+SELECT * FROM t1 WHERE c1 > NULL + 1;
+c1
+DROP TABLE t1;
+
End of 5.0 tests
diff -Nrup a/mysql-test/t/select.test b/mysql-test/t/select.test
--- a/mysql-test/t/select.test 2007-11-14 18:56:12 +04:00
+++ b/mysql-test/t/select.test 2007-11-17 22:59:36 +04:00
@@ -3661,4 +3661,15 @@ DROP TABLE t2;
###########################################################################
+#
+# Bug #32335: Error on BIGINT > NULL + 1
+#
+
+CREATE TABLE t1 (c1 BIGINT NOT NULL);
+INSERT INTO t1 (c1) VALUES (1);
+SELECT * FROM t1 WHERE c1 > NULL + 1;
+DROP TABLE t1;
+
+--echo
+
--echo End of 5.0 tests
diff -Nrup a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
--- a/sql/item_cmpfunc.cc 2007-11-10 23:58:21 +04:00
+++ b/sql/item_cmpfunc.cc 2007-11-17 22:59:35 +04:00
@@ -24,7 +24,7 @@
#include <m_ctype.h>
#include "sql_select.h"
-static bool convert_constant_item(THD *thd, Field *field, Item **item);
+static bool convert_constant_item(THD *thd, Item_field *field, Item **item);
static Item_result item_store_type(Item_result a, Item *item,
my_bool unsigned_flag)
@@ -340,7 +340,7 @@ longlong Item_func_nop_all::val_int()
1 Item was replaced with an integer version of the item
*/
-static bool convert_constant_item(THD *thd, Field *field, Item **item)
+static bool convert_constant_item(THD *thd, Item_field *field, Item **item)
{
if (!(*item)->with_subselect && (*item)->const_item())
{
@@ -350,11 +350,13 @@ static bool convert_constant_item(THD *t
thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
MODE_INVALID_DATES;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
- if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
+ if (!(*item)->is_null() && !(*item)->save_in_field(field->field, 1))
{
- Item *tmp=new Item_int_with_ref(field->val_int(), *item,
- test(field->flags & UNSIGNED_FLAG));
+ Item *tmp=new Item_int_with_ref(field->field->val_int(), *item,
+ test(field->field->flags &
+ UNSIGNED_FLAG));
thd->variables.sql_mode= orig_sql_mode;
+ thd->count_cuted_fields= orig_count_cuted_fields;
if (tmp)
thd->change_item_tree(item, tmp);
return 1; // Item was replaced
@@ -413,8 +415,8 @@ void Item_bool_func2::fix_length_and_dec
Item *arg_real_item= args[0]->real_item();
if (arg_real_item->type() == FIELD_ITEM)
{
- Field *field=((Item_field*) arg_real_item)->field;
- if (field->can_be_compared_as_longlong() &&
+ Item_field *field= (Item_field*) arg_real_item;
+ if (field->field->can_be_compared_as_longlong() &&
!(arg_real_item->is_datetime() &&
args[1]->result_type() == STRING_RESULT))
{
@@ -430,8 +432,8 @@ void Item_bool_func2::fix_length_and_dec
arg_real_item= args[1]->real_item();
if (arg_real_item->type() == FIELD_ITEM)
{
- Field *field=((Item_field*) arg_real_item)->field;
- if (field->can_be_compared_as_longlong() &&
+ Item_field *field= (Item_field*) arg_real_item;
+ if (field->field->can_be_compared_as_longlong() &&
!(arg_real_item->is_datetime() &&
args[0]->result_type() == STRING_RESULT))
{
@@ -1888,8 +1890,8 @@ void Item_func_between::fix_length_and_d
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
{
- Field *field=((Item_field*) (args[0]->real_item()))->field;
- if (field->can_be_compared_as_longlong())
+ Item_field *field= (Item_field*) (args[0]->real_item());
+ if (field->field->can_be_compared_as_longlong())
{
/*
The following can't be recoded with || as convert_constant_item
@@ -3490,8 +3492,8 @@ void Item_func_in::fix_length_and_dec()
thd->lex->sql_command != SQLCOM_SHOW_CREATE &&
cmp_type != INT_RESULT)
{
- Field *field= ((Item_field*) (args[0]->real_item()))->field;
- if (field->can_be_compared_as_longlong())
+ Item_field *field= (Item_field*) (args[0]->real_item());
+ if (field->field->can_be_compared_as_longlong())
{
bool all_converted= TRUE;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
| Thread |
|---|
| • bk commit into 5.0 tree (gshchepa:1.2566) BUG#32335 | gshchepa | 17 Nov |