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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
4cb96343
Commit
4cb96343
authored
Jul 20, 2005
by
mronstrom@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #10600 After review fixes
parent
2d23c691
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
29 deletions
+18
-29
sql/lock.cc
sql/lock.cc
+1
-2
sql/mysql_priv.h
sql/mysql_priv.h
+4
-3
sql/sql_base.cc
sql/sql_base.cc
+7
-15
sql/sql_table.cc
sql/sql_table.cc
+6
-9
No files found.
sql/lock.cc
View file @
4cb96343
...
@@ -549,9 +549,8 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
...
@@ -549,9 +549,8 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list)
}
}
{
{
uint
flags
=
0
;
if
(
remove_table_from_cache
(
thd
,
db
,
if
(
remove_table_from_cache
(
thd
,
db
,
table_list
->
real_name
,
flags
))
table_list
->
real_name
,
RTFC_NO_FLAG
))
{
{
DBUG_RETURN
(
1
);
// Table is in use
DBUG_RETURN
(
1
);
// Table is in use
}
}
...
...
sql/mysql_priv.h
View file @
4cb96343
...
@@ -606,9 +606,10 @@ bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
...
@@ -606,9 +606,10 @@ bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
const
char
*
table_name
);
const
char
*
table_name
);
void
remove_db_from_cache
(
const
my_string
db
);
void
remove_db_from_cache
(
const
my_string
db
);
void
flush_tables
();
void
flush_tables
();
#define OWNED_BY_THD_FLAG 1
#define RTFC_NO_FLAG 0x0000
#define WAIT_OTHER_THREAD_FLAG 2
#define RTFC_OWNED_BY_THD_FLAG 0x0001
#define CHECK_KILLED_FLAG 4
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
#define RTFC_CHECK_KILLED_FLAG 0x0004
bool
remove_table_from_cache
(
THD
*
thd
,
const
char
*
db
,
const
char
*
table
,
bool
remove_table_from_cache
(
THD
*
thd
,
const
char
*
db
,
const
char
*
table
,
uint
flags
);
uint
flags
);
bool
close_cached_tables
(
THD
*
thd
,
bool
wait_for_refresh
,
TABLE_LIST
*
tables
);
bool
close_cached_tables
(
THD
*
thd
,
bool
wait_for_refresh
,
TABLE_LIST
*
tables
);
...
...
sql/sql_base.cc
View file @
4cb96343
...
@@ -370,9 +370,8 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
...
@@ -370,9 +370,8 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
bool
found
=
0
;
bool
found
=
0
;
for
(
TABLE_LIST
*
table
=
tables
;
table
;
table
=
table
->
next
)
for
(
TABLE_LIST
*
table
=
tables
;
table
;
table
=
table
->
next
)
{
{
uint
flags
=
OWNED_BY_THD_FLAG
;
if
(
remove_table_from_cache
(
thd
,
table
->
db
,
table
->
real_name
,
if
(
remove_table_from_cache
(
thd
,
table
->
db
,
table
->
real_name
,
flags
))
RTFC_OWNED_BY_THD_FLAG
))
found
=
1
;
found
=
1
;
}
}
if
(
!
found
)
if
(
!
found
)
...
@@ -2415,13 +2414,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
...
@@ -2415,13 +2414,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
uint
key_length
;
uint
key_length
;
TABLE
*
table
;
TABLE
*
table
;
bool
result
=
0
,
signalled
=
0
;
bool
result
=
0
,
signalled
=
0
;
bool
return_if_owned_by_thd
=
flags
&
OWNED_BY_THD_FLAG
;
bool
wait_for_other_thread
=
flags
&
WAIT_OTHER_THREAD_FLAG
;
bool
check_killed_flag
=
flags
&
CHECK_KILLED_FLAG
;
DBUG_ENTER
(
"remove_table_from_cache"
);
DBUG_ENTER
(
"remove_table_from_cache"
);
key_length
=
(
uint
)
(
strmov
(
strmov
(
key
,
db
)
+
1
,
table_name
)
-
key
)
+
1
;
key_length
=
(
uint
)
(
strmov
(
strmov
(
key
,
db
)
+
1
,
table_name
)
-
key
)
+
1
;
do
for
(;;)
{
{
result
=
signalled
=
0
;
result
=
signalled
=
0
;
...
@@ -2465,21 +2461,17 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
...
@@ -2465,21 +2461,17 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
thd_table
=
thd_table
->
next
)
thd_table
=
thd_table
->
next
)
{
{
if
(
thd_table
->
db_stat
)
// If table is open
if
(
thd_table
->
db_stat
)
// If table is open
{
signalled
|=
mysql_lock_abort_for_thread
(
thd
,
thd_table
);
bool
found
;
found
=
mysql_lock_abort_for_thread
(
thd
,
thd_table
);
signalled
|=
found
;
}
}
}
}
}
else
else
result
=
result
||
return_if_owned_by_thd
;
result
=
result
||
(
flags
&
RTFC_OWNED_BY_THD_FLAG
)
;
}
}
while
(
unused_tables
&&
!
unused_tables
->
version
)
while
(
unused_tables
&&
!
unused_tables
->
version
)
VOID
(
hash_delete
(
&
open_cache
,(
byte
*
)
unused_tables
));
VOID
(
hash_delete
(
&
open_cache
,(
byte
*
)
unused_tables
));
if
(
result
&&
wait_for_other_thread
)
if
(
result
&&
(
flags
&
RTFC_WAIT_OTHER_THREAD_FLAG
)
)
{
{
if
(
!
check_killed_flag
||
!
thd
->
killed
)
if
(
!
(
flags
&
RTFC_CHECK_KILLED_FLAG
)
||
!
thd
->
killed
)
{
{
if
(
likely
(
signalled
))
if
(
likely
(
signalled
))
{
{
...
@@ -2508,7 +2500,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
...
@@ -2508,7 +2500,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
}
}
}
}
break
;
break
;
}
while
(
1
);
}
DBUG_RETURN
(
result
);
DBUG_RETURN
(
result
);
}
}
...
...
sql/sql_table.cc
View file @
4cb96343
...
@@ -187,7 +187,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
...
@@ -187,7 +187,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
}
abort_locked_tables
(
thd
,
db
,
table
->
real_name
);
abort_locked_tables
(
thd
,
db
,
table
->
real_name
);
flags
=
WAIT_OTHER_THREAD_FLAG
|
CHECK_KILLED_FLAG
;
flags
=
RTFC_WAIT_OTHER_THREAD_FLAG
|
RTFC_
CHECK_KILLED_FLAG
;
remove_table_from_cache
(
thd
,
db
,
table
->
real_name
,
flags
);
remove_table_from_cache
(
thd
,
db
,
table
->
real_name
,
flags
);
drop_locked_tables
(
thd
,
db
,
table
->
real_name
);
drop_locked_tables
(
thd
,
db
,
table
->
real_name
);
if
(
thd
->
killed
)
if
(
thd
->
killed
)
...
@@ -976,7 +976,6 @@ mysql_rename_table(enum db_type base,
...
@@ -976,7 +976,6 @@ mysql_rename_table(enum db_type base,
static
void
wait_while_table_is_used
(
THD
*
thd
,
TABLE
*
table
,
static
void
wait_while_table_is_used
(
THD
*
thd
,
TABLE
*
table
,
enum
ha_extra_function
function
)
enum
ha_extra_function
function
)
{
{
uint
flags
;
DBUG_PRINT
(
"enter"
,(
"table: %s"
,
table
->
real_name
));
DBUG_PRINT
(
"enter"
,(
"table: %s"
,
table
->
real_name
));
DBUG_ENTER
(
"wait_while_table_is_used"
);
DBUG_ENTER
(
"wait_while_table_is_used"
);
safe_mutex_assert_owner
(
&
LOCK_open
);
safe_mutex_assert_owner
(
&
LOCK_open
);
...
@@ -986,9 +985,8 @@ static void wait_while_table_is_used(THD *thd,TABLE *table,
...
@@ -986,9 +985,8 @@ static void wait_while_table_is_used(THD *thd,TABLE *table,
mysql_lock_abort
(
thd
,
table
);
// end threads waiting on lock
mysql_lock_abort
(
thd
,
table
);
// end threads waiting on lock
/* Wait until all there are no other threads that has this table open */
/* Wait until all there are no other threads that has this table open */
flags
=
WAIT_OTHER_THREAD_FLAG
;
remove_table_from_cache
(
thd
,
table
->
table_cache_key
,
remove_table_from_cache
(
thd
,
table
->
table_cache_key
,
table
->
real_name
,
flags
);
table
->
real_name
,
RTFC_WAIT_OTHER_THREAD_FLAG
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -1305,7 +1303,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
...
@@ -1305,7 +1303,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
const
char
*
old_message
=
thd
->
enter_cond
(
&
COND_refresh
,
&
LOCK_open
,
const
char
*
old_message
=
thd
->
enter_cond
(
&
COND_refresh
,
&
LOCK_open
,
"Waiting to get writelock"
);
"Waiting to get writelock"
);
mysql_lock_abort
(
thd
,
table
->
table
);
mysql_lock_abort
(
thd
,
table
->
table
);
flags
=
WAIT_OTHER_THREAD_FLAG
|
CHECK_KILLED_FLAG
;
flags
=
RTFC_WAIT_OTHER_THREAD_FLAG
|
RTFC_
CHECK_KILLED_FLAG
;
remove_table_from_cache
(
thd
,
table
->
table
->
table_cache_key
,
remove_table_from_cache
(
thd
,
table
->
table
->
table_cache_key
,
table
->
table
->
real_name
,
flags
);
table
->
table
->
real_name
,
flags
);
thd
->
exit_cond
(
old_message
);
thd
->
exit_cond
(
old_message
);
...
@@ -1372,10 +1370,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
...
@@ -1372,10 +1370,9 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
table
->
table
->
version
=
0
;
// Force close of table
table
->
table
->
version
=
0
;
// Force close of table
else
if
(
open_for_modify
)
else
if
(
open_for_modify
)
{
{
uint
flags
=
0
;
pthread_mutex_lock
(
&
LOCK_open
);
pthread_mutex_lock
(
&
LOCK_open
);
remove_table_from_cache
(
thd
,
table
->
table
->
table_cache_key
,
remove_table_from_cache
(
thd
,
table
->
table
->
table_cache_key
,
table
->
table
->
real_name
,
flags
);
table
->
table
->
real_name
,
RTFC_NO_FLAG
);
pthread_mutex_unlock
(
&
LOCK_open
);
pthread_mutex_unlock
(
&
LOCK_open
);
/* May be something modified consequently we have to invalidate cache */
/* May be something modified consequently we have to invalidate cache */
query_cache_invalidate3
(
thd
,
table
->
table
,
0
);
query_cache_invalidate3
(
thd
,
table
->
table
,
0
);
...
@@ -2099,9 +2096,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
...
@@ -2099,9 +2096,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/
*/
if
(
table
)
if
(
table
)
{
{
uint
flags
=
0
;
VOID
(
table
->
file
->
extra
(
HA_EXTRA_FORCE_REOPEN
));
// Use new file
VOID
(
table
->
file
->
extra
(
HA_EXTRA_FORCE_REOPEN
));
// Use new file
remove_table_from_cache
(
thd
,
db
,
table_name
,
flags
);
// Mark in-use copies old
remove_table_from_cache
(
thd
,
db
,
table_name
,
RTFC_NO_FLAG
);
// Mark in-use copies old
mysql_lock_abort
(
thd
,
table
);
// end threads waiting on lock
mysql_lock_abort
(
thd
,
table
);
// end threads waiting on lock
}
}
VOID
(
quick_rm_table
(
old_db_type
,
db
,
old_name
));
VOID
(
quick_rm_table
(
old_db_type
,
db
,
old_name
));
...
...
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