724
# CREATE TABLE ... SELECT and LOCK TABLES
726
# There is little sense in using CREATE TABLE ... SELECT under
727
# LOCK TABLES as it mostly does not work. At least we check that
728
# the server doesn't crash, hang and produces sensible errors.
729
# Includes test for bug #20662 "Infinite loop in CREATE TABLE
730
# IF NOT EXISTS ... SELECT with locked tables".
731
create table t1 (i int);
732
insert into t1 values (1), (2);
734
--error ER_TABLE_NOT_LOCKED
735
create table t2 select * from t1;
736
--error ER_TABLE_NOT_LOCKED
737
create table if not exists t2 select * from t1;
739
create table t2 (j int);
741
--error ER_TABLE_NOT_LOCKED
742
create table t2 select * from t1;
743
# This should not be ever allowed as it will undermine
744
# lock-all-at-once approach
745
--error ER_TABLE_NOT_LOCKED
746
create table if not exists t2 select * from t1;
748
lock table t1 read, t2 read;
749
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
750
create table t2 select * from t1;
751
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
752
create table if not exists t2 select * from t1;
754
lock table t1 read, t2 write;
755
--error ER_TABLE_EXISTS_ERROR
756
create table t2 select * from t1;
757
# This is the only case which really works.
758
create table if not exists t2 select * from t1;
763
# OTOH CREATE TEMPORARY TABLE ... SELECT should work
764
# well under LOCK TABLES.
766
create temporary table t2 select * from t1;
767
create temporary table if not exists t2 select * from t1;
774
724
# Bug#21772: can not name a column 'upgrade' when create a table
776
726
create table t1 (upgrade int);