Below is the list of changes that have just been committed into a local
5.1 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:47:59+04:00, kostja@stripped +20 -0
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge
MERGE: 1.2273.125.9
mysql-test/r/ps.result@stripped, 2006-10-23 11:17:43+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.77.1.1
mysql-test/r/view.result@stripped, 2006-10-23 11:47:54+04:00, kostja@stripped +2 -3
Manual merge.
MERGE: 1.182.1.4
mysql-test/t/func_gconcat.test@stripped, 2006-10-23 11:17:43+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.48.1.1
mysql-test/t/ps.test@stripped, 2006-10-23 11:17:44+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.74.1.1
mysql-test/t/view.test@stripped, 2006-10-23 11:47:54+04:00, kostja@stripped +2 -3
Manual merge.
MERGE: 1.165.1.3
sql/item_func.cc@stripped, 2006-10-23 11:17:44+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.320.1.1
sql/item_func.h@stripped, 2006-10-23 11:17:44+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.140.6.1
sql/log_event.cc@stripped, 2006-10-23 11:17:44+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.245.1.1
sql/mysql_priv.h@stripped, 2006-10-23 11:17:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.448.1.5
sql/set_var.cc@stripped, 2006-10-23 11:17:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.192.1.1
sql/sql_base.cc@stripped, 2006-10-23 11:17:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.355.1.1
sql/sql_class.h@stripped, 2006-10-23 11:17:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.320.2.1
sql/sql_insert.cc@stripped, 2006-10-23 11:17:45+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.230.2.1
sql/sql_lex.cc@stripped, 2006-10-23 11:17:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.200.1.1
sql/sql_lex.h@stripped, 2006-10-23 11:17:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.244.1.1
sql/sql_select.cc@stripped, 2006-10-23 11:17:46+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.452.2.1
sql/sql_update.cc@stripped, 2006-10-23 11:17:47+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.209.1.1
sql/sql_view.cc@stripped, 2006-10-23 11:17:47+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.101.4.8
sql/sql_yacc.yy@stripped, 2006-10-23 11:17:47+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.507.1.1
tests/mysql_client_test.c@stripped, 2006-10-23 11:17:48+04:00, kostja@stripped +0 -0
Auto merged
MERGE: 1.216.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.1-runtime-merge/RESYNC
--- 1.450/sql/mysql_priv.h 2006-10-23 11:48:11 +04:00
+++ 1.451/sql/mysql_priv.h 2006-10-23 11:48:11 +04:00
@@ -150,7 +150,7 @@ MY_LOCALE *my_locale_by_name(const char
Feel free to raise this by the smallest amount you can to get the
"execution_constants" test to pass.
*/
-#define STACK_MIN_SIZE 9336 // Abort if less stack during eval.
+#define STACK_MIN_SIZE 10788 // Abort if less stack during eval.
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
#define STACK_BUFF_ALLOC 256 // For stack overrun checks
@@ -784,6 +784,9 @@ bool quick_rm_table(handlerton *base,con
const char *table_name, uint flags);
void close_cached_table(THD *thd, TABLE *table);
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
+bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
+ char *new_table_name, char *new_table_alias,
+ bool skip_error);
bool mysql_change_db(THD *thd,const char *name,bool no_access_check);
void mysql_parse(THD *thd,char *inBuf,uint length);
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
@@ -870,7 +873,8 @@ bool mysql_xa_recover(THD *thd);
bool check_simple_select();
int mysql_alter_tablespace(THD* thd, st_alter_tablespace *ts_info);
-SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length);
+SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length,
+ SORT_FIELD *sortorder);
int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
List<Item> &fields, List <Item> &all_fields, ORDER *order);
int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
--- 1.359/sql/sql_base.cc 2006-10-23 11:48:11 +04:00
+++ 1.360/sql/sql_base.cc 2006-10-23 11:48:11 +04:00
@@ -1365,6 +1365,10 @@ TABLE_LIST *find_table_in_list(TABLE_LIS
Also SELECT::exclude_from_table_unique_test used to exclude from check
tables of main SELECT of multi-delete and multi-update
+ We also skip tables with TABLE_LIST::prelocking_placeholder set,
+ because we want to allow SELECTs from them, and their modification
+ will rise the error anyway.
+
TODO: when we will have table/view change detection we can do this check
only once for PS/SP
@@ -1411,12 +1415,13 @@ TABLE_LIST* unique_table(THD *thd, TABLE
if (((! (res= find_table_in_global_list(table_list, d_name, t_name))) &&
(! (res= mysql_lock_have_duplicate(thd, table, table_list)))) ||
((!res->table || res->table != table->table) &&
- res->select_lex &&
!res->select_lex->exclude_from_table_unique_test))
+ res->select_lex &&
!res->select_lex->exclude_from_table_unique_test &&
+ !res->prelocking_placeholder))
break;
/*
- If we found entry of this table or or table of SELECT which already
+ If we found entry of this table or table of SELECT which already
processed in derived table or top select of multi-update/multi-delete
- (exclude_from_table_unique_test).
+ (exclude_from_table_unique_test) or prelocking placeholder.
*/
table_list= res->next_global;
DBUG_PRINT("info",
--- 1.201/sql/sql_lex.cc 2006-10-23 11:48:12 +04:00
+++ 1.202/sql/sql_lex.cc 2006-10-23 11:48:12 +04:00
@@ -1146,7 +1146,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.246/sql/sql_lex.h 2006-10-23 11:48:12 +04:00
+++ 1.247/sql/sql_lex.h 2006-10-23 11:48:12 +04:00
@@ -867,6 +867,25 @@ public:
};
+/*
+ st_parsing_options contains the flags for constructions that are
+ allowed in the current statement.
+*/
+
+struct st_parsing_options
+{
+ bool allows_variable;
+ bool allows_select_into;
+ bool allows_select_procedure;
+ bool allows_derived;
+
+ st_parsing_options()
+ : allows_variable(TRUE), allows_select_into(TRUE),
+ allows_select_procedure(TRUE), allows_derived(TRUE)
+ {}
+};
+
+
/* The state of the lex parsing. This is saved in the THD struct */
typedef struct st_lex : public Query_tables_list
@@ -1023,7 +1042,7 @@ typedef struct st_lex : public Query_tab
bool stmt_prepare_mode;
bool safe_to_cache_query;
bool subqueries, ignore;
- bool variables_used;
+ st_parsing_options parsing_options;
ALTER_INFO alter_info;
/* Prepared statements SQL syntax:*/
LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */
--- 1.508/sql/sql_yacc.yy 2006-10-23 11:48:12 +04:00
+++ 1.509/sql/sql_yacc.yy 2006-10-23 11:48:12 +04:00
@@ -3600,6 +3600,7 @@ part_bit_expr:
{
Item *part_expr= $1;
bool not_corr_func;
+ int part_expression_ok= 1;
LEX *lex= Lex;
THD *thd= YYTHD;
longlong item_value;
@@ -3617,13 +3618,18 @@ part_bit_expr:
mem_alloc_error(sizeof(part_elem_value));
YYABORT;
}
-
+ if (part_expr->walk(&Item::check_partition_func_processor, 0,
+ NULL))
+ {
+ my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
+ YYABORT;
+ }
if (part_expr->fix_fields(YYTHD, (Item**)0) ||
((context->table_list= save_list), FALSE) ||
(!part_expr->const_item()) ||
(!lex->safe_to_cache_query))
{
- yyerror(ER(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR));
+ my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
YYABORT;
}
thd->where= save_where;
--- 1.185/mysql-test/r/view.result 2006-10-23 11:48:12 +04:00
+++ 1.186/mysql-test/r/view.result 2006-10-23 11:48:12 +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;
@@ -2954,6 +2954,18 @@ Level Code Message
SHOW CREATE VIEW v1;
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 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;
DROP VIEW v1;
DROP TABLE t1, t2;
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT
NULL);
@@ -2967,3 +2979,4 @@ ERROR HY000: CHECK OPTION failed 'test.v
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests.
+End of 5.1 tests.
--- 1.168/mysql-test/t/view.test 2006-10-23 11:48:12 +04:00
+++ 1.169/mysql-test/t/view.test 2006-10-23 11:48:12 +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;
#
@@ -2886,6 +2878,38 @@ 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)
#
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT
NULL);
@@ -2900,3 +2924,5 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.0 tests.
+--echo End of 5.1 tests.
+
--- 1.110/sql/sql_view.cc 2006-10-23 11:48:12 +04:00
+++ 1.111/sql/sql_view.cc 2006-10-23 11:48:12 +04:00
@@ -236,25 +236,9 @@ bool mysql_create_view(THD *thd,
bool res= FALSE;
DBUG_ENTER("mysql_create_view");
- if (lex->proc_list.first ||
- lex->result)
- {
- my_error(ER_VIEW_SELECT_CLAUSE, MYF(0), (lex->result ?
- "INTO" :
- "PROCEDURE"));
- res= TRUE;
- goto err;
- }
- if (lex->derived_tables ||
- lex->variables_used || lex->param_list.elements)
- {
- int err= (lex->derived_tables ?
- ER_VIEW_SELECT_DERIVED :
- ER_VIEW_SELECT_VARIABLE);
- my_message(err, ER(err), MYF(0));
- res= TRUE;
- goto err;
- }
+ /* This is ensured in the parser. */
+ DBUG_ASSERT(!lex->proc_list.first && !lex->result &&
+ !lex->param_list.elements && !lex->derived_tables);
if (mode != VIEW_CREATE_NEW)
{
@@ -582,40 +566,40 @@ static const int num_view_backups= 3;
*/
static File_option view_parameters[]=
{{{ C_STRING_WITH_LEN("query")},
- offsetof(TABLE_LIST, query),
+ my_offsetof(TABLE_LIST, query),
FILE_OPTIONS_ESTRING},
{{ C_STRING_WITH_LEN("md5")},
- offsetof(TABLE_LIST, md5),
+ my_offsetof(TABLE_LIST, md5),
FILE_OPTIONS_STRING},
{{ C_STRING_WITH_LEN("updatable")},
- offsetof(TABLE_LIST, updatable_view),
+ my_offsetof(TABLE_LIST, updatable_view),
FILE_OPTIONS_ULONGLONG},
{{ C_STRING_WITH_LEN("algorithm")},
- offsetof(TABLE_LIST, algorithm),
+ my_offsetof(TABLE_LIST, algorithm),
FILE_OPTIONS_ULONGLONG},
{{ C_STRING_WITH_LEN("definer_user")},
- offsetof(TABLE_LIST, definer.user),
+ my_offsetof(TABLE_LIST, definer.user),
FILE_OPTIONS_STRING},
{{ C_STRING_WITH_LEN("definer_host")},
- offsetof(TABLE_LIST, definer.host),
+ my_offsetof(TABLE_LIST, definer.host),
FILE_OPTIONS_STRING},
{{ C_STRING_WITH_LEN("suid")},
- offsetof(TABLE_LIST, view_suid),
+ my_offsetof(TABLE_LIST, view_suid),
FILE_OPTIONS_ULONGLONG},
{{ C_STRING_WITH_LEN("with_check_option")},
- offsetof(TABLE_LIST, with_check),
+ my_offsetof(TABLE_LIST, with_check),
FILE_OPTIONS_ULONGLONG},
{{ C_STRING_WITH_LEN("revision")},
- offsetof(TABLE_LIST, revision),
+ my_offsetof(TABLE_LIST, revision),
FILE_OPTIONS_REV},
{{ C_STRING_WITH_LEN("timestamp")},
- offsetof(TABLE_LIST, timestamp),
+ my_offsetof(TABLE_LIST, timestamp),
FILE_OPTIONS_TIMESTAMP},
{{ C_STRING_WITH_LEN("create-version")},
- offsetof(TABLE_LIST, file_version),
+ my_offsetof(TABLE_LIST, file_version),
FILE_OPTIONS_ULONGLONG},
{{ C_STRING_WITH_LEN("source")},
- offsetof(TABLE_LIST, source),
+ my_offsetof(TABLE_LIST, source),
FILE_OPTIONS_ESTRING},
{{NullS, 0}, 0,
FILE_OPTIONS_STRING}
--- 1.49/mysql-test/t/func_gconcat.test 2006-10-23 11:48:12 +04:00
+++ 1.50/mysql-test/t/func_gconcat.test 2006-10-23 11:48:12 +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.1 tree (kostja:1.2321) | konstantin | 23 Oct |