summaryrefslogtreecommitdiff
path: root/mysql-test/t/create.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/create.test')
-rw-r--r--mysql-test/t/create.test73
1 files changed, 68 insertions, 5 deletions
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 68d68929f07..cda9307804b 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -2,7 +2,10 @@
# Check some special create statements.
#
-drop table if exists t1,t2;
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1 (b char(0));
insert into t1 values (""),(null);
select * from t1;
@@ -12,7 +15,7 @@ create table t1 (b char(0) not null);
create table if not exists t1 (b char(0) not null);
insert into t1 values (""),(null);
select * from t1;
-drop table if exists t1;
+drop table t1;
#
# Test of some CREATE TABLE'S that should fail
@@ -22,12 +25,12 @@ drop table if exists t1;
!$1146 create table t2 select auto+1 from t1;
drop table if exists t1,t2;
!$1167 create table t1 (b char(0) not null, index(b));
-!$1164 create table t1 (a int not null auto_increment,primary key (a)) type=heap;
+create table t1 (a int not null auto_increment,primary key (a)) type=heap;
!$1163 create table t1 (a int not null,b text) type=heap;
!$1171 create table t1 (a int ,primary key(a)) type=heap;
drop table if exists t1;
-!$1164 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
+!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
!$1171 create table t1 (ordid int(8), primary key (ordid));
-- error 1044,1
@@ -91,6 +94,25 @@ describe t2;
drop table t1,t2;
#
+# Test of CREATE ... SELECT with duplicate fields
+#
+
+create table t1 (a tinyint);
+create table t2 (a int) select * from t1;
+describe t1;
+describe t2;
+drop table if exists t2;
+--error 1060
+create table t2 (a int, a float) select * from t1;
+drop table if exists t2;
+--error 1060
+create table t2 (a int) select a as b, a+1 as b from t1;
+drop table if exists t2;
+--error 1060
+create table t2 (b int) select a as b, a+1 as b from t1;
+drop table if exists t1,t2;
+
+#
# Test of primary key with 32 index
#
@@ -102,6 +124,48 @@ drop table t1;
create table t1 select if('2002'='2002','Y','N');
select * from t1;
drop table if exists t1;
+create table t1 (a int, key(a));
+create table t2 (b int, foreign key(b) references t1(a), key(b));
+drop table if exists t1,t2;
+
+#
+# Test for CREATE TABLE .. LIKE ..
+#
+
+create table t1(id int not null, name char(20));
+insert into t1 values(10,'mysql'),(20,'monty- the creator');
+create table t2(id int not null);
+insert into t2 values(10),(20);
+create table t3 like t1;
+show create table t3;
+select * from t3;
+create table if not exists t3 like t1;
+select @@warning_count;
+create temporary table t3 like t2;
+show create table t3;
+select * from t3;
+drop table t3;
+show create table t3;
+select * from t3;
+drop table t2, t3;
+drop database if exists test_$1;
+create database test_$1;
+create table test_$1.t3 like t1;
+create temporary table t3 like test_$1.t3;
+show create table t3;
+create table t2 like t3;
+show create table t2;
+select * from t2;
+create table t3 like t1;
+!$1050 create table t3 like test_$1.t3;
+--error 1044,1
+create table non_existing_database.t1 like t1;
+!$1051 create table t3 like non_existing_table;
+!$1050 create temporary table t3 like t1;
+!$1103 create table t3 like `a/a`;
+drop table t1, t2, t3;
+drop table t3;
+drop database test_$1;
#
# Test default table type
@@ -118,4 +182,3 @@ CREATE TABLE t1 (a int not null);
show create table t1;
SET SESSION table_type=default;
drop table t1;
-