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
5b16dbf9
Commit
5b16dbf9
authored
Mar 04, 2005
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Manual merge SP-locking improvements patch with current tree.
parents
9e02be68
5a6c7027
Changes
29
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
1813 additions
and
915 deletions
+1813
-915
mysql-test/r/lock.result
mysql-test/r/lock.result
+1
-1
mysql-test/r/mysqldump.result
mysql-test/r/mysqldump.result
+1
-0
mysql-test/r/sp.result
mysql-test/r/sp.result
+208
-52
mysql-test/t/lock.test
mysql-test/t/lock.test
+1
-1
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+1
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+261
-68
sql/item_func.cc
sql/item_func.cc
+0
-5
sql/mysql_priv.h
sql/mysql_priv.h
+1
-1
sql/sp.cc
sql/sp.cc
+135
-54
sql/sp.h
sql/sp.h
+4
-4
sql/sp_head.cc
sql/sp_head.cc
+416
-258
sql/sp_head.h
sql/sp_head.h
+130
-91
sql/sp_rcontext.cc
sql/sp_rcontext.cc
+4
-4
sql/sp_rcontext.h
sql/sp_rcontext.h
+6
-5
sql/sql_acl.cc
sql/sql_acl.cc
+3
-26
sql/sql_base.cc
sql/sql_base.cc
+344
-27
sql/sql_class.cc
sql/sql_class.cc
+3
-2
sql/sql_class.h
sql/sql_class.h
+41
-3
sql/sql_handler.cc
sql/sql_handler.cc
+1
-1
sql/sql_lex.cc
sql/sql_lex.cc
+5
-2
sql/sql_lex.h
sql/sql_lex.h
+26
-10
sql/sql_parse.cc
sql/sql_parse.cc
+24
-144
sql/sql_prepare.cc
sql/sql_prepare.cc
+7
-18
sql/sql_trigger.h
sql/sql_trigger.h
+10
-3
sql/sql_update.cc
sql/sql_update.cc
+2
-2
sql/sql_view.cc
sql/sql_view.cc
+30
-42
sql/sql_yacc.yy
sql/sql_yacc.yy
+142
-88
sql/table.h
sql/table.h
+5
-0
sql/tztime.cc
sql/tztime.cc
+1
-3
No files found.
mysql-test/r/lock.result
View file @
5b16dbf9
...
@@ -42,7 +42,7 @@ check table t2;
...
@@ -42,7 +42,7 @@ check table t2;
Table Op Msg_type Msg_text
Table Op Msg_type Msg_text
test.t2 check error Table 't2' was not locked with LOCK TABLES
test.t2 check error Table 't2' was not locked with LOCK TABLES
insert into t1 select index1,nr from t1;
insert into t1 select index1,nr from t1;
ERROR
42000: INSERT command denied to user 'root'@'localhost' for column 'index1' in table 't1'
ERROR
HY000: Table 't1' was not locked with LOCK TABLES
unlock tables;
unlock tables;
lock tables t1 write, t1 as t1_alias read;
lock tables t1 write, t1 as t1_alias read;
insert into t1 select index1,nr from t1 as t1_alias;
insert into t1 select index1,nr from t1 as t1_alias;
...
...
mysql-test/r/mysqldump.result
View file @
5b16dbf9
DROP TABLE IF EXISTS t1, `"t"1`, t1aa,t2aa;
DROP TABLE IF EXISTS t1, `"t"1`, t1aa,t2aa;
drop database if exists mysqldump_test_db;
drop database if exists mysqldump_test_db;
drop view if exists v1;
CREATE TABLE t1(a int);
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t1 VALUES (1), (2);
<?xml version="1.0"?>
<?xml version="1.0"?>
...
...
mysql-test/r/sp.result
View file @
5b16dbf9
...
@@ -237,6 +237,13 @@ insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)|
...
@@ -237,6 +237,13 @@ insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)|
drop procedure if exists sub1|
drop procedure if exists sub1|
create procedure sub1(id char(16), x int)
create procedure sub1(id char(16), x int)
insert into test.t1 values (id, x)|
insert into test.t1 values (id, x)|
drop procedure if exists sub2|
create procedure sub2(id char(16))
begin
declare x int;
set x = (select sum(t.i) from test.t2 t);
insert into test.t1 values (id, x);
end|
drop procedure if exists sub3|
drop procedure if exists sub3|
create function sub3(i int) returns int
create function sub3(i int) returns int
return i+1|
return i+1|
...
@@ -244,16 +251,19 @@ call sub1("sub1a", (select 7))|
...
@@ -244,16 +251,19 @@ call sub1("sub1a", (select 7))|
call sub1("sub1b", (select max(i) from t2))|
call sub1("sub1b", (select max(i) from t2))|
call sub1("sub1c", (select i,d from t2 limit 1))|
call sub1("sub1c", (select i,d from t2 limit 1))|
call sub1("sub1d", (select 1 from (select 1) a))|
call sub1("sub1d", (select 1 from (select 1) a))|
call sub2("sub2");
select * from t1|
select * from t1|
id data
id data
sub1a 7
sub1a 7
sub1b 3
sub1b 3
sub1c 1
sub1c 1
sub1d 1
sub1d 1
sub2 6
select sub3((select max(i) from t2))|
select sub3((select max(i) from t2))|
sub3((select max(i) from t2))
sub3((select max(i) from t2))
4
4
drop procedure sub1|
drop procedure sub1|
drop procedure sub2|
drop function sub3|
drop function sub3|
delete from t2|
delete from t2|
drop procedure if exists a0|
drop procedure if exists a0|
...
@@ -269,6 +279,7 @@ sub1a 7
...
@@ -269,6 +279,7 @@ sub1a 7
sub1b 3
sub1b 3
sub1c 1
sub1c 1
sub1d 1
sub1d 1
sub2 6
a0 2
a0 2
a0 1
a0 1
a0 0
a0 0
...
@@ -1045,6 +1056,200 @@ select row_count()|
...
@@ -1045,6 +1056,200 @@ select row_count()|
row_count()
row_count()
-1
-1
drop procedure rc|
drop procedure rc|
drop function if exists f0|
drop function if exists f1|
drop function if exists f2|
drop function if exists f3|
drop function if exists f4|
drop function if exists f5|
drop function if exists f6|
drop function if exists f7|
drop function if exists f8|
drop view if exists v0|
drop view if exists v1|
drop view if exists v2|
delete from t1|
delete from t2|
insert into t1 values ("a", 1), ("b", 2) |
insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) |
create function f1() returns int
return (select sum(data) from t1)|
select f1()|
f1()
3
select id, f1() from t1|
id f1()
a 3
b 3
create function f2() returns int
return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
select f2()|
f2()
1
select id, f2() from t1|
id f2()
a 1
b 1
create function f3() returns int
begin
declare n int;
declare m int;
set n:= (select min(data) from t1);
set m:= (select max(data) from t1);
return n < m;
end|
select f3()|
f3()
1
select id, f3() from t1|
id f3()
a 1
b 1
select f1(), f3()|
f1() f3()
3 1
select id, f1(), f3() from t1|
id f1() f3()
a 3 1
b 3 1
create function f4() returns double
return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
select f4()|
f4()
2
select s, f4() from t2|
s f4()
a 2
b 2
c 2
create function f5(i int) returns int
begin
if i <= 0 then
return 0;
elseif i = 1 then
return (select count(*) from t1 where data = i);
else
return (select count(*) + f5( i - 1) from t1 where data = i);
end if;
end|
select f5(1)|
f5(1)
1
select f5(2)|
ERROR HY000: Table 't1' was not locked with LOCK TABLES
create function f6() returns int
begin
declare n int;
set n:= f1();
return (select count(*) from t1 where data <= f7() and data <= n);
end|
create function f7() returns int
return (select sum(data) from t1 where data <= f1())|
select f6()|
f6()
2
select id, f6() from t1|
id f6()
a 2
b 2
create view v1 (a) as select f1()|
select * from v1|
a
3
select id, a from t1, v1|
id a
a 3
b 3
select * from v1, v1 as v|
a a
3 3
create view v2 (a) as select a*10 from v1|
select * from v2|
a
30
select id, a from t1, v2|
id a
a 30
b 30
select * from v1, v2|
a a
3 30
create function f8 () returns int
return (select count(*) from v2)|
select *, f8() from v1|
a f8()
3 1
drop function f1|
select * from v1|
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s)
create function f1() returns int
return (select sum(data) from t1) + (select sum(data) from v1)|
drop function f1|
create function f1() returns int
return (select sum(data) from t1)|
create function f0() returns int
return (select * from (select 100) as r)|
select f0()|
f0()
100
select *, f0() from (select 1) as t|
1 f0()
1 100
create view v0 as select f0()|
select * from v0|
f0()
100
select *, f0() from v0|
f0() f0()
100 100
lock tables t1 read, t1 as t11 read, mysql.proc read|
select f3()|
f3()
1
select id, f3() from t1 as t11|
id f3()
a 1
b 1
select f0()|
f0()
100
select * from v0|
f0()
100
select *, f0() from v0, (select 123) as d1|
f0() 123 f0()
100 123 100
select id, f3() from t1|
ERROR HY000: Table 't1' was not locked with LOCK TABLES
select f4()|
ERROR HY000: Table 't2' was not locked with LOCK TABLES
unlock tables|
lock tables v2 read, mysql.proc read|
select * from v2|
a
30
select * from v1|
a
3
select * from v1, v2|
ERROR HY000: Table 't1' was not locked with LOCK TABLES
select f4()|
ERROR HY000: Table 't2' was not locked with LOCK TABLES
unlock tables|
drop function f0|
drop function f1|
drop function f2|
drop function f3|
drop function f4|
drop function f5|
drop function f6|
drop function f7|
drop function f8|
drop view v0|
drop view v1|
drop view v2|
delete from t1 |
delete from t2 |
drop procedure if exists bug822|
drop procedure if exists bug822|
create procedure bug822(a_id char(16), a_data int)
create procedure bug822(a_id char(16), a_data int)
begin
begin
...
@@ -1177,56 +1382,6 @@ select @x2|
...
@@ -1177,56 +1382,6 @@ select @x2|
@x2
@x2
2
2
drop procedure bug2260|
drop procedure bug2260|
drop procedure if exists bug2267_1|
create procedure bug2267_1()
begin
show procedure status;
end|
drop procedure if exists bug2267_2|
create procedure bug2267_2()
begin
show function status;
end|
drop procedure if exists bug2267_3|
create procedure bug2267_3()
begin
show create procedure bug2267_1;
end|
drop procedure if exists bug2267_4|
create procedure bug2267_4()
begin
show create function fac;
end|
call bug2267_1()|
Db Name Type Definer Modified Created Security_type Comment
test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
call bug2267_2()|
Db Name Type Definer Modified Created Security_type Comment
test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
call bug2267_3()|
Procedure sql_mode Create Procedure
bug2267_1 CREATE PROCEDURE `test`.`bug2267_1`()
begin
show procedure status;
end
call bug2267_4()|
Function sql_mode Create Function
fac CREATE FUNCTION `test`.`fac`(n int unsigned) RETURNS bigint unsigned
begin
declare f bigint unsigned default 1;
while n > 1 do
set f = f * n;
set n = n - 1;
end while;
return f;
end
drop procedure bug2267_1|
drop procedure bug2267_2|
drop procedure bug2267_3|
drop procedure bug2267_4|
drop procedure if exists bug2227|
drop procedure if exists bug2227|
create procedure bug2227(x int)
create procedure bug2227(x int)
begin
begin
...
@@ -1331,7 +1486,7 @@ declare t2 int;
...
@@ -1331,7 +1486,7 @@ declare t2 int;
declare t3 int;
declare t3 int;
declare rc int default 0;
declare rc int default 0;
declare continue handler for 1065 set rc = 1;
declare continue handler for 1065 set rc = 1;
drop table if exists temp_t1;
drop t
emporary t
able if exists temp_t1;
create temporary table temp_t1 (
create temporary table temp_t1 (
f1 int auto_increment, f2 varchar(20), primary key (f1)
f1 int auto_increment, f2 varchar(20), primary key (f1)
);
);
...
@@ -1349,6 +1504,7 @@ f1 rc t3
...
@@ -1349,6 +1504,7 @@ f1 rc t3
2 0 NULL
2 0 NULL
2 0 NULL
2 0 NULL
drop procedure bug1863|
drop procedure bug1863|
drop temporary table temp_t1;
drop table t3, t4|
drop table t3, t4|
drop table if exists t3, t4|
drop table if exists t3, t4|
create table t3 (
create table t3 (
...
@@ -2515,7 +2671,7 @@ delete from t1|
...
@@ -2515,7 +2671,7 @@ delete from t1|
insert into t1 values ("answer", 42)|
insert into t1 values ("answer", 42)|
select id, bug5240() from t1|
select id, bug5240() from t1|
id bug5240()
id bug5240()
42
42
answer
42
drop function bug5240|
drop function bug5240|
drop function if exists bug5278|
drop function if exists bug5278|
create function bug5278 () returns char
create function bug5278 () returns char
...
...
mysql-test/t/lock.test
View file @
5b16dbf9
...
@@ -53,7 +53,7 @@ check table t1;
...
@@ -53,7 +53,7 @@ check table t1;
# Check error message
# Check error message
lock
tables
t1
write
;
lock
tables
t1
write
;
check
table
t2
;
check
table
t2
;
--
error
11
43
--
error
11
00
insert
into
t1
select
index1
,
nr
from
t1
;
insert
into
t1
select
index1
,
nr
from
t1
;
unlock
tables
;
unlock
tables
;
lock
tables
t1
write
,
t1
as
t1_alias
read
;
lock
tables
t1
write
,
t1
as
t1_alias
read
;
...
...
mysql-test/t/mysqldump.test
View file @
5b16dbf9
--
disable_warnings
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
`"t"1`
,
t1aa
,
t2aa
;
DROP
TABLE
IF
EXISTS
t1
,
`"t"1`
,
t1aa
,
t2aa
;
drop
database
if
exists
mysqldump_test_db
;
drop
database
if
exists
mysqldump_test_db
;
drop
view
if
exists
v1
;
--
enable_warnings
--
enable_warnings
# XML output
# XML output
...
...
mysql-test/t/sp.test
View file @
5b16dbf9
...
@@ -339,16 +339,15 @@ drop procedure if exists sub1|
...
@@ -339,16 +339,15 @@ drop procedure if exists sub1|
create
procedure
sub1
(
id
char
(
16
),
x
int
)
create
procedure
sub1
(
id
char
(
16
),
x
int
)
insert
into
test
.
t1
values
(
id
,
x
)
|
insert
into
test
.
t1
values
(
id
,
x
)
|
# QQ This doesn't work yet
--
disable_warnings
#--disable_warnings
drop
procedure
if
exists
sub2
|
#drop procedure if exists sub2|
--
enable_warnings
#--enable_warnings
create
procedure
sub2
(
id
char
(
16
))
#create procedure sub2(id char(16))
begin
#begin
declare
x
int
;
# declare x int;
set
x
=
(
select
sum
(
t
.
i
)
from
test
.
t2
t
);
# set x = (select sum(t.x) from test.t2 t);
insert
into
test
.
t1
values
(
id
,
x
);
# insert into test.t1 values (id, x);
end
|
#end|
--
disable_warnings
--
disable_warnings
drop
procedure
if
exists
sub3
|
drop
procedure
if
exists
sub3
|
...
@@ -360,11 +359,11 @@ call sub1("sub1a", (select 7))|
...
@@ -360,11 +359,11 @@ call sub1("sub1a", (select 7))|
call
sub1
(
"sub1b"
,
(
select
max
(
i
)
from
t2
))
|
call
sub1
(
"sub1b"
,
(
select
max
(
i
)
from
t2
))
|
call
sub1
(
"sub1c"
,
(
select
i
,
d
from
t2
limit
1
))
|
call
sub1
(
"sub1c"
,
(
select
i
,
d
from
t2
limit
1
))
|
call
sub1
(
"sub1d"
,
(
select
1
from
(
select
1
)
a
))
|
call
sub1
(
"sub1d"
,
(
select
1
from
(
select
1
)
a
))
|
#
call sub2("sub2");
call
sub2
(
"sub2"
);
select
*
from
t1
|
select
*
from
t1
|
select
sub3
((
select
max
(
i
)
from
t2
))
|
select
sub3
((
select
max
(
i
)
from
t2
))
|
drop
procedure
sub1
|
drop
procedure
sub1
|
#
drop procedure sub2|
drop
procedure
sub2
|
drop
function
sub3
|
drop
function
sub3
|
delete
from
t2
|
delete
from
t2
|
...
@@ -1278,6 +1277,202 @@ select row_count()|
...
@@ -1278,6 +1277,202 @@ select row_count()|
drop
procedure
rc
|
drop
procedure
rc
|
#
# Let us test how well new locking scheme works.
#
# Let us prepare playground
--
disable_warnings
drop
function
if
exists
f0
|
drop
function
if
exists
f1
|
drop
function
if
exists
f2
|
drop
function
if
exists
f3
|
drop
function
if
exists
f4
|
drop
function
if
exists
f5
|
drop
function
if
exists
f6
|
drop
function
if
exists
f7
|
drop
function
if
exists
f8
|
drop
view
if
exists
v0
|
drop
view
if
exists
v1
|
drop
view
if
exists
v2
|
--
enable_warnings
delete
from
t1
|
delete
from
t2
|
insert
into
t1
values
(
"a"
,
1
),
(
"b"
,
2
)
|
insert
into
t2
values
(
"a"
,
1
,
1.0
),
(
"b"
,
2
,
2.0
),
(
"c"
,
3
,
3.0
)
|
# Test the simplest function using tables
create
function
f1
()
returns
int
return
(
select
sum
(
data
)
from
t1
)
|
select
f1
()
|
# This should work too (and give 2 rows as result)
select
id
,
f1
()
from
t1
|
# Function which uses two instances of table simultaneously
create
function
f2
()
returns
int
return
(
select
data
from
t1
where
data
<=
(
select
sum
(
data
)
from
t1
)
limit
1
)
|
select
f2
()
|
select
id
,
f2
()
from
t1
|
# Function which uses the same table twice in different queries
create
function
f3
()
returns
int
begin
declare
n
int
;
declare
m
int
;
set
n
:=
(
select
min
(
data
)
from
t1
);
set
m
:=
(
select
max
(
data
)
from
t1
);
return
n
<
m
;
end
|
select
f3
()
|
select
id
,
f3
()
from
t1
|
# Calling two functions using same table
select
f1
(),
f3
()
|
select
id
,
f1
(),
f3
()
from
t1
|
# Function which uses two different tables
create
function
f4
()
returns
double
return
(
select
d
from
t1
,
t2
where
t1
.
data
=
t2
.
i
and
t1
.
id
=
"b"
)
|
select
f4
()
|
select
s
,
f4
()
from
t2
|
# Recursive functions which due to this recursion require simultaneous
# access to several instance of the same table won't work
create
function
f5
(
i
int
)
returns
int
begin
if
i
<=
0
then
return
0
;
elseif
i
=
1
then
return
(
select
count
(
*
)
from
t1
where
data
=
i
);
else
return
(
select
count
(
*
)
+
f5
(
i
-
1
)
from
t1
where
data
=
i
);
end
if
;
end
|
select
f5
(
1
)
|
# This should generate an error about insuficient number of tables locked
--
error
1100
select
f5
(
2
)
|
# But now it simply miserably fails because we are trying to use the same
# lex on the next iteration :/ It should generate some error too...
# select f5(3)|
# OTOH this should work
create
function
f6
()
returns
int
begin
declare
n
int
;
set
n
:=
f1
();
return
(
select
count
(
*
)
from
t1
where
data
<=
f7
()
and
data
<=
n
);
end
|
create
function
f7
()
returns
int
return
(
select
sum
(
data
)
from
t1
where
data
<=
f1
())
|
select
f6
()
|
select
id
,
f6
()
from
t1
|
# TODO Test temporary table handling
#
# Let us test how new locking work with views
#
# The most trivial view
create
view
v1
(
a
)
as
select
f1
()
|
select
*
from
v1
|
select
id
,
a
from
t1
,
v1
|
select
*
from
v1
,
v1
as
v
|
# A bit more complex construction
create
view
v2
(
a
)
as
select
a
*
10
from
v1
|
select
*
from
v2
|
select
id
,
a
from
t1
,
v2
|
select
*
from
v1
,
v2
|
# Nice example where the same view is used on
# on different expression levels
create
function
f8
()
returns
int
return
(
select
count
(
*
)
from
v2
)
|
select
*
,
f8
()
from
v1
|
# Let us test what will happen if function is missing
drop
function
f1
|
--
error
1356
select
*
from
v1
|
# And what will happen if we have recursion which involves
# views and functions ?
create
function
f1
()
returns
int
return
(
select
sum
(
data
)
from
t1
)
+
(
select
sum
(
data
)
from
v1
)
|
# FIXME All these just exceed file limit for me :)
#select f1()|
#select * from v1|
#select * from v2|
# Back to the normal cases
drop
function
f1
|
create
function
f1
()
returns
int
return
(
select
sum
(
data
)
from
t1
)
|
# Let us also test some weird cases where no real tables is used
create
function
f0
()
returns
int
return
(
select
*
from
(
select
100
)
as
r
)
|
select
f0
()
|
select
*
,
f0
()
from
(
select
1
)
as
t
|
create
view
v0
as
select
f0
()
|
select
*
from
v0
|
select
*
,
f0
()
from
v0
|
#
# Let us test how well prelocking works with explicit LOCK TABLES.
#
# Nowdays we have to lock mysql.proc to be able to read SP definitions.
# But Monty was going to fix this.
lock
tables
t1
read
,
t1
as
t11
read
,
mysql
.
proc
read
|
# These should work well
select
f3
()
|
select
id
,
f3
()
from
t1
as
t11
|
# Degenerate cases work too :)
select
f0
()
|
select
*
from
v0
|
select
*
,
f0
()
from
v0
,
(
select
123
)
as
d1
|
# But these should not !
--
error
1100
select
id
,
f3
()
from
t1
|
--
error
1100
select
f4
()
|
unlock
tables
|
# Let us test how LOCK TABLES which implicitly depends on functions
# works
lock
tables
v2
read
,
mysql
.
proc
read
|
select
*
from
v2
|
select
*
from
v1
|
# These should not work as we have too little instances of tables locked
--
error
1100
select
*
from
v1
,
v2
|
--
error
1100
select
f4
()
|
unlock
tables
|
# TODO We also should test integration with triggers
# Cleanup
drop
function
f0
|
drop
function
f1
|
drop
function
f2
|
drop
function
f3
|
drop
function
f4
|
drop
function
f5
|
drop
function
f6
|
drop
function
f7
|
drop
function
f8
|
drop
view
v0
|
drop
view
v1
|
drop
view
v2
|
delete
from
t1
|
delete
from
t2
|
# End of non-bug tests
#
#
# Test cases for old bugs
# Test cases for old bugs
#
#
...
@@ -1453,49 +1648,56 @@ drop procedure bug2260|
...
@@ -1453,49 +1648,56 @@ drop procedure bug2260|
#
#
# BUG#2267
# BUG#2267
#
#
--
disable_warnings
# NOTE: This test case will be fixed as soon as Monty
drop
procedure
if
exists
bug2267_1
|
# will allow to open mysql.proc table under LOCK TABLES
--
enable_warnings
# without mentioning in lock list.
create
procedure
bug2267_1
()
#
begin
# FIXME: Other solution would be to use preopened proc table
show
procedure
status
;
# instead of opening it anew.
end
|
#
#--disable_warnings
--
disable_warnings
#drop procedure if exists bug2267_1|
drop
procedure
if
exists
bug2267_2
|
#--enable_warnings
--
enable_warnings
#create procedure bug2267_1()
create
procedure
bug2267_2
()
#begin
begin
# show procedure status;
show
function
status
;
#end|
end
|
#
#--disable_warnings
--
disable_warnings
#drop procedure if exists bug2267_2|
drop
procedure
if
exists
bug2267_3
|
#--enable_warnings
--
enable_warnings
#create procedure bug2267_2()
create
procedure
bug2267_3
()
#begin
begin
# show function status;
show
create
procedure
bug2267_1
;
#end|
end
|
#
#--disable_warnings
--
disable_warnings
#drop procedure if exists bug2267_3|
drop
procedure
if
exists
bug2267_4
|
#--enable_warnings
--
enable_warnings
#create procedure bug2267_3()
create
procedure
bug2267_4
()
#begin
begin
# show create procedure bug2267_1;
show
create
function
fac
;
#end|
end
|
#
#--disable_warnings
--
replace_column
5
'0000-00-00 00:00:00'
6
'0000-00-00 00:00:00'
#drop procedure if exists bug2267_4|
call
bug2267_1
()
|
#--enable_warnings
--
replace_column
5
'0000-00-00 00:00:00'
6
'0000-00-00 00:00:00'
#create procedure bug2267_4()
call
bug2267_2
()
|
#begin
call
bug2267_3
()
|
# show create function fac;
call
bug2267_4
()
|
#end|
#
drop
procedure
bug2267_1
|
#--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
drop
procedure
bug2267_2
|
#call bug2267_1()|
drop
procedure
bug2267_3
|
#--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
drop
procedure
bug2267_4
|
#call bug2267_2()|
#call bug2267_3()|
#call bug2267_4()|
#
#drop procedure bug2267_1|
#drop procedure bug2267_2|
#drop procedure bug2267_3|
#drop procedure bug2267_4|
#
#
# BUG#2227
# BUG#2227
...
@@ -1529,7 +1731,7 @@ drop procedure bug2227|
...
@@ -1529,7 +1731,7 @@ drop procedure bug2227|
#--enable_warnings
#--enable_warnings
#create procedure bug2614()
#create procedure bug2614()
#begin
#begin
# drop table if exists t3;
# drop t
emporary t
able if exists t3;
# create temporary table t3 (id int default '0' not null);
# create temporary table t3 (id int default '0' not null);
# insert into t3 select 12;
# insert into t3 select 12;
# insert into t3 select * from t3;
# insert into t3 select * from t3;
...
@@ -1539,7 +1741,7 @@ drop procedure bug2227|
...
@@ -1539,7 +1741,7 @@ drop procedure bug2227|
#call bug2614()|
#call bug2614()|
#--enable_warnings
#--enable_warnings
#call bug2614()|
#call bug2614()|
#drop table t3|
#drop t
emporary t
able t3|
#drop procedure bug2614|
#drop procedure bug2614|
#
#
...
@@ -1680,7 +1882,7 @@ begin
...
@@ -1680,7 +1882,7 @@ begin
declare
rc
int
default
0
;
declare
rc
int
default
0
;
declare
continue
handler
for
1065
set
rc
=
1
;
declare
continue
handler
for
1065
set
rc
=
1
;
drop
table
if
exists
temp_t1
;
drop
t
emporary
t
able
if
exists
temp_t1
;
create
temporary
table
temp_t1
(
create
temporary
table
temp_t1
(
f1
int
auto_increment
,
f2
varchar
(
20
),
primary
key
(
f1
)
f1
int
auto_increment
,
f2
varchar
(
20
),
primary
key
(
f1
)
);
);
...
@@ -1702,6 +1904,7 @@ call bug1863(10)|
...
@@ -1702,6 +1904,7 @@ call bug1863(10)|
select
*
from
t4
|
select
*
from
t4
|
drop
procedure
bug1863
|
drop
procedure
bug1863
|
drop
temporary
table
temp_t1
;
drop
table
t3
,
t4
|
drop
table
t3
,
t4
|
#
#
...
@@ -3005,15 +3208,6 @@ select * from t3|
...
@@ -3005,15 +3208,6 @@ select * from t3|
drop
table
t3
|
drop
table
t3
|
drop
function
getcount
|
drop
function
getcount
|
#
# Former BUG#1654
# QQ Currently crashes
#
#create function bug1654() returns int
# return (select sum(t1.data) from test.t1 t)|
#
#select bug1654()|
#
#
# BUG#5240: Stored procedure crash if function has cursor declaration
# BUG#5240: Stored procedure crash if function has cursor declaration
#
#
...
@@ -3039,7 +3233,6 @@ end|
...
@@ -3039,7 +3233,6 @@ end|
delete
from
t1
|
delete
from
t1
|
insert
into
t1
values
(
"answer"
,
42
)
|
insert
into
t1
values
(
"answer"
,
42
)
|
# QQ BUG: This returns the wrong result, id=42 instead of "answer".
select
id
,
bug5240
()
from
t1
|
select
id
,
bug5240
()
from
t1
|
drop
function
bug5240
|
drop
function
bug5240
|
...
...
sql/item_func.cc
View file @
5b16dbf9
...
@@ -4414,11 +4414,6 @@ Item_func_sp::execute(Item **itp)
...
@@ -4414,11 +4414,6 @@ Item_func_sp::execute(Item **itp)
}
}
#endif
#endif
/*
We don't need to suppress sending of OK packet here (by setting
thd->net.no_send_ok to true), because we are not allowing statements
in functions now.
*/
res
=
m_sp
->
execute_function
(
thd
,
args
,
arg_count
,
itp
);
res
=
m_sp
->
execute_function
(
thd
,
args
,
arg_count
,
itp
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
#ifndef NO_EMBEDDED_ACCESS_CHECKS
...
...
sql/mysql_priv.h
View file @
5b16dbf9
...
@@ -870,7 +870,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
...
@@ -870,7 +870,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
int
setup_ftfuncs
(
SELECT_LEX
*
select
);
int
setup_ftfuncs
(
SELECT_LEX
*
select
);
int
init_ftfuncs
(
THD
*
thd
,
SELECT_LEX
*
select
,
bool
no_order
);
int
init_ftfuncs
(
THD
*
thd
,
SELECT_LEX
*
select
,
bool
no_order
);
void
wait_for_refresh
(
THD
*
thd
);
void
wait_for_refresh
(
THD
*
thd
);
int
open_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
,
uint
*
counter
);
int
open_tables
(
THD
*
thd
,
TABLE_LIST
*
*
tables
,
uint
*
counter
);
int
simple_open_n_lock_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
int
simple_open_n_lock_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
open_and_lock_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
open_and_lock_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
open_normal_and_derived_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
bool
open_normal_and_derived_tables
(
THD
*
thd
,
TABLE_LIST
*
tables
);
...
...
sql/sp.cc
View file @
5b16dbf9
...
@@ -720,8 +720,29 @@ sp_drop_db_routines(THD *thd, char *db)
...
@@ -720,8 +720,29 @@ sp_drop_db_routines(THD *thd, char *db)
PROCEDURE
PROCEDURE
******************************************************************************/
******************************************************************************/
/*
Obtain object representing stored procedure by its name from
stored procedures cache and looking into mysql.proc if needed.
SYNOPSIS
sp_find_procedure()
thd - thread context
name - name of procedure
cache_only - if true perform cache-only lookup
(Don't look in mysql.proc).
TODO
We should consider merging of sp_find_procedure() and
sp_find_function() into one sp_find_routine() function
(the same applies to other similarly paired functions).
RETURN VALUE
Non-0 pointer to sp_head object for the procedure, or
0 - in case of error.
*/
sp_head
*
sp_head
*
sp_find_procedure
(
THD
*
thd
,
sp_name
*
name
)
sp_find_procedure
(
THD
*
thd
,
sp_name
*
name
,
bool
cache_only
)
{
{
sp_head
*
sp
;
sp_head
*
sp
;
DBUG_ENTER
(
"sp_find_procedure"
);
DBUG_ENTER
(
"sp_find_procedure"
);
...
@@ -729,7 +750,7 @@ sp_find_procedure(THD *thd, sp_name *name)
...
@@ -729,7 +750,7 @@ sp_find_procedure(THD *thd, sp_name *name)
name
->
m_db
.
length
,
name
->
m_db
.
str
,
name
->
m_db
.
length
,
name
->
m_db
.
str
,
name
->
m_name
.
length
,
name
->
m_name
.
str
));
name
->
m_name
.
length
,
name
->
m_name
.
str
));
if
(
!
(
sp
=
sp_cache_lookup
(
&
thd
->
sp_proc_cache
,
name
)))
if
(
!
(
sp
=
sp_cache_lookup
(
&
thd
->
sp_proc_cache
,
name
))
&&
!
cache_only
)
{
{
if
(
db_find_routine
(
thd
,
TYPE_ENUM_PROCEDURE
,
name
,
&
sp
)
==
SP_OK
)
if
(
db_find_routine
(
thd
,
TYPE_ENUM_PROCEDURE
,
name
,
&
sp
)
==
SP_OK
)
sp_cache_insert
(
&
thd
->
sp_proc_cache
,
sp
);
sp_cache_insert
(
&
thd
->
sp_proc_cache
,
sp
);
...
@@ -855,6 +876,25 @@ sp_show_status_procedure(THD *thd, const char *wild)
...
@@ -855,6 +876,25 @@ sp_show_status_procedure(THD *thd, const char *wild)
FUNCTION
FUNCTION
******************************************************************************/
******************************************************************************/
/*
Obtain object representing stored function by its name from
stored functions cache and looking into mysql.proc if needed.
SYNOPSIS
sp_find_function()
thd - thread context
name - name of function
cache_only - if true perform cache-only lookup
(Don't look in mysql.proc).
NOTE
See TODO section for sp_find_procedure().
RETURN VALUE
Non-0 pointer to sp_head object for the function, or
0 - in case of error.
*/
sp_head
*
sp_head
*
sp_find_function
(
THD
*
thd
,
sp_name
*
name
,
bool
cache_only
)
sp_find_function
(
THD
*
thd
,
sp_name
*
name
,
bool
cache_only
)
{
{
...
@@ -988,46 +1028,97 @@ sp_add_to_hash(HASH *h, sp_name *fun)
...
@@ -988,46 +1028,97 @@ sp_add_to_hash(HASH *h, sp_name *fun)
}
}
void
/*
Merge contents of two hashes containing LEX_STRING's
SYNOPSIS
sp_merge_hash()
dst - hash to which elements should be added
src - hash from which elements merged
RETURN VALUE
TRUE - if we have added some new elements to destination hash.
FALSE - there were no new elements in src.
*/
bool
sp_merge_hash
(
HASH
*
dst
,
HASH
*
src
)
sp_merge_hash
(
HASH
*
dst
,
HASH
*
src
)
{
{
bool
res
=
FALSE
;
for
(
uint
i
=
0
;
i
<
src
->
records
;
i
++
)
for
(
uint
i
=
0
;
i
<
src
->
records
;
i
++
)
{
{
LEX_STRING
*
ls
=
(
LEX_STRING
*
)
hash_element
(
src
,
i
);
LEX_STRING
*
ls
=
(
LEX_STRING
*
)
hash_element
(
src
,
i
);
if
(
!
hash_search
(
dst
,
(
byte
*
)
ls
->
str
,
ls
->
length
))
if
(
!
hash_search
(
dst
,
(
byte
*
)
ls
->
str
,
ls
->
length
))
{
my_hash_insert
(
dst
,
(
byte
*
)
ls
);
my_hash_insert
(
dst
,
(
byte
*
)
ls
);
res
=
TRUE
;
}
}
}
return
res
;
}
}
int
/*
sp_cache_routines
(
THD
*
thd
,
LEX
*
lex
,
int
type
)
Cache all routines implicitly or explicitly used by query
(or whatever object is represented by LEX).
SYNOPSIS
sp_cache_routines()
thd - thread context
lex - LEX representing query
NOTE
If some function is missing this won't be reported here.
Instead this fact will be discovered during query execution.
TODO
Currently if after passing through routine hashes we discover
that we have added something to them, we do one more pass to
process all routines which were missed on previous pass because
of these additions. We can avoid this if along with hashes
we use lists holding routine names and iterate other these
lists instead of hashes (since addition to the end of list
does not reorder elements in it).
*/
void
sp_cache_routines
(
THD
*
thd
,
LEX
*
lex
)
{
{
bool
routines_added
=
TRUE
;
DBUG_ENTER
(
"sp_cache_routines"
);
while
(
routines_added
)
{
routines_added
=
FALSE
;
for
(
int
type
=
TYPE_ENUM_FUNCTION
;
type
<
TYPE_ENUM_TRIGGER
;
type
++
)
{
HASH
*
h
=
(
type
==
TYPE_ENUM_FUNCTION
?
&
lex
->
spfuns
:
&
lex
->
spprocs
);
HASH
*
h
=
(
type
==
TYPE_ENUM_FUNCTION
?
&
lex
->
spfuns
:
&
lex
->
spprocs
);
int
ret
=
0
;
for
(
uint
i
=
0
;
i
<
h
->
records
;
i
++
)
for
(
uint
i
=
0
;
i
<
h
->
records
;
i
++
)
{
{
LEX_STRING
*
ls
=
(
LEX_STRING
*
)
hash_element
(
h
,
i
);
LEX_STRING
*
ls
=
(
LEX_STRING
*
)
hash_element
(
h
,
i
);
sp_name
name
(
*
ls
);
sp_name
name
(
*
ls
);
sp_head
*
sp
;
name
.
m_qname
=
*
ls
;
name
.
m_qname
=
*
ls
;
if
(
!
sp_cache_lookup
((
type
==
TYPE_ENUM_FUNCTION
?
if
(
!
(
sp
=
sp_cache_lookup
((
type
==
TYPE_ENUM_FUNCTION
?
&
thd
->
sp_func_cache
:
&
thd
->
sp_proc_cache
),
&
thd
->
sp_func_cache
:
&
thd
->
sp_proc_cache
),
&
name
))
&
name
)
))
{
{
sp_head
*
sp
;
LEX
*
oldlex
=
thd
->
lex
;
LEX
*
oldlex
=
thd
->
lex
;
LEX
*
newlex
=
new
st_lex
;
LEX
*
newlex
=
new
st_lex
;
thd
->
lex
=
newlex
;
thd
->
lex
=
newlex
;
newlex
->
proc_table
=
oldlex
->
proc_table
;
// hint if mysql.oper is opened
/* Pass hint pointer to mysql.proc table */
newlex
->
proc_table
=
oldlex
->
proc_table
;
newlex
->
current_select
=
NULL
;
newlex
->
current_select
=
NULL
;
name
.
m_name
.
str
=
strchr
(
name
.
m_qname
.
str
,
'.'
);
name
.
m_name
.
str
=
strchr
(
name
.
m_qname
.
str
,
'.'
);
name
.
m_db
.
length
=
name
.
m_name
.
str
-
name
.
m_qname
.
str
;
name
.
m_db
.
length
=
name
.
m_name
.
str
-
name
.
m_qname
.
str
;
name
.
m_db
.
str
=
strmake_root
(
thd
->
mem_root
,
name
.
m_db
.
str
=
strmake_root
(
thd
->
mem_root
,
name
.
m_qname
.
str
,
name
.
m_qname
.
str
,
name
.
m_db
.
length
);
name
.
m_db
.
length
);
name
.
m_name
.
str
+=
1
;
name
.
m_name
.
str
+=
1
;
name
.
m_name
.
length
=
name
.
m_qname
.
length
-
name
.
m_db
.
length
-
1
;
name
.
m_name
.
length
=
name
.
m_qname
.
length
-
name
.
m_db
.
length
-
1
;
...
@@ -1037,30 +1128,20 @@ sp_cache_routines(THD *thd, LEX *lex, int type)
...
@@ -1037,30 +1128,20 @@ sp_cache_routines(THD *thd, LEX *lex, int type)
sp_cache_insert
(
&
thd
->
sp_func_cache
,
sp
);
sp_cache_insert
(
&
thd
->
sp_func_cache
,
sp
);
else
else
sp_cache_insert
(
&
thd
->
sp_proc_cache
,
sp
);
sp_cache_insert
(
&
thd
->
sp_proc_cache
,
sp
);
ret
=
sp_cache_routines
(
thd
,
newlex
,
TYPE_ENUM_FUNCTION
);
if
(
!
ret
)
{
sp_merge_hash
(
&
lex
->
spfuns
,
&
newlex
->
spfuns
);
ret
=
sp_cache_routines
(
thd
,
newlex
,
TYPE_ENUM_PROCEDURE
);
}
if
(
!
ret
)
{
sp_merge_hash
(
&
lex
->
spprocs
,
&
newlex
->
spprocs
);
sp_merge_table_hash
(
&
lex
->
sptabs
,
&
sp
->
m_sptabs
);
}
}
delete
newlex
;
delete
newlex
;
thd
->
lex
=
oldlex
;
thd
->
lex
=
oldlex
;
if
(
ret
)
break
;
}
}
else
if
(
sp
)
{
{
delete
newlex
;
routines_added
|=
sp_merge_hash
(
&
lex
->
spfuns
,
&
sp
->
m_spfuns
);
thd
->
lex
=
oldlex
;
routines_added
|=
sp_merge_hash
(
&
lex
->
spprocs
,
&
sp
->
m_spprocs
);
}
}
}
}
}
}
}
return
ret
;
DBUG_VOID_RETURN
;
}
}
/*
/*
...
...
sql/sp.h
View file @
5b16dbf9
...
@@ -34,7 +34,7 @@ int
...
@@ -34,7 +34,7 @@ int
sp_drop_db_routines
(
THD
*
thd
,
char
*
db
);
sp_drop_db_routines
(
THD
*
thd
,
char
*
db
);
sp_head
*
sp_head
*
sp_find_procedure
(
THD
*
thd
,
sp_name
*
name
);
sp_find_procedure
(
THD
*
thd
,
sp_name
*
name
,
bool
cache_only
=
0
);
int
int
sp_exists_routine
(
THD
*
thd
,
TABLE_LIST
*
procs
,
bool
any
,
bool
no_error
);
sp_exists_routine
(
THD
*
thd
,
TABLE_LIST
*
procs
,
bool
any
,
bool
no_error
);
...
@@ -82,10 +82,10 @@ sp_function_exists(THD *thd, sp_name *name);
...
@@ -82,10 +82,10 @@ sp_function_exists(THD *thd, sp_name *name);
*/
*/
void
void
sp_add_to_hash
(
HASH
*
h
,
sp_name
*
fun
);
sp_add_to_hash
(
HASH
*
h
,
sp_name
*
fun
);
void
bool
sp_merge_hash
(
HASH
*
dst
,
HASH
*
src
);
sp_merge_hash
(
HASH
*
dst
,
HASH
*
src
);
int
void
sp_cache_routines
(
THD
*
thd
,
LEX
*
lex
,
int
type
);
sp_cache_routines
(
THD
*
thd
,
LEX
*
lex
);
//
//
...
...
sql/sp_head.cc
View file @
5b16dbf9
This diff is collapsed.
Click to expand it.
sql/sp_head.h
View file @
5b16dbf9
This diff is collapsed.
Click to expand it.
sql/sp_rcontext.cc
View file @
5b16dbf9
...
@@ -125,9 +125,9 @@ sp_rcontext::restore_variables(uint fp)
...
@@ -125,9 +125,9 @@ sp_rcontext::restore_variables(uint fp)
}
}
void
void
sp_rcontext
::
push_cursor
(
LEX
*
lex
)
sp_rcontext
::
push_cursor
(
sp_lex_keeper
*
lex_keeper
)
{
{
m_cstack
[
m_ccount
++
]
=
new
sp_cursor
(
lex
);
m_cstack
[
m_ccount
++
]
=
new
sp_cursor
(
lex
_keeper
);
}
}
void
void
...
@@ -148,7 +148,7 @@ sp_rcontext::pop_cursors(uint count)
...
@@ -148,7 +148,7 @@ sp_rcontext::pop_cursors(uint count)
// We have split this in two to make it easy for sp_instr_copen
// We have split this in two to make it easy for sp_instr_copen
// to reuse the sp_instr::exec_stmt() code.
// to reuse the sp_instr::exec_stmt() code.
LEX
*
sp_lex_keeper
*
sp_cursor
::
pre_open
(
THD
*
thd
)
sp_cursor
::
pre_open
(
THD
*
thd
)
{
{
if
(
m_isopen
)
if
(
m_isopen
)
...
@@ -168,7 +168,7 @@ sp_cursor::pre_open(THD *thd)
...
@@ -168,7 +168,7 @@ sp_cursor::pre_open(THD *thd)
m_nseof
=
thd
->
net
.
no_send_eof
;
m_nseof
=
thd
->
net
.
no_send_eof
;
thd
->
net
.
no_send_eof
=
TRUE
;
thd
->
net
.
no_send_eof
=
TRUE
;
return
m_lex
;
return
m_lex
_keeper
;
}
}
void
void
...
...
sql/sp_rcontext.h
View file @
5b16dbf9
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
struct
sp_cond_type
;
struct
sp_cond_type
;
class
sp_cursor
;
class
sp_cursor
;
struct
sp_pvar
;
struct
sp_pvar
;
class
sp_lex_keeper
;
#define SP_HANDLER_NONE 0
#define SP_HANDLER_NONE 0
#define SP_HANDLER_EXIT 1
#define SP_HANDLER_EXIT 1
...
@@ -164,7 +165,7 @@ class sp_rcontext : public Sql_alloc
...
@@ -164,7 +165,7 @@ class sp_rcontext : public Sql_alloc
restore_variables
(
uint
fp
);
restore_variables
(
uint
fp
);
void
void
push_cursor
(
LEX
*
lex
);
push_cursor
(
sp_lex_keeper
*
lex_keeper
);
void
void
pop_cursors
(
uint
count
);
pop_cursors
(
uint
count
);
...
@@ -207,8 +208,8 @@ class sp_cursor : public Sql_alloc
...
@@ -207,8 +208,8 @@ class sp_cursor : public Sql_alloc
{
{
public:
public:
sp_cursor
(
LEX
*
lex
)
sp_cursor
(
sp_lex_keeper
*
lex_keeper
)
:
m_lex
(
lex
),
m_prot
(
NULL
),
m_isopen
(
0
),
m_current_row
(
NULL
)
:
m_lex
_keeper
(
lex_keeper
),
m_prot
(
NULL
),
m_isopen
(
0
),
m_current_row
(
NULL
)
{
{
/* Empty */
/* Empty */
}
}
...
@@ -220,7 +221,7 @@ public:
...
@@ -220,7 +221,7 @@ public:
// We have split this in two to make it easy for sp_instr_copen
// We have split this in two to make it easy for sp_instr_copen
// to reuse the sp_instr::exec_stmt() code.
// to reuse the sp_instr::exec_stmt() code.
LEX
*
sp_lex_keeper
*
pre_open
(
THD
*
thd
);
pre_open
(
THD
*
thd
);
void
void
post_open
(
THD
*
thd
,
my_bool
was_opened
);
post_open
(
THD
*
thd
,
my_bool
was_opened
);
...
@@ -240,7 +241,7 @@ public:
...
@@ -240,7 +241,7 @@ public:
private:
private:
MEM_ROOT
m_mem_root
;
// My own mem_root
MEM_ROOT
m_mem_root
;
// My own mem_root
LEX
*
m_lex
;
sp_lex_keeper
*
m_lex_keeper
;
Protocol_cursor
*
m_prot
;
Protocol_cursor
*
m_prot
;
my_bool
m_isopen
;
my_bool
m_isopen
;
my_bool
m_nseof
;
// Original no_send_eof
my_bool
m_nseof
;
// Original no_send_eof
...
...
sql/sql_acl.cc
View file @
5b16dbf9
...
@@ -138,7 +138,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
...
@@ -138,7 +138,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
TABLE_LIST
tables
[
3
];
TABLE_LIST
tables
[
3
];
TABLE
*
table
;
TABLE
*
table
;
READ_RECORD
read_record_info
;
READ_RECORD
read_record_info
;
MYSQL_LOCK
*
lock
;
my_bool
return_val
=
1
;
my_bool
return_val
=
1
;
bool
check_no_resolve
=
specialflag
&
SPECIAL_NO_RESOLVE
;
bool
check_no_resolve
=
specialflag
&
SPECIAL_NO_RESOLVE
;
char
tmp_name
[
NAME_LEN
+
1
];
char
tmp_name
[
NAME_LEN
+
1
];
...
@@ -176,20 +175,9 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
...
@@ -176,20 +175,9 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
tables
[
0
].
lock_type
=
tables
[
1
].
lock_type
=
tables
[
2
].
lock_type
=
TL_READ
;
tables
[
0
].
lock_type
=
tables
[
1
].
lock_type
=
tables
[
2
].
lock_type
=
TL_READ
;
tables
[
0
].
db
=
tables
[
1
].
db
=
tables
[
2
].
db
=
thd
->
db
;
tables
[
0
].
db
=
tables
[
1
].
db
=
tables
[
2
].
db
=
thd
->
db
;
uint
counter
;
if
(
simple_open_n_lock_tables
(
thd
,
tables
))
if
(
open_tables
(
thd
,
tables
,
&
counter
))
{
sql_print_error
(
"Fatal error: Can't open privilege tables: %s"
,
thd
->
net
.
last_error
);
goto
end
;
}
TABLE
*
ptr
[
3
];
// Lock tables for quick update
ptr
[
0
]
=
tables
[
0
].
table
;
ptr
[
1
]
=
tables
[
1
].
table
;
ptr
[
2
]
=
tables
[
2
].
table
;
if
(
!
(
lock
=
mysql_lock_tables
(
thd
,
ptr
,
3
)))
{
{
sql_print_error
(
"Fatal error: Can't lock privilege tables: %s"
,
sql_print_error
(
"Fatal error: Can't
open and
lock privilege tables: %s"
,
thd
->
net
.
last_error
);
thd
->
net
.
last_error
);
goto
end
;
goto
end
;
}
}
...
@@ -459,7 +447,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
...
@@ -459,7 +447,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
freeze_size
(
&
acl_dbs
);
freeze_size
(
&
acl_dbs
);
init_check_host
();
init_check_host
();
mysql_unlock_tables
(
thd
,
lock
);
initialized
=
1
;
initialized
=
1
;
thd
->
version
--
;
// Force close to free memory
thd
->
version
--
;
// Force close to free memory
return_val
=
0
;
return_val
=
0
;
...
@@ -3112,7 +3099,6 @@ my_bool grant_init(THD *org_thd)
...
@@ -3112,7 +3099,6 @@ my_bool grant_init(THD *org_thd)
{
{
THD
*
thd
;
THD
*
thd
;
TABLE_LIST
tables
[
3
];
TABLE_LIST
tables
[
3
];
MYSQL_LOCK
*
lock
;
MEM_ROOT
*
memex_ptr
;
MEM_ROOT
*
memex_ptr
;
my_bool
return_val
=
1
;
my_bool
return_val
=
1
;
TABLE
*
t_table
,
*
c_table
,
*
p_table
;
TABLE
*
t_table
,
*
c_table
,
*
p_table
;
...
@@ -3146,15 +3132,7 @@ my_bool grant_init(THD *org_thd)
...
@@ -3146,15 +3132,7 @@ my_bool grant_init(THD *org_thd)
tables
[
0
].
lock_type
=
tables
[
1
].
lock_type
=
tables
[
2
].
lock_type
=
TL_READ
;
tables
[
0
].
lock_type
=
tables
[
1
].
lock_type
=
tables
[
2
].
lock_type
=
TL_READ
;
tables
[
0
].
db
=
tables
[
1
].
db
=
tables
[
2
].
db
=
thd
->
db
;
tables
[
0
].
db
=
tables
[
1
].
db
=
tables
[
2
].
db
=
thd
->
db
;
uint
counter
;
if
(
simple_open_n_lock_tables
(
thd
,
tables
))
if
(
open_tables
(
thd
,
tables
,
&
counter
))
goto
end
;
TABLE
*
ptr
[
3
];
// Lock tables for quick update
ptr
[
0
]
=
tables
[
0
].
table
;
ptr
[
1
]
=
tables
[
1
].
table
;
ptr
[
2
]
=
tables
[
2
].
table
;
if
(
!
(
lock
=
mysql_lock_tables
(
thd
,
ptr
,
3
)))
goto
end
;
goto
end
;
t_table
=
tables
[
0
].
table
;
c_table
=
tables
[
1
].
table
;
t_table
=
tables
[
0
].
table
;
c_table
=
tables
[
1
].
table
;
...
@@ -3244,7 +3222,6 @@ my_bool grant_init(THD *org_thd)
...
@@ -3244,7 +3222,6 @@ my_bool grant_init(THD *org_thd)
end_unlock:
end_unlock:
t_table
->
file
->
ha_index_end
();
t_table
->
file
->
ha_index_end
();
p_table
->
file
->
ha_index_end
();
p_table
->
file
->
ha_index_end
();
mysql_unlock_tables
(
thd
,
lock
);
thd
->
version
--
;
// Force close to free memory
thd
->
version
--
;
// Force close to free memory
end:
end:
...
...
sql/sql_base.cc
View file @
5b16dbf9
This diff is collapsed.
Click to expand it.
sql/sql_class.cc
View file @
5b16dbf9
...
@@ -253,6 +253,7 @@ THD::THD()
...
@@ -253,6 +253,7 @@ THD::THD()
tablespace_op
=
FALSE
;
tablespace_op
=
FALSE
;
ulong
tmp
=
sql_rnd_with_mutex
();
ulong
tmp
=
sql_rnd_with_mutex
();
randominit
(
&
rand
,
tmp
+
(
ulong
)
&
rand
,
tmp
+
(
ulong
)
::
query_id
);
randominit
(
&
rand
,
tmp
+
(
ulong
)
&
rand
,
tmp
+
(
ulong
)
::
query_id
);
prelocked_mode
=
NON_PRELOCKED
;
}
}
...
...
sql/sql_class.h
View file @
5b16dbf9
...
@@ -925,6 +925,15 @@ struct Item_change_record;
...
@@ -925,6 +925,15 @@ struct Item_change_record;
typedef
I_List
<
Item_change_record
>
Item_change_list
;
typedef
I_List
<
Item_change_record
>
Item_change_list
;
/*
Type of prelocked mode.
See comment for THD::prelocked_mode for complete description.
*/
enum
prelocked_mode_type
{
NON_PRELOCKED
=
0
,
PRELOCKED
=
1
,
PRELOCKED_UNDER_LOCK_TABLES
=
2
};
/*
/*
For each client connection we create a separate thread with THD serving as
For each client connection we create a separate thread with THD serving as
a thread/connection descriptor
a thread/connection descriptor
...
@@ -1025,7 +1034,13 @@ public:
...
@@ -1025,7 +1034,13 @@ public:
See also lock_tables() for details.
See also lock_tables() for details.
*/
*/
MYSQL_LOCK
*
lock
;
/* Current locks */
MYSQL_LOCK
*
lock
;
/* Current locks */
MYSQL_LOCK
*
locked_tables
;
/* Tables locked with LOCK */
/*
Tables that were locked with explicit or implicit LOCK TABLES.
(Implicit LOCK TABLES happens when we are prelocking tables for
execution of statement which uses stored routines. See description
THD::prelocked_mode for more info.)
*/
MYSQL_LOCK
*
locked_tables
;
HASH
handler_tables_hash
;
HASH
handler_tables_hash
;
/*
/*
One thread can hold up to one named user-level lock. This variable
One thread can hold up to one named user-level lock. This variable
...
@@ -1192,8 +1207,6 @@ public:
...
@@ -1192,8 +1207,6 @@ public:
sp_rcontext
*
spcont
;
// SP runtime context
sp_rcontext
*
spcont
;
// SP runtime context
sp_cache
*
sp_proc_cache
;
sp_cache
*
sp_proc_cache
;
sp_cache
*
sp_func_cache
;
sp_cache
*
sp_func_cache
;
bool
shortcut_make_view
;
/* Don't do full mysql_make_view()
during pre-opening of tables. */
/*
/*
If we do a purge of binary logs, log index info of the threads
If we do a purge of binary logs, log index info of the threads
...
@@ -1209,6 +1222,31 @@ public:
...
@@ -1209,6 +1222,31 @@ public:
long
long_value
;
long
long_value
;
}
sys_var_tmp
;
}
sys_var_tmp
;
/*
prelocked_mode_type enum and prelocked_mode member are used for
indicating whenever "prelocked mode" is on, and what type of
"prelocked mode" is it.
Prelocked mode is used for execution of queries which explicitly
or implicitly (via views or triggers) use functions, thus may need
some additional tables (mentioned in query table list) for their
execution.
First open_tables() call for such query will analyse all functions
used by it and add all additional tables to table its list. It will
also mark this query as requiring prelocking. After that lock_tables()
will issue implicit LOCK TABLES for the whole table list and change
thd::prelocked_mode to non-0. All queries called in functions invoked
by the main query will use prelocked tables. Non-0 prelocked_mode
will also surpress mentioned analysys in those queries thus saving
cycles. Prelocked mode will be turned off once close_thread_tables()
for the main query will be called.
Note: Since not all "tables" present in table list are really locked
thd::relocked_mode does not imply thd::locked_tables.
*/
prelocked_mode_type
prelocked_mode
;
THD
();
THD
();
~
THD
();
~
THD
();
...
...
sql/sql_handler.cc
View file @
5b16dbf9
...
@@ -187,7 +187,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
...
@@ -187,7 +187,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
/* for now HANDLER can be used only for real TABLES */
/* for now HANDLER can be used only for real TABLES */
tables
->
required_type
=
FRMTYPE_TABLE
;
tables
->
required_type
=
FRMTYPE_TABLE
;
error
=
open_tables
(
thd
,
tables
,
&
counter
);
error
=
open_tables
(
thd
,
&
tables
,
&
counter
);
HANDLER_TABLES_HACK
(
thd
);
HANDLER_TABLES_HACK
(
thd
);
if
(
error
)
if
(
error
)
...
...
sql/sql_lex.cc
View file @
5b16dbf9
...
@@ -169,13 +169,12 @@ void lex_start(THD *thd, uchar *buf,uint length)
...
@@ -169,13 +169,12 @@ void lex_start(THD *thd, uchar *buf,uint length)
lex
->
sphead
=
NULL
;
lex
->
sphead
=
NULL
;
lex
->
spcont
=
NULL
;
lex
->
spcont
=
NULL
;
lex
->
proc_list
.
first
=
0
;
lex
->
proc_list
.
first
=
0
;
lex
->
query_tables_own_last
=
0
;
if
(
lex
->
spfuns
.
records
)
if
(
lex
->
spfuns
.
records
)
my_hash_reset
(
&
lex
->
spfuns
);
my_hash_reset
(
&
lex
->
spfuns
);
if
(
lex
->
spprocs
.
records
)
if
(
lex
->
spprocs
.
records
)
my_hash_reset
(
&
lex
->
spprocs
);
my_hash_reset
(
&
lex
->
spprocs
);
if
(
lex
->
sptabs
.
records
)
my_hash_reset
(
&
lex
->
sptabs
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -1868,6 +1867,8 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
...
@@ -1868,6 +1867,8 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local)
*/
*/
if
((
query_tables
=
query_tables
->
next_global
))
if
((
query_tables
=
query_tables
->
next_global
))
query_tables
->
prev_global
=
&
query_tables
;
query_tables
->
prev_global
=
&
query_tables
;
else
query_tables_last
=
&
query_tables
;
first
->
next_global
=
0
;
first
->
next_global
=
0
;
/*
/*
...
@@ -1973,6 +1974,8 @@ void st_lex::link_first_table_back(TABLE_LIST *first,
...
@@ -1973,6 +1974,8 @@ void st_lex::link_first_table_back(TABLE_LIST *first,
{
{
if
((
first
->
next_global
=
query_tables
))
if
((
first
->
next_global
=
query_tables
))
query_tables
->
prev_global
=
&
first
->
next_global
;
query_tables
->
prev_global
=
&
first
->
next_global
;
else
query_tables_last
=
&
first
->
next_global
;
query_tables
=
first
;
query_tables
=
first
;
if
(
link_to_local
)
if
(
link_to_local
)
...
...
sql/sql_lex.h
View file @
5b16dbf9
...
@@ -784,7 +784,6 @@ typedef struct st_lex
...
@@ -784,7 +784,6 @@ typedef struct st_lex
sp_pcontext
*
spcont
;
sp_pcontext
*
spcont
;
HASH
spfuns
;
/* Called functions */
HASH
spfuns
;
/* Called functions */
HASH
spprocs
;
/* Called procedures */
HASH
spprocs
;
/* Called procedures */
HASH
sptabs
;
/* Merged table lists */
st_sp_chistics
sp_chistics
;
st_sp_chistics
sp_chistics
;
bool
only_view
;
/* used for SHOW CREATE TABLE/VIEW */
bool
only_view
;
/* used for SHOW CREATE TABLE/VIEW */
/*
/*
...
@@ -803,23 +802,25 @@ typedef struct st_lex
...
@@ -803,23 +802,25 @@ typedef struct st_lex
*/
*/
SQL_LIST
trg_table_fields
;
SQL_LIST
trg_table_fields
;
st_lex
()
:
result
(
0
),
sql_command
(
SQLCOM_END
)
/*
If non-0 then indicates that query requires prelocking and points to
next_global member of last own element in query table list (i.e. last
table which was not added to it as part of preparation to prelocking).
0 - indicates that this query does not need prelocking.
*/
TABLE_LIST
**
query_tables_own_last
;
st_lex
()
:
result
(
0
),
sql_command
(
SQLCOM_END
),
query_tables_own_last
(
0
)
{
{
extern
byte
*
sp_lex_sp_key
(
const
byte
*
ptr
,
uint
*
plen
,
my_bool
first
);
extern
byte
*
sp_lex_sp_key
(
const
byte
*
ptr
,
uint
*
plen
,
my_bool
first
);
extern
byte
*
sp_table_key
(
const
byte
*
ptr
,
uint
*
plen
,
my_bool
first
);
hash_init
(
&
spfuns
,
system_charset_info
,
0
,
0
,
0
,
sp_lex_sp_key
,
0
,
0
);
hash_init
(
&
spfuns
,
system_charset_info
,
0
,
0
,
0
,
sp_lex_sp_key
,
0
,
0
);
hash_init
(
&
spprocs
,
system_charset_info
,
0
,
0
,
0
,
sp_lex_sp_key
,
0
,
0
);
hash_init
(
&
spprocs
,
system_charset_info
,
0
,
0
,
0
,
sp_lex_sp_key
,
0
,
0
);
hash_init
(
&
sptabs
,
system_charset_info
,
0
,
0
,
0
,
sp_table_key
,
0
,
0
);
}
}
~
st_lex
()
~
st_lex
()
{
{
if
(
spfuns
.
array
.
buffer
)
hash_free
(
&
spfuns
);
hash_free
(
&
spfuns
);
if
(
spprocs
.
array
.
buffer
)
hash_free
(
&
spprocs
);
hash_free
(
&
spprocs
);
if
(
sptabs
.
array
.
buffer
)
hash_free
(
&
sptabs
);
}
}
inline
void
uncacheable
(
uint8
cause
)
inline
void
uncacheable
(
uint8
cause
)
...
@@ -856,6 +857,21 @@ typedef struct st_lex
...
@@ -856,6 +857,21 @@ typedef struct st_lex
bool
can_not_use_merged
();
bool
can_not_use_merged
();
bool
only_view_structure
();
bool
only_view_structure
();
bool
need_correct_ident
();
bool
need_correct_ident
();
inline
bool
requires_prelocking
()
{
return
query_tables_own_last
;
}
inline
void
mark_as_requiring_prelocking
(
TABLE_LIST
**
tables_own_last
)
{
query_tables_own_last
=
tables_own_last
;
}
/* Return pointer to first not-own table in query-tables or 0 */
TABLE_LIST
*
first_not_own_table
()
{
return
(
query_tables_own_last
?
*
query_tables_own_last
:
0
);
}
}
LEX
;
}
LEX
;
struct
st_lex_local
:
public
st_lex
struct
st_lex_local
:
public
st_lex
...
...
sql/sql_parse.cc
View file @
5b16dbf9
...
@@ -1453,105 +1453,6 @@ bool do_command(THD *thd)
...
@@ -1453,105 +1453,6 @@ bool do_command(THD *thd)
}
}
#endif
/* EMBEDDED_LIBRARY */
#endif
/* EMBEDDED_LIBRARY */
static
void
release_local_lock
(
THD
*
thd
,
TABLE_LIST
*
locked_tables
,
bool
old_innodb_table_locks
)
{
if
(
locked_tables
)
{
#ifdef HAVE_INNOBASE_DB
thd
->
variables
.
innodb_table_locks
=
old_innodb_table_locks
;
#endif
if
(
thd
->
locked_tables
)
sp_unlock_tables
(
thd
);
}
}
static
bool
process_nested_sp
(
THD
*
thd
,
LEX
*
lex
,
TABLE_LIST
**
locked_tables
)
{
DBUG_ENTER
(
"process_nested_sp"
);
while
(
1
)
{
if
(
sp_cache_routines
(
thd
,
lex
,
TYPE_ENUM_FUNCTION
))
DBUG_RETURN
(
TRUE
);
if
(
sp_cache_routines
(
thd
,
lex
,
TYPE_ENUM_PROCEDURE
))
DBUG_RETURN
(
TRUE
);
if
(
!
thd
->
locked_tables
&&
lex
->
sql_command
!=
SQLCOM_CREATE_TABLE
&&
lex
->
sql_command
!=
SQLCOM_CREATE_VIEW
)
{
MEM_ROOT
*
thdmemroot
=
NULL
;
sp_merge_routine_tables
(
thd
,
lex
);
// QQ Preopen tables to find views and triggers.
// This means we open, close and open again, which sucks, but
// right now it's the easiest way to get it to work. A better
// solution will hopefully be found soon...
if
(
lex
->
sptabs
.
records
||
lex
->
query_tables
)
{
uint
procs
,
funs
,
tabs
;
if
(
thd
->
mem_root
!=
thd
->
current_arena
->
mem_root
)
{
thdmemroot
=
thd
->
mem_root
;
thd
->
mem_root
=
thd
->
current_arena
->
mem_root
;
}
if
(
!
sp_merge_table_list
(
thd
,
&
lex
->
sptabs
,
lex
->
query_tables
))
DBUG_RETURN
(
TRUE
);
procs
=
lex
->
spprocs
.
records
;
funs
=
lex
->
spfuns
.
records
;
tabs
=
lex
->
sptabs
.
records
;
if
(((
*
locked_tables
)
=
sp_hash_to_table_list
(
thd
,
&
lex
->
sptabs
)))
{
// We don't want these updated now
uint
ctmpdtabs
=
thd
->
status_var
.
created_tmp_disk_tables
;
uint
ctmptabs
=
thd
->
status_var
.
created_tmp_tables
;
uint
count
;
thd
->
shortcut_make_view
=
TRUE
;
open_tables
(
thd
,
*
locked_tables
,
&
count
);
thd
->
shortcut_make_view
=
FALSE
;
close_thread_tables
(
thd
);
thd
->
status_var
.
created_tmp_disk_tables
=
ctmpdtabs
;
thd
->
status_var
.
created_tmp_tables
=
ctmptabs
;
thd
->
clear_error
();
mysql_reset_errors
(
thd
);
(
*
locked_tables
)
=
NULL
;
}
// A kludge: Decrease all temp. table's query ids to allow a
// second opening.
for
(
TABLE
*
table
=
thd
->
temporary_tables
;
table
;
table
=
table
->
next
)
table
->
query_id
-=
1
;
if
(
procs
<
lex
->
spprocs
.
records
||
funs
<
lex
->
spfuns
.
records
||
tabs
<
lex
->
sptabs
.
records
)
{
if
(
thdmemroot
)
thd
->
mem_root
=
thdmemroot
;
continue
;
// Found more SPs or tabs, try again
}
}
if
(
lex
->
sptabs
.
records
&&
(
lex
->
spfuns
.
records
||
lex
->
spprocs
.
records
)
&&
sp_merge_table_list
(
thd
,
&
lex
->
sptabs
,
lex
->
query_tables
))
{
if
(((
*
locked_tables
)
=
sp_hash_to_table_list
(
thd
,
&
lex
->
sptabs
)))
{
#ifdef HAVE_INNOBASE_DB
thd
->
variables
.
innodb_table_locks
=
FALSE
;
#endif
sp_open_and_lock_tables
(
thd
,
*
locked_tables
);
}
}
if
(
thdmemroot
)
thd
->
mem_root
=
thdmemroot
;
}
break
;
}
// while (1)
DBUG_RETURN
(
FALSE
);
}
/*
/*
Perform one connection-level (COM_XXXX) command.
Perform one connection-level (COM_XXXX) command.
...
@@ -1752,7 +1653,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -1752,7 +1653,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
in embedded server - just store them to be executed later
in embedded server - just store them to be executed later
*/
*/
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
if
(
thd
->
lock
||
thd
->
open_tables
||
thd
->
derived_tables
)
if
(
thd
->
lock
||
thd
->
open_tables
||
thd
->
derived_tables
||
thd
->
prelocked_mode
)
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
#endif
#endif
ulong
length
=
(
ulong
)(
packet_end
-
packet
);
ulong
length
=
(
ulong
)(
packet_end
-
packet
);
...
@@ -1855,19 +1757,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -1855,19 +1757,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
select_lex
.
table_list
.
link_in_list
((
byte
*
)
&
table_list
,
select_lex
.
table_list
.
link_in_list
((
byte
*
)
&
table_list
,
(
byte
**
)
&
table_list
.
next_local
);
(
byte
**
)
&
table_list
.
next_local
);
thd
->
lex
->
query_tables
=
&
table_list
;
thd
->
lex
->
query_tables
=
&
table_list
;
thd
->
shortcut_make_view
=
0
;
process_nested_sp
(
thd
,
thd
->
lex
,
&
locked_tables
);
/* switch on VIEW optimisation: do not fill temporary tables */
/* switch on VIEW optimisation: do not fill temporary tables */
thd
->
lex
->
sql_command
=
SQLCOM_SHOW_FIELDS
;
thd
->
lex
->
sql_command
=
SQLCOM_SHOW_FIELDS
;
mysqld_list_fields
(
thd
,
&
table_list
,
fields
);
mysqld_list_fields
(
thd
,
&
table_list
,
fields
);
thd
->
lex
->
unit
.
cleanup
();
thd
->
lex
->
unit
.
cleanup
();
thd
->
cleanup_after_query
();
thd
->
cleanup_after_query
();
#ifdef HAVE_INNOBASE_DB
release_local_lock
(
thd
,
locked_tables
,
old_innodb_table_locks
);
#else
release_local_lock
(
thd
,
locked_tables
,
false
);
#endif
break
;
break
;
}
}
#endif
#endif
...
@@ -2089,7 +1984,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
...
@@ -2089,7 +1984,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
my_message
(
ER_UNKNOWN_COM_ERROR
,
ER
(
ER_UNKNOWN_COM_ERROR
),
MYF
(
0
));
my_message
(
ER_UNKNOWN_COM_ERROR
,
ER
(
ER_UNKNOWN_COM_ERROR
),
MYF
(
0
));
break
;
break
;
}
}
if
(
thd
->
lock
||
thd
->
open_tables
||
thd
->
derived_tables
)
if
(
thd
->
lock
||
thd
->
open_tables
||
thd
->
derived_tables
||
thd
->
prelocked_mode
)
{
{
thd
->
proc_info
=
"closing tables"
;
thd
->
proc_info
=
"closing tables"
;
close_thread_tables
(
thd
);
/* Free tables */
close_thread_tables
(
thd
);
/* Free tables */
...
@@ -2334,11 +2230,7 @@ mysql_execute_command(THD *thd)
...
@@ -2334,11 +2230,7 @@ mysql_execute_command(THD *thd)
TABLE_LIST
*
all_tables
;
TABLE_LIST
*
all_tables
;
/* most outer SELECT_LEX_UNIT of query */
/* most outer SELECT_LEX_UNIT of query */
SELECT_LEX_UNIT
*
unit
=
&
lex
->
unit
;
SELECT_LEX_UNIT
*
unit
=
&
lex
->
unit
;
/* Locked closure of all tables */
TABLE_LIST
*
locked_tables
=
NULL
;
/* Saved variable value */
/* Saved variable value */
my_bool
old_innodb_table_locks
=
IF_INNOBASE_DB
(
thd
->
variables
.
innodb_table_locks
,
FALSE
);
DBUG_ENTER
(
"mysql_execute_command"
);
DBUG_ENTER
(
"mysql_execute_command"
);
thd
->
net
.
no_send_error
=
0
;
thd
->
net
.
no_send_error
=
0
;
...
@@ -2361,26 +2253,14 @@ mysql_execute_command(THD *thd)
...
@@ -2361,26 +2253,14 @@ mysql_execute_command(THD *thd)
/* should be assigned after making first tables same */
/* should be assigned after making first tables same */
all_tables
=
lex
->
query_tables
;
all_tables
=
lex
->
query_tables
;
thd
->
shortcut_make_view
=
0
;
if
(
lex
->
sql_command
!=
SQLCOM_CREATE_PROCEDURE
&&
lex
->
sql_command
!=
SQLCOM_CREATE_SPFUNCTION
&&
lex
->
sql_command
!=
SQLCOM_LOCK_TABLES
&&
lex
->
sql_command
!=
SQLCOM_UNLOCK_TABLES
)
{
thd
->
no_warnings_for_error
=
1
;
res
=
process_nested_sp
(
thd
,
lex
,
&
locked_tables
);
thd
->
no_warnings_for_error
=
0
;
if
(
res
)
DBUG_RETURN
(
TRUE
);
}
/*
/*
Reset warning count for each query that uses tables
Reset warning count for each query that uses tables
A better approach would be to reset this for any commands
A better approach would be to reset this for any commands
that is not a SHOW command or a select that only access local
that is not a SHOW command or a select that only access local
variables, but for now this is probably good enough.
variables, but for now this is probably good enough.
*/
*/
if
(
all_tables
||
&
lex
->
select_lex
!=
lex
->
all_selects_list
)
if
(
all_tables
||
&
lex
->
select_lex
!=
lex
->
all_selects_list
||
lex
->
spfuns
.
records
||
lex
->
spprocs
.
records
)
mysql_reset_errors
(
thd
);
mysql_reset_errors
(
thd
);
#ifdef HAVE_REPLICATION
#ifdef HAVE_REPLICATION
...
@@ -2614,9 +2494,8 @@ mysql_execute_command(THD *thd)
...
@@ -2614,9 +2494,8 @@ mysql_execute_command(THD *thd)
break
;
break
;
}
}
case
SQLCOM_DO
:
case
SQLCOM_DO
:
if
(
all_tables
&&
if
(
check_table_access
(
thd
,
SELECT_ACL
,
all_tables
,
0
)
||
(
check_table_access
(
thd
,
SELECT_ACL
,
all_tables
,
0
)
||
open_and_lock_tables
(
thd
,
all_tables
))
open_and_lock_tables
(
thd
,
all_tables
)))
goto
error
;
goto
error
;
res
=
mysql_do
(
thd
,
*
lex
->
insert_list
);
res
=
mysql_do
(
thd
,
*
lex
->
insert_list
);
...
@@ -3485,8 +3364,7 @@ unsent_create_error:
...
@@ -3485,8 +3364,7 @@ unsent_create_error:
case
SQLCOM_SET_OPTION
:
case
SQLCOM_SET_OPTION
:
{
{
List
<
set_var_base
>
*
lex_var_list
=
&
lex
->
var_list
;
List
<
set_var_base
>
*
lex_var_list
=
&
lex
->
var_list
;
if
(
all_tables
&&
if
((
check_table_access
(
thd
,
SELECT_ACL
,
all_tables
,
0
)
||
(
check_table_access
(
thd
,
SELECT_ACL
,
all_tables
,
0
)
||
open_and_lock_tables
(
thd
,
all_tables
)))
open_and_lock_tables
(
thd
,
all_tables
)))
goto
error
;
goto
error
;
if
(
lex
->
one_shot_set
&&
not_all_support_one_shot
(
lex_var_list
))
if
(
lex
->
one_shot_set
&&
not_all_support_one_shot
(
lex_var_list
))
...
@@ -3532,7 +3410,7 @@ unsent_create_error:
...
@@ -3532,7 +3410,7 @@ unsent_create_error:
thd
->
in_lock_tables
=
1
;
thd
->
in_lock_tables
=
1
;
thd
->
options
|=
OPTION_TABLE_LOCK
;
thd
->
options
|=
OPTION_TABLE_LOCK
;
if
(
!
(
res
=
open_and
_lock_tables
(
thd
,
all_tables
)))
if
(
!
(
res
=
simple_open_n
_lock_tables
(
thd
,
all_tables
)))
{
{
#ifdef HAVE_QUERY_CACHE
#ifdef HAVE_QUERY_CACHE
if
(
thd
->
variables
.
query_cache_wlock_invalidate
)
if
(
thd
->
variables
.
query_cache_wlock_invalidate
)
...
@@ -4115,7 +3993,20 @@ unsent_create_error:
...
@@ -4115,7 +3993,20 @@ unsent_create_error:
{
{
sp_head
*
sp
;
sp_head
*
sp
;
if
(
!
(
sp
=
sp_find_procedure
(
thd
,
lex
->
spname
)))
/*
This will cache all SP and SF and open and lock all tables
required for execution.
*/
if
(
check_table_access
(
thd
,
SELECT_ACL
,
all_tables
,
0
)
||
open_and_lock_tables
(
thd
,
all_tables
))
goto
error
;
/*
By this moment all needed SPs should be in cache so no need
to look into DB. Moreover we may be unable to do it becuase
we may don't have read lock on mysql.proc
*/
if
(
!
(
sp
=
sp_find_procedure
(
thd
,
lex
->
spname
,
TRUE
)))
{
{
my_error
(
ER_SP_DOES_NOT_EXIST
,
MYF
(
0
),
"PROCEDURE"
,
my_error
(
ER_SP_DOES_NOT_EXIST
,
MYF
(
0
),
"PROCEDURE"
,
lex
->
spname
->
m_qname
.
str
);
lex
->
spname
->
m_qname
.
str
);
...
@@ -4130,12 +4021,6 @@ unsent_create_error:
...
@@ -4130,12 +4021,6 @@ unsent_create_error:
/* bits that should be cleared in thd->server_status */
/* bits that should be cleared in thd->server_status */
uint
bits_to_be_cleared
=
0
;
uint
bits_to_be_cleared
=
0
;
/* In case the arguments are subselects... */
if
(
all_tables
&&
(
check_table_access
(
thd
,
SELECT_ACL
,
all_tables
,
0
)
||
open_and_lock_tables
(
thd
,
all_tables
)))
goto
error
;
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
my_bool
nsok
=
thd
->
net
.
no_send_ok
;
my_bool
nsok
=
thd
->
net
.
no_send_ok
;
thd
->
net
.
no_send_ok
=
TRUE
;
thd
->
net
.
no_send_ok
=
TRUE
;
...
@@ -4606,11 +4491,6 @@ cleanup:
...
@@ -4606,11 +4491,6 @@ cleanup:
if
(
thd
->
lock
==
thd
->
locked_tables
)
if
(
thd
->
lock
==
thd
->
locked_tables
)
thd
->
lock
=
0
;
thd
->
lock
=
0
;
}
}
#ifdef HAVE_INNOBASE_DB
release_local_lock
(
thd
,
locked_tables
,
old_innodb_table_locks
);
#else
release_local_lock
(
thd
,
locked_tables
,
false
);
#endif
DBUG_RETURN
(
res
||
thd
->
net
.
report_error
);
DBUG_RETURN
(
res
||
thd
->
net
.
report_error
);
}
}
...
...
sql/sql_prepare.cc
View file @
5b16dbf9
...
@@ -1004,7 +1004,7 @@ static int mysql_test_update(Prepared_statement *stmt,
...
@@ -1004,7 +1004,7 @@ static int mysql_test_update(Prepared_statement *stmt,
if
(
update_precheck
(
thd
,
table_list
))
if
(
update_precheck
(
thd
,
table_list
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
if
(
!
open_tables
(
thd
,
table_list
,
&
table_count
))
if
(
!
open_tables
(
thd
,
&
table_list
,
&
table_count
))
{
{
if
(
table_list
->
ancestor
&&
table_list
->
ancestor
->
next_local
)
if
(
table_list
->
ancestor
&&
table_list
->
ancestor
->
next_local
)
{
{
...
@@ -1545,22 +1545,6 @@ static int check_prepared_statement(Prepared_statement *stmt,
...
@@ -1545,22 +1545,6 @@ static int check_prepared_statement(Prepared_statement *stmt,
lex
->
first_lists_tables_same
();
lex
->
first_lists_tables_same
();
tables
=
lex
->
query_tables
;
tables
=
lex
->
query_tables
;
/*
Preopen 'proc' system table and cache all functions used in this
statement. We must do that before we open ordinary tables to avoid
deadlocks. We can't open and lock any table once query tables were
opened.
*/
if
(
lex
->
sql_command
!=
SQLCOM_CREATE_PROCEDURE
&&
lex
->
sql_command
!=
SQLCOM_CREATE_SPFUNCTION
)
{
/* The error is printed inside */
if
(
sp_cache_routines
(
thd
,
lex
,
TYPE_ENUM_FUNCTION
))
DBUG_RETURN
(
-
1
);
if
(
sp_cache_routines
(
thd
,
lex
,
TYPE_ENUM_PROCEDURE
))
DBUG_RETURN
(
-
1
);
}
switch
(
sql_command
)
{
switch
(
sql_command
)
{
case
SQLCOM_REPLACE
:
case
SQLCOM_REPLACE
:
case
SQLCOM_INSERT
:
case
SQLCOM_INSERT
:
...
@@ -1793,9 +1777,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
...
@@ -1793,9 +1777,9 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
thd
->
lex
->
sphead
=
NULL
;
thd
->
lex
->
sphead
=
NULL
;
}
}
lex_end
(
lex
);
lex_end
(
lex
);
close_thread_tables
(
thd
);
thd
->
restore_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
thd
->
restore_backup_statement
(
stmt
,
&
thd
->
stmt_backup
);
cleanup_items
(
stmt
->
free_list
);
cleanup_items
(
stmt
->
free_list
);
close_thread_tables
(
thd
);
thd
->
rollback_item_tree_changes
();
thd
->
rollback_item_tree_changes
();
thd
->
cleanup_after_query
();
thd
->
cleanup_after_query
();
thd
->
current_arena
=
thd
;
thd
->
current_arena
=
thd
;
...
@@ -1885,6 +1869,11 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
...
@@ -1885,6 +1869,11 @@ void reset_stmt_for_execute(THD *thd, LEX *lex)
to indicate the table is altered, and re-do the setup_*
to indicate the table is altered, and re-do the setup_*
and open the tables back.
and open the tables back.
*/
*/
/*
NOTE: We should reset whole table list here including all tables added
by prelocking algorithm (it is not a problem for substatements since
they have their own table list).
*/
for
(
TABLE_LIST
*
tables
=
lex
->
query_tables
;
for
(
TABLE_LIST
*
tables
=
lex
->
query_tables
;
tables
;
tables
;
tables
=
tables
->
next_global
)
tables
=
tables
->
next_global
)
...
...
sql/sql_trigger.h
View file @
5b16dbf9
...
@@ -42,14 +42,21 @@ public:
...
@@ -42,14 +42,21 @@ public:
if
(
bodies
[
event
][
time_type
])
if
(
bodies
[
event
][
time_type
])
{
{
/*
#ifndef EMBEDDED_LIBRARY
Similar to function invocation we don't need to surpress sending of
/* Surpress OK packets in case if we will execute statements */
ok packets here because don't allow execute statements from trigger.
my_bool
nsok
=
thd
->
net
.
no_send_ok
;
thd
->
net
.
no_send_ok
=
TRUE
;
#endif
/*
FIXME: We should juggle with security context here (because trigger
FIXME: We should juggle with security context here (because trigger
should be invoked with creator rights).
should be invoked with creator rights).
*/
*/
res
=
bodies
[
event
][
time_type
]
->
execute_function
(
thd
,
0
,
0
,
0
);
res
=
bodies
[
event
][
time_type
]
->
execute_function
(
thd
,
0
,
0
,
0
);
#ifndef EMBEDDED_LIBRARY
thd
->
net
.
no_send_ok
=
nsok
;
#endif
}
}
return
res
;
return
res
;
...
...
sql/sql_update.cc
View file @
5b16dbf9
...
@@ -136,7 +136,7 @@ int mysql_update(THD *thd,
...
@@ -136,7 +136,7 @@ int mysql_update(THD *thd,
LINT_INIT
(
timestamp_query_id
);
LINT_INIT
(
timestamp_query_id
);
if
(
open_tables
(
thd
,
table_list
,
&
table_count
))
if
(
open_tables
(
thd
,
&
table_list
,
&
table_count
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
if
(
table_list
->
ancestor
&&
table_list
->
ancestor
->
next_local
)
if
(
table_list
->
ancestor
&&
table_list
->
ancestor
->
next_local
)
...
@@ -635,7 +635,7 @@ bool mysql_multi_update_prepare(THD *thd)
...
@@ -635,7 +635,7 @@ bool mysql_multi_update_prepare(THD *thd)
thd
->
lex
->
sql_command
=
SQLCOM_UPDATE_MULTI
;
thd
->
lex
->
sql_command
=
SQLCOM_UPDATE_MULTI
;
/* open tables and create derived ones, but do not lock and fill them */
/* open tables and create derived ones, but do not lock and fill them */
if
((
original_multiupdate
&&
open_tables
(
thd
,
table_list
,
&
table_count
))
||
if
((
original_multiupdate
&&
open_tables
(
thd
,
&
table_list
,
&
table_count
))
||
mysql_handle_derived
(
lex
,
&
mysql_derived_prepare
))
mysql_handle_derived
(
lex
,
&
mysql_derived_prepare
))
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
/*
/*
...
...
sql/sql_view.cc
View file @
5b16dbf9
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "sql_select.h"
#include "sql_select.h"
#include "parse_file.h"
#include "parse_file.h"
#include "sp.h"
#include "sp.h"
#include "sp_head.h"
#define MD5_BUFF_LENGTH 33
#define MD5_BUFF_LENGTH 33
...
@@ -615,10 +616,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -615,10 +616,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
table
->
view
=
lex
=
thd
->
lex
=
(
LEX
*
)
new
(
thd
->
mem_root
)
st_lex_local
;
table
->
view
=
lex
=
thd
->
lex
=
(
LEX
*
)
new
(
thd
->
mem_root
)
st_lex_local
;
lex_start
(
thd
,
(
uchar
*
)
table
->
query
.
str
,
table
->
query
.
length
);
lex_start
(
thd
,
(
uchar
*
)
table
->
query
.
str
,
table
->
query
.
length
);
view_select
=
&
lex
->
select_lex
;
view_select
=
&
lex
->
select_lex
;
/* Only if we're not in the pre-open phase */
if
(
!
thd
->
shortcut_make_view
)
view_select
->
select_number
=
++
thd
->
select_number
;
view_select
->
select_number
=
++
thd
->
select_number
;
old_lex
->
derived_tables
|=
DERIVED_VIEW
;
{
{
ulong
options
=
thd
->
options
;
ulong
options
=
thd
->
options
;
/* switch off modes which can prevent normal parsing of VIEW
/* switch off modes which can prevent normal parsing of VIEW
...
@@ -662,35 +660,13 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -662,35 +660,13 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
TABLE_LIST
*
view_tables_tail
=
0
;
TABLE_LIST
*
view_tables_tail
=
0
;
TABLE_LIST
*
tbl
;
TABLE_LIST
*
tbl
;
/* move SP to main LEX */
if
(
lex
->
spfuns
.
records
)
sp_merge_hash
(
&
old_lex
->
spfuns
,
&
lex
->
spfuns
);
/* cleanup LEX */
if
(
lex
->
spfuns
.
array
.
buffer
)
hash_free
(
&
lex
->
spfuns
);
if
(
lex
->
spprocs
.
array
.
buffer
)
hash_free
(
&
lex
->
spprocs
);
if
(
lex
->
sptabs
.
array
.
buffer
)
hash_free
(
&
lex
->
sptabs
);
/* If we're pre-opening tables to find SPs and tables we need
not go any further; doing so will cause an infinite loop. */
if
(
thd
->
shortcut_make_view
)
{
extern
bool
sp_merge_table_list
(
THD
*
thd
,
HASH
*
h
,
TABLE_LIST
*
table
,
LEX
*
lex_for_tmp_check
=
0
);
sp_merge_table_list
(
thd
,
&
old_lex
->
sptabs
,
view_tables
);
goto
ok
;
}
/*
/*
check rights to run commands (EXPLAIN SELECT & SHOW CREATE) which show
Check rights to run commands (EXPLAIN SELECT & SHOW CREATE) which show
underlying tables
underlying tables.
Skip this step if we are opening view for prelocking only.
*/
*/
if
((
old_lex
->
sql_command
==
SQLCOM_SELECT
&&
old_lex
->
describe
))
if
(
!
table
->
prelocking_placeholder
&&
(
old_lex
->
sql_command
==
SQLCOM_SELECT
&&
old_lex
->
describe
))
{
{
if
(
check_table_access
(
thd
,
SELECT_ACL
,
view_tables
,
1
)
&&
if
(
check_table_access
(
thd
,
SELECT_ACL
,
view_tables
,
1
)
&&
check_table_access
(
thd
,
SHOW_VIEW_ACL
,
table
,
1
))
check_table_access
(
thd
,
SHOW_VIEW_ACL
,
table
,
1
))
...
@@ -699,7 +675,8 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -699,7 +675,8 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
goto
err
;
goto
err
;
}
}
}
}
else
if
(
old_lex
->
sql_command
==
SQLCOM_SHOW_CREATE
)
else
if
(
!
table
->
prelocking_placeholder
&&
old_lex
->
sql_command
==
SQLCOM_SHOW_CREATE
)
{
{
if
(
check_table_access
(
thd
,
SHOW_VIEW_ACL
,
table
,
0
))
if
(
check_table_access
(
thd
,
SHOW_VIEW_ACL
,
table
,
0
))
goto
err
;
goto
err
;
...
@@ -717,13 +694,6 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -717,13 +694,6 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
tbl
->
belong_to_view
=
top_view
;
tbl
->
belong_to_view
=
top_view
;
}
}
/* move SQL_NO_CACHE & Co to whole query */
old_lex
->
safe_to_cache_query
=
(
old_lex
->
safe_to_cache_query
&&
lex
->
safe_to_cache_query
);
/* move SQL_CACHE to whole query */
if
(
view_select
->
options
&
OPTION_TO_QUERY_CACHE
)
old_lex
->
select_lex
.
options
|=
OPTION_TO_QUERY_CACHE
;
/*
/*
Put tables of VIEW after VIEW TABLE_LIST
Put tables of VIEW after VIEW TABLE_LIST
...
@@ -740,12 +710,29 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -740,12 +710,29 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
}
}
else
else
{
{
lex
->
query_tables_last
=
&
view_tables_tail
->
next_global
;
old_
lex
->
query_tables_last
=
&
view_tables_tail
->
next_global
;
}
}
view_tables
->
prev_global
=
&
table
->
next_global
;
view_tables
->
prev_global
=
&
table
->
next_global
;
table
->
next_global
=
view_tables
;
table
->
next_global
=
view_tables
;
}
}
/*
If we are opening this view as part of implicit LOCK TABLES, then
this view serves as simple placeholder and we should not continue
further processing.
*/
if
(
table
->
prelocking_placeholder
)
goto
ok2
;
old_lex
->
derived_tables
|=
DERIVED_VIEW
;
/* move SQL_NO_CACHE & Co to whole query */
old_lex
->
safe_to_cache_query
=
(
old_lex
->
safe_to_cache_query
&&
lex
->
safe_to_cache_query
);
/* move SQL_CACHE to whole query */
if
(
view_select
->
options
&
OPTION_TO_QUERY_CACHE
)
old_lex
->
select_lex
.
options
|=
OPTION_TO_QUERY_CACHE
;
/*
/*
check MERGE algorithm ability
check MERGE algorithm ability
- algorithm is not explicit TEMPORARY TABLE
- algorithm is not explicit TEMPORARY TABLE
...
@@ -850,8 +837,6 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
...
@@ -850,8 +837,6 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
goto
err
;
goto
err
;
ok:
ok:
if
(
arena
)
thd
->
restore_backup_item_arena
(
arena
,
&
backup
);
/* global SELECT list linking */
/* global SELECT list linking */
end
=
view_select
;
// primary SELECT_LEX is always last
end
=
view_select
;
// primary SELECT_LEX is always last
end
->
link_next
=
old_lex
->
all_selects_list
;
end
->
link_next
=
old_lex
->
all_selects_list
;
...
@@ -860,6 +845,9 @@ ok:
...
@@ -860,6 +845,9 @@ ok:
lex
->
all_selects_list
->
link_prev
=
lex
->
all_selects_list
->
link_prev
=
(
st_select_lex_node
**
)
&
old_lex
->
all_selects_list
;
(
st_select_lex_node
**
)
&
old_lex
->
all_selects_list
;
ok2:
if
(
arena
)
thd
->
restore_backup_item_arena
(
arena
,
&
backup
);
thd
->
lex
=
old_lex
;
thd
->
lex
=
old_lex
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
...
sql/sql_yacc.yy
View file @
5b16dbf9
This diff is collapsed.
Click to expand it.
sql/table.h
View file @
5b16dbf9
...
@@ -429,6 +429,11 @@ typedef struct st_table_list
...
@@ -429,6 +429,11 @@ typedef struct st_table_list
/* FRMTYPE_ERROR if any type is acceptable */
/* FRMTYPE_ERROR if any type is acceptable */
enum
frm_type_enum
required_type
;
enum
frm_type_enum
required_type
;
char
timestamp_buffer
[
20
];
/* buffer for timestamp (19+1) */
char
timestamp_buffer
[
20
];
/* buffer for timestamp (19+1) */
/*
This TABLE_LIST object is just placeholder for prelocking, it will be
used for implicit LOCK TABLES only and won't be used in real statement.
*/
bool
prelocking_placeholder
;
void
calc_md5
(
char
*
buffer
);
void
calc_md5
(
char
*
buffer
);
void
set_ancestor
();
void
set_ancestor
();
...
...
sql/tztime.cc
View file @
5b16dbf9
...
@@ -1524,7 +1524,6 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
...
@@ -1524,7 +1524,6 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
TZ_NAMES_ENTRY
*
tmp_tzname
;
TZ_NAMES_ENTRY
*
tmp_tzname
;
my_bool
return_val
=
1
;
my_bool
return_val
=
1
;
int
res
;
int
res
;
uint
counter
;
DBUG_ENTER
(
"my_tz_init"
);
DBUG_ENTER
(
"my_tz_init"
);
/*
/*
...
@@ -1593,8 +1592,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
...
@@ -1593,8 +1592,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap)
last_global_next_ptr
=
&
(
tables_buff
[
0
].
next_global
);
last_global_next_ptr
=
&
(
tables_buff
[
0
].
next_global
);
tz_init_table_list
(
tables_buff
+
1
,
&
last_global_next_ptr
);
tz_init_table_list
(
tables_buff
+
1
,
&
last_global_next_ptr
);
if
(
open_tables
(
thd
,
tables_buff
,
&
counter
)
||
if
(
simple_open_n_lock_tables
(
thd
,
tables_buff
))
lock_tables
(
thd
,
tables_buff
,
counter
))
{
{
sql_print_warning
(
"Can't open and lock time zone table: %s "
sql_print_warning
(
"Can't open and lock time zone table: %s "
"trying to live without them"
,
thd
->
net
.
last_error
);
"trying to live without them"
,
thd
->
net
.
last_error
);
...
...
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