Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-10-23 11:51:45+04:00, kostja@stripped +10 -0
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into bodhi.local:/opt/local/work/mysql-5.0-runtime-merge
MERGE: 1.2277.1.12
mysql-test/r/view.result@stripped, 2006-10-23 11:51:41+04:00, kostja@stripped +0 -2
Manual merge.
MERGE: 1.178.1.4
mysql-test/t/func_gconcat.test@stripped, 2006-10-23 11:50:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.46.1.1
mysql-test/t/view.test@stripped, 2006-10-23 11:51:42+04:00, kostja@stripped +0 -2
Manual merge.
MERGE: 1.166.1.2
sql/item_func.cc@stripped, 2006-10-23 11:50:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.307.1.1
sql/sql_base.cc@stripped, 2006-10-23 11:50:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.353.1.4
sql/sql_insert.cc@stripped, 2006-10-23 11:50:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.203.1.2
sql/sql_lex.cc@stripped, 2006-10-23 11:50:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.201.1.1
sql/sql_lex.h@stripped, 2006-10-23 11:50:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.228.1.1
sql/sql_select.cc@stripped, 2006-10-23 11:50:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.458.7.1
sql/sql_update.cc@stripped, 2006-10-23 11:50:47+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.200.1.1
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: kostja
# Host: bodhi.local
# Root: /opt/local/work/mysql-5.0-runtime-merge/RESYNC
--- 1.354/sql/sql_base.cc 2006-10-23 11:51:54 +04:00
+++ 1.355/sql/sql_base.cc 2006-10-23 11:51:54 +04:00
@@ -3455,13 +3455,20 @@ find_item_in_list(Item *find, List<Item>
const char *field_name=0;
const char *table_name=0;
bool found_unaliased_non_uniq= 0;
+ /*
+ true if the item that we search for is a valid name reference
+ (and not an item that happens to have a name).
+ */
+ bool is_ref_by_name= 0;
uint unaliased_counter;
LINT_INIT(unaliased_counter); // Dependent on found_unaliased
*unaliased= FALSE;
- if (find->type() == Item::FIELD_ITEM || find->type() == Item::REF_ITEM)
+ is_ref_by_name= (find->type() == Item::FIELD_ITEM ||
+ find->type() == Item::REF_ITEM);
+ if (is_ref_by_name)
{
field_name= ((Item_ident*) find)->field_name;
table_name= ((Item_ident*) find)->table_name;
@@ -3573,7 +3580,7 @@ find_item_in_list(Item *find, List<Item>
}
}
else if (!table_name && (find->eq(item,0) ||
- find->name && item->name &&
+ is_ref_by_name && find->name && item->name &&
!my_strcasecmp(system_charset_info,
item->name,find->name)))
{
@@ -4904,6 +4911,7 @@ int setup_conds(THD *thd, TABLE_LIST *ta
thd->set_query_id=1;
select_lex->cond_count= 0;
+ select_lex->between_count= 0;
for (table= tables; table; table= table->next_local)
{
--- 1.202/sql/sql_lex.cc 2006-10-23 11:51:54 +04:00
+++ 1.203/sql/sql_lex.cc 2006-10-23 11:51:54 +04:00
@@ -1137,7 +1137,7 @@ void st_select_lex::init_query()
initialization is checked for failure.
*/
parent_lex->push_context(&context);
- cond_count= with_wild= 0;
+ cond_count= between_count= with_wild= 0;
conds_processed_with_permanent_arena= 0;
ref_pointer_array= 0;
select_n_having_items= 0;
--- 1.229/sql/sql_lex.h 2006-10-23 11:51:54 +04:00
+++ 1.230/sql/sql_lex.h 2006-10-23 11:51:54 +04:00
@@ -530,7 +530,8 @@ public:
list during split_sum_func
*/
uint select_n_having_items;
- uint cond_count; /* number of arguments of and/or/xor in where/having */
+ uint cond_count; /* number of arguments of and/or/xor in where/having/on */
+ uint between_count; /* number of between predicates in where/having/on */
enum_parsing_place parsing_place; /* where we are parsing expression */
bool with_sum_func; /* sum function indicator */
/*
--- 1.201/sql/sql_update.cc 2006-10-23 11:51:54 +04:00
+++ 1.202/sql/sql_update.cc 2006-10-23 11:51:54 +04:00
@@ -311,7 +311,7 @@ int mysql_update(THD *thd,
table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
MYF(MY_FAE | MY_ZEROFILL));
- if (!(sortorder=make_unireg_sortorder(order, &length)) ||
+ if (!(sortorder=make_unireg_sortorder(order, &length, NULL)) ||
(table->sort.found_records = filesort(thd, table, sortorder, length,
select, limit,
&examined_rows))
--- 1.180/mysql-test/r/view.result 2006-10-23 11:51:54 +04:00
+++ 1.181/mysql-test/r/view.result 2006-10-23 11:51:54 +04:00
@@ -12,6 +12,9 @@ create table t1 (a int, b int);
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
create view v1 (c,d) as select a,b+@@global.max_user_connections from t1;
ERROR HY000: View's SELECT contains a variable or parameter
+create view v1 (c,d) as select a,b from t1
+where a = @@global.max_user_connections;
+ERROR HY000: View's SELECT contains a variable or parameter
create view v1 (c) as select b+1 from t1;
select c from v1;
c
@@ -596,11 +599,6 @@ ERROR HY000: View 'test.v1' references i
drop view v1;
create view v1 (a,a) as select 'a','a';
ERROR 42S21: Duplicate column name 'a'
-drop procedure if exists p1;
-create procedure p1 () begin declare v int; create view v1 as select v; end;//
-call p1();
-ERROR HY000: View's SELECT contains a variable or parameter
-drop procedure p1;
create table t1 (col1 int,col2 char(22));
insert into t1 values(5,'Hello, world of views');
create view v1 as select * from t1;
@@ -886,6 +884,8 @@ ERROR HY000: View's SELECT contains a 'I
create table t1 (a int);
create view v1 as select a from t1 procedure analyse();
ERROR HY000: View's SELECT contains a 'PROCEDURE' clause
+create view v1 as select 1 from (select 1) as d1;
+ERROR HY000: View's SELECT contains a subquery in the FROM clause
drop table t1;
create table t1 (s1 int, primary key (s1));
create view v1 as select * from t1;
@@ -2956,6 +2956,18 @@ View Create View
v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS
select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver`
= (select max(`t`.`ver`) AS `MAX(t.ver)` from `t2` `t` where (`t`.`org` = `t2`.`org`))))))
DROP VIEW v1;
DROP TABLE t1, t2;
+DROP FUNCTION IF EXISTS f1;
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+CREATE VIEW v1 AS SELECT MAX(i) FROM t1;
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+SET NEW.i = (SELECT * FROM v1) + 1;
+INSERT INTO t1 VALUES (1);
+CREATE FUNCTION f1() RETURNS INT RETURN (SELECT * FROM v1);
+UPDATE t1 SET i= f1();
+DROP FUNCTION f1;
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT
NULL);
CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK
OPTION;
INSERT INTO v1 (val) VALUES (2);
--- 1.167/mysql-test/t/view.test 2006-10-23 11:51:54 +04:00
+++ 1.168/mysql-test/t/view.test 2006-10-23 11:51:54 +04:00
@@ -23,8 +23,11 @@ create table t1 (a int, b int);
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
# view with variable
--- error 1351
+-- error ER_VIEW_SELECT_VARIABLE
create view v1 (c,d) as select a,b+@@global.max_user_connections from t1;
+-- error ER_VIEW_SELECT_VARIABLE
+create view v1 (c,d) as select a,b from t1
+ where a = @@global.max_user_connections;
# simple view
create view v1 (c) as select b+1 from t1;
@@ -487,19 +490,6 @@ drop view v1;
create view v1 (a,a) as select 'a','a';
#
-# SP variables inside view test
-#
---disable_warnings
-drop procedure if exists p1;
---enable_warnings
-delimiter //;
-create procedure p1 () begin declare v int; create view v1 as select v; end;//
-delimiter ;//
--- error 1351
-call p1();
-drop procedure p1;
-
-#
# updatablity should be transitive
#
create table t1 (col1 int,col2 char(22));
@@ -820,6 +810,8 @@ create view v1 as select 5 into outfile
create table t1 (a int);
-- error 1350
create view v1 as select a from t1 procedure analyse();
+-- error ER_VIEW_SELECT_DERIVED
+create view v1 as select 1 from (select 1) as d1;
drop table t1;
#
@@ -2597,6 +2589,7 @@ SELECT * FROM t2;
DROP VIEW v1;
DROP TABLE t1,t2;
+
#
# Bug#16110: insert permitted into view col w/o default value
#
@@ -2879,6 +2872,40 @@ SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1, t2;
+
+
+#
+# Bug#19111: TRIGGERs selecting from a VIEW on the firing base table
+# fail
+#
+# Allow to select from a view on a table being modified in a trigger
+# and stored function, since plain select is allowed there.
+#
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1);
+
+CREATE VIEW v1 AS SELECT MAX(i) FROM t1;
+
+# Plain 'SET NEW.i = (SELECT MAX(i) FROM t1) + 1' works, so select
+# from a view should work too.
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+ SET NEW.i = (SELECT * FROM v1) + 1;
+INSERT INTO t1 VALUES (1);
+
+# Plain 'RETURN (SELECT MAX(i) FROM t1)' works in INSERT, so select
+# from a view should work too.
+CREATE FUNCTION f1() RETURNS INT RETURN (SELECT * FROM v1);
+UPDATE t1 SET i= f1();
+
+DROP FUNCTION f1;
+DROP VIEW v1;
+DROP TABLE t1;
#
# Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
--- 1.47/mysql-test/t/func_gconcat.test 2006-10-23 11:51:54 +04:00
+++ 1.48/mysql-test/t/func_gconcat.test 2006-10-23 11:51:54 +04:00
@@ -32,7 +32,6 @@ select grp,group_concat(d order by a des
select grp,group_concat(a order by a,d+c-ascii(c)-a) from t1 group by grp;
select grp,group_concat(a order by d+c-ascii(c),a) from t1 group by grp;
select grp,group_concat(c order by 1) from t1 group by grp;
-select grp,group_concat(c order by "c") from t1 group by grp;
select grp,group_concat(distinct c order by c) from t1 group by grp;
select grp,group_concat(distinct c order by c desc) from t1 group by grp;
explain extended select grp,group_concat(distinct c order by c desc) from t1 group by
grp;
| Thread |
|---|
| • bk commit into 5.0 tree (kostja:1.2291) | konstantin | 23 Oct |