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
5ad68a0d
Commit
5ad68a0d
authored
Apr 09, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't use I_S constants for open_table_def and get_table_share,
have a specially defined enum with clearly named values
parent
cda52b2c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
37 deletions
+31
-37
sql/handler.cc
sql/handler.cc
+2
-2
sql/sql_admin.cc
sql/sql_admin.cc
+2
-2
sql/sql_base.cc
sql/sql_base.cc
+14
-18
sql/sql_base.h
sql/sql_base.h
+1
-1
sql/sql_show.cc
sql/sql_show.cc
+2
-2
sql/sql_table.cc
sql/sql_table.cc
+1
-1
sql/table.cc
sql/table.cc
+3
-9
sql/table.h
sql/table.h
+6
-2
No files found.
sql/handler.cc
View file @
5ad68a0d
...
...
@@ -4104,7 +4104,7 @@ int ha_create_table(THD *thd, const char *path,
DBUG_ENTER
(
"ha_create_table"
);
init_tmp_table_share
(
thd
,
&
share
,
db
,
0
,
table_name
,
path
);
if
(
open_table_def
(
thd
,
&
share
,
0
)
||
if
(
open_table_def
(
thd
,
&
share
)
||
open_table_from_share
(
thd
,
&
share
,
""
,
0
,
(
uint
)
READ_ALL
,
0
,
&
table
,
TRUE
))
goto
err
;
...
...
@@ -4171,7 +4171,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
DBUG_RETURN
(
2
);
init_tmp_table_share
(
thd
,
&
share
,
db
,
0
,
name
,
path
);
if
(
open_table_def
(
thd
,
&
share
,
0
))
if
(
open_table_def
(
thd
,
&
share
))
{
DBUG_RETURN
(
3
);
}
...
...
sql/sql_admin.cc
View file @
5ad68a0d
...
...
@@ -128,8 +128,8 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
hash_value
=
my_calc_hash
(
&
table_def_cache
,
(
uchar
*
)
key
,
key_length
);
mysql_mutex_lock
(
&
LOCK_open
);
share
=
get_table_share
(
thd
,
table_list
,
key
,
key_length
,
0
,
&
error
,
hash_value
);
share
=
get_table_share
(
thd
,
table_list
,
key
,
key_length
,
FRM_READ_TABLE_ONLY
,
&
error
,
hash_value
);
mysql_mutex_unlock
(
&
LOCK_open
);
if
(
share
==
NULL
)
DBUG_RETURN
(
0
);
// Can't open frm file
...
...
sql/sql_base.cc
View file @
5ad68a0d
...
...
@@ -575,7 +575,7 @@ static void table_def_unuse_table(TABLE *table)
*/
TABLE_SHARE
*
get_table_share
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
char
*
key
,
uint
key_length
,
uint
db_flags
,
int
*
error
,
uint
key_length
,
enum
read_frm_op
op
,
int
*
error
,
my_hash_value_type
hash_value
)
{
TABLE_SHARE
*
share
;
...
...
@@ -622,7 +622,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
free_table_share
(
share
);
DBUG_RETURN
(
0
);
// return error
}
if
(
open_table_def
(
thd
,
share
,
db_flags
))
if
(
open_table_def
(
thd
,
share
,
op
))
{
*
error
=
share
->
error
;
(
void
)
my_hash_delete
(
&
table_def_cache
,
(
uchar
*
)
share
);
...
...
@@ -644,7 +644,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
open_table_error
(
share
,
share
->
error
,
share
->
open_errno
,
share
->
errarg
);
DBUG_RETURN
(
0
);
}
if
(
share
->
is_view
&&
!
(
db_flags
&
OPEN_VIEW
)
)
if
(
share
->
is_view
&&
op
!=
FRM_READ_NO_ERROR_FOR_VIEW
)
{
open_table_error
(
share
,
1
,
ENOENT
,
0
);
DBUG_RETURN
(
0
);
...
...
@@ -685,7 +685,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
static
TABLE_SHARE
*
get_table_share_with_discover
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
char
*
key
,
uint
key_length
,
uint
db_flags
,
int
*
error
,
enum
read_frm_op
op
,
int
*
error
,
my_hash_value_type
hash_value
)
{
...
...
@@ -693,7 +693,7 @@ get_table_share_with_discover(THD *thd, TABLE_LIST *table_list,
bool
exists
;
DBUG_ENTER
(
"get_table_share_with_discover"
);
share
=
get_table_share
(
thd
,
table_list
,
key
,
key_length
,
db_flags
,
error
,
share
=
get_table_share
(
thd
,
table_list
,
key
,
key_length
,
op
,
error
,
hash_value
);
/*
If share is not NULL, we found an existing share.
...
...
@@ -3014,10 +3014,9 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
mysql_mutex_lock
(
&
LOCK_open
);
if
(
!
(
share
=
get_table_share_with_discover
(
thd
,
table_list
,
key
,
key_length
,
OPEN_VIEW
,
&
error
,
hash_value
)))
if
(
!
(
share
=
get_table_share_with_discover
(
thd
,
table_list
,
key
,
key_length
,
FRM_READ_NO_ERROR_FOR_VIEW
,
&
error
,
hash_value
)))
{
mysql_mutex_unlock
(
&
LOCK_open
);
/*
...
...
@@ -3856,10 +3855,8 @@ bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias,
cache_key_length
);
mysql_mutex_lock
(
&
LOCK_open
);
if
(
!
(
share
=
get_table_share
(
thd
,
table_list
,
cache_key
,
cache_key_length
,
OPEN_VIEW
,
&
error
,
hash_value
)))
if
(
!
(
share
=
get_table_share
(
thd
,
table_list
,
cache_key
,
cache_key_length
,
FRM_READ_NO_ERROR_FOR_VIEW
,
&
error
,
hash_value
)))
goto
err
;
if
(
share
->
is_view
&&
...
...
@@ -3949,9 +3946,8 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
cache_key_length
);
mysql_mutex_lock
(
&
LOCK_open
);
if
(
!
(
share
=
get_table_share
(
thd
,
table_list
,
cache_key
,
cache_key_length
,
OPEN_VIEW
,
&
not_used
,
if
(
!
(
share
=
get_table_share
(
thd
,
table_list
,
cache_key
,
cache_key_length
,
FRM_READ_NO_ERROR_FOR_VIEW
,
&
not_used
,
hash_value
)))
goto
end_unlock
;
...
...
@@ -6117,7 +6113,7 @@ TABLE *open_table_uncached(THD *thd, const char *path, const char *db,
init_tmp_table_share
(
thd
,
share
,
saved_cache_key
,
key_length
,
strend
(
saved_cache_key
)
+
1
,
tmp_path
);
if
(
open_table_def
(
thd
,
share
,
0
)
||
if
(
open_table_def
(
thd
,
share
)
||
open_table_from_share
(
thd
,
share
,
table_name
,
(
uint
)
(
HA_OPEN_KEYFILE
|
HA_OPEN_RNDFILE
|
HA_GET_INDEX
),
...
...
@@ -9249,7 +9245,7 @@ my_bool mysql_rm_tmp_tables(void)
memcpy
(
filePathCopy
,
filePath
,
filePath_len
-
ext_len
);
filePathCopy
[
filePath_len
-
ext_len
]
=
0
;
init_tmp_table_share
(
thd
,
&
share
,
""
,
0
,
""
,
filePathCopy
);
if
(
!
open_table_def
(
thd
,
&
share
,
0
)
&&
if
(
!
open_table_def
(
thd
,
&
share
)
&&
((
handler_file
=
get_new_handler
(
&
share
,
thd
->
mem_root
,
share
.
db_type
()))))
{
...
...
sql/sql_base.h
View file @
5ad68a0d
...
...
@@ -108,7 +108,7 @@ create_table_def_key(char *key, const char *db, const char *table_name)
}
TABLE_SHARE
*
get_table_share
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
char
*
key
,
uint
key_length
,
uint
db_flags
,
int
*
error
,
uint
key_length
,
enum
read_frm_op
op
,
int
*
error
,
my_hash_value_type
hash_value
);
void
release_table_share
(
TABLE_SHARE
*
share
);
TABLE_SHARE
*
get_cached_table_share
(
const
char
*
db
,
const
char
*
table_name
);
...
...
sql/sql_show.cc
View file @
5ad68a0d
...
...
@@ -4383,8 +4383,8 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables,
key_length
=
create_table_def_key
(
thd
,
key
,
&
table_list
,
0
);
hash_value
=
my_calc_hash
(
&
table_def_cache
,
(
uchar
*
)
key
,
key_length
);
mysql_mutex_lock
(
&
LOCK_open
);
share
=
get_table_share
(
thd
,
&
table_list
,
key
,
key_length
,
OPEN
_VIEW
,
&
not_used
,
hash_value
);
share
=
get_table_share
(
thd
,
&
table_list
,
key
,
key_length
,
FRM_READ_NO_ERROR_FOR
_VIEW
,
&
not_used
,
hash_value
);
if
(
!
share
)
{
res
=
0
;
...
...
sql/sql_table.cc
View file @
5ad68a0d
...
...
@@ -4023,7 +4023,7 @@ static bool check_if_created_table_can_be_opened(THD *thd,
init_tmp_table_share
(
thd
,
&
share
,
db
,
0
,
table_name
,
path
);
result
=
(
open_table_def
(
thd
,
&
share
,
0
)
||
result
=
(
open_table_def
(
thd
,
&
share
)
||
open_table_from_share
(
thd
,
&
share
,
""
,
0
,
(
uint
)
READ_ALL
,
0
,
&
table
,
TRUE
));
if
(
!
result
)
...
...
sql/table.cc
View file @
5ad68a0d
...
...
@@ -619,7 +619,7 @@ static bool has_disabled_path_chars(const char *str)
6 Unknown .frm version
*/
int
open_table_def
(
THD
*
thd
,
TABLE_SHARE
*
share
,
uint
db_flags
)
int
open_table_def
(
THD
*
thd
,
TABLE_SHARE
*
share
,
enum
read_frm_op
op
)
{
int
error
,
table_type
;
bool
error_given
;
...
...
@@ -693,17 +693,11 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags)
if
(
head
[
2
]
==
FRM_VER
||
head
[
2
]
==
FRM_VER
+
1
||
(
head
[
2
]
>=
FRM_VER
+
3
&&
head
[
2
]
<=
FRM_VER
+
4
))
{
/* Open view only */
if
(
db_flags
&
OPEN_VIEW_ONLY
)
{
error_given
=
1
;
goto
err
;
}
table_type
=
1
;
}
else
{
error
=
6
;
// Unkown .frm version
error
=
6
;
// Unk
n
own .frm version
goto
err
;
}
}
...
...
@@ -713,7 +707,7 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags)
if
(
memcmp
(
head
+
5
,
"VIEW"
,
4
)
==
0
)
{
share
->
is_view
=
1
;
if
(
db_flags
&
OPEN
_VIEW
)
if
(
op
==
FRM_READ_NO_ERROR_FOR
_VIEW
)
error
=
0
;
}
goto
err
;
...
...
sql/table.h
View file @
5ad68a0d
...
...
@@ -2433,10 +2433,13 @@ static inline void dbug_tmp_restore_column_maps(MY_BITMAP *read_set,
#endif
}
enum
read_frm_op
{
FRM_READ_TABLE_ONLY
,
FRM_READ_NO_ERROR_FOR_VIEW
};
size_t
max_row_length
(
TABLE
*
table
,
const
uchar
*
data
);
void
init_mdl_requests
(
TABLE_LIST
*
table_list
);
int
open_table_from_share
(
THD
*
thd
,
TABLE_SHARE
*
share
,
const
char
*
alias
,
...
...
@@ -2451,7 +2454,8 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
uint
key_length
,
const
char
*
table_name
,
const
char
*
path
);
void
free_table_share
(
TABLE_SHARE
*
share
);
int
open_table_def
(
THD
*
thd
,
TABLE_SHARE
*
share
,
uint
db_flags
);
int
open_table_def
(
THD
*
thd
,
TABLE_SHARE
*
share
,
enum
read_frm_op
op
=
FRM_READ_TABLE_ONLY
);
void
open_table_error
(
TABLE_SHARE
*
share
,
int
error
,
int
db_errno
,
int
errarg
);
void
update_create_info_from_table
(
HA_CREATE_INFO
*
info
,
TABLE
*
form
);
bool
check_and_convert_db_name
(
LEX_STRING
*
db
,
bool
preserve_lettercase
);
...
...
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