Commit e2d99179 authored by hf@deer.mysql.r18.ru's avatar hf@deer.mysql.r18.ru

SCRUM

DEFAULT in SELECT & UPDATE corrections
parent 87681bb8
......@@ -12,15 +12,17 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 type=heap;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
drop table t1;
create table t1 (a tinyint not null auto_increment primary key, b char(20));
insert into t1 values (126,"first"),(0,"last");
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
insert into t1 values (0,"error");
Duplicate entry '127' for key 1
replace into t1 values (0,"error");
Duplicate entry '127' for key 1
replace into t1 values (126,"first updated");
replace into t1 values (63,default);
select * from t1;
a b
126 first updated
63 default_value
127 last
drop table t1;
......@@ -27,12 +27,13 @@ drop table t1;
# Test when using replace on a key that has used up it's whole range
#
create table t1 (a tinyint not null auto_increment primary key, b char(20));
insert into t1 values (126,"first"),(0,"last");
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
--error 1062
insert into t1 values (0,"error");
--error 1062
replace into t1 values (0,"error");
replace into t1 values (126,"first updated");
replace into t1 values (63,default);
select * from t1;
drop table t1;
......@@ -1128,7 +1128,7 @@ bool Item_ref::check_loop(uint id)
bool Item_default_value::eq(const Item *item, bool binary_cmp) const
{
return item->type() == DEFAULT_ITEM &&
return item->type() == DEFAULT_VALUE_ITEM &&
((Item_default_value *)item)->arg->eq(arg, binary_cmp);
}
......@@ -1167,6 +1167,7 @@ void Item_default_value::print(String *str)
if (!arg)
{
str->append("DEFAULT");
return;
}
str->append("DEFAULT(");
arg->print(str);
......
......@@ -33,7 +33,7 @@ public:
enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_ITEM,
COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM,
PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM,
FIELD_VARIANCE_ITEM, CONST_ITEM,
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM};
......@@ -663,7 +663,7 @@ public:
Item_field((const char *)NULL, (const char *)NULL, (const char *)NULL), arg(NULL) {}
Item_default_value(Item *a) :
Item_field((const char *)NULL, (const char *)NULL, (const char *)NULL), arg(a) {}
enum Type type() const { return DEFAULT_ITEM; }
enum Type type() const { return DEFAULT_VALUE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, struct st_table_list *, Item **);
bool check_loop(uint id)
......@@ -682,12 +682,7 @@ public:
}
return Item_field::save_in_field(field, no_conversions);
}
table_map used_tables() const
{
if (!arg)
return (table_map) 0L;
return Item_field::used_tables();
}
table_map used_tables() const { return (table_map)0L; }
};
class Item_cache: public Item
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment