mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
open frm for DROP TABLE
needed to get partitioning and information about secondary objects
This commit is contained in:
parent
c1b4f3a32c
commit
aa09cb3b11
6 changed files with 57 additions and 18 deletions
|
@ -176,7 +176,7 @@ create table t2 (b int, constraint foo check (b < 10));
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
show status like "feature_check_constraint";
|
show status like "feature_check_constraint";
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Feature_check_constraint 2
|
Feature_check_constraint 4
|
||||||
#
|
#
|
||||||
# Feature insert...returning
|
# Feature insert...returning
|
||||||
#
|
#
|
||||||
|
|
|
@ -444,7 +444,7 @@ d int(11) YES UNI NULL
|
||||||
drop table t1;
|
drop table t1;
|
||||||
SHOW STATUS LIKE 'Feature_invisible_columns';
|
SHOW STATUS LIKE 'Feature_invisible_columns';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Feature_invisible_columns 52
|
Feature_invisible_columns 54
|
||||||
#invisible is non reserved
|
#invisible is non reserved
|
||||||
create table t1(a int unique , invisible int invisible, c int );
|
create table t1(a int unique , invisible int invisible, c int );
|
||||||
desc t1;
|
desc t1;
|
||||||
|
|
|
@ -93,7 +93,7 @@ drop table t0;
|
||||||
db.opt
|
db.opt
|
||||||
show status like 'Handler_discover';
|
show status like 'Handler_discover';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
Handler_discover 6
|
Handler_discover 7
|
||||||
#
|
#
|
||||||
# Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
|
# Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
|
||||||
#
|
#
|
||||||
|
|
|
@ -1329,6 +1329,13 @@ public:
|
||||||
{
|
{
|
||||||
return strmake_lex_cstring(from.str, from.length);
|
return strmake_lex_cstring(from.str, from.length);
|
||||||
}
|
}
|
||||||
|
LEX_CUSTRING strmake_lex_custring(const LEX_CUSTRING &from) const
|
||||||
|
{
|
||||||
|
const void *tmp= memdup(from.str, from.length);
|
||||||
|
if (!tmp)
|
||||||
|
return {0,0};
|
||||||
|
return {(const uchar*)tmp, from.length};
|
||||||
|
}
|
||||||
LEX_CSTRING strmake_lex_cstring_trim_whitespace(const LEX_CSTRING &from,
|
LEX_CSTRING strmake_lex_cstring_trim_whitespace(const LEX_CSTRING &from,
|
||||||
CHARSET_INFO *cs)
|
CHARSET_INFO *cs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1265,6 +1265,7 @@ static uint32 get_comment(THD *thd, uint32 comment_pos,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Execute the drop of a sequence, view or table (normal or temporary).
|
Execute the drop of a sequence, view or table (normal or temporary).
|
||||||
|
|
||||||
|
@ -1535,20 +1536,51 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables,
|
||||||
|
|
||||||
cpath = { path, (size_t)(path_end - path) };
|
cpath = { path, (size_t)(path_end - path) };
|
||||||
|
|
||||||
|
Dummy_error_handler err_handler;
|
||||||
|
thd->push_internal_handler(&err_handler);
|
||||||
|
if (TABLE_SHARE *share= tdc_acquire_share(thd, table, GTS_TABLE))
|
||||||
{
|
{
|
||||||
char engine_buf[NAME_CHAR_LEN + 1];
|
table_type= share->table_type;
|
||||||
LEX_CSTRING engine= { engine_buf, 0 };
|
hton= plugin_hton(plugin_lock(thd, share->db_plugin));
|
||||||
|
version= thd->strmake_lex_custring(share->tabledef_version);
|
||||||
table_type= dd_frm_type(thd, path, &engine, &partition_engine_name,
|
if (plugin_ref pp= IF_PARTITIONING(share->default_part_plugin, NULL))
|
||||||
&version);
|
partition_engine_name= thd->strmake_lex_cstring(*plugin_name(pp));
|
||||||
if (table_type == TABLE_TYPE_NORMAL || table_type == TABLE_TYPE_SEQUENCE)
|
tdc_release_share(share);
|
||||||
{
|
|
||||||
plugin_ref p= plugin_lock_by_name(thd, &engine,
|
|
||||||
MYSQL_STORAGE_ENGINE_PLUGIN);
|
|
||||||
hton= p ? plugin_hton(p) : NULL;
|
|
||||||
}
|
|
||||||
// note that for TABLE_TYPE_VIEW and TABLE_TYPE_UNKNOWN hton == NULL
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (err_handler.got_error()) {
|
||||||
|
case ER_WRONG_OBJECT:
|
||||||
|
table_type= TABLE_TYPE_VIEW;
|
||||||
|
break;
|
||||||
|
case ER_NO_SUCH_TABLE: /* no .frm */
|
||||||
|
table_type= TABLE_TYPE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
case ER_NOT_FORM_FILE:
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
cannot open the frm, let's at least get the engine
|
||||||
|
see main.partition_not_blackhole and connect.drop-open-error
|
||||||
|
*/
|
||||||
|
char engine_buf[NAME_CHAR_LEN + 1];
|
||||||
|
LEX_CSTRING engine= { engine_buf, 0 };
|
||||||
|
table_type= dd_frm_type(thd, path, &engine, NULL, &version);
|
||||||
|
if (table_type == TABLE_TYPE_NORMAL || table_type == TABLE_TYPE_SEQUENCE)
|
||||||
|
{
|
||||||
|
plugin_ref p= plugin_lock_by_name(thd, &engine,
|
||||||
|
MYSQL_STORAGE_ENGINE_PLUGIN);
|
||||||
|
hton= p ? plugin_hton(p) : NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ER_FAILED_READ_FROM_PAR_FILE: /* no .par file */
|
||||||
|
hton= partition_hton;
|
||||||
|
/* fall through */
|
||||||
|
default: /* unreadable (corrupted?) .frm, still need to DROP it */
|
||||||
|
table_type= TABLE_TYPE_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thd->pop_internal_handler();
|
||||||
|
|
||||||
thd->replication_flags= 0;
|
thd->replication_flags= 0;
|
||||||
const bool was_view= table_type == TABLE_TYPE_VIEW;
|
const bool was_view= table_type == TABLE_TYPE_VIEW;
|
||||||
|
|
|
@ -663,7 +663,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
|
||||||
File file;
|
File file;
|
||||||
uchar *buf;
|
uchar *buf;
|
||||||
uchar head[FRM_HEADER_SIZE];
|
uchar head[FRM_HEADER_SIZE];
|
||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN + 1];
|
||||||
size_t frmlen, read_length;
|
size_t frmlen, read_length;
|
||||||
uint length;
|
uint length;
|
||||||
DBUG_ENTER("open_table_def");
|
DBUG_ENTER("open_table_def");
|
||||||
|
@ -672,8 +672,8 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
|
||||||
|
|
||||||
share->error= OPEN_FRM_OPEN_ERROR;
|
share->error= OPEN_FRM_OPEN_ERROR;
|
||||||
|
|
||||||
length=(uint) (strxmov(path, share->normalized_path.str, reg_ext, NullS) -
|
length=(uint) (strxnmov(path, sizeof(path) - 1,
|
||||||
path);
|
share->normalized_path.str, reg_ext, NullS) - path);
|
||||||
if (flags & GTS_FORCE_DISCOVERY)
|
if (flags & GTS_FORCE_DISCOVERY)
|
||||||
{
|
{
|
||||||
const char *path2= share->normalized_path.str;
|
const char *path2= share->normalized_path.str;
|
||||||
|
|
Loading…
Reference in a new issue