diff options
author | unknown <kaa@kaamos.(none)> | 2008-02-14 12:48:25 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-02-14 12:48:25 +0300 |
commit | c4fc5b096e582f23bac8bc14cb93f6ade63f476f (patch) | |
tree | ca9c65e3e64cff12692b4d0d2a97491755672946 | |
parent | be891fc6117a78345b7ca888dc23e02438d69f4e (diff) | |
parent | c6610b57912ba010acf9ead06095309bf71f7c96 (diff) | |
download | mariadb-git-c4fc5b096e582f23bac8bc14cb93f6ade63f476f.tar.gz |
Merge ssh://bk-internal.mysql.com//home/bk/mysql-5.0-opt
into kaamos.(none):/data/src/opt/mysql-5.0-opt
-rw-r--r-- | mysql-test/r/view.result | 16 | ||||
-rw-r--r-- | mysql-test/t/view.test | 22 | ||||
-rw-r--r-- | sql/item.cc | 24 |
3 files changed, 50 insertions, 12 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index fb36304e562..f7f6debee6e 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3618,4 +3618,20 @@ ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default val set @@sql_mode=@old_mode; drop view v1; drop table t1; +create table t1 (a int, key(a)); +create table t2 (c int); +create view v1 as select a b from t1; +create view v2 as select 1 a from t2, v1 where c in +(select 1 from t1 where b = a); +insert into t1 values (1), (1); +insert into t2 values (1), (1); +prepare stmt from "select * from v2 where a = 1"; +execute stmt; +a +1 +1 +1 +1 +drop view v1, v2; +drop table t1, t2; End of 5.0 tests. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 340a34db5a1..b321f8604f7 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3470,5 +3470,27 @@ insert into v1 values(1); set @@sql_mode=@old_mode; drop view v1; drop table t1; + +# +# Bug #33389: Selecting from a view into a table from within SP or trigger +# crashes server +# + +create table t1 (a int, key(a)); +create table t2 (c int); + +create view v1 as select a b from t1; +create view v2 as select 1 a from t2, v1 where c in + (select 1 from t1 where b = a); + +insert into t1 values (1), (1); +insert into t2 values (1), (1); + +prepare stmt from "select * from v2 where a = 1"; +execute stmt; + +drop view v1, v2; +drop table t1, t2; + --echo End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index 182632bb40f..6b008f7dbb9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3903,6 +3903,18 @@ bool Item_field::fix_fields(THD *thd, Item **reference) else if (!from_field) goto error; + if (!outer_fixed && cached_table && cached_table->select_lex && + context->select_lex && + cached_table->select_lex != context->select_lex) + { + int ret; + if ((ret= fix_outer_field(thd, &from_field, reference)) < 0) + goto error; + else if (!ret) + return FALSE; + outer_fixed= 1; + } + /* if it is not expression from merged VIEW we will set this field. @@ -3918,18 +3930,6 @@ bool Item_field::fix_fields(THD *thd, Item **reference) if (from_field == view_ref_found) return FALSE; - if (!outer_fixed && cached_table && cached_table->select_lex && - context->select_lex && - cached_table->select_lex != context->select_lex) - { - int ret; - if ((ret= fix_outer_field(thd, &from_field, reference)) < 0) - goto error; - else if (!ret) - return FALSE; - outer_fixed= 1; - } - set_field(from_field); if (thd->lex->in_sum_func && thd->lex->in_sum_func->nest_level == |