summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <hf@deer.mysql.r18.ru>2003-01-22 20:08:12 +0400
committerunknown <hf@deer.mysql.r18.ru>2003-01-22 20:08:12 +0400
commitc73e02756f3f08e1c1decd903aa7a1052ba231a3 (patch)
treee6c817b6f680cd04d4a4d3cbea3962d434941db7
parent96b86dcc9a1e87f01f73186308e8c35f6f900452 (diff)
downloadmariadb-git-c73e02756f3f08e1c1decd903aa7a1052ba231a3.tar.gz
SCRUM
DEFAULT in SELECT & UPDATE corrections mysql-test/r/replace.result: test slightly extended mysql-test/t/replace.test: test slightly extended with replace(default) sql/item.cc: DEFAULT_ITEM replaced sql/item.h: some modifications after talking with Sergey
-rw-r--r--mysql-test/r/replace.result6
-rw-r--r--mysql-test/t/replace.test5
-rw-r--r--sql/item.cc3
-rw-r--r--sql/item.h11
4 files changed, 12 insertions, 13 deletions
diff --git a/mysql-test/r/replace.result b/mysql-test/r/replace.result
index 0aa80e18ccc..4a71428b2f4 100644
--- a/mysql-test/r/replace.result
+++ b/mysql-test/r/replace.result
@@ -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;
diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test
index 7aeb2475ab5..2afce2fcc84 100644
--- a/mysql-test/t/replace.test
+++ b/mysql-test/t/replace.test
@@ -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;
diff --git a/sql/item.cc b/sql/item.cc
index 881e65310cf..1200ae7c951 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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);
diff --git a/sql/item.h b/sql/item.h
index 1881b15f6e5..ee68563d5cf 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -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