Commit 7694eecc authored by lars@mysql.com's avatar lars@mysql.com

Merge mysql.com:/users/lthalmann/bkroot/mysql-5.0

into  mysql.com:/users/lthalmann/bk/mysql-5.0-base64
parents 827d745c bfc8e85b
......@@ -3532,4 +3532,47 @@ select @a|
Local
drop function bug13941|
drop procedure bug13941|
DROP PROCEDURE IF EXISTS bug13095;
DROP TABLE IF EXISTS bug13095_t1;
DROP VIEW IF EXISTS bug13095_v1;
CREATE PROCEDURE bug13095(tbl_name varchar(32))
BEGIN
SET @str =
CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))");
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" );
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name);
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
SELECT * FROM bug13095_v1;
SET @str =
"DROP VIEW bug13095_v1";
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
END|
CALL bug13095('bug13095_t1');
@str
CREATE TABLE bug13095_t1(stuff char(15))
@str
INSERT INTO bug13095_t1 VALUES('row1'),('row2'),('row3')
@str
CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM bug13095_t1
c1
row1
row2
row3
@str
DROP VIEW bug13095_v1
DROP PROCEDURE IF EXISTS bug13095;
DROP VIEW IF EXISTS bug13095_v1;
DROP TABLE IF EXISTS bug13095_t1;
drop table t1,t2;
......@@ -15,3 +15,4 @@ rpl_relayrotate : Unstable test case, bug#12429
rpl_until : Unstable test case, bug#12429
rpl_deadlock : Unstable test case, bug#12429
kill : Unstable test case, bug#9712
federated : Broken test case, bug#14272
......@@ -4433,6 +4433,62 @@ drop function bug13941|
drop procedure bug13941|
#
# BUG#13095: Cannot create VIEWs in prepared statements
#
delimiter ;|
--disable_warnings
DROP PROCEDURE IF EXISTS bug13095;
DROP TABLE IF EXISTS bug13095_t1;
DROP VIEW IF EXISTS bug13095_v1;
--enable_warnings
delimiter |;
CREATE PROCEDURE bug13095(tbl_name varchar(32))
BEGIN
SET @str =
CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))");
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" );
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name);
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
SELECT * FROM bug13095_v1;
SET @str =
"DROP VIEW bug13095_v1";
SELECT @str;
PREPARE stmt FROM @str;
EXECUTE stmt;
END|
delimiter ;|
CALL bug13095('bug13095_t1');
--disable_warnings
DROP PROCEDURE IF EXISTS bug13095;
DROP VIEW IF EXISTS bug13095_v1;
DROP TABLE IF EXISTS bug13095_t1;
--enable_warnings
delimiter |;
#
# BUG#NNNN: New bug synopsis
#
......
......@@ -6811,6 +6811,7 @@ ha_innobase::store_lock(
|| thd->lex->sql_command == SQLCOM_CALL)
&& !thd->tablespace_op
&& thd->lex->sql_command != SQLCOM_TRUNCATE
&& thd->lex->sql_command != SQLCOM_OPTIMIZE
&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
lock_type = TL_WRITE_ALLOW_WRITE;
......
......@@ -738,6 +738,7 @@ typedef struct st_lex
/* store original leaf_tables for INSERT SELECT and PS/SP */
TABLE_LIST *leaf_tables_insert;
st_lex_user *create_view_definer;
char *create_view_start;
char *create_view_select_start;
List<key_part_spec> col_list;
......
......@@ -1742,6 +1742,8 @@ static bool check_prepared_statement(Prepared_statement *stmt,
case SQLCOM_ROLLBACK:
case SQLCOM_TRUNCATE:
case SQLCOM_CALL:
case SQLCOM_CREATE_VIEW:
case SQLCOM_DROP_VIEW:
break;
default:
......
......@@ -643,7 +643,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
view->query.length= str.length()-1; // we do not need last \0
view->source.str= thd->lex->create_view_select_start;
view->source.length= (thd->query_length -
(thd->lex->create_view_select_start - thd->query));
(thd->lex->create_view_select_start -
thd->lex->create_view_start));
view->file_version= 1;
view->calc_md5(md5);
view->md5.str= md5;
......
......@@ -1263,6 +1263,7 @@ create:
THD *thd= YYTHD;
LEX *lex= thd->lex;
lex->sql_command= SQLCOM_CREATE_VIEW;
lex->create_view_start= thd->query;
/* first table in list is target VIEW name */
if (!lex->select_lex.add_table_to_list(thd, $7, NULL, 0))
YYABORT;
......@@ -3425,6 +3426,7 @@ alter:
THD *thd= YYTHD;
LEX *lex= thd->lex;
lex->sql_command= SQLCOM_CREATE_VIEW;
lex->create_view_start= thd->query;
lex->create_view_mode= VIEW_ALTER;
/* first table in list is target VIEW name */
lex->select_lex.add_table_to_list(thd, $6, NULL, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment