mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge magare.gmz:/home/kgeorge/mysql/work/B29325-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B29325-5.1-opt include/my_base.h: Auto merged mysql-test/t/create.test: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/mi_create.c: Auto merged mysql-test/r/create.result: 5.0-opt -> 5.1-opt merge sql/set_var.cc: 5.0-opt -> 5.1-opt merge sql/sql_class.h: 5.0-opt -> 5.1-opt merge sql/sql_table.cc: 5.0-opt -> 5.1-opt merge sql/unireg.cc: 5.0-opt -> 5.1-opt merge
This commit is contained in:
@ -299,6 +299,7 @@ enum ha_base_keytype {
|
||||
#define HA_PACK_RECORD 2 /* Request packed record format */
|
||||
#define HA_CREATE_TMP_TABLE 4
|
||||
#define HA_CREATE_CHECKSUM 8
|
||||
#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
|
||||
#define HA_CREATE_DELAY_KEY_WRITE 64
|
||||
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
|
||||
|
||||
|
@ -1516,6 +1516,23 @@ t1 CREATE TABLE `t1` (
|
||||
`c17` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
CREATE DATABASE db1;
|
||||
CREATE DATABASE db2;
|
||||
USE db2;
|
||||
INSERT INTO db2.t1 VALUES (1);
|
||||
SELECT * FROM db2.t1;
|
||||
b
|
||||
1
|
||||
RESET QUERY CACHE;
|
||||
USE db1;
|
||||
SET SESSION keep_files_on_create = TRUE;
|
||||
CREATE TABLE t1 (a INT) ENGINE MYISAM;
|
||||
ERROR HY000: Can't create/write to file './db1/t1.MYD' (Errcode: 17)
|
||||
SET SESSION keep_files_on_create = DEFAULT;
|
||||
DROP TABLE db2.t1;
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
USE test;
|
||||
End of 5.0 tests
|
||||
CREATE TABLE t1 (a int, b int);
|
||||
insert into t1 values (1,1),(1,2);
|
||||
|
@ -1122,6 +1122,37 @@ show create table t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #29325: create table overwrites .MYD file of other table (datadir)
|
||||
#
|
||||
|
||||
CREATE DATABASE db1;
|
||||
CREATE DATABASE db2;
|
||||
|
||||
USE db2;
|
||||
--disable_query_log
|
||||
eval CREATE TABLE t1 (b INT) ENGINE MYISAM
|
||||
DATA DIRECTORY = '$MYSQLTEST_VARDIR/master-data/db1/';
|
||||
--enable_query_log
|
||||
|
||||
INSERT INTO db2.t1 VALUES (1);
|
||||
SELECT * FROM db2.t1;
|
||||
RESET QUERY CACHE;
|
||||
|
||||
USE db1;
|
||||
|
||||
#no warning from create table
|
||||
SET SESSION keep_files_on_create = TRUE;
|
||||
--disable_abort_on_error
|
||||
CREATE TABLE t1 (a INT) ENGINE MYISAM;
|
||||
--enable_abort_on_error
|
||||
SET SESSION keep_files_on_create = DEFAULT;
|
||||
|
||||
DROP TABLE db2.t1;
|
||||
DROP DATABASE db1;
|
||||
DROP DATABASE db2;
|
||||
USE test;
|
||||
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
|
@ -616,6 +616,8 @@ sys_var_thd_time_zone sys_time_zone(&vars, "time_zone");
|
||||
/* Global read-only variable containing hostname */
|
||||
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
|
||||
|
||||
sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
|
||||
&SV::keep_files_on_create);
|
||||
/* Read only variables */
|
||||
|
||||
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
|
||||
|
@ -305,6 +305,7 @@ struct system_variables
|
||||
my_bool old_mode;
|
||||
my_bool query_cache_wlock_invalidate;
|
||||
my_bool engine_condition_pushdown;
|
||||
my_bool keep_files_on_create;
|
||||
my_bool ndb_force_send;
|
||||
my_bool ndb_use_copying_alter_table;
|
||||
my_bool ndb_use_exact_count;
|
||||
|
@ -4697,8 +4697,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
|
||||
DBUG_EXECUTE_IF("sleep_create_like_before_ha_create", my_sleep(6000000););
|
||||
|
||||
dst_path[dst_path_length - reg_ext_length]= '\0'; // Remove .frm
|
||||
if (thd->variables.keep_files_on_create)
|
||||
create_info->options|= HA_CREATE_KEEP_FILES;
|
||||
err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
|
||||
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
|
||||
{
|
||||
if (err || !open_temporary_table(thd, dst_path, db, table_name, 1))
|
||||
|
@ -355,6 +355,8 @@ int rea_create_table(THD *thd, const char *path,
|
||||
|
||||
// Make sure mysql_create_frm din't remove extension
|
||||
DBUG_ASSERT(*fn_rext(frm_name));
|
||||
if (thd->variables.keep_files_on_create)
|
||||
create_info->options|= HA_CREATE_KEEP_FILES;
|
||||
if (file->create_handler_files(path, NULL, CHF_CREATE_FLAG, create_info))
|
||||
goto err_handler;
|
||||
if (!create_info->frm_only && ha_create_table(thd, path, db, table_name,
|
||||
|
@ -1889,6 +1889,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
|
||||
|
||||
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
|
||||
create_flags|= HA_CREATE_TMP_TABLE;
|
||||
if (ha_create_info->options & HA_CREATE_KEEP_FILES)
|
||||
create_flags|= HA_CREATE_KEEP_FILES;
|
||||
if (options & HA_OPTION_PACK_RECORD)
|
||||
create_flags|= HA_PACK_RECORD;
|
||||
if (options & HA_OPTION_CHECKSUM)
|
||||
|
@ -615,6 +615,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
|
||||
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
|
||||
linkname_ptr=0;
|
||||
/* Replace the current file */
|
||||
if (!(flags & HA_CREATE_KEEP_FILES))
|
||||
create_flag=MY_DELETE_OLD;
|
||||
}
|
||||
|
||||
@ -689,6 +690,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
|
||||
fn_format(filename,name,"", MI_NAME_DEXT,
|
||||
MY_UNPACK_FILENAME | MY_APPEND_EXT);
|
||||
linkname_ptr=0;
|
||||
if (!(flags & HA_CREATE_KEEP_FILES))
|
||||
create_flag=MY_DELETE_OLD;
|
||||
}
|
||||
if ((dfile=
|
||||
|
Reference in New Issue
Block a user