summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2005-06-22 04:48:25 +0400
committerunknown <evgen@moonbone.local>2005-06-22 04:48:25 +0400
commit8fc03d970b24cd7bc61da98b8ff00033af27f809 (patch)
treee62ded7629b972fb7bcc1b0e172fc5147ff4c229
parent8f011afe0344f3500b4cfce4ea34be6dd5c7a0bc (diff)
parent401fa3cb4b47e2eee663058905a4430104c9b75f (diff)
downloadmariadb-git-8fc03d970b24cd7bc61da98b8ff00033af27f809.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into moonbone.local:/work/mysql-5.0-bug-11298 sql/item.cc: Auto merged sql/item.h: Auto merged mysql-test/r/view.result: SCCS merged mysql-test/t/view.test: SCCS merged
-rw-r--r--mysql-test/r/view.result14
-rw-r--r--mysql-test/t/view.test13
-rw-r--r--sql/item.cc22
-rw-r--r--sql/item.h3
4 files changed, 50 insertions, 2 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 8d1b8757a3e..cf3a1739710 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -1757,6 +1757,20 @@ select * from v1;
cast(1 as decimal)
1.00
drop view v1;
+create table t1(f1 int);
+create table t2(f2 int);
+insert into t1 values(1),(2),(3);
+insert into t2 values(1),(2),(3);
+create view v1 as select * from t1,t2 where f1=f2;
+create table t3 (f1 int, f2 int);
+insert into t3 select * from v1 order by 1;
+select * from t3;
+f1 f2
+1 1
+2 2
+3 3
+drop view v1;
+drop table t1,t2,t3;
create view v1 as select '\\','\\shazam';
select * from v1;
\ \shazam
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index b2d54b51d2d..c97813e39ff 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1599,6 +1599,19 @@ drop table t1;
create view v1 as select cast(1 as decimal);
select * from v1;
drop view v1;
+#
+# Bug#11298 insert into select from VIEW produces incorrect result when
+# using ORDER BY
+create table t1(f1 int);
+create table t2(f2 int);
+insert into t1 values(1),(2),(3);
+insert into t2 values(1),(2),(3);
+create view v1 as select * from t1,t2 where f1=f2;
+create table t3 (f1 int, f2 int);
+insert into t3 select * from v1 order by 1;
+select * from t3;
+drop view v1;
+drop table t1,t2,t3;
#
# Generation unique names for columns, and correct names check (BUG#7448)
diff --git a/sql/item.cc b/sql/item.cc
index 58033af14ae..e645d0db945 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4361,6 +4361,28 @@ my_decimal *Item_ref::val_decimal(my_decimal *decimal_value)
return val;
}
+int Item_ref::save_in_field(Field *to, bool no_conversions)
+{
+ int res;
+ if(result_field){
+ if (result_field->is_null())
+ {
+ null_value= 1;
+ return set_field_to_null_with_conversions(to, no_conversions);
+ }
+ else
+ {
+ to->set_notnull();
+ field_conv(to, result_field);
+ null_value= 0;
+ }
+ return 0;
+ }
+ res= (*ref)->save_in_field(to, no_conversions);
+ null_value= (*ref)->null_value;
+ return res;
+}
+
void Item_ref_null_helper::print(String *str)
{
diff --git a/sql/item.h b/sql/item.h
index 219bbe2d59c..c912ad3f0a7 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1345,8 +1345,7 @@ public:
bool send(Protocol *prot, String *tmp);
void make_field(Send_field *field) { (*ref)->make_field(field); }
bool fix_fields(THD *, struct st_table_list *, Item **);
- int save_in_field(Field *field, bool no_conversions)
- { return (*ref)->save_in_field(field, no_conversions); }
+ int save_in_field(Field *field, bool no_conversions);
void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); }
enum Item_result result_type () const { return (*ref)->result_type(); }
enum_field_types field_type() const { return (*ref)->field_type(); }