Skip to content

Commit 6ff2113

Browse files
WL#1324 table name to file name encoding
- Encoding itself, implemented as a charset "filename". Originally planned to use '.' as an escape character, but now changed to '@' for two reasons: "ls" does not return file names starting with '.' considering them as a kind of hidden files; some platforms do not allow several dots in a file name. - replacing many calls of my_snprintf() and strnxmov() to the new build_table_filename(). - Adding MY_APPEND_EXT mysys flag, to append an extention rather that replace it. - Replacing all numeric constants in fn_format flag arguments to their mysys definitions, e.g. MY_UNPACK_FILENAME, - Predictability in several function/methods: when a table name can appear with or withot .frm extension. Some functions/methods were changed so accept names strictly with .frm, other - strictly without .frm extensions. Several DBUG_ASSERTs were added to check whether an extension is passed. Many files: table name to file name encoding mysql_priv.h: Prototypes for new table name encoding tools. ctype-utf8.c: Implementing "filename" charset for table name to file name encoding. row0mysql.c: Fixing table name prefix. mf_format.c: Adding MY_APPEND_EXT processing. Many files: Fixing tests. my_sys.h: Adding new flag to append rather than replace an extension. m_ctype.h: Adding "filename" charset definition.
1 parent 83d8979 commit 6ff2113

42 files changed

Lines changed: 1805 additions & 271 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/m_ctype.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ extern CHARSET_INFO my_charset_ujis_bin;
269269
extern CHARSET_INFO my_charset_utf8_general_ci;
270270
extern CHARSET_INFO my_charset_utf8_bin;
271271
extern CHARSET_INFO my_charset_cp1250_czech_ci;
272+
extern CHARSET_INFO my_charset_filename;
272273

273274
/* declarations for simple charsets */
274275
extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *,

include/my_sys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ extern int NEAR my_errno; /* Last error in mysys */
9898
#define MY_RETURN_REAL_PATH 32 /* return full path for file */
9999
#define MY_SAFE_PATH 64 /* Return NULL if too long path */
100100
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
101+
#define MY_APPEND_EXT 256 /* add 'ext' as additional extension*/
102+
101103

102104
/* My seek flags */
103105
#define MY_SEEK_SET 0

mysql-test/r/alter_table.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
373373
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
374374
DROP TABLE t1;
375375
create table t1 (a int);
376-
alter table t1 rename to `t1\\`;
377-
ERROR 42000: Incorrect table name 't1\\'
378-
rename table t1 to `t1\\`;
379-
ERROR 42000: Incorrect table name 't1\\'
376+
alter table t1 rename to ``;
377+
ERROR 42000: Incorrect table name ''
378+
rename table t1 to ``;
379+
ERROR 42000: Incorrect table name ''
380380
drop table t1;
381381
drop table if exists t1, t2;
382382
Warnings:

