Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
35f566db
Commit
35f566db
authored
Jun 15, 2020
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: make dd_frm_type to work as documented
remove redundant argument, return all possible enum values
parent
2bb5981c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
35 deletions
+26
-35
sql/datadict.cc
sql/datadict.cc
+4
-9
sql/datadict.h
sql/datadict.h
+2
-4
sql/handler.cc
sql/handler.cc
+17
-16
sql/sql_plugin.cc
sql/sql_plugin.cc
+1
-2
sql/sql_show.cc
sql/sql_show.cc
+1
-2
storage/rocksdb/rdb_datadic.cc
storage/rocksdb/rdb_datadic.cc
+1
-2
No files found.
sql/datadict.cc
View file @
35f566db
...
...
@@ -49,16 +49,13 @@ static int read_string(File file, uchar**to, size_t length)
If engine_name is 0, then the function will only test if the file is a
view or not
@param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise
@retval TABLE_TYPE_UNKNOWN error - file can't be opened
@retval TABLE_TYPE_NORMAL table
@retval TABLE_TYPE_SEQUENCE sequence table
@retval TABLE_TYPE_VIEW view
*/
Table_type
dd_frm_type
(
THD
*
thd
,
char
*
path
,
LEX_CSTRING
*
engine_name
,
bool
*
is_sequence
)
Table_type
dd_frm_type
(
THD
*
thd
,
char
*
path
,
LEX_CSTRING
*
engine_name
)
{
File
file
;
uchar
header
[
40
];
//"TYPE=VIEW\n" it is 10 characters
...
...
@@ -67,10 +64,8 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
uchar
dbt
;
DBUG_ENTER
(
"dd_frm_type"
);
*
is_sequence
=
0
;
if
((
file
=
mysql_file_open
(
key_file_frm
,
path
,
O_RDONLY
|
O_SHARE
,
MYF
(
0
)))
<
0
)
file
=
mysql_file_open
(
key_file_frm
,
path
,
O_RDONLY
|
O_SHARE
,
MYF
(
0
));
if
(
file
<
0
)
DBUG_RETURN
(
TABLE_TYPE_UNKNOWN
);
/*
...
...
@@ -110,7 +105,7 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
if
(((
header
[
39
]
>>
4
)
&
3
)
==
HA_CHOICE_YES
)
{
DBUG_PRINT
(
"info"
,
(
"Sequence found"
));
*
is_sequence
=
1
;
type
=
TABLE_TYPE_SEQUENCE
;
}
/* cannot use ha_resolve_by_legacy_type without a THD */
...
...
sql/datadict.h
View file @
35f566db
...
...
@@ -38,13 +38,11 @@ enum Table_type
To check whether it's an frm of a view, use dd_frm_is_view().
*/
enum
Table_type
dd_frm_type
(
THD
*
thd
,
char
*
path
,
LEX_CSTRING
*
engine_name
,
bool
*
is_sequence
);
enum
Table_type
dd_frm_type
(
THD
*
thd
,
char
*
path
,
LEX_CSTRING
*
engine_name
);
static
inline
bool
dd_frm_is_view
(
THD
*
thd
,
char
*
path
)
{
bool
not_used2
;
return
dd_frm_type
(
thd
,
path
,
NULL
,
&
not_used2
)
==
TABLE_TYPE_VIEW
;
return
dd_frm_type
(
thd
,
path
,
NULL
)
==
TABLE_TYPE_VIEW
;
}
bool
dd_recreate_table
(
THD
*
thd
,
const
char
*
db
,
const
char
*
table_name
);
...
...
sql/handler.cc
View file @
35f566db
...
...
@@ -5837,27 +5837,28 @@ bool ha_table_exists(THD *thd, const LEX_CSTRING *db,
{
char
engine_buf
[
NAME_CHAR_LEN
+
1
];
LEX_CSTRING
engine
=
{
engine_buf
,
0
};
Table_type
type
;
Table_type
type
=
dd_frm_type
(
thd
,
path
,
&
engine
)
;
if
((
type
=
dd_frm_type
(
thd
,
path
,
&
engine
,
is_sequence
))
==
TABLE_TYPE_UNKNOWN
)
{
DBUG_PRINT
(
"exit"
,
(
"Does not exist"
));
switch
(
type
)
{
case
TABLE_TYPE_UNKNOWN
:
DBUG_PRINT
(
"exit"
,
(
"Exist, cannot be opened"
));
DBUG_RETURN
(
true
);
// Frm exists
}
if
(
type
!=
TABLE_TYPE_VIEW
)
{
plugin_ref
p
=
plugin_lock_by_name
(
thd
,
&
engine
,
MYSQL_STORAGE_ENGINE_PLUGIN
);
*
hton
=
p
?
plugin_hton
(
p
)
:
NULL
;
if
(
*
hton
)
case
TABLE_TYPE_VIEW
:
*
hton
=
view_pseudo_hton
;
DBUG_PRINT
(
"exit"
,
(
"Exist, view"
));
DBUG_RETURN
(
true
);
// Frm exists
case
TABLE_TYPE_SEQUENCE
:
*
is_sequence
=
true
;
/* fall through */
case
TABLE_TYPE_NORMAL
:
{
// verify that the table really exists
exists
=
discover_existence
(
thd
,
p
,
&
args
);
plugin_ref
p
=
plugin_lock_by_name
(
thd
,
&
engine
,
MYSQL_STORAGE_ENGINE_PLUGIN
);
*
hton
=
p
?
plugin_hton
(
p
)
:
NULL
;
if
(
*
hton
)
// verify that the table really exists
exists
=
discover_existence
(
thd
,
p
,
&
args
);
}
}
else
*
hton
=
view_pseudo_hton
;
}
DBUG_PRINT
(
"exit"
,
(
exists
?
"Exists"
:
"Does not exist"
));
DBUG_RETURN
(
exists
);
...
...
sql/sql_plugin.cc
View file @
35f566db
...
...
@@ -1720,8 +1720,7 @@ int plugin_init(int *argc, char **argv, int flags)
{
char
path
[
FN_REFLEN
+
1
];
build_table_filename
(
path
,
sizeof
(
path
)
-
1
,
"mysql"
,
"plugin"
,
reg_ext
,
0
);
bool
dummy
;
Table_type
ttype
=
dd_frm_type
(
0
,
path
,
&
plugin_table_engine_name
,
&
dummy
);
Table_type
ttype
=
dd_frm_type
(
0
,
path
,
&
plugin_table_engine_name
);
if
(
ttype
!=
TABLE_TYPE_NORMAL
)
plugin_table_engine_name
=
empty_clex_str
;
}
...
...
sql/sql_show.cc
View file @
35f566db
...
...
@@ -4479,8 +4479,7 @@ static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
char
path
[
FN_REFLEN
];
build_table_filename
(
path
,
sizeof
(
path
)
-
1
,
db
->
str
,
table
->
str
,
reg_ext
,
0
);
bool
is_sequence
;
if
(
dd_frm_type
(
thd
,
path
,
&
engine_name
,
&
is_sequence
)
==
TABLE_TYPE_NORMAL
)
if
(
dd_frm_type
(
thd
,
path
,
&
engine_name
)
==
TABLE_TYPE_NORMAL
)
tl
->
option
=
engine_name
.
str
;
}
}
...
...
storage/rocksdb/rdb_datadic.cc
View file @
35f566db
...
...
@@ -3793,8 +3793,7 @@ bool Rdb_validate_tbls::check_frm_file(const std::string &fullpath,
*/
char
eng_type_buf
[
NAME_CHAR_LEN
+
1
];
LEX_CSTRING
eng_type_str
=
{
eng_type_buf
,
0
};
bool
is_sequence
;
enum
Table_type
type
=
dd_frm_type
(
nullptr
,
fullfilename
.
c_ptr
(),
&
eng_type_str
,
&
is_sequence
);
enum
Table_type
type
=
dd_frm_type
(
nullptr
,
fullfilename
.
c_ptr
(),
&
eng_type_str
);
if
(
type
==
TABLE_TYPE_UNKNOWN
)
{
// NO_LINT_DEBUG
sql_print_warning
(
"RocksDB: Failed to open/read .from file: %s"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment