SCRUM
DEFAULT in SELECT & UPDATE corrections
This commit is contained in:
parent
87681bb85e
commit
e2d991795c
@ -12,15 +12,17 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1);
|
|||||||
alter table t1 type=heap;
|
alter table t1 type=heap;
|
||||||
replace into t1 (gesuchnr,benutzer_id) values (1,1);
|
replace into t1 (gesuchnr,benutzer_id) values (1,1);
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 (a tinyint not null auto_increment primary key, b char(20));
|
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
|
||||||
insert into t1 values (126,"first"),(0,"last");
|
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
|
||||||
insert into t1 values (0,"error");
|
insert into t1 values (0,"error");
|
||||||
Duplicate entry '127' for key 1
|
Duplicate entry '127' for key 1
|
||||||
replace into t1 values (0,"error");
|
replace into t1 values (0,"error");
|
||||||
Duplicate entry '127' for key 1
|
Duplicate entry '127' for key 1
|
||||||
replace into t1 values (126,"first updated");
|
replace into t1 values (126,"first updated");
|
||||||
|
replace into t1 values (63,default);
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b
|
a b
|
||||||
126 first updated
|
126 first updated
|
||||||
|
63 default_value
|
||||||
127 last
|
127 last
|
||||||
drop table t1;
|
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
|
# 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));
|
create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
|
||||||
insert into t1 values (126,"first"),(0,"last");
|
insert into t1 values (126,"first"),(63, "middle"),(0,"last");
|
||||||
--error 1062
|
--error 1062
|
||||||
insert into t1 values (0,"error");
|
insert into t1 values (0,"error");
|
||||||
--error 1062
|
--error 1062
|
||||||
replace into t1 values (0,"error");
|
replace into t1 values (0,"error");
|
||||||
replace into t1 values (126,"first updated");
|
replace into t1 values (126,"first updated");
|
||||||
|
replace into t1 values (63,default);
|
||||||
select * from t1;
|
select * from t1;
|
||||||
drop table 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
|
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);
|
((Item_default_value *)item)->arg->eq(arg, binary_cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1167,6 +1167,7 @@ void Item_default_value::print(String *str)
|
|||||||
if (!arg)
|
if (!arg)
|
||||||
{
|
{
|
||||||
str->append("DEFAULT");
|
str->append("DEFAULT");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
str->append("DEFAULT(");
|
str->append("DEFAULT(");
|
||||||
arg->print(str);
|
arg->print(str);
|
||||||
|
11
sql/item.h
11
sql/item.h
@ -33,7 +33,7 @@ public:
|
|||||||
|
|
||||||
enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
|
enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
|
||||||
INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_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,
|
PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM,
|
||||||
FIELD_VARIANCE_ITEM, CONST_ITEM,
|
FIELD_VARIANCE_ITEM, CONST_ITEM,
|
||||||
SUBSELECT_ITEM, ROW_ITEM, CACHE_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_field((const char *)NULL, (const char *)NULL, (const char *)NULL), arg(NULL) {}
|
||||||
Item_default_value(Item *a) :
|
Item_default_value(Item *a) :
|
||||||
Item_field((const char *)NULL, (const char *)NULL, (const char *)NULL), arg(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 eq(const Item *item, bool binary_cmp) const;
|
||||||
bool fix_fields(THD *, struct st_table_list *, Item **);
|
bool fix_fields(THD *, struct st_table_list *, Item **);
|
||||||
bool check_loop(uint id)
|
bool check_loop(uint id)
|
||||||
@ -682,12 +682,7 @@ public:
|
|||||||
}
|
}
|
||||||
return Item_field::save_in_field(field, no_conversions);
|
return Item_field::save_in_field(field, no_conversions);
|
||||||
}
|
}
|
||||||
table_map used_tables() const
|
table_map used_tables() const { return (table_map)0L; }
|
||||||
{
|
|
||||||
if (!arg)
|
|
||||||
return (table_map) 0L;
|
|
||||||
return Item_field::used_tables();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Item_cache: public Item
|
class Item_cache: public Item
|
||||||
|
Loading…
x
Reference in New Issue
Block a user