diff options
author | unknown <bell@sanja.is.com.ua> | 2004-08-24 20:29:44 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-08-24 20:29:44 +0300 |
commit | 52b735a1a2ddd54ec265844c54690ea846dbcaa8 (patch) | |
tree | 9feb289b2fcf8651750a54b3ee08c6bd1b5cc2ca | |
parent | 964955b1c0c85c460efa4bbd757848d5e042b37d (diff) | |
download | mariadb-git-52b735a1a2ddd54ec265844c54690ea846dbcaa8.tar.gz |
fixed aggregate function processing in VIEWs (BUG#4665)
mysql-test/r/view.result:
Aggregate functions in view list
mysql-test/t/view.test:
Aggregate functions in view list
sql/table.cc:
fixed aggregate function processing in VIEWs
-rw-r--r-- | mysql-test/r/view.result | 9 | ||||
-rw-r--r-- | mysql-test/t/view.test | 11 | ||||
-rw-r--r-- | sql/table.cc | 7 |
3 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 059b8d4cf70..87d64a69e49 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1074,3 +1074,12 @@ s1 s2 2 3 drop view v1; drop tables t1, t2; +create table t1 (col1 int); +insert into t1 values (1); +create view v1 as select count(*) from t1; +insert into t1 values (null); +select * from v1; +count(*) +2 +drop view v1; +drop table t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 805d033c525..0cc403c5dfd 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1016,3 +1016,14 @@ create view v1 as select * from t1,t2 union all select * from t1,t2; select * from v1; drop view v1; drop tables t1, t2; + +# +# Aggregate functions in view list +# +create table t1 (col1 int); +insert into t1 values (1); +create view v1 as select count(*) from t1; +insert into t1 values (null); +select * from v1; +drop view v1; +drop table t1; diff --git a/sql/table.cc b/sql/table.cc index 097dc8aabf6..a1e1faa36a6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1506,6 +1506,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds) uint i= 0; bool save_set_query_id= thd->set_query_id; bool save_wrapper= thd->lex->select_lex.no_wrap_view_item; + bool save_allow_sum_func= thd->allow_sum_func; DBUG_ENTER("st_table_list::setup_ancestor"); if (ancestor->ancestor && @@ -1525,6 +1526,8 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds) uint want_privilege= ancestor->table->grant.want_privilege; /* real rights will be checked in VIEW field */ ancestor->table->grant.want_privilege= 0; + /* aggregate function are allowed */ + thd->allow_sum_func= 1; if (!(*i)->fixed && (*i)->fix_fields(thd, ancestor, i)) goto err; ancestor->table->grant.want_privilege= want_privilege; @@ -1558,6 +1561,8 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds) uint want_privilege= ancestor->table->grant.want_privilege; /* real rights will be checked in VIEW field */ ancestor->table->grant.want_privilege= 0; + /* aggregate function are allowed */ + thd->allow_sum_func= 1; if (!item->fixed && item->fix_fields(thd, ancestor, &item)) { goto err; @@ -1602,6 +1607,7 @@ ok: thd->lex->select_lex.no_wrap_view_item= save_wrapper; thd->lex->current_select= current_select_save; thd->set_query_id= save_set_query_id; + thd->allow_sum_func= save_allow_sum_func; DBUG_RETURN(0); err: @@ -1614,6 +1620,7 @@ err: thd->lex->select_lex.no_wrap_view_item= save_wrapper; thd->lex->current_select= current_select_save; thd->set_query_id= save_set_query_id; + thd->allow_sum_func= save_allow_sum_func; DBUG_RETURN(1); } |