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
b6ab762d
Commit
b6ab762d
authored
Feb 28, 2003
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closing tables during SP execution the proper way.
parent
16cff7e7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
37 deletions
+18
-37
mysql-test/r/show_check.result
mysql-test/r/show_check.result
+1
-0
mysql-test/r/status.result
mysql-test/r/status.result
+1
-1
sql/sp.cc
sql/sp.cc
+11
-9
sql/sp_head.cc
sql/sp_head.cc
+5
-0
sql/sql_class.cc
sql/sql_class.cc
+0
-27
No files found.
mysql-test/r/show_check.result
View file @
b6ab762d
...
...
@@ -127,6 +127,7 @@ insert into t1 values (1);
show open tables;
Database Table In_use Name_locked
test t1 0 0
mysql proc 0 0
drop table t1;
create table t1 (a int not null, b VARCHAR(10), INDEX (b) ) AVG_ROW_LENGTH=10 CHECKSUM=1 COMMENT="test" TYPE=MYISAM MIN_ROWS=10 MAX_ROWS=100 PACK_KEYS=1 DELAY_KEY_WRITE=1 ROW_FORMAT=fixed;
show create table t1;
...
...
mysql-test/r/status.result
View file @
b6ab762d
...
...
@@ -14,6 +14,6 @@ update t1 set n = 3;
unlock tables;
show status like 'Table_lock%';
Variable_name Value
Table_locks_immediate
3
Table_locks_immediate
4
Table_locks_waited 1
drop table t1;
sql/sp.cc
View file @
b6ab762d
...
...
@@ -50,13 +50,16 @@ db_find_routine_aux(THD *thd, int type, char *name, uint namelen,
tables
.
db
=
(
char
*
)
"mysql"
;
tables
.
real_name
=
tables
.
alias
=
(
char
*
)
"proc"
;
if
(
!
(
table
=
open_ltable
(
thd
,
&
tables
,
ltype
)))
{
*
tablep
=
NULL
;
DBUG_RETURN
(
SP_OPEN_TABLE_FAILED
);
}
if
(
table
->
file
->
index_read_idx
(
table
->
record
[
0
],
0
,
key
,
keylen
,
HA_READ_KEY_EXACT
))
{
close_thread_tables
(
thd
)
;
*
tablep
=
NULL
;
DBUG_RETURN
(
SP_KEY_NOT_FOUND
);
}
*
tablep
=
table
;
...
...
@@ -94,7 +97,7 @@ db_find_routine(THD *thd, int type, char *name, uint namelen, sp_head **sphp)
*
sphp
=
tmplex
->
sphead
;
done:
if
(
ret
!=
SP_OK
&&
table
)
if
(
table
)
close_thread_tables
(
thd
);
DBUG_RETURN
(
ret
);
}
...
...
@@ -129,7 +132,6 @@ db_create_routine(THD *thd, int type,
ret
=
SP_OK
;
}
if
(
ret
==
SP_OK
&&
table
)
close_thread_tables
(
thd
);
DBUG_RETURN
(
ret
);
}
...
...
@@ -149,7 +151,6 @@ db_drop_routine(THD *thd, int type, char *name, uint namelen)
ret
=
SP_DELETE_ROW_FAILED
;
}
if
(
ret
==
SP_OK
&&
table
)
close_thread_tables
(
thd
);
DBUG_RETURN
(
ret
);
}
...
...
@@ -251,12 +252,13 @@ bool
sp_function_exists
(
THD
*
thd
,
LEX_STRING
*
name
)
{
TABLE
*
table
;
bool
ret
=
FALSE
;
if
(
db_find_routine_aux
(
thd
,
TYPE_ENUM_FUNCTION
,
name
->
str
,
name
->
length
,
TL_READ
,
&
table
)
==
SP_OK
)
{
close_thread_tables
(
thd
);
return
TRUE
;
ret
=
TRUE
;
}
return
FALSE
;
close_thread_tables
(
thd
);
return
ret
;
}
sql/sp_head.cc
View file @
b6ab762d
...
...
@@ -415,6 +415,11 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
thd
->
lex
.
thd
=
thd
;
res
=
mysql_execute_command
(
thd
);
if
(
thd
->
lock
||
thd
->
open_tables
||
thd
->
derived_tables
)
{
thd
->
proc_info
=
"closing tables"
;
close_thread_tables
(
thd
);
/* Free tables */
}
memcpy
(
&
thd
->
lex
,
&
olex
,
sizeof
(
LEX
));
// Restore the other lex
...
...
sql/sql_class.cc
View file @
b6ab762d
...
...
@@ -801,15 +801,6 @@ void select_export::send_error(uint errcode, const char *err)
bool
select_export
::
send_eof
()
{
/* This mimics select_send::send_eof(), which unlocks this way.
* It appears to be necessary, since tables aren't unlock after
* selects otherwise.
*/
if
(
thd
->
lock
)
{
mysql_unlock_tables
(
thd
,
thd
->
lock
);
thd
->
lock
=
0
;
}
int
error
=
test
(
end_io_cache
(
&
cache
));
if
(
my_close
(
file
,
MYF
(
MY_WME
)))
error
=
1
;
...
...
@@ -920,15 +911,6 @@ void select_dump::send_error(uint errcode,const char *err)
bool
select_dump
::
send_eof
()
{
/* This mimics select_send::send_eof(), which unlocks this way.
* It appears to be necessary, since tables aren't unlock after
* selects otherwise.
*/
if
(
thd
->
lock
)
{
mysql_unlock_tables
(
thd
,
thd
->
lock
);
thd
->
lock
=
0
;
}
int
error
=
test
(
end_io_cache
(
&
cache
));
if
(
my_close
(
file
,
MYF
(
MY_WME
)))
error
=
1
;
...
...
@@ -1061,15 +1043,6 @@ bool select_dumpvar::send_data(List<Item> &items)
bool
select_dumpvar
::
send_eof
()
{
/* This mimics select_send::send_eof(), which unlocks this way.
* It appears to be necessary, since tables aren't unlock after
* selects otherwise.
*/
if
(
thd
->
lock
)
{
mysql_unlock_tables
(
thd
,
thd
->
lock
);
thd
->
lock
=
0
;
}
if
(
row_count
)
{
::
send_ok
(
thd
,
row_count
);
...
...
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