summaryrefslogtreecommitdiff
path: root/mysql-test/main/create_not_windows.test
blob: d6dfc0d3fa1db0d9fe5fe36e808f7a0c99a99af5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Non-windows specific create tests.

--source include/not_windows.inc
--source include/have_debug.inc
--source include/not_embedded.inc

#
# Bug#19479:mysqldump creates invalid dump
#
--disable_warnings
drop table if exists `about:text`;
--enable_warnings
create table `about:text` ( 
_id int not null auto_increment,
`about:text` varchar(255) not null default '',
primary key (_id)
);

show create table `about:text`; 
drop table `about:text`;


# End of 5.0 tests

#
# Bug#16532:mysql server assert in debug if table det is removed
#
use test;
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(a int) engine=myisam;
insert into t1 values(1);
let $MYSQLD_DATADIR= `select @@datadir`;
remove_file $MYSQLD_DATADIR/test/t1.frm;
--echo "We get an error because the table is in the definition cache"
--error ER_TABLE_EXISTS_ERROR
create table t1(a int, b int);
--echo "Flush the cache and recreate the table anew to be able to drop it"
flush tables;
show open tables like "t%";
create table t1(a int, b int, c int);
--echo "Try to select from the table. This should not crash the server"
select count(a) from t1;
drop table t1;

--echo #
--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE
--echo #

# This does not work on Windows because of max path limit 255
# (actually it does not work for path 254 already)
# Note: on Windows use ER_BAD_DB_ERROR instead of ER_CANT_CREATE_TABLE
# unless MDEV-28746 is fixed.

--echo # Test multi-byte characters in table name
set names utf8;
let $save_debug=`select @@debug_dbug`;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo # Filename is too long because it is converted to @274e@274e@274e@274e...
--echo # so each '❎' is 5 bytes in filesystem, 51 x 5 = 255 bytes
let $t= `select repeat('❎', 51)`;
--error ER_CANT_CREATE_TABLE
eval create table $t (x int);
# The below case is useful for experimenting on Windows
--echo # Let's find out max length for '❎'...
--disable_query_log
let $i= 50;
while ($i)
{
  let $t= `select repeat('❎', $i)`;
  --error 0,ER_CANT_CREATE_TABLE
  eval create table $t (x int);
  let $good_len= $i;
  dec $i;
  if (!$mysql_errno)
  {
    let $i= 0;
  }
}
let $fn_len= `select $good_len * 5 + 4`; # 4 is extension length
eval drop table $t;
--enable_query_log
--echo # Acceptable name length: $good_len; Filename length: $fn_len
--echo # OK with 64-characters table name, filesystem name is 40 x 5 + 24 = 224 bytes
let $t= `select concat(repeat('t', 24), repeat('❎', 40))`;
eval create table $t (x int);
--echo # Not OK with 65-characters table name
let $t2= `select concat(repeat('t', 25), repeat('❎', 40))`;
--error ER_WRONG_TABLE_NAME
eval create table $t2 (x int);
show tables;
# Let's try atomic replace with such long name and see what happens
eval create or replace table $t (y int);
eval show create table $t;
set @@debug_dbug="+d,ddl_log_create_after_save_backup", @debug_crash_counter=1;
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--disable_reconnect
--error 2013
eval create or replace table $t (z int);
--replace_regex /-\w+-\w+-ttt/-PID-TID-ttt/
--list_files $MYSQLD_DATADIR/test *sql*
--enable_reconnect
--source include/wait_until_connected_again.inc
eval drop table $t;
eval set @@debug_dbug="$save_debug";