mysql-test/r/create.result

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ ERROR 42000: Incorrect table definition; there can be only one auto column and i
4141
create table not_existing_database.test (a int);
4242
ERROR 42000: Unknown database 'not_existing_database'
4343
create table `a/a` (a int);
44-
ERROR 42000: Incorrect table name 'a/a'
44+
show create table `a/a`;
45+
Table Create Table
46+
a/a CREATE TABLE `a/a` (
47+
`a` int(11) default NULL
48+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
49+
create table t1 like `a/a`;
50+
drop table `a/a`;
51+
drop table `t1`;
4552
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
4653
ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
4754
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
@@ -360,8 +367,6 @@ create table t3 like non_existing_table;
360367
ERROR 42S02: Unknown table 'non_existing_table'
361368
create temporary table t3 like t1;
362369
ERROR 42S01: Table 't3' already exists
363-
create table t3 like `a/a`;
364-
ERROR 42000: Incorrect table name 'a/a'
365370
drop table t1, t2, t3;
366371
drop table t3;
367372
drop database mysqltest;

mysql-test/r/mysqldump.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ mysqldump: Couldn't find table: "T_"
16271627
test_sequence
16281628
------ Testing with illegal database names ------
16291629
mysqldump: Got error: 1049: Unknown database 'mysqldump_test_d' when selecting the database
1630-
mysqldump: Got error: 1102: Incorrect database name 'mysqld\ump_test_db' when selecting the database
1630+
mysqldump: Got error: 1049: Unknown database 'mysqld\ump_test_db' when selecting the database
16311631
drop table t1, t2, t3;
16321632
drop database mysqldump_test_db;
16331633
use test;

mysql-test/r/show_check.result

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,42 @@ f float(3,3) YES NULL
274274
drop table t1;
275275
SET @old_sql_mode= @@sql_mode, sql_mode= '';
276276
SET @old_sql_quote_show_create= @@sql_quote_show_create, sql_quote_show_create= OFF;
277-
CREATE TABLE `a/b` (i INT);
278-
ERROR 42000: Incorrect table name 'a/b'
277+
CREATE TABLE ```ab``cd``` (i INT);
278+
SHOW CREATE TABLE ```ab``cd```;
279+
Table Create Table
280+
`ab`cd` CREATE TABLE ```ab``cd``` (
281+
i int(11) default NULL
282+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
283+
DROP TABLE ```ab``cd```;
284+
CREATE TABLE ```ab````cd``` (i INT);
285+
SHOW CREATE TABLE ```ab````cd```;
286+
Table Create Table
287+
`ab``cd` CREATE TABLE ```ab````cd``` (
288+
i int(11) default NULL
289+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
290+
DROP TABLE ```ab````cd```;
291+
CREATE TABLE ```a` (i INT);
292+
SHOW CREATE TABLE ```a`;
293+
Table Create Table
294+
`a CREATE TABLE ```a` (
295+
i int(11) default NULL
296+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
297+
DROP TABLE ```a`;
298+
CREATE TABLE `a.1` (i INT);
299+
SHOW CREATE TABLE `a.1`;
300+
Table Create Table
301+
a.1 CREATE TABLE `a.1` (
302+
i int(11) default NULL
303+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
304+
DROP TABLE `a.1`;
305+
SET sql_mode= 'ANSI_QUOTES';
306+
CREATE TABLE """a" (i INT);
307+
SHOW CREATE TABLE """a";
308+
Table Create Table
309+
"a CREATE TABLE """a" (
310+
i int(11) default NULL
311+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
312+
DROP TABLE """a";
279313
SET sql_mode= '';
280314
SET sql_quote_show_create= OFF;
281315
CREATE TABLE t1 (i INT);

mysql-test/t/alter_table.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ DROP TABLE t1;
232232
#
233233
create table t1 (a int);
234234
--error 1103
235-
alter table t1 rename to `t1\\`;
235+
alter table t1 rename to ``;
236236
--error 1103
237-
rename table t1 to `t1\\`;
237+
rename table t1 to ``;
238238
drop table t1;
239239

240240
#

mysql-test/t/create.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null
4141

4242
-- error 1049
4343
create table not_existing_database.test (a int);
44-
--error 1103
4544
create table `a/a` (a int);
45+
show create table `a/a`;
46+
create table t1 like `a/a`;
47+
drop table `a/a`;
48+
drop table `t1`;
4649
--error 1103
4750
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
4851
--error 1059
@@ -304,8 +307,6 @@ create table non_existing_database.t1 like t1;
304307
create table t3 like non_existing_table;
305308
--error 1050
306309
create temporary table t3 like t1;
307-
--error 1103
308-
create table t3 like `a/a`;
309310
drop table t1, t2, t3;
310311
drop table t3;
311312
drop database mysqltest;

mysql-test/t/show_check.test

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -162,43 +162,35 @@ drop table t1;
162162
SET @old_sql_mode= @@sql_mode, sql_mode= '';
163163
SET @old_sql_quote_show_create= @@sql_quote_show_create, sql_quote_show_create= OFF;
164164

165-
######### hook for WL#1324 #
166-
--error 1103
167-
CREATE TABLE `a/b` (i INT);
168-
# the above test should WORK when WL#1324 is done,
169-
# it should be removed and
170-
# the following part should be uncommented then
171-
#########################################################
172-
# begin of part that must be uncommented when WL#1324 is done
173-
#########################################################
174-
#CREATE TABLE ```ab``cd``` (i INT);
175-
#SHOW CREATE TABLE ```ab``cd```;
176-
#DROP TABLE ```ab``cd```;
177-
178-
#CREATE TABLE ```ab````cd``` (i INT);
179-
#SHOW CREATE TABLE ```ab````cd```;
180-
#DROP TABLE ```ab````cd```;
181-
#
182-
#CREATE TABLE ```a` (i INT);
183-
#SHOW CREATE TABLE ```a`;
184-
#DROP TABLE ```a`;
185-
#
186-
#SET sql_mode= 'ANSI_QUOTES';
187-
#
188-
#CREATE TABLE """a" (i INT);
189-
#SHOW CREATE TABLE """a";
190-
#DROP TABLE """a";
191-
#
165+
CREATE TABLE ```ab``cd``` (i INT);
166+
SHOW CREATE TABLE ```ab``cd```;
167+
DROP TABLE ```ab``cd```;
168+
169+
CREATE TABLE ```ab````cd``` (i INT);
170+
SHOW CREATE TABLE ```ab````cd```;
171+
DROP TABLE ```ab````cd```;
172+
173+
CREATE TABLE ```a` (i INT);
174+
SHOW CREATE TABLE ```a`;
175+
DROP TABLE ```a`;
176+
177+
CREATE TABLE `a.1` (i INT);
178+
SHOW CREATE TABLE `a.1`;
179+
DROP TABLE `a.1`;
180+
181+
SET sql_mode= 'ANSI_QUOTES';
182+
183+
CREATE TABLE """a" (i INT);
184+
SHOW CREATE TABLE """a";
185+
DROP TABLE """a";
186+
192187
#Bug #4374 SHOW TABLE STATUS FROM ignores collation_connection
193188
#set names latin1;
194189
#create database `�`;
195190
#create table `�`.`�` (a int) engine=heap;
196191
#--replace_column 7 # 8 # 9 #
197192
#show table status from `�` LIKE '�';
198193
#drop database `�`;
199-
#########################################################
200-
# end of part that must be uncommented when WL#1324 is done
201-
#########################################################
202194

203195
# to test quotes around keywords.. :
204196

mysys/mf_format.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ my_string fn_format(my_string to, const char *name, const char *dir,
5454
if (flag & MY_UNPACK_FILENAME)
5555
(void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */
5656

57-
if ((pos= (char*) strchr(name,FN_EXTCHAR)) != NullS)
57+
if (!(flag & MY_APPEND_EXT) &&
58+
(pos= (char*) strchr(name,FN_EXTCHAR)) != NullS)
5859
{
5960
if ((flag & MY_REPLACE_EXT) == 0) /* If we should keep old ext */
6061
{

0 commit comments

Comments
 (0)