Created
September 22, 2015 22:41
-
-
Save BenoitDuffez/8dc23ed48e995d3e3254 to your computer and use it in GitHub Desktop.
MySQL bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MYSQL="mysql" # add -u xyz -pabcd or export MYSQL_PWD, etc | |
echo "Init" | |
$MYSQL -e "drop database if exists test" | |
$MYSQL -e "create database test" | |
$MYSQL test -e 'delimiter $$ | |
create function func() returns int(10) | |
begin | |
return 1; | |
end$$' | |
echo "Create procedure with statement" | |
$MYSQL test -e 'delimiter $$ | |
create procedure testbug() | |
begin | |
drop table if exists src; | |
drop table if exists result; | |
create temporary table src (id int); | |
set @sql = "create temporary table result | |
select * from (select * from src where id < func()) a"; | |
PREPARE s FROM @sql; | |
EXECUTE s; | |
deallocate prepare s; | |
END$$' | |
echo "Running script" | |
$MYSQL test -e 'call testbug(); show columns from result' | |
echo "Modifying procedure" | |
$MYSQL test -e 'drop procedure testbug' | |
$MYSQL test -e 'delimiter $$ | |
create procedure testbug() | |
begin | |
drop table if exists src; | |
drop table if exists result; | |
create temporary table src (id int); | |
create temporary table result | |
select * from (select * from src where id < func()) a; | |
END$$' | |
echo "Running script again" | |
$MYSQL test -e 'call testbug(); show columns from result' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./bug.sh | |
Init | |
Create procedure with statement | |
Running script | |
ERROR 1146 (42S02) at line 1: Table 'test.src' doesn't exist | |
Modifying procedure | |
Running script again | |
+-------+---------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+---------+------+-----+---------+-------+ | |
| id | int(11) | YES | | NULL | | | |
+-------+---------+------+-----+---------+-------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment