Couldn't verify your test case with Server version: 5.6.22-72.0-log Percona Server (GPL), Release 72.0, Revision 738
I also tried to verify with 5.6.23 and same, no error. Can you please try to check with latest PS 5.6.23?
nilnandan@desktop:~/sandboxes/rsandbox_Percona-Server-5_6_22/master$ mysql -uroot -p --socket=/tmp/mysql_sandbox21087.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.22-72.0-log Percona Server (GPL), Release 72.0, Revision 738
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dbtest |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.05 sec)
mysql> CREATE DATABASE `sample` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.02 sec)
mysql> use sample
Database changed
mysql>
mysql> create table t1 (id int, name varchar(10));
Query OK, 0 rows affected (0.15 sec)
mysql> create table t2 (id int, name varchar(10), city varchar(10));
Query OK, 0 rows affected (0.04 sec)
mysql> create table t3 (id int, phone int, email varchar(25));
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> CREATE DATABASE `sample_stats` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> use sample
Database changed
mysql> delimiter //
mysql>
mysql> CREATE DEFINER=`root`@`localhost` PROCEDURE `recreate_views_for_stats`()
-> begin
-> declare PROCEDURE_VERSION_INFO varchar(200);
-> declare p_done int;
-> declare p_table_name varchar(64);
-> declare p_stats_schema varchar(64);
-> declare p_cnt int;
-> declare p_cnt_view int;
-> declare p_stmt varchar(400);
->
-> declare view_cursor cursor for select table_name from information_schema.tables v1 where v1.table_schema=concat(database(),'_stats') and v1.table_type='VIEW';
-> declare table_cursor cursor for select table_name from information_schema.tables v1 where v1.table_schema=database();
->
-> declare continue handler for SQLSTATE '02000' begin set p_done = 1; end;
->
-> set PROCEDURE_VERSION_INFO = 'v 1.11 ';
->
-> select PROCEDURE_VERSION_INFO;
->
-> set p_done = 0;
-> set p_cnt_view = 0;
-> set p_stats_schema = concat(database(),'_stats');
-> open view_cursor;
-> repeat
-> fetch view_cursor into p_table_name;
-> if not p_done then
-> set @sql = concat('drop view if exists ',p_stats_schema,'.',p_table_name);
-> prepare p_stmt from @sql;
-> execute p_stmt;
-> deallocate prepare p_stmt;
-> set p_cnt_view = p_cnt_view + 1;
->
-> end if;
-> until p_done end repeat;
->
-> set p_done = 0;
-> set p_cnt = 0;
-> open table_cursor;
-> repeat
-> fetch table_cursor into p_table_name;
-> if not p_done then
-> set @sql = concat('create view ',p_stats_schema,'.',p_table_name,' as select * from ',p_table_name);
-> prepare p_stmt from @sql;
-> execute p_stmt;
-> deallocate prepare p_stmt;
-> set p_cnt = p_cnt + 1;
-> end if;
-> until p_done end repeat;
->
-> select p_cnt_view as views_dropped, p_cnt as views_created, count(*) as views_total from information_schema.views where table_schema=p_stats_schema;
-> end //
Query OK, 0 rows affected (0.14 sec)
mysql> delimiter ;
mysql>
mysql> call recreate_views_for_stats();
+------------------------+
| PROCEDURE_VERSION_INFO |
+------------------------+
| v 1.11 |
+------------------------+
1 row in set (0.01 sec)
Hi,
Couldn't verify your test case with Server version: 5.6.22-72.0-log Percona Server (GPL), Release 72.0, Revision 738
I also tried to verify with 5.6.23 and same, no error. Can you please try to check with latest PS 5.6.23?
nilnandan@ desktop: ~/sandboxes/ rsandbox_ Percona- Server- 5_6_22/ master$ mysql -uroot -p --socket= /tmp/mysql_ sandbox21087. sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.22-72.0-log Percona Server (GPL), Release 72.0, Revision 738
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; ------- ------- + ------- ------- + ------- ------- +
+------
| Database |
+------
| information_schema |
| dbtest |
| mysql |
| performance_schema |
| test |
+------
5 rows in set (0.05 sec)
mysql> CREATE DATABASE `sample` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.02 sec)
mysql> use sample
Database changed
mysql>
mysql> create table t1 (id int, name varchar(10));
Query OK, 0 rows affected (0.15 sec)
mysql> create table t2 (id int, name varchar(10), city varchar(10));
Query OK, 0 rows affected (0.04 sec)
mysql> create table t3 (id int, phone int, email varchar(25));
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> CREATE DATABASE `sample_stats` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.00 sec)
mysql> `root`@ `localhost` PROCEDURE `recreate_ views_for_ stats`( ) VERSION_ INFO varchar(200); schema. tables v1 where v1.table_ schema= concat( database( ),'_stats' ) and v1.table_ type='VIEW' ; schema. tables v1 where v1.table_ schema= database( ); VERSION_ INFO = 'v 1.11 '; VERSION_ INFO; database( ),'_stats' ); schema, '.',p_table_ name); schema, '.',p_table_ name,' as select * from ',p_table_name); schema. views where table_schema= p_stats_ schema;
mysql> use sample
Database changed
mysql> delimiter //
mysql>
mysql> CREATE DEFINER=
-> begin
-> declare PROCEDURE_
-> declare p_done int;
-> declare p_table_name varchar(64);
-> declare p_stats_schema varchar(64);
-> declare p_cnt int;
-> declare p_cnt_view int;
-> declare p_stmt varchar(400);
->
-> declare view_cursor cursor for select table_name from information_
-> declare table_cursor cursor for select table_name from information_
->
-> declare continue handler for SQLSTATE '02000' begin set p_done = 1; end;
->
-> set PROCEDURE_
->
-> select PROCEDURE_
->
-> set p_done = 0;
-> set p_cnt_view = 0;
-> set p_stats_schema = concat(
-> open view_cursor;
-> repeat
-> fetch view_cursor into p_table_name;
-> if not p_done then
-> set @sql = concat('drop view if exists ',p_stats_
-> prepare p_stmt from @sql;
-> execute p_stmt;
-> deallocate prepare p_stmt;
-> set p_cnt_view = p_cnt_view + 1;
->
-> end if;
-> until p_done end repeat;
->
-> set p_done = 0;
-> set p_cnt = 0;
-> open table_cursor;
-> repeat
-> fetch table_cursor into p_table_name;
-> if not p_done then
-> set @sql = concat('create view ',p_stats_
-> prepare p_stmt from @sql;
-> execute p_stmt;
-> deallocate prepare p_stmt;
-> set p_cnt = p_cnt + 1;
-> end if;
-> until p_done end repeat;
->
-> select p_cnt_view as views_dropped, p_cnt as views_created, count(*) as views_total from information_
-> end //
Query OK, 0 rows affected (0.14 sec)
mysql> delimiter ; views_for_ stats() ; ------- ------- ----+ VERSION_ INFO | ------- ------- ----+ ------- ------- ----+
mysql>
mysql> call recreate_
+------
| PROCEDURE_
+------
| v 1.11 |
+------
1 row in set (0.01 sec)
+------ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+
| views_dropped | views_created | views_total |
+------
| 0 | 3 | 3 |
+------
1 row in set (0.13 sec)
Query OK, 0 rows affected (0.13 sec)
mysql> views_for_ stats() ; ------- ------- ----+ VERSION_ INFO | ------- ------- ----+ ------- ------- ----+
mysql> call recreate_
+------
| PROCEDURE_
+------
| v 1.11 |
+------
1 row in set (0.00 sec)
+------ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+
| views_dropped | views_created | views_total |
+------
| 3 | 3 | 3 |
+------
1 row in set (0.03 sec)
Query OK, 0 rows affected (0.03 sec)
mysql> call recreate_ views_for_ stats() ; ------- ------- ----+ VERSION_ INFO | ------- ------- ----+ ------- ------- ----+
+------
| PROCEDURE_
+------
| v 1.11 |
+------
1 row in set (0.00 sec)
+------ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+
| views_dropped | views_created | views_total |
+------
| 3 | 3 | 3 |
+------
1 row in set (0.02 sec)
Query OK, 0 rows affected (0.02 sec)
mysql>