I downloaded from below link as you suggested and try to reproduce on CentOS 5.9 but again no error. It seems, it has something related to your environment/configurations. From the stacktrace, I can see this.
[root@localhost ~]# mysql -uroot -p --socket=/tmp/mysql_sandbox5622.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.22-71.0 Percona Server (GPL), Release 71.0, Revision 726
Copyright (c) 2000, 2011, 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 |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> CREATE DATABASE `sample` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.00 sec)
mysql> use sample
Database changed
mysql>
mysql> create table t1 (id int, name varchar(10));
Query OK, 0 rows affected (0.00 sec)
mysql> create table t2 (id int, name varchar(10), city varchar(10));
Query OK, 0 rows affected (0.01 sec)
mysql> create table t3 (id int, phone int, email varchar(25));
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE DATABASE `sample_stats` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.00 sec)
mysql> use sample
Database changed
mysql>
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.00 sec)
mysql> delimiter ;
mysql>
mysql> call recreate_views_for_stats();
+------------------------+
| PROCEDURE_VERSION_INFO |
+------------------------+
| v 1.11 |
+------------------------+
1 row in set (0.00 sec)
Hi,
I downloaded from below link as you suggested and try to reproduce on CentOS 5.9 but again no error. It seems, it has something related to your environment/ configurations. From the stacktrace, I can see this.
/home/mysql/ lib/mysql/ plugin/ query_response_ time.so[ 0x2b2555f98b22]
Are you using any plugin? can you provide your my.cnf ?
[root@localhost ~]# uname -a localdomain 2.6.18-348.el5 #1 SMP Tue Jan 8 17:53:53 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
Linux localhost.
[root@localhost ~]#
[root@localhost ~]# lsb_release -a 0-amd64: core-4. 0-ia32: core-4. 0-noarch: graphics- 4.0-amd64: graphics- 4.0-ia32: graphics- 4.0-noarch: printing- 4.0-amd64: printing- 4.0-ia32: printing- 4.0-noarch
LSB Version: :core-4.
Distributor ID: CentOS
Description: CentOS release 5.9 (Final)
Release: 5.9
Codename: Final
[root@localhost ~]#
[root@localhost ~]# ll Percona- Server- 5.6.22- rel71.0- 726.Linux. x86_64. tar.gz Server- 5.6.22- rel71.0- 726.Linux. x86_64. tar.gz
-rw-r--r-- 1 root root 109151984 Jan 10 00:56 Percona-
[root@localhost ~]#
[root@localhost ~]# mysql -uroot -p --socket= /tmp/mysql_ sandbox5622. sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.22-71.0 Percona Server (GPL), Release 71.0, Revision 726
Copyright (c) 2000, 2011, 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 |
| mysql |
| performance_schema |
| test |
+------
4 rows in set (0.00 sec)
mysql> CREATE DATABASE `sample` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.00 sec)
mysql> use sample
Database changed
mysql>
mysql> create table t1 (id int, name varchar(10));
Query OK, 0 rows affected (0.00 sec)
mysql> create table t2 (id int, name varchar(10), city varchar(10));
Query OK, 0 rows affected (0.01 sec)
mysql> create table t3 (id int, phone int, email varchar(25));
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE DATABASE `sample_stats` /*!40100 DEFAULT CHARACTER SET utf8 */;
Query OK, 1 row affected (0.00 sec)
mysql> use sample `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;
Database changed
mysql>
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.00 sec)
mysql> delimiter ; views_for_ stats() ; ------- ------- ----+ VERSION_ INFO | ------- ------- ----+ ------- ------- ----+
mysql>
mysql> call recreate_
+------
| PROCEDURE_
+------
| v 1.11 |
+------
1 row in set (0.00 sec)
+------ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+ ------- --+---- ------- ----+-- ------- ----+
| views_dropped | views_created | views_total |
+------
| 0 | 3 | 3 |
+------
1 row in set (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
mysql> views_for_ stats() ; ------- ------- ----+ VERSION_ INFO | ------- ------- ----+ ------- ------- ----+
mysql>
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.00 sec)
Query OK, 0 rows affected (0.00 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.00 sec)
Query OK, 0 rows affected (0.00 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.00 sec)
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@localhost ~]#