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
fffa919f
Commit
fffa919f
authored
Aug 27, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-5.0
parents
7a6f5cf1
8fa394da
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
565 additions
and
392 deletions
+565
-392
include/mysqld_error.h
include/mysqld_error.h
+1
-0
mysql-test/r/sp-error.result
mysql-test/r/sp-error.result
+46
-0
mysql-test/r/sp.result
mysql-test/r/sp.result
+60
-20
mysql-test/t/sp-error.test
mysql-test/t/sp-error.test
+48
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+73
-19
sql/share/czech/errmsg.txt
sql/share/czech/errmsg.txt
+1
-0
sql/share/danish/errmsg.txt
sql/share/danish/errmsg.txt
+1
-0
sql/share/dutch/errmsg.txt
sql/share/dutch/errmsg.txt
+1
-0
sql/share/english/errmsg.txt
sql/share/english/errmsg.txt
+1
-0
sql/share/estonian/errmsg.txt
sql/share/estonian/errmsg.txt
+1
-0
sql/share/french/errmsg.txt
sql/share/french/errmsg.txt
+1
-0
sql/share/german/errmsg.txt
sql/share/german/errmsg.txt
+1
-0
sql/share/greek/errmsg.txt
sql/share/greek/errmsg.txt
+1
-0
sql/share/hungarian/errmsg.txt
sql/share/hungarian/errmsg.txt
+1
-0
sql/share/italian/errmsg.txt
sql/share/italian/errmsg.txt
+1
-0
sql/share/japanese/errmsg.txt
sql/share/japanese/errmsg.txt
+1
-0
sql/share/korean/errmsg.txt
sql/share/korean/errmsg.txt
+1
-0
sql/share/norwegian-ny/errmsg.txt
sql/share/norwegian-ny/errmsg.txt
+1
-0
sql/share/norwegian/errmsg.txt
sql/share/norwegian/errmsg.txt
+1
-0
sql/share/polish/errmsg.txt
sql/share/polish/errmsg.txt
+1
-0
sql/share/portuguese/errmsg.txt
sql/share/portuguese/errmsg.txt
+1
-0
sql/share/romanian/errmsg.txt
sql/share/romanian/errmsg.txt
+1
-0
sql/share/russian/errmsg.txt
sql/share/russian/errmsg.txt
+1
-0
sql/share/serbian/errmsg.txt
sql/share/serbian/errmsg.txt
+1
-0
sql/share/slovak/errmsg.txt
sql/share/slovak/errmsg.txt
+1
-0
sql/share/spanish/errmsg.txt
sql/share/spanish/errmsg.txt
+1
-0
sql/share/swedish/errmsg.txt
sql/share/swedish/errmsg.txt
+1
-0
sql/share/ukrainian/errmsg.txt
sql/share/ukrainian/errmsg.txt
+1
-0
sql/sp_head.cc
sql/sp_head.cc
+43
-21
sql/sp_head.h
sql/sp_head.h
+52
-59
sql/sp_pcontext.cc
sql/sp_pcontext.cc
+83
-127
sql/sp_pcontext.h
sql/sp_pcontext.h
+50
-63
sql/sql_yacc.yy
sql/sql_yacc.yy
+86
-83
No files found.
include/mysqld_error.h
View file @
fffa919f
...
@@ -373,4 +373,5 @@
...
@@ -373,4 +373,5 @@
#define ER_WARN_VIEW_WITHOUT_KEY 1354
#define ER_WARN_VIEW_WITHOUT_KEY 1354
#define ER_VIEW_INVALID 1355
#define ER_VIEW_INVALID 1355
#define ER_SP_NO_DROP_SP 1356
#define ER_SP_NO_DROP_SP 1356
#define ER_SP_GOTO_IN_HNDLR 1357
#define ER_ERROR_MESSAGES 357
#define ER_ERROR_MESSAGES 357
mysql-test/r/sp-error.result
View file @
fffa919f
...
@@ -68,6 +68,42 @@ goto foo;
...
@@ -68,6 +68,42 @@ goto foo;
end|
end|
ERROR 42000: GOTO with no matching label: foo
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
create procedure foo()
begin
begin
label foo;
end;
goto foo;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
begin
goto foo;
begin
label foo;
end;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
begin
begin
goto foo;
end;
begin
label foo;
end;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
begin
begin
label foo;
end;
begin
goto foo;
end;
end|
ERROR 42000: GOTO with no matching label: foo
create procedure foo()
foo: loop
foo: loop
foo: loop
foo: loop
set @x=2;
set @x=2;
...
@@ -288,6 +324,16 @@ declare continue handler for sqlstate '42S99' set x = 1;
...
@@ -288,6 +324,16 @@ declare continue handler for sqlstate '42S99' set x = 1;
declare c cursor for select * from t1;
declare c cursor for select * from t1;
end|
end|
ERROR 42000: Cursor declaration after handler declaration
ERROR 42000: Cursor declaration after handler declaration
create procedure p()
begin
declare continue handler for sqlexception
begin
goto L1;
end;
select field from t1;
label L1;
end|
ERROR HY000: GOTO is not allowed in a stored procedure handler
create procedure bug1965()
create procedure bug1965()
begin
begin
declare c cursor for select val from t1 order by valname;
declare c cursor for select val from t1 order by valname;
...
...
mysql-test/r/sp.result
View file @
fffa919f
reset master;
use test;
use test;
drop table if exists t1;
drop table if exists t1;
drop table if exists t2;
drop table if exists t2;
...
@@ -398,7 +397,7 @@ id data
...
@@ -398,7 +397,7 @@ id data
i 3
i 3
delete from t1|
delete from t1|
drop procedure i|
drop procedure i|
create procedure
j
()
create procedure
goto1
()
begin
begin
declare y int;
declare y int;
label a;
label a;
...
@@ -411,7 +410,7 @@ insert into t1 values ("j", y);
...
@@ -411,7 +410,7 @@ insert into t1 values ("j", y);
goto a;
goto a;
label b;
label b;
end|
end|
call
j
()|
call
goto1
()|
id data
id data
id data
id data
j 0
j 0
...
@@ -422,8 +421,8 @@ id data
...
@@ -422,8 +421,8 @@ id data
j 0
j 0
j 1
j 1
j 2
j 2
drop procedure
j
|
drop procedure
goto1
|
create procedure
k
(a int)
create procedure
goto2
(a int)
begin
begin
declare x int default 0;
declare x int default 0;
declare continue handler for sqlstate '42S98' set x = 1;
declare continue handler for sqlstate '42S98' set x = 1;
...
@@ -446,7 +445,7 @@ end;
...
@@ -446,7 +445,7 @@ end;
end while b;
end while b;
select * from t1;
select * from t1;
end|
end|
call
k
(0)|
call
goto2
(0)|
id data
id data
j 0
j 0
j 1
j 1
...
@@ -455,7 +454,7 @@ id data
...
@@ -455,7 +454,7 @@ id data
j 0
j 0
j 1
j 1
j 2
j 2
call
k
(1)|
call
goto2
(1)|
id data
id data
j 0
j 0
j 1
j 1
...
@@ -464,7 +463,7 @@ id data
...
@@ -464,7 +463,7 @@ id data
j 0
j 0
j 1
j 1
j 2
j 2
call
k
(2)|
call
goto2
(2)|
id data
id data
j 0
j 0
j 1
j 1
...
@@ -477,8 +476,60 @@ id data
...
@@ -477,8 +476,60 @@ id data
j 0
j 0
j 1
j 1
j 2
j 2
drop procedure
k
|
drop procedure
goto2
|
delete from t1|
delete from t1|
create procedure goto3()
begin
label L1;
begin
end;
goto L1;
end|
drop procedure goto3|
create procedure goto4()
begin
begin
label lab1;
begin
goto lab1;
end;
end;
end|
drop procedure goto4|
create procedure goto5()
begin
begin
begin
goto lab1;
end;
label lab1;
end;
end|
drop procedure goto5|
create procedure goto6()
begin
label L1;
goto L5;
begin
label L2;
goto L1;
goto L5;
begin
label L3;
goto L1;
goto L2;
goto L3;
goto L4;
goto L5;
end;
goto L2;
goto L4;
label L4;
end;
label L5;
goto L1;
end|
drop procedure goto6|
insert into t1 values ("foo", 3), ("bar", 19)|
insert into t1 values ("foo", 3), ("bar", 19)|
insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
create procedure sel1()
create procedure sel1()
...
@@ -1536,11 +1587,8 @@ show errors;
...
@@ -1536,11 +1587,8 @@ show errors;
show columns from t1;
show columns from t1;
show grants for 'root'@'localhost';
show grants for 'root'@'localhost';
show keys from t1;
show keys from t1;
show master status;
show open tables like 'foo';
show open tables like 'foo';
show privileges;
show privileges;
show slave hosts;
show slave status;
show status like 'foo';
show status like 'foo';
show tables like 'foo';
show tables like 'foo';
show variables like 'foo';
show variables like 'foo';
...
@@ -1567,8 +1615,6 @@ data int(11) 0
...
@@ -1567,8 +1615,6 @@ data int(11) 0
Grants for root@localhost
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 22451
Database Table In_use Name_locked
Database Table In_use Name_locked
Privilege Context Comment
Privilege Context Comment
Alter Tables To alter the table
Alter Tables To alter the table
...
@@ -1594,8 +1640,6 @@ Shutdown Server Admin To shut down the server
...
@@ -1594,8 +1640,6 @@ Shutdown Server Admin To shut down the server
Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
Update Tables To update existing rows
Update Tables To update existing rows
Usage Server Admin No privileges - allow connect only
Usage Server Admin No privileges - allow connect only
Server_id Host Port Rpl_recovery_rank Master_id
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
Variable_name Value
Variable_name Value
Tables_in_test (foo) table_type
Tables_in_test (foo) table_type
Variable_name Value
Variable_name Value
...
@@ -1621,8 +1665,6 @@ data int(11) 0
...
@@ -1621,8 +1665,6 @@ data int(11) 0
Grants for root@localhost
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 22451
Database Table In_use Name_locked
Database Table In_use Name_locked
Privilege Context Comment
Privilege Context Comment
Alter Tables To alter the table
Alter Tables To alter the table
...
@@ -1648,8 +1690,6 @@ Shutdown Server Admin To shut down the server
...
@@ -1648,8 +1690,6 @@ Shutdown Server Admin To shut down the server
Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
Update Tables To update existing rows
Update Tables To update existing rows
Usage Server Admin No privileges - allow connect only
Usage Server Admin No privileges - allow connect only
Server_id Host Port Rpl_recovery_rank Master_id
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
Variable_name Value
Variable_name Value
Tables_in_test (foo) table_type
Tables_in_test (foo) table_type
Variable_name Value
Variable_name Value
...
...
mysql-test/t/sp-error.test
View file @
fffa919f
...
@@ -103,6 +103,42 @@ create procedure foo()
...
@@ -103,6 +103,42 @@ create procedure foo()
begin
begin
goto
foo
;
goto
foo
;
end
|
end
|
--
error
1307
create
procedure
foo
()
begin
begin
label
foo
;
end
;
goto
foo
;
end
|
--
error
1307
create
procedure
foo
()
begin
goto
foo
;
begin
label
foo
;
end
;
end
|
--
error
1307
create
procedure
foo
()
begin
begin
goto
foo
;
end
;
begin
label
foo
;
end
;
end
|
--
error
1307
create
procedure
foo
()
begin
begin
label
foo
;
end
;
begin
goto
foo
;
end
;
end
|
# Redefining label
# Redefining label
--
error
1308
--
error
1308
...
@@ -380,6 +416,18 @@ begin
...
@@ -380,6 +416,18 @@ begin
declare
c
cursor
for
select
*
from
t1
;
declare
c
cursor
for
select
*
from
t1
;
end
|
end
|
--
error
1357
create
procedure
p
()
begin
declare
continue
handler
for
sqlexception
begin
goto
L1
;
end
;
select
field
from
t1
;
label
L1
;
end
|
#
#
# BUG#1965
# BUG#1965
#
#
...
...
mysql-test/t/sp.test
View file @
fffa919f
#
#
# Basic stored PROCEDURE tests
# Basic stored PROCEDURE tests
#
#
#
# Please keep this file free of --error cases and other
# things that will not run in a single debugged mysqld
# Let us reset binary logs in order to make show master status
# process (e.g. master-slave things).
# in test for bug 4902 repeatable.
reset
master
;
use
test
;
use
test
;
...
@@ -470,10 +468,10 @@ drop procedure i|
...
@@ -470,10 +468,10 @@ drop procedure i|
# The non-standard GOTO, for compatibility
# The non-standard GOTO, for compatibility
#
#
# QQQ The "label" syntax is temporary
.
# QQQ The "label" syntax is temporary
, it will (hopefully)
#
QQQ This is no nearly enough, more tests are needed
#
change to the more common "L:" syntax soon.
#
#
create
procedure
j
()
create
procedure
goto1
()
begin
begin
declare
y
int
;
declare
y
int
;
...
@@ -488,12 +486,11 @@ label a;
...
@@ -488,12 +486,11 @@ label a;
label
b
;
label
b
;
end
|
end
|
call
j
()
|
call
goto1
()
|
drop
procedure
goto1
|
drop
procedure
j
|
# With dummy handlers, just to test restore of contexts with jumps
# With dummy handlers, just to test restore of contexts with jumps
create
procedure
k
(
a
int
)
create
procedure
goto2
(
a
int
)
begin
begin
declare
x
int
default
0
;
declare
x
int
default
0
;
declare
continue
handler
for
sqlstate
'42S98'
set
x
=
1
;
declare
continue
handler
for
sqlstate
'42S98'
set
x
=
1
;
...
@@ -520,13 +517,70 @@ b:
...
@@ -520,13 +517,70 @@ b:
select
*
from
t1
;
select
*
from
t1
;
end
|
end
|
call
k
(
0
)
|
call
goto2
(
0
)
|
call
k
(
1
)
|
call
goto2
(
1
)
|
call
k
(
2
)
|
call
goto2
(
2
)
|
drop
procedure
k
|
drop
procedure
goto2
|
delete
from
t1
|
delete
from
t1
|
# Check label visibility for some more cases. We don't call these.
create
procedure
goto3
()
begin
label
L1
;
begin
end
;
goto
L1
;
end
|
drop
procedure
goto3
|
create
procedure
goto4
()
begin
begin
label
lab1
;
begin
goto
lab1
;
end
;
end
;
end
|
drop
procedure
goto4
|
create
procedure
goto5
()
begin
begin
begin
goto
lab1
;
end
;
label
lab1
;
end
;
end
|
drop
procedure
goto5
|
create
procedure
goto6
()
begin
label
L1
;
goto
L5
;
begin
label
L2
;
goto
L1
;
goto
L5
;
begin
label
L3
;
goto
L1
;
goto
L2
;
goto
L3
;
goto
L4
;
goto
L5
;
end
;
goto
L2
;
goto
L4
;
label
L4
;
end
;
label
L5
;
goto
L1
;
end
|
drop
procedure
goto6
|
# SELECT with one of more result set sent back to the clinet
# SELECT with one of more result set sent back to the clinet
insert
into
t1
values
(
"foo"
,
3
),
(
"bar"
,
19
)
|
insert
into
t1
values
(
"foo"
,
3
),
(
"bar"
,
19
)
|
insert
into
t2
values
(
"x"
,
9
,
4.1
),
(
"y"
,
-
1
,
19.2
),
(
"z"
,
3
,
2.2
)
|
insert
into
t2
values
(
"x"
,
9
,
4.1
),
(
"y"
,
-
1
,
19.2
),
(
"z"
,
3
,
2.2
)
|
...
@@ -1761,11 +1815,8 @@ begin
...
@@ -1761,11 +1815,8 @@ begin
show
columns
from
t1
;
show
columns
from
t1
;
show
grants
for
'root'
@
'localhost'
;
show
grants
for
'root'
@
'localhost'
;
show
keys
from
t1
;
show
keys
from
t1
;
show
master
status
;
show
open
tables
like
'foo'
;
show
open
tables
like
'foo'
;
show
privileges
;
show
privileges
;
show
slave
hosts
;
show
slave
status
;
show
status
like
'foo'
;
show
status
like
'foo'
;
show
tables
like
'foo'
;
show
tables
like
'foo'
;
show
variables
like
'foo'
;
show
variables
like
'foo'
;
...
@@ -1773,6 +1824,9 @@ begin
...
@@ -1773,6 +1824,9 @@ begin
end
|
end
|
#show binlog events;
#show binlog events;
#show storage engines;
#show storage engines;
#show master status;
#show slave hosts;
#show slave status;
call
bug4902
()
|
call
bug4902
()
|
call
bug4902
()
|
call
bug4902
()
|
...
...
sql/share/czech/errmsg.txt
View file @
fffa919f
...
@@ -369,3 +369,4 @@ character-set=latin2
...
@@ -369,3 +369,4 @@ character-set=latin2
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/danish/errmsg.txt
View file @
fffa919f
...
@@ -363,3 +363,4 @@ character-set=latin1
...
@@ -363,3 +363,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/dutch/errmsg.txt
View file @
fffa919f
...
@@ -371,3 +371,4 @@ character-set=latin1
...
@@ -371,3 +371,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/english/errmsg.txt
View file @
fffa919f
...
@@ -360,3 +360,4 @@ character-set=latin1
...
@@ -360,3 +360,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/estonian/errmsg.txt
View file @
fffa919f
...
@@ -365,3 +365,4 @@ character-set=latin7
...
@@ -365,3 +365,4 @@ character-set=latin7
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/french/errmsg.txt
View file @
fffa919f
...
@@ -360,3 +360,4 @@ character-set=latin1
...
@@ -360,3 +360,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/german/errmsg.txt
View file @
fffa919f
...
@@ -372,3 +372,4 @@ character-set=latin1
...
@@ -372,3 +372,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/greek/errmsg.txt
View file @
fffa919f
...
@@ -360,3 +360,4 @@ character-set=greek
...
@@ -360,3 +360,4 @@ character-set=greek
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/hungarian/errmsg.txt
View file @
fffa919f
...
@@ -362,3 +362,4 @@ character-set=latin2
...
@@ -362,3 +362,4 @@ character-set=latin2
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/italian/errmsg.txt
View file @
fffa919f
...
@@ -360,3 +360,4 @@ character-set=latin1
...
@@ -360,3 +360,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/japanese/errmsg.txt
View file @
fffa919f
...
@@ -362,3 +362,4 @@ character-set=ujis
...
@@ -362,3 +362,4 @@ character-set=ujis
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/korean/errmsg.txt
View file @
fffa919f
...
@@ -360,3 +360,4 @@ character-set=euckr
...
@@ -360,3 +360,4 @@ character-set=euckr
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/norwegian-ny/errmsg.txt
View file @
fffa919f
...
@@ -362,3 +362,4 @@ character-set=latin1
...
@@ -362,3 +362,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/norwegian/errmsg.txt
View file @
fffa919f
...
@@ -362,3 +362,4 @@ character-set=latin1
...
@@ -362,3 +362,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/polish/errmsg.txt
View file @
fffa919f
...
@@ -364,3 +364,4 @@ character-set=latin2
...
@@ -364,3 +364,4 @@ character-set=latin2
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/portuguese/errmsg.txt
View file @
fffa919f
...
@@ -361,3 +361,4 @@ character-set=latin1
...
@@ -361,3 +361,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/romanian/errmsg.txt
View file @
fffa919f
...
@@ -364,3 +364,4 @@ character-set=latin2
...
@@ -364,3 +364,4 @@ character-set=latin2
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/russian/errmsg.txt
View file @
fffa919f
...
@@ -362,3 +362,4 @@ character-set=koi8r
...
@@ -362,3 +362,4 @@ character-set=koi8r
" view ()"
" view ()"
"View '%-.64s.%-.64s' "
"View '%-.64s.%-.64s' "
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/serbian/errmsg.txt
View file @
fffa919f
...
@@ -366,3 +366,4 @@ character-set=cp1250
...
@@ -366,3 +366,4 @@ character-set=cp1250
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/slovak/errmsg.txt
View file @
fffa919f
...
@@ -368,3 +368,4 @@ character-set=latin2
...
@@ -368,3 +368,4 @@ character-set=latin2
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/spanish/errmsg.txt
View file @
fffa919f
...
@@ -362,3 +362,4 @@ character-set=latin1
...
@@ -362,3 +362,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/swedish/errmsg.txt
View file @
fffa919f
...
@@ -360,3 +360,4 @@ character-set=latin1
...
@@ -360,3 +360,4 @@ character-set=latin1
"View being updated does not have complete key of underlying table in it"
"View being updated does not have complete key of underlying table in it"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/share/ukrainian/errmsg.txt
View file @
fffa919f
...
@@ -365,3 +365,4 @@ character-set=koi8u
...
@@ -365,3 +365,4 @@ character-set=koi8u
"View, , ͦ æ(), Ҧ "
"View, , ͦ æ(), Ҧ "
"View '%-.64s.%-.64s' Ŧަ æ æ"
"View '%-.64s.%-.64s' Ŧަ æ æ"
"Can't drop a %s from within another stored routine"
"Can't drop a %s from within another stored routine"
"GOTO is not allowed in a stored procedure handler"
sql/sp_head.cc
View file @
fffa919f
...
@@ -257,7 +257,7 @@ sp_head::operator delete(void *ptr, size_t size)
...
@@ -257,7 +257,7 @@ sp_head::operator delete(void *ptr, size_t size)
sp_head
::
sp_head
()
sp_head
::
sp_head
()
:
Item_arena
((
bool
)
FALSE
),
m_returns_cs
(
NULL
),
m_has_return
(
FALSE
),
:
Item_arena
((
bool
)
FALSE
),
m_returns_cs
(
NULL
),
m_has_return
(
FALSE
),
m_simple_case
(
FALSE
),
m_multi_results
(
FALSE
)
m_simple_case
(
FALSE
),
m_multi_results
(
FALSE
)
,
m_in_handler
(
FALSE
)
{
{
DBUG_ENTER
(
"sp_head::sp_head"
);
DBUG_ENTER
(
"sp_head::sp_head"
);
...
@@ -272,7 +272,7 @@ sp_head::init(LEX *lex)
...
@@ -272,7 +272,7 @@ sp_head::init(LEX *lex)
{
{
DBUG_ENTER
(
"sp_head::init"
);
DBUG_ENTER
(
"sp_head::init"
);
lex
->
spcont
=
m_pcont
=
new
sp_pcontext
();
lex
->
spcont
=
m_pcont
=
new
sp_pcontext
(
NULL
);
my_init_dynamic_array
(
&
m_instr
,
sizeof
(
sp_instr
*
),
16
,
8
);
my_init_dynamic_array
(
&
m_instr
,
sizeof
(
sp_instr
*
),
16
,
8
);
m_param_begin
=
m_param_end
=
m_returns_begin
=
m_returns_end
=
m_body_begin
=
0
;
m_param_begin
=
m_param_end
=
m_returns_begin
=
m_returns_end
=
m_body_begin
=
0
;
m_qname
.
str
=
m_db
.
str
=
m_name
.
str
=
m_params
.
str
=
m_retstr
.
str
=
m_qname
.
str
=
m_db
.
str
=
m_name
.
str
=
m_params
.
str
=
m_retstr
.
str
=
...
@@ -514,10 +514,10 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
...
@@ -514,10 +514,10 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
{
{
DBUG_ENTER
(
"sp_head::execute_function"
);
DBUG_ENTER
(
"sp_head::execute_function"
);
DBUG_PRINT
(
"info"
,
(
"function %s"
,
m_name
.
str
));
DBUG_PRINT
(
"info"
,
(
"function %s"
,
m_name
.
str
));
uint
csize
=
m_pcont
->
max_
framesize
();
uint
csize
=
m_pcont
->
max_
pvars
();
uint
params
=
m_pcont
->
param
s
();
uint
params
=
m_pcont
->
current_pvar
s
();
uint
hmax
=
m_pcont
->
handlers
();
uint
hmax
=
m_pcont
->
max_
handlers
();
uint
cmax
=
m_pcont
->
cursors
();
uint
cmax
=
m_pcont
->
max_
cursors
();
sp_rcontext
*
octx
=
thd
->
spcont
;
sp_rcontext
*
octx
=
thd
->
spcont
;
sp_rcontext
*
nctx
=
NULL
;
sp_rcontext
*
nctx
=
NULL
;
uint
i
;
uint
i
;
...
@@ -594,10 +594,10 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
...
@@ -594,10 +594,10 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
DBUG_ENTER
(
"sp_head::execute_procedure"
);
DBUG_ENTER
(
"sp_head::execute_procedure"
);
DBUG_PRINT
(
"info"
,
(
"procedure %s"
,
m_name
.
str
));
DBUG_PRINT
(
"info"
,
(
"procedure %s"
,
m_name
.
str
));
int
ret
=
0
;
int
ret
=
0
;
uint
csize
=
m_pcont
->
max_
framesize
();
uint
csize
=
m_pcont
->
max_
pvars
();
uint
params
=
m_pcont
->
param
s
();
uint
params
=
m_pcont
->
current_pvar
s
();
uint
hmax
=
m_pcont
->
handlers
();
uint
hmax
=
m_pcont
->
max_
handlers
();
uint
cmax
=
m_pcont
->
cursors
();
uint
cmax
=
m_pcont
->
max_
cursors
();
sp_rcontext
*
octx
=
thd
->
spcont
;
sp_rcontext
*
octx
=
thd
->
spcont
;
sp_rcontext
*
nctx
=
NULL
;
sp_rcontext
*
nctx
=
NULL
;
my_bool
tmp_octx
=
FALSE
;
// True if we have allocated a temporary octx
my_bool
tmp_octx
=
FALSE
;
// True if we have allocated a temporary octx
...
@@ -851,12 +851,18 @@ sp_head::backpatch(sp_label_t *lab)
...
@@ -851,12 +851,18 @@ sp_head::backpatch(sp_label_t *lab)
(
bp
->
lab
->
type
==
SP_LAB_REF
&&
(
bp
->
lab
->
type
==
SP_LAB_REF
&&
my_strcasecmp
(
system_charset_info
,
bp
->
lab
->
name
,
lab
->
name
)
==
0
))
my_strcasecmp
(
system_charset_info
,
bp
->
lab
->
name
,
lab
->
name
)
==
0
))
{
{
sp_scope_t
sdiff
;
if
(
bp
->
lab
->
type
!=
SP_LAB_REF
)
bp
->
instr
->
backpatch
(
dest
,
lab
->
ctx
);
else
{
sp_label_t
*
dstlab
=
bp
->
lab
->
ctx
->
find_label
(
lab
->
name
);
if
(
bp
->
lab
->
type
==
SP_LAB_REF
)
if
(
dstlab
)
{
bp
->
lab
=
lab
;
bp
->
lab
=
lab
;
m_pcont
->
diff_scopes
(
0
,
&
sdiff
);
bp
->
instr
->
backpatch
(
dest
,
dstlab
->
ctx
);
bp
->
instr
->
backpatch
(
dest
,
sdiff
.
hndlrs
,
sdiff
.
curs
);
}
}
}
}
}
}
}
}
...
@@ -1236,7 +1242,7 @@ sp_instr_jump::print(String *str)
...
@@ -1236,7 +1242,7 @@ sp_instr_jump::print(String *str)
uint
uint
sp_instr_jump
::
opt_mark
(
sp_head
*
sp
)
sp_instr_jump
::
opt_mark
(
sp_head
*
sp
)
{
{
m_dest
=
opt_shortcut_jump
(
sp
);
m_dest
=
opt_shortcut_jump
(
sp
,
this
);
if
(
m_dest
!=
m_ip
+
1
)
/* Jumping to following instruction? */
if
(
m_dest
!=
m_ip
+
1
)
/* Jumping to following instruction? */
marked
=
1
;
marked
=
1
;
m_optdest
=
sp
->
get_instr
(
m_dest
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
...
@@ -1244,15 +1250,18 @@ sp_instr_jump::opt_mark(sp_head *sp)
...
@@ -1244,15 +1250,18 @@ sp_instr_jump::opt_mark(sp_head *sp)
}
}
uint
uint
sp_instr_jump
::
opt_shortcut_jump
(
sp_head
*
sp
)
sp_instr_jump
::
opt_shortcut_jump
(
sp_head
*
sp
,
sp_instr
*
start
)
{
{
uint
dest
=
m_dest
;
uint
dest
=
m_dest
;
sp_instr
*
i
;
sp_instr
*
i
;
while
((
i
=
sp
->
get_instr
(
dest
)))
while
((
i
=
sp
->
get_instr
(
dest
)))
{
{
uint
ndest
=
i
->
opt_shortcut_jump
(
sp
)
;
uint
ndest
;
if
(
start
==
i
)
break
;
ndest
=
i
->
opt_shortcut_jump
(
sp
,
start
);
if
(
ndest
==
dest
)
if
(
ndest
==
dest
)
break
;
break
;
dest
=
ndest
;
dest
=
ndest
;
...
@@ -1320,7 +1329,7 @@ sp_instr_jump_if::opt_mark(sp_head *sp)
...
@@ -1320,7 +1329,7 @@ sp_instr_jump_if::opt_mark(sp_head *sp)
marked
=
1
;
marked
=
1
;
if
((
i
=
sp
->
get_instr
(
m_dest
)))
if
((
i
=
sp
->
get_instr
(
m_dest
)))
{
{
m_dest
=
i
->
opt_shortcut_jump
(
sp
);
m_dest
=
i
->
opt_shortcut_jump
(
sp
,
this
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
}
}
sp
->
opt_mark
(
m_dest
);
sp
->
opt_mark
(
m_dest
);
...
@@ -1377,7 +1386,7 @@ sp_instr_jump_if_not::opt_mark(sp_head *sp)
...
@@ -1377,7 +1386,7 @@ sp_instr_jump_if_not::opt_mark(sp_head *sp)
marked
=
1
;
marked
=
1
;
if
((
i
=
sp
->
get_instr
(
m_dest
)))
if
((
i
=
sp
->
get_instr
(
m_dest
)))
{
{
m_dest
=
i
->
opt_shortcut_jump
(
sp
);
m_dest
=
i
->
opt_shortcut_jump
(
sp
,
this
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
}
}
sp
->
opt_mark
(
m_dest
);
sp
->
opt_mark
(
m_dest
);
...
@@ -1460,7 +1469,7 @@ sp_instr_hpush_jump::opt_mark(sp_head *sp)
...
@@ -1460,7 +1469,7 @@ sp_instr_hpush_jump::opt_mark(sp_head *sp)
marked
=
1
;
marked
=
1
;
if
((
i
=
sp
->
get_instr
(
m_dest
)))
if
((
i
=
sp
->
get_instr
(
m_dest
)))
{
{
m_dest
=
i
->
opt_shortcut_jump
(
sp
);
m_dest
=
i
->
opt_shortcut_jump
(
sp
,
this
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
m_optdest
=
sp
->
get_instr
(
m_dest
);
}
}
sp
->
opt_mark
(
m_dest
);
sp
->
opt_mark
(
m_dest
);
...
@@ -1487,6 +1496,13 @@ sp_instr_hpop::print(String *str)
...
@@ -1487,6 +1496,13 @@ sp_instr_hpop::print(String *str)
str
->
qs_append
(
m_count
);
str
->
qs_append
(
m_count
);
}
}
void
sp_instr_hpop
::
backpatch
(
uint
dest
,
sp_pcontext
*
dst_ctx
)
{
m_count
=
m_ctx
->
diff_handlers
(
dst_ctx
);
}
//
//
// sp_instr_hreturn
// sp_instr_hreturn
//
//
...
@@ -1551,6 +1567,12 @@ sp_instr_cpop::print(String *str)
...
@@ -1551,6 +1567,12 @@ sp_instr_cpop::print(String *str)
str
->
qs_append
(
m_count
);
str
->
qs_append
(
m_count
);
}
}
void
sp_instr_cpop
::
backpatch
(
uint
dest
,
sp_pcontext
*
dst_ctx
)
{
m_count
=
m_ctx
->
diff_cursors
(
dst_ctx
);
}
//
//
// sp_instr_copen
// sp_instr_copen
//
//
...
...
sql/sp_head.h
View file @
fffa919f
...
@@ -86,6 +86,7 @@ public:
...
@@ -86,6 +86,7 @@ public:
my_bool
m_has_return
;
// For FUNCTIONs only
my_bool
m_has_return
;
// For FUNCTIONs only
my_bool
m_simple_case
;
// TRUE if parsing simple case, FALSE otherwise
my_bool
m_simple_case
;
// TRUE if parsing simple case, FALSE otherwise
my_bool
m_multi_results
;
// TRUE if a procedure with SELECT(s)
my_bool
m_multi_results
;
// TRUE if a procedure with SELECT(s)
my_bool
m_in_handler
;
// TRUE if parser in a handler body
uint
m_old_cmq
;
// Old CLIENT_MULTI_QUERIES value
uint
m_old_cmq
;
// Old CLIENT_MULTI_QUERIES value
st_sp_chistics
*
m_chistics
;
st_sp_chistics
*
m_chistics
;
ulong
m_sql_mode
;
// For SHOW CREATE
ulong
m_sql_mode
;
// For SHOW CREATE
...
@@ -262,10 +263,11 @@ public:
...
@@ -262,10 +263,11 @@ public:
uint
marked
;
uint
marked
;
Item
*
free_list
;
// My Items
Item
*
free_list
;
// My Items
uint
m_ip
;
// My index
uint
m_ip
;
// My index
sp_pcontext
*
m_ctx
;
// My parse context
// Should give each a name or type code for debugging purposes?
// Should give each a name or type code for debugging purposes?
sp_instr
(
uint
ip
)
sp_instr
(
uint
ip
,
sp_pcontext
*
ctx
)
:
Sql_alloc
(),
marked
(
0
),
free_list
(
0
),
m_ip
(
ip
)
:
Sql_alloc
(),
marked
(
0
),
free_list
(
0
),
m_ip
(
ip
)
,
m_ctx
(
ctx
)
{}
{}
virtual
~
sp_instr
()
virtual
~
sp_instr
()
...
@@ -279,7 +281,7 @@ public:
...
@@ -279,7 +281,7 @@ public:
virtual
void
print
(
String
*
str
)
=
0
;
virtual
void
print
(
String
*
str
)
=
0
;
virtual
void
backpatch
(
uint
dest
,
uint
hpop
,
uint
cpop
)
virtual
void
backpatch
(
uint
dest
,
sp_pcontext
*
dst_ctx
)
{}
{}
virtual
uint
opt_mark
(
sp_head
*
sp
)
virtual
uint
opt_mark
(
sp_head
*
sp
)
...
@@ -288,7 +290,7 @@ public:
...
@@ -288,7 +290,7 @@ public:
return
m_ip
+
1
;
return
m_ip
+
1
;
}
}
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
)
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
,
sp_instr
*
start
)
{
{
return
m_ip
;
return
m_ip
;
}
}
...
@@ -311,8 +313,8 @@ class sp_instr_stmt : public sp_instr
...
@@ -311,8 +313,8 @@ class sp_instr_stmt : public sp_instr
public:
public:
sp_instr_stmt
(
uint
ip
)
sp_instr_stmt
(
uint
ip
,
sp_pcontext
*
ctx
)
:
sp_instr
(
ip
),
m_lex
(
NULL
)
:
sp_instr
(
ip
,
ctx
),
m_lex
(
NULL
)
{}
{}
virtual
~
sp_instr_stmt
();
virtual
~
sp_instr_stmt
();
...
@@ -353,8 +355,10 @@ public:
...
@@ -353,8 +355,10 @@ public:
TABLE_LIST
*
tables
;
TABLE_LIST
*
tables
;
sp_instr_set
(
uint
ip
,
uint
offset
,
Item
*
val
,
enum
enum_field_types
type
)
sp_instr_set
(
uint
ip
,
sp_pcontext
*
ctx
,
:
sp_instr
(
ip
),
tables
(
NULL
),
m_offset
(
offset
),
m_value
(
val
),
m_type
(
type
)
uint
offset
,
Item
*
val
,
enum
enum_field_types
type
)
:
sp_instr
(
ip
,
ctx
),
tables
(
NULL
),
m_offset
(
offset
),
m_value
(
val
),
m_type
(
type
)
{}
{}
virtual
~
sp_instr_set
()
virtual
~
sp_instr_set
()
...
@@ -382,12 +386,12 @@ public:
...
@@ -382,12 +386,12 @@ public:
uint
m_dest
;
// Where we will go
uint
m_dest
;
// Where we will go
sp_instr_jump
(
uint
ip
)
sp_instr_jump
(
uint
ip
,
sp_pcontext
*
ctx
)
:
sp_instr
(
ip
),
m_dest
(
0
),
m_optdest
(
0
)
:
sp_instr
(
ip
,
ctx
),
m_dest
(
0
),
m_optdest
(
0
)
{}
{}
sp_instr_jump
(
uint
ip
,
uint
dest
)
sp_instr_jump
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
dest
)
:
sp_instr
(
ip
),
m_dest
(
dest
),
m_optdest
(
0
)
:
sp_instr
(
ip
,
ctx
),
m_dest
(
dest
),
m_optdest
(
0
)
{}
{}
virtual
~
sp_instr_jump
()
virtual
~
sp_instr_jump
()
...
@@ -399,11 +403,11 @@ public:
...
@@ -399,11 +403,11 @@ public:
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
);
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
,
sp_instr
*
start
);
virtual
void
opt_move
(
uint
dst
,
List
<
sp_instr
>
*
ibp
);
virtual
void
opt_move
(
uint
dst
,
List
<
sp_instr
>
*
ibp
);
virtual
void
backpatch
(
uint
dest
,
uint
hpop
,
uint
cpop
)
virtual
void
backpatch
(
uint
dest
,
sp_pcontext
*
dst_ctx
)
{
{
if
(
m_dest
==
0
)
// Don't reset
if
(
m_dest
==
0
)
// Don't reset
m_dest
=
dest
;
m_dest
=
dest
;
...
@@ -425,12 +429,12 @@ public:
...
@@ -425,12 +429,12 @@ public:
TABLE_LIST
*
tables
;
TABLE_LIST
*
tables
;
sp_instr_jump_if
(
uint
ip
,
Item
*
i
)
sp_instr_jump_if
(
uint
ip
,
sp_pcontext
*
ctx
,
Item
*
i
)
:
sp_instr_jump
(
ip
),
tables
(
NULL
),
m_expr
(
i
)
:
sp_instr_jump
(
ip
,
ctx
),
tables
(
NULL
),
m_expr
(
i
)
{}
{}
sp_instr_jump_if
(
uint
ip
,
Item
*
i
,
uint
dest
)
sp_instr_jump_if
(
uint
ip
,
sp_pcontext
*
ctx
,
Item
*
i
,
uint
dest
)
:
sp_instr_jump
(
ip
,
dest
),
tables
(
NULL
),
m_expr
(
i
)
:
sp_instr_jump
(
ip
,
ctx
,
dest
),
tables
(
NULL
),
m_expr
(
i
)
{}
{}
virtual
~
sp_instr_jump_if
()
virtual
~
sp_instr_jump_if
()
...
@@ -442,7 +446,7 @@ public:
...
@@ -442,7 +446,7 @@ public:
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
)
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
,
sp_instr
*
start
)
{
{
return
m_ip
;
return
m_ip
;
}
}
...
@@ -463,12 +467,12 @@ public:
...
@@ -463,12 +467,12 @@ public:
TABLE_LIST
*
tables
;
TABLE_LIST
*
tables
;
sp_instr_jump_if_not
(
uint
ip
,
Item
*
i
)
sp_instr_jump_if_not
(
uint
ip
,
sp_pcontext
*
ctx
,
Item
*
i
)
:
sp_instr_jump
(
ip
),
tables
(
NULL
),
m_expr
(
i
)
:
sp_instr_jump
(
ip
,
ctx
),
tables
(
NULL
),
m_expr
(
i
)
{}
{}
sp_instr_jump_if_not
(
uint
ip
,
Item
*
i
,
uint
dest
)
sp_instr_jump_if_not
(
uint
ip
,
sp_pcontext
*
ctx
,
Item
*
i
,
uint
dest
)
:
sp_instr_jump
(
ip
,
dest
),
tables
(
NULL
),
m_expr
(
i
)
:
sp_instr_jump
(
ip
,
ctx
,
dest
),
tables
(
NULL
),
m_expr
(
i
)
{}
{}
virtual
~
sp_instr_jump_if_not
()
virtual
~
sp_instr_jump_if_not
()
...
@@ -480,7 +484,7 @@ public:
...
@@ -480,7 +484,7 @@ public:
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
)
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
,
sp_instr
*
start
)
{
{
return
m_ip
;
return
m_ip
;
}
}
...
@@ -501,8 +505,9 @@ public:
...
@@ -501,8 +505,9 @@ public:
TABLE_LIST
*
tables
;
TABLE_LIST
*
tables
;
sp_instr_freturn
(
uint
ip
,
Item
*
val
,
enum
enum_field_types
type
)
sp_instr_freturn
(
uint
ip
,
sp_pcontext
*
ctx
,
:
sp_instr
(
ip
),
tables
(
NULL
),
m_value
(
val
),
m_type
(
type
)
Item
*
val
,
enum
enum_field_types
type
)
:
sp_instr
(
ip
,
ctx
),
tables
(
NULL
),
m_value
(
val
),
m_type
(
type
)
{}
{}
virtual
~
sp_instr_freturn
()
virtual
~
sp_instr_freturn
()
...
@@ -533,8 +538,8 @@ class sp_instr_hpush_jump : public sp_instr_jump
...
@@ -533,8 +538,8 @@ class sp_instr_hpush_jump : public sp_instr_jump
public:
public:
sp_instr_hpush_jump
(
uint
ip
,
int
htype
,
uint
fp
)
sp_instr_hpush_jump
(
uint
ip
,
sp_pcontext
*
ctx
,
int
htype
,
uint
fp
)
:
sp_instr_jump
(
ip
),
m_type
(
htype
),
m_frame
(
fp
)
:
sp_instr_jump
(
ip
,
ctx
),
m_type
(
htype
),
m_frame
(
fp
)
{
{
m_handler
=
ip
+
1
;
m_handler
=
ip
+
1
;
m_cond
.
empty
();
m_cond
.
empty
();
...
@@ -551,7 +556,7 @@ public:
...
@@ -551,7 +556,7 @@ public:
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_mark
(
sp_head
*
sp
);
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
)
virtual
uint
opt_shortcut_jump
(
sp_head
*
sp
,
sp_instr
*
start
)
{
{
return
m_ip
;
return
m_ip
;
}
}
...
@@ -578,8 +583,8 @@ class sp_instr_hpop : public sp_instr
...
@@ -578,8 +583,8 @@ class sp_instr_hpop : public sp_instr
public:
public:
sp_instr_hpop
(
uint
ip
,
uint
count
)
sp_instr_hpop
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
count
)
:
sp_instr
(
ip
),
m_count
(
count
)
:
sp_instr
(
ip
,
ctx
),
m_count
(
count
)
{}
{}
virtual
~
sp_instr_hpop
()
virtual
~
sp_instr_hpop
()
...
@@ -589,13 +594,7 @@ public:
...
@@ -589,13 +594,7 @@ public:
virtual
void
print
(
String
*
str
);
virtual
void
print
(
String
*
str
);
virtual
void
backpatch
(
uint
dest
,
uint
hpop
,
uint
cpop
)
virtual
void
backpatch
(
uint
dest
,
sp_pcontext
*
dst_ctx
);
{
if
(
hpop
>
m_count
)
m_count
=
0
;
else
m_count
-=
hpop
;
}
virtual
uint
opt_mark
(
sp_head
*
sp
)
virtual
uint
opt_mark
(
sp_head
*
sp
)
{
{
...
@@ -618,8 +617,8 @@ class sp_instr_hreturn : public sp_instr
...
@@ -618,8 +617,8 @@ class sp_instr_hreturn : public sp_instr
public:
public:
sp_instr_hreturn
(
uint
ip
,
uint
fp
)
sp_instr_hreturn
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
fp
)
:
sp_instr
(
ip
),
m_frame
(
fp
)
:
sp_instr
(
ip
,
ctx
),
m_frame
(
fp
)
{}
{}
virtual
~
sp_instr_hreturn
()
virtual
~
sp_instr_hreturn
()
...
@@ -649,8 +648,8 @@ class sp_instr_cpush : public sp_instr
...
@@ -649,8 +648,8 @@ class sp_instr_cpush : public sp_instr
public:
public:
sp_instr_cpush
(
uint
ip
,
LEX
*
lex
)
sp_instr_cpush
(
uint
ip
,
sp_pcontext
*
ctx
,
LEX
*
lex
)
:
sp_instr
(
ip
),
m_lex
(
lex
)
:
sp_instr
(
ip
,
ctx
),
m_lex
(
lex
)
{}
{}
virtual
~
sp_instr_cpush
();
virtual
~
sp_instr_cpush
();
...
@@ -673,8 +672,8 @@ class sp_instr_cpop : public sp_instr
...
@@ -673,8 +672,8 @@ class sp_instr_cpop : public sp_instr
public:
public:
sp_instr_cpop
(
uint
ip
,
uint
count
)
sp_instr_cpop
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
count
)
:
sp_instr
(
ip
),
m_count
(
count
)
:
sp_instr
(
ip
,
ctx
),
m_count
(
count
)
{}
{}
virtual
~
sp_instr_cpop
()
virtual
~
sp_instr_cpop
()
...
@@ -684,13 +683,7 @@ public:
...
@@ -684,13 +683,7 @@ public:
virtual
void
print
(
String
*
str
);
virtual
void
print
(
String
*
str
);
virtual
void
backpatch
(
uint
dest
,
uint
hpop
,
uint
cpop
)
virtual
void
backpatch
(
uint
dest
,
sp_pcontext
*
dst_ctx
);
{
if
(
cpop
>
m_count
)
m_count
=
0
;
else
m_count
-=
cpop
;
}
virtual
uint
opt_mark
(
sp_head
*
sp
)
virtual
uint
opt_mark
(
sp_head
*
sp
)
{
{
...
@@ -713,8 +706,8 @@ class sp_instr_copen : public sp_instr_stmt
...
@@ -713,8 +706,8 @@ class sp_instr_copen : public sp_instr_stmt
public:
public:
sp_instr_copen
(
uint
ip
,
uint
c
)
sp_instr_copen
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
c
)
:
sp_instr_stmt
(
ip
),
m_cursor
(
c
)
:
sp_instr_stmt
(
ip
,
ctx
),
m_cursor
(
c
)
{}
{}
virtual
~
sp_instr_copen
()
virtual
~
sp_instr_copen
()
...
@@ -738,8 +731,8 @@ class sp_instr_cclose : public sp_instr
...
@@ -738,8 +731,8 @@ class sp_instr_cclose : public sp_instr
public:
public:
sp_instr_cclose
(
uint
ip
,
uint
c
)
sp_instr_cclose
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
c
)
:
sp_instr
(
ip
),
m_cursor
(
c
)
:
sp_instr
(
ip
,
ctx
),
m_cursor
(
c
)
{}
{}
virtual
~
sp_instr_cclose
()
virtual
~
sp_instr_cclose
()
...
@@ -763,8 +756,8 @@ class sp_instr_cfetch : public sp_instr
...
@@ -763,8 +756,8 @@ class sp_instr_cfetch : public sp_instr
public:
public:
sp_instr_cfetch
(
uint
ip
,
uint
c
)
sp_instr_cfetch
(
uint
ip
,
sp_pcontext
*
ctx
,
uint
c
)
:
sp_instr
(
ip
),
m_cursor
(
c
)
:
sp_instr
(
ip
,
ctx
),
m_cursor
(
c
)
{
{
m_varlist
.
empty
();
m_varlist
.
empty
();
}
}
...
@@ -796,8 +789,8 @@ class sp_instr_error : public sp_instr
...
@@ -796,8 +789,8 @@ class sp_instr_error : public sp_instr
public:
public:
sp_instr_error
(
uint
ip
,
int
errcode
)
sp_instr_error
(
uint
ip
,
sp_pcontext
*
ctx
,
int
errcode
)
:
sp_instr
(
ip
),
m_errcode
(
errcode
)
:
sp_instr
(
ip
,
ctx
),
m_errcode
(
errcode
)
{}
{}
virtual
~
sp_instr_error
()
virtual
~
sp_instr_error
()
...
...
sql/sp_pcontext.cc
View file @
fffa919f
...
@@ -26,79 +26,98 @@
...
@@ -26,79 +26,98 @@
#include "sp_pcontext.h"
#include "sp_pcontext.h"
#include "sp_head.h"
#include "sp_head.h"
sp_pcontext
::
sp_pcontext
()
sp_pcontext
::
sp_pcontext
(
sp_pcontext
*
prev
)
:
Sql_alloc
(),
m_p
arams
(
0
),
m_framesize
(
0
),
m_handlers
(
0
),
m_cursmax
(
0
),
:
Sql_alloc
(),
m_p
subsize
(
0
),
m_csubsize
(
0
),
m_hsubsize
(
0
),
m_
hndlrlev
(
0
)
m_
parent
(
prev
),
m_handlers
(
0
)
{
{
VOID
(
my_init_dynamic_array
(
&
m_pvar
,
sizeof
(
sp_pvar_t
*
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_pvar
,
sizeof
(
sp_pvar_t
*
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_cond
,
sizeof
(
sp_cond_type_t
*
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_cond
,
sizeof
(
sp_cond_type_t
*
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_cursor
,
sizeof
(
LEX_STRING
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_cursor
,
sizeof
(
LEX_STRING
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_scopes
,
sizeof
(
sp_scope_t
),
16
,
8
));
VOID
(
my_init_dynamic_array
(
&
m_glabel
,
sizeof
(
sp_label_t
*
),
16
,
8
));
m_label
.
empty
();
m_label
.
empty
();
m_children
.
empty
();
if
(
!
prev
)
m_poffset
=
m_coffset
=
0
;
else
{
m_poffset
=
prev
->
current_pvars
();
m_coffset
=
prev
->
current_cursors
();
}
}
}
void
void
sp_pcontext
::
destroy
()
sp_pcontext
::
destroy
()
{
{
List_iterator_fast
<
sp_pcontext
>
li
(
m_children
);
sp_pcontext
*
child
;
while
((
child
=
li
++
))
child
->
destroy
();
m_children
.
empty
();
m_label
.
empty
();
delete_dynamic
(
&
m_pvar
);
delete_dynamic
(
&
m_pvar
);
delete_dynamic
(
&
m_cond
);
delete_dynamic
(
&
m_cond
);
delete_dynamic
(
&
m_cursor
);
delete_dynamic
(
&
m_cursor
);
delete_dynamic
(
&
m_scopes
);
delete_dynamic
(
&
m_glabel
);
m_label
.
empty
();
}
}
void
sp_pcontext
*
sp_pcontext
::
push_
scope
()
sp_pcontext
::
push_
context
()
{
{
sp_scope_t
s
;
sp_pcontext
*
child
=
new
sp_pcontext
(
this
);
s
.
vars
=
m_pvar
.
elements
;
if
(
child
)
s
.
conds
=
m_cond
.
elements
;
m_children
.
push_back
(
child
);
s
.
hndlrs
=
m_hndlrlev
;
return
child
;
s
.
curs
=
m_cursor
.
elements
;
s
.
glab
=
m_glabel
.
elements
;
insert_dynamic
(
&
m_scopes
,
(
gptr
)
&
s
);
}
}
void
sp_pcontext
*
sp_pcontext
::
pop_
scope
(
sp_scope_t
*
sp
)
sp_pcontext
::
pop_
context
(
)
{
{
byte
*
p
=
pop_dynamic
(
&
m_scopes
);
uint
submax
=
max_pvars
();
if
(
sp
&&
p
)
if
(
submax
>
m_parent
->
m_psubsize
)
memcpy
(
sp
,
p
,
sizeof
(
sp_scope_t
));
m_parent
->
m_psubsize
=
submax
;
submax
=
max_handlers
();
if
(
submax
>
m_parent
->
m_hsubsize
)
m_parent
->
m_hsubsize
=
submax
;
submax
=
max_cursors
();
if
(
submax
>
m_parent
->
m_csubsize
)
m_parent
->
m_csubsize
=
submax
;
return
m_parent
;
}
}
void
uint
sp_pcontext
::
diff_
scopes
(
uint
sold
,
sp_scope_t
*
diffs
)
sp_pcontext
::
diff_
handlers
(
sp_pcontext
*
ctx
)
{
{
uint
snew
=
m_scopes
.
elements
;
uint
n
=
0
;
sp_
scope_t
scope
;
sp_
pcontext
*
pctx
=
this
;
diffs
->
vars
=
diffs
->
conds
=
diffs
->
hndlrs
=
diffs
->
curs
=
diffs
->
glab
=
0
;
while
(
pctx
&&
pctx
!=
ctx
)
while
(
snew
--
>
sold
)
{
{
get_dynamic
(
&
m_scopes
,
(
gptr
)
&
scope
,
snew
);
n
+=
pctx
->
max_handlers
();
diffs
->
vars
+=
scope
.
vars
;
pctx
=
pctx
->
parent_context
();
diffs
->
conds
+=
scope
.
conds
;
diffs
->
hndlrs
+=
scope
.
hndlrs
;
diffs
->
curs
+=
scope
.
curs
;
diffs
->
glab
+=
scope
.
glab
;
}
}
if
(
sold
)
if
(
pctx
)
return
n
;
return
0
;
// Didn't find ctx
}
uint
sp_pcontext
::
diff_cursors
(
sp_pcontext
*
ctx
)
{
uint
n
=
0
;
sp_pcontext
*
pctx
=
this
;
while
(
pctx
&&
pctx
!=
ctx
)
{
{
get_dynamic
(
&
m_scopes
,
(
gptr
)
&
scope
,
sold
-
1
);
n
+=
pctx
->
max_cursors
();
diffs
->
vars
-=
scope
.
vars
;
pctx
=
pctx
->
parent_context
();
diffs
->
conds
-=
scope
.
conds
;
diffs
->
hndlrs
-=
scope
.
hndlrs
;
diffs
->
curs
-=
scope
.
curs
;
diffs
->
glab
-=
scope
.
glab
;
}
}
if
(
pctx
)
return
n
;
return
0
;
// Didn't find ctx
}
}
/* This does a linear search (from newer to older variables, in case
/* This does a linear search (from newer to older variables, in case
** we have shadowed names).
** we have shadowed names).
** It's possible to have a more efficient allocation and search method,
** It's possible to have a more efficient allocation and search method,
...
@@ -109,20 +128,9 @@ sp_pcontext::diff_scopes(uint sold, sp_scope_t *diffs)
...
@@ -109,20 +128,9 @@ sp_pcontext::diff_scopes(uint sold, sp_scope_t *diffs)
sp_pvar_t
*
sp_pvar_t
*
sp_pcontext
::
find_pvar
(
LEX_STRING
*
name
,
my_bool
scoped
)
sp_pcontext
::
find_pvar
(
LEX_STRING
*
name
,
my_bool
scoped
)
{
{
uint
i
=
m_pvar
.
elements
;
uint
i
=
m_pvar
.
elements
;
uint
limit
;
if
(
!
scoped
||
m_scopes
.
elements
==
0
)
while
(
i
--
)
limit
=
0
;
else
{
sp_scope_t
s
;
get_dynamic
(
&
m_scopes
,
(
gptr
)
&
s
,
m_scopes
.
elements
-
1
);
limit
=
s
.
vars
;
}
while
(
i
--
>
limit
)
{
{
sp_pvar_t
*
p
;
sp_pvar_t
*
p
;
...
@@ -134,6 +142,8 @@ sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped)
...
@@ -134,6 +142,8 @@ sp_pcontext::find_pvar(LEX_STRING *name, my_bool scoped)
return
p
;
return
p
;
}
}
}
}
if
(
!
scoped
&&
m_parent
)
return
m_parent
->
find_pvar
(
name
,
scoped
);
return
NULL
;
return
NULL
;
}
}
...
@@ -145,13 +155,13 @@ sp_pcontext::push_pvar(LEX_STRING *name, enum enum_field_types type,
...
@@ -145,13 +155,13 @@ sp_pcontext::push_pvar(LEX_STRING *name, enum enum_field_types type,
if
(
p
)
if
(
p
)
{
{
if
(
m_pvar
.
elements
==
m_
frame
size
)
if
(
m_pvar
.
elements
==
m_
psub
size
)
m_
framesize
+=
1
;
m_
psubsize
+=
1
;
p
->
name
.
str
=
name
->
str
;
p
->
name
.
str
=
name
->
str
;
p
->
name
.
length
=
name
->
length
;
p
->
name
.
length
=
name
->
length
;
p
->
type
=
type
;
p
->
type
=
type
;
p
->
mode
=
mode
;
p
->
mode
=
mode
;
p
->
offset
=
m_pvar
.
elements
;
p
->
offset
=
current_pvars
()
;
p
->
isset
=
(
mode
==
sp_param_out
?
FALSE
:
TRUE
);
p
->
isset
=
(
mode
==
sp_param_out
?
FALSE
:
TRUE
);
p
->
dflt
=
NULL
;
p
->
dflt
=
NULL
;
insert_dynamic
(
&
m_pvar
,
(
gptr
)
&
p
);
insert_dynamic
(
&
m_pvar
,
(
gptr
)
&
p
);
...
@@ -168,7 +178,7 @@ sp_pcontext::push_label(char *name, uint ip)
...
@@ -168,7 +178,7 @@ sp_pcontext::push_label(char *name, uint ip)
lab
->
name
=
name
;
lab
->
name
=
name
;
lab
->
ip
=
ip
;
lab
->
ip
=
ip
;
lab
->
type
=
SP_LAB_GOTO
;
lab
->
type
=
SP_LAB_GOTO
;
lab
->
scopes
=
0
;
lab
->
ctx
=
this
;
m_label
.
push_front
(
lab
);
m_label
.
push_front
(
lab
);
}
}
return
lab
;
return
lab
;
...
@@ -184,6 +194,8 @@ sp_pcontext::find_label(char *name)
...
@@ -184,6 +194,8 @@ sp_pcontext::find_label(char *name)
if
(
my_strcasecmp
(
system_charset_info
,
name
,
lab
->
name
)
==
0
)
if
(
my_strcasecmp
(
system_charset_info
,
name
,
lab
->
name
)
==
0
)
return
lab
;
return
lab
;
if
(
m_parent
)
return
m_parent
->
find_label
(
name
);
return
NULL
;
return
NULL
;
}
}
...
@@ -207,20 +219,9 @@ sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val)
...
@@ -207,20 +219,9 @@ sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val)
sp_cond_type_t
*
sp_cond_type_t
*
sp_pcontext
::
find_cond
(
LEX_STRING
*
name
,
my_bool
scoped
)
sp_pcontext
::
find_cond
(
LEX_STRING
*
name
,
my_bool
scoped
)
{
{
uint
i
=
m_cond
.
elements
;
uint
i
=
m_cond
.
elements
;
uint
limit
;
if
(
!
scoped
||
m_scopes
.
elements
==
0
)
limit
=
0
;
else
{
sp_scope_t
s
;
get_dynamic
(
&
m_scopes
,
(
gptr
)
&
s
,
m_scopes
.
elements
-
1
);
limit
=
s
.
conds
;
}
while
(
i
--
>
limit
)
while
(
i
--
)
{
{
sp_cond_t
*
p
;
sp_cond_t
*
p
;
...
@@ -232,6 +233,8 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped)
...
@@ -232,6 +233,8 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped)
return
p
->
val
;
return
p
->
val
;
}
}
}
}
if
(
!
scoped
&&
m_parent
)
return
m_parent
->
find_cond
(
name
,
scoped
);
return
NULL
;
return
NULL
;
}
}
...
@@ -240,11 +243,11 @@ sp_pcontext::push_cursor(LEX_STRING *name)
...
@@ -240,11 +243,11 @@ sp_pcontext::push_cursor(LEX_STRING *name)
{
{
LEX_STRING
n
;
LEX_STRING
n
;
if
(
m_cursor
.
elements
==
m_csubsize
)
m_csubsize
+=
1
;
n
.
str
=
name
->
str
;
n
.
str
=
name
->
str
;
n
.
length
=
name
->
length
;
n
.
length
=
name
->
length
;
insert_dynamic
(
&
m_cursor
,
(
gptr
)
&
n
);
insert_dynamic
(
&
m_cursor
,
(
gptr
)
&
n
);
if
(
m_cursor
.
elements
>
m_cursmax
)
m_cursmax
=
m_cursor
.
elements
;
}
}
/*
/*
...
@@ -253,20 +256,9 @@ sp_pcontext::push_cursor(LEX_STRING *name)
...
@@ -253,20 +256,9 @@ sp_pcontext::push_cursor(LEX_STRING *name)
my_bool
my_bool
sp_pcontext
::
find_cursor
(
LEX_STRING
*
name
,
uint
*
poff
,
my_bool
scoped
)
sp_pcontext
::
find_cursor
(
LEX_STRING
*
name
,
uint
*
poff
,
my_bool
scoped
)
{
{
uint
i
=
m_cursor
.
elements
;
uint
i
=
m_cursor
.
elements
;
uint
limit
;
if
(
!
scoped
||
m_scopes
.
elements
==
0
)
while
(
i
--
)
limit
=
0
;
else
{
sp_scope_t
s
;
get_dynamic
(
&
m_scopes
,
(
gptr
)
&
s
,
m_scopes
.
elements
-
1
);
limit
=
s
.
curs
;
}
while
(
i
--
>
limit
)
{
{
LEX_STRING
n
;
LEX_STRING
n
;
...
@@ -279,43 +271,7 @@ sp_pcontext::find_cursor(LEX_STRING *name, uint *poff, my_bool scoped)
...
@@ -279,43 +271,7 @@ sp_pcontext::find_cursor(LEX_STRING *name, uint *poff, my_bool scoped)
return
TRUE
;
return
TRUE
;
}
}
}
}
if
(
!
scoped
&&
m_parent
)
return
m_parent
->
find_cursor
(
name
,
poff
,
scoped
);
return
FALSE
;
return
FALSE
;
}
}
sp_label_t
*
sp_pcontext
::
push_glabel
(
char
*
name
,
uint
ip
)
{
sp_label_t
*
lab
=
(
sp_label_t
*
)
sql_alloc
(
sizeof
(
sp_label_t
));
if
(
lab
)
{
lab
->
name
=
name
;
lab
->
ip
=
ip
;
lab
->
type
=
SP_LAB_GOTO
;
lab
->
scopes
=
0
;
insert_dynamic
(
&
m_glabel
,
(
gptr
)
&
lab
);
}
return
lab
;
}
sp_label_t
*
sp_pcontext
::
find_glabel
(
char
*
name
)
{
uint
i
=
m_glabel
.
elements
;
while
(
i
--
)
{
sp_label_t
*
lab
;
get_dynamic
(
&
m_glabel
,
(
gptr
)
&
lab
,
i
);
if
(
my_strcasecmp
(
system_charset_info
,
name
,
lab
->
name
)
==
0
)
return
lab
;
}
return
NULL
;
}
void
sp_pcontext
::
pop_glabel
(
uint
count
)
{
(
void
)
pop_dynamic
(
&
m_glabel
);
}
sql/sp_pcontext.h
View file @
fffa919f
...
@@ -50,7 +50,7 @@ typedef struct sp_label
...
@@ -50,7 +50,7 @@ typedef struct sp_label
char
*
name
;
char
*
name
;
uint
ip
;
// Instruction index
uint
ip
;
// Instruction index
int
type
;
// begin/iter or ref/free
int
type
;
// begin/iter or ref/free
uint
scopes
;
// No. of scopes at label
struct
sp_pcontext
*
ctx
;
// The label's context
}
sp_label_t
;
}
sp_label_t
;
typedef
struct
sp_cond_type
typedef
struct
sp_cond_type
...
@@ -66,11 +66,6 @@ typedef struct sp_cond
...
@@ -66,11 +66,6 @@ typedef struct sp_cond
sp_cond_type_t
*
val
;
sp_cond_type_t
*
val
;
}
sp_cond_t
;
}
sp_cond_t
;
typedef
struct
sp_scope
{
uint
vars
,
conds
,
hndlrs
,
curs
,
glab
;
}
sp_scope_t
;
class
sp_pcontext
:
public
Sql_alloc
class
sp_pcontext
:
public
Sql_alloc
{
{
sp_pcontext
(
const
sp_pcontext
&
);
/* Prevent use of these */
sp_pcontext
(
const
sp_pcontext
&
);
/* Prevent use of these */
...
@@ -78,28 +73,30 @@ class sp_pcontext : public Sql_alloc
...
@@ -78,28 +73,30 @@ class sp_pcontext : public Sql_alloc
public:
public:
sp_pcontext
();
sp_pcontext
(
sp_pcontext
*
prev
);
// Free memory
// Free memory
void
void
destroy
();
destroy
();
// For error checking of duplicate things
sp_pcontext
*
void
push_context
();
push_scope
();
void
// Returns the previous context, not the one we pop
pop_scope
(
sp_scope_t
*
sp
=
0
);
sp_pcontext
*
pop_context
();
uint
sp_pcontext
*
scopes
()
parent_context
()
{
{
return
m_
scopes
.
elements
;
return
m_
parent
;
}
}
// Sets '*diffs' to the differences between current scope index snew and sold
uint
void
diff_handlers
(
sp_pcontext
*
ctx
);
diff_scopes
(
uint
sold
,
sp_scope_t
*
diffs
);
uint
diff_cursors
(
sp_pcontext
*
ctx
);
//
//
...
@@ -107,28 +104,27 @@ class sp_pcontext : public Sql_alloc
...
@@ -107,28 +104,27 @@ class sp_pcontext : public Sql_alloc
//
//
inline
uint
inline
uint
max_
framesize
()
max_
pvars
()
{
{
return
m_
framesize
;
return
m_
psubsize
+
m_pvar
.
elements
;
}
}
inline
uint
inline
uint
current_
framesize
()
current_
pvars
()
{
{
return
m_pvar
.
elements
;
return
m_p
offset
+
m_p
var
.
elements
;
}
}
inline
uint
inline
uint
param
s
()
context_pvar
s
()
{
{
return
m_p
aram
s
;
return
m_p
var
.
element
s
;
}
}
// Set the number of parameters to the current esize
inline
uint
inline
void
pvar_context2index
(
uint
i
)
set_params
()
{
{
m_params
=
m_pvar
.
elements
;
return
m_poffset
+
i
;
}
}
inline
void
inline
void
...
@@ -199,7 +195,11 @@ class sp_pcontext : public Sql_alloc
...
@@ -199,7 +195,11 @@ class sp_pcontext : public Sql_alloc
inline
sp_label_t
*
inline
sp_label_t
*
last_label
()
last_label
()
{
{
return
m_label
.
head
();
sp_label_t
*
lab
=
m_label
.
head
();
if
(
!
lab
&&
m_parent
)
lab
=
m_parent
->
last_label
();
return
lab
;
}
}
inline
sp_label_t
*
inline
sp_label_t
*
...
@@ -236,21 +236,15 @@ class sp_pcontext : public Sql_alloc
...
@@ -236,21 +236,15 @@ class sp_pcontext : public Sql_alloc
}
}
inline
uint
inline
uint
handlers
()
max_handlers
()
{
return
m_handlers
;
}
inline
void
push_handlers
(
uint
count
)
{
{
m_hndlrlev
+=
count
;
return
m_hsubsize
+
m_handlers
;
}
}
inline
void
inline
void
p
op_handlers
(
uint
count
)
p
ush_handlers
(
uint
n
)
{
{
m_h
ndlrlev
-=
count
;
m_h
andlers
+=
n
;
}
}
//
//
...
@@ -263,48 +257,41 @@ class sp_pcontext : public Sql_alloc
...
@@ -263,48 +257,41 @@ class sp_pcontext : public Sql_alloc
my_bool
my_bool
find_cursor
(
LEX_STRING
*
name
,
uint
*
poff
,
my_bool
scoped
=
0
);
find_cursor
(
LEX_STRING
*
name
,
uint
*
poff
,
my_bool
scoped
=
0
);
inline
void
inline
uint
pop_cursor
(
uint
num
)
max_cursors
(
)
{
{
while
(
num
--
)
return
m_csubsize
+
m_cursor
.
elements
;
pop_dynamic
(
&
m_cursor
);
}
}
inline
uint
inline
uint
cursors
()
cur
rent_cur
sors
()
{
{
return
m_c
ursmax
;
return
m_c
offset
+
m_cursor
.
elements
;
}
}
//
protected:
// GOTO labels
//
sp_label_t
*
// The maximum sub context's framesizes
push_glabel
(
char
*
name
,
uint
ip
);
uint
m_psubsize
;
uint
m_csubsize
;
sp_label_t
*
uint
m_hsubsize
;
find_glabel
(
char
*
name
);
void
pop_glabel
(
uint
count
);
private:
private:
uint
m_params
;
// The number of parameters
sp_pcontext
*
m_parent
;
// Parent context
uint
m_framesize
;
// The maximum framesize
uint
m_
handlers
;
// The total number of handlers
uint
m_
poffset
;
// Variable offset for this context
uint
m_c
ursmax
;
// The maximum number of cursors
uint
m_c
offset
;
// Cursor offset for this context
uint
m_h
ndlrlev
;
// Current number of active handlers
uint
m_h
andlers
;
// No. of handlers in this context
DYNAMIC_ARRAY
m_pvar
;
// Parameters/variables
DYNAMIC_ARRAY
m_pvar
;
// Parameters/variables
DYNAMIC_ARRAY
m_cond
;
// Conditions
DYNAMIC_ARRAY
m_cond
;
// Conditions
DYNAMIC_ARRAY
m_cursor
;
// Cursors
DYNAMIC_ARRAY
m_cursor
;
// Cursors
DYNAMIC_ARRAY
m_scopes
;
// For error checking
DYNAMIC_ARRAY
m_glabel
;
// Goto labels
List
<
sp_label_t
>
m_label
;
// The label list
List
<
sp_label_t
>
m_label
;
// The label list
List
<
sp_pcontext
>
m_children
;
// Children contexts, used for destruction
};
// class sp_pcontext : public Sql_alloc
};
// class sp_pcontext : public Sql_alloc
...
...
sql/sql_yacc.yy
View file @
fffa919f
...
@@ -1169,7 +1169,6 @@ create:
...
@@ -1169,7 +1169,6 @@ create:
LEX *lex= Lex;
LEX *lex= Lex;
lex->sphead->m_param_end= lex->tok_start;
lex->sphead->m_param_end= lex->tok_start;
lex->spcont->set_params();
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
}
}
sp_c_chistics
sp_c_chistics
...
@@ -1258,7 +1257,6 @@ create_function_tail:
...
@@ -1258,7 +1257,6 @@ create_function_tail:
{
{
LEX *lex= Lex;
LEX *lex= Lex;
lex->spcont->set_params();
lex->sphead->m_param_end= lex->tok_start;
lex->sphead->m_param_end= lex->tok_start;
}
}
RETURNS_SYM
RETURNS_SYM
...
@@ -1470,25 +1468,28 @@ sp_decl:
...
@@ -1470,25 +1468,28 @@ sp_decl:
DECLARE_SYM sp_decl_idents type sp_opt_default
DECLARE_SYM sp_decl_idents type sp_opt_default
{
{
LEX *lex= Lex;
LEX *lex= Lex;
uint max= lex->spcont->current_framesize();
sp_pcontext *ctx= lex->spcont;
uint max= ctx->context_pvars();
enum enum_field_types type= (enum enum_field_types)$3;
enum enum_field_types type= (enum enum_field_types)$3;
Item *it= $4;
Item *it= $4;
for (uint i = max-$2 ; i < max ; i++)
for (uint i = max-$2 ; i < max ; i++)
{
{
lex->spcont
->set_type(i, type);
ctx
->set_type(i, type);
if (! it)
if (! it)
lex->spcont
->set_isset(i, FALSE);
ctx
->set_isset(i, FALSE);
else
else
{
{
sp_instr_set *in= new sp_instr_set(lex->sphead->instructions(),
sp_instr_set *in= new sp_instr_set(lex->sphead->instructions(),
i, it, type);
ctx,
ctx->pvar_context2index(i),
it, type);
in->tables= lex->query_tables;
in->tables= lex->query_tables;
lex->query_tables= 0;
lex->query_tables= 0;
lex->sphead->add_instr(in);
lex->sphead->add_instr(in);
lex->spcont
->set_isset(i, TRUE);
ctx
->set_isset(i, TRUE);
lex->spcont
->set_default(i, it);
ctx
->set_default(i, it);
}
}
}
}
$$.vars= $2;
$$.vars= $2;
...
@@ -1514,30 +1515,33 @@ sp_decl:
...
@@ -1514,30 +1515,33 @@ sp_decl:
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
sp_instr_hpush_jump *i=
sp_instr_hpush_jump *i=
new sp_instr_hpush_jump(sp->instructions(), $2,
new sp_instr_hpush_jump(sp->instructions(),
ctx,
$2,
ctx->current_
framesize
());
ctx->current_
pvars
());
sp->add_instr(i);
sp->add_instr(i);
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
ctx->add_handler();
ctx->add_handler();
sp->m_in_handler= TRUE;
}
}
sp_hcond_list sp_proc_stmt
sp_hcond_list sp_proc_stmt
{
{
LEX *lex= Lex;
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_label_t *hlab= lex->spcont->pop_label(); /* After this hdlr */
sp_label_t *hlab= lex->spcont->pop_label(); /* After this hdlr */
if ($2 == SP_HANDLER_CONTINUE)
if ($2 == SP_HANDLER_CONTINUE)
sp->add_instr(new sp_instr_hreturn(sp->instructions(),
sp->add_instr(new sp_instr_hreturn(sp->instructions(),
ctx,
lex->spcont->current_framesize
()));
ctx->current_pvars
()));
else
else
{ /* EXIT or UNDO handler, just jump to the end of the block */
{ /* EXIT or UNDO handler, just jump to the end of the block */
sp_instr_jump *i= new sp_instr_jump(sp->instructions());
sp_instr_jump *i= new sp_instr_jump(sp->instructions()
, ctx
);
sp->add_instr(i);
sp->add_instr(i);
sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
}
}
lex->sphead->backpatch(hlab);
lex->sphead->backpatch(hlab);
sp->m_in_handler= FALSE;
$$.vars= $$.conds= $$.curs= 0;
$$.vars= $$.conds= $$.curs= 0;
$$.hndlrs= $6;
$$.hndlrs= $6;
}
}
...
@@ -1545,19 +1549,19 @@ sp_decl:
...
@@ -1545,19 +1549,19 @@ sp_decl:
{
{
LEX *lex= Lex;
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *
spc
= lex->spcont;
sp_pcontext *
ctx
= lex->spcont;
uint offp;
uint offp;
sp_instr_cpush *i;
sp_instr_cpush *i;
if (
spc
->find_cursor(&$2, &offp, TRUE))
if (
ctx
->find_cursor(&$2, &offp, TRUE))
{
{
net_printf(YYTHD, ER_SP_DUP_CURS, $2.str);
net_printf(YYTHD, ER_SP_DUP_CURS, $2.str);
delete $5;
delete $5;
YYABORT;
YYABORT;
}
}
i= new sp_instr_cpush(sp->instructions(), $5);
i= new sp_instr_cpush(sp->instructions(),
ctx,
$5);
sp->add_instr(i);
sp->add_instr(i);
lex->spcont
->push_cursor(&$2);
ctx
->push_cursor(&$2);
$$.vars= $$.conds= $$.hndlrs= 0;
$$.vars= $$.conds= $$.hndlrs= 0;
$$.curs= 1;
$$.curs= 1;
}
}
...
@@ -1748,7 +1752,8 @@ sp_proc_stmt:
...
@@ -1748,7 +1752,8 @@ sp_proc_stmt:
}
}
else
else
{
{
sp_instr_stmt *i=new sp_instr_stmt(lex->sphead->instructions());
sp_instr_stmt *i=new sp_instr_stmt(lex->sphead->instructions(),
lex->spcont);
i->set_lex(lex);
i->set_lex(lex);
lex->sphead->add_instr(i);
lex->sphead->add_instr(i);
...
@@ -1776,6 +1781,7 @@ sp_proc_stmt:
...
@@ -1776,6 +1781,7 @@ sp_proc_stmt:
YYABORT;
YYABORT;
}
}
i= new sp_instr_freturn(lex->sphead->instructions(),
i= new sp_instr_freturn(lex->sphead->instructions(),
lex->spcont,
$2, lex->sphead->m_returns);
$2, lex->sphead->m_returns);
lex->sphead->add_instr(i);
lex->sphead->add_instr(i);
lex->sphead->m_has_return= TRUE;
lex->sphead->m_has_return= TRUE;
...
@@ -1794,8 +1800,9 @@ sp_proc_stmt:
...
@@ -1794,8 +1800,9 @@ sp_proc_stmt:
at the same frame level, so we then know that it's the
at the same frame level, so we then know that it's the
top-most variable in the frame. */
top-most variable in the frame. */
LEX *lex= Lex;
LEX *lex= Lex;
uint offset= lex->spcont->current_
framesize
();
uint offset= lex->spcont->current_
pvars
();
sp_instr_set *i = new sp_instr_set(lex->sphead->instructions(),
sp_instr_set *i = new sp_instr_set(lex->sphead->instructions(),
lex->spcont,
offset, $2, MYSQL_TYPE_STRING);
offset, $2, MYSQL_TYPE_STRING);
LEX_STRING dummy;
LEX_STRING dummy;
...
@@ -1839,19 +1846,17 @@ sp_proc_stmt:
...
@@ -1839,19 +1846,17 @@ sp_proc_stmt:
else
else
{
{
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_scope_t sdiff;
sp_instr_jump *i;
sp_instr_jump *i;
sp_instr_hpop *ih;
sp_instr_hpop *ih;
sp_instr_cpop *ic;
sp_instr_cpop *ic;
ctx->diff_scopes(0, &sdiff);
ih= new sp_instr_hpop(ip++, ctx, 0);
ih= new sp_instr_hpop(ip++, sdiff.hndlrs);
sp->push_backpatch(ih, lab);
sp->push_backpatch(ih, lab);
sp->add_instr(ih);
sp->add_instr(ih);
ic= new sp_instr_cpop(ip++,
sdiff.curs
);
ic= new sp_instr_cpop(ip++,
ctx, 0
);
sp->push_backpatch(ic, lab);
sp->push_backpatch(ic, lab);
sp->add_instr(ic);
sp->add_instr(ic);
i= new sp_instr_jump(ip);
i= new sp_instr_jump(ip
, ctx
);
sp->push_backpatch(i, lab); /* Jumping forward */
sp->push_backpatch(i, lab); /* Jumping forward */
sp->add_instr(i);
sp->add_instr(i);
}
}
...
@@ -1872,14 +1877,15 @@ sp_proc_stmt:
...
@@ -1872,14 +1877,15 @@ sp_proc_stmt:
{
{
sp_instr_jump *i;
sp_instr_jump *i;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_scope_t sdiff;
uint n;
ctx->diff_scopes(lab->scopes, &sdiff);
n= ctx->diff_handlers(lab->ctx);
if (sdiff.hndlrs)
if (n)
sp->add_instr(new sp_instr_hpop(ip++, sdiff.hndlrs));
sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
if (sdiff.curs)
n= ctx->diff_cursors(lab->ctx);
sp->add_instr(new sp_instr_cpop(ip++, sdiff.curs));
if (n)
i= new sp_instr_jump(ip, lab->ip); /* Jump back */
sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
sp->add_instr(i);
sp->add_instr(i);
}
}
}
}
...
@@ -1890,8 +1896,6 @@ sp_proc_stmt:
...
@@ -1890,8 +1896,6 @@ sp_proc_stmt:
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
sp_label_t *lab= ctx->find_label($2.str);
sp_label_t *lab= ctx->find_label($2.str);
if (! lab)
lab= ctx->find_glabel($2.str);
if (lab)
if (lab)
{
{
net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $2.str);
net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $2.str);
...
@@ -1899,9 +1903,9 @@ sp_proc_stmt:
...
@@ -1899,9 +1903,9 @@ sp_proc_stmt:
}
}
else
else
{
{
lab= ctx->push_
g
label($2.str, sp->instructions());
lab= ctx->push_label($2.str, sp->instructions());
lab->type= SP_LAB_GOTO;
lab->type= SP_LAB_GOTO;
lab->
scopes= ctx->scopes()
;
lab->
ctx= ctx
;
sp->backpatch(lab);
sp->backpatch(lab);
}
}
}
}
...
@@ -1911,48 +1915,52 @@ sp_proc_stmt:
...
@@ -1911,48 +1915,52 @@ sp_proc_stmt:
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
sp_label_t *lab= ctx->find_label($2.str);
sp_label_t *lab;
sp_scope_t sdiff;
sp_instr_jump *i;
sp_instr_jump *i;
sp_instr_hpop *ih;
sp_instr_hpop *ih;
sp_instr_cpop *ic;
sp_instr_cpop *ic;
if (! lab)
if (sp->m_in_handler)
lab= ctx->find_glabel($2.str);
{
send_error(lex->thd, ER_SP_GOTO_IN_HNDLR);
YYABORT;
}
lab= ctx->find_label($2.str);
if (! lab)
if (! lab)
{
{
lab= (sp_label_t *)YYTHD->alloc(sizeof(sp_label_t));
lab= (sp_label_t *)YYTHD->alloc(sizeof(sp_label_t));
lab->name= $2.str;
lab->name= $2.str;
lab->ip= 0;
lab->ip= 0;
lab->type= SP_LAB_REF;
lab->type= SP_LAB_REF;
lab->
scopes= 0
;
lab->
ctx= ctx
;
ctx->diff_scopes(0, &sdiff);
ih= new sp_instr_hpop(ip++, ctx, 0);
ih= new sp_instr_hpop(ip++, sdiff.hndlrs);
sp->push_backpatch(ih, lab);
sp->push_backpatch(ih, lab);
sp->add_instr(ih);
sp->add_instr(ih);
ic= new sp_instr_cpop(ip++,
sdiff.curs
);
ic= new sp_instr_cpop(ip++,
ctx, 0
);
sp->add_instr(ic);
sp->add_instr(ic);
sp->push_backpatch(ic, lab);
sp->push_backpatch(ic, lab);
i= new sp_instr_jump(ip);
i= new sp_instr_jump(ip
, ctx
);
sp->push_backpatch(i, lab); /* Jumping forward */
sp->push_backpatch(i, lab); /* Jumping forward */
sp->add_instr(i);
sp->add_instr(i);
}
}
else
else
{
{
ctx->diff_scopes(lab->scopes, &sdiff);
uint n;
if (sdiff.hndlrs)
n= ctx->diff_handlers(lab->ctx);
if (n)
{
{
ih= new sp_instr_hpop(ip++,
sdiff.hndlrs
);
ih= new sp_instr_hpop(ip++,
ctx, n
);
sp->add_instr(ih);
sp->add_instr(ih);
}
}
if (sdiff.curs)
n= ctx->diff_cursors(lab->ctx);
if (n)
{
{
ic= new sp_instr_cpop(ip++,
sdiff.curs
);
ic= new sp_instr_cpop(ip++,
ctx, n
);
sp->add_instr(ic);
sp->add_instr(ic);
}
}
i= new sp_instr_jump(ip, lab->ip); /* Jump back */
i= new sp_instr_jump(ip,
ctx,
lab->ip); /* Jump back */
sp->add_instr(i);
sp->add_instr(i);
}
}
}
}
...
@@ -1968,7 +1976,7 @@ sp_proc_stmt:
...
@@ -1968,7 +1976,7 @@ sp_proc_stmt:
net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
YYABORT;
YYABORT;
}
}
i= new sp_instr_copen(sp->instructions(), offset);
i= new sp_instr_copen(sp->instructions(),
lex->spcont,
offset);
sp->add_instr(i);
sp->add_instr(i);
}
}
| FETCH_SYM ident INTO
| FETCH_SYM ident INTO
...
@@ -1983,7 +1991,7 @@ sp_proc_stmt:
...
@@ -1983,7 +1991,7 @@ sp_proc_stmt:
net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
YYABORT;
YYABORT;
}
}
i= new sp_instr_cfetch(sp->instructions(), offset);
i= new sp_instr_cfetch(sp->instructions(),
lex->spcont,
offset);
sp->add_instr(i);
sp->add_instr(i);
}
}
sp_fetch_list
sp_fetch_list
...
@@ -2000,7 +2008,7 @@ sp_proc_stmt:
...
@@ -2000,7 +2008,7 @@ sp_proc_stmt:
net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
YYABORT;
YYABORT;
}
}
i= new sp_instr_cclose(sp->instructions(), offset);
i= new sp_instr_cclose(sp->instructions(),
lex->spcont,
offset);
sp->add_instr(i);
sp->add_instr(i);
}
}
;
;
...
@@ -2056,7 +2064,7 @@ sp_if:
...
@@ -2056,7 +2064,7 @@ sp_if:
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, $1);
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip,
ctx,
$1);
i->tables= lex->query_tables;
i->tables= lex->query_tables;
lex->query_tables= 0;
lex->query_tables= 0;
...
@@ -2068,7 +2076,7 @@ sp_if:
...
@@ -2068,7 +2076,7 @@ sp_if:
sp_head *sp= Lex->sphead;
sp_head *sp= Lex->sphead;
sp_pcontext *ctx= Lex->spcont;
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip);
sp_instr_jump *i = new sp_instr_jump(ip
, ctx
);
sp->add_instr(i);
sp->add_instr(i);
sp->backpatch(ctx->pop_label());
sp->backpatch(ctx->pop_label());
...
@@ -2098,7 +2106,7 @@ sp_case:
...
@@ -2098,7 +2106,7 @@ sp_case:
sp_instr_jump_if_not *i;
sp_instr_jump_if_not *i;
if (! sp->m_simple_case)
if (! sp->m_simple_case)
i= new sp_instr_jump_if_not(ip, $1);
i= new sp_instr_jump_if_not(ip,
ctx,
$1);
else
else
{ /* Simple case: <caseval> = <whenval> */
{ /* Simple case: <caseval> = <whenval> */
LEX_STRING ivar;
LEX_STRING ivar;
...
@@ -2106,10 +2114,10 @@ sp_case:
...
@@ -2106,10 +2114,10 @@ sp_case:
ivar.str= (char *)"_tmp_";
ivar.str= (char *)"_tmp_";
ivar.length= 5;
ivar.length= 5;
Item *var= (Item*) new Item_splocal(ivar,
Item *var= (Item*) new Item_splocal(ivar,
ctx->current_
framesize
()-1);
ctx->current_
pvars
()-1);
Item *expr= new Item_func_eq(var, $1);
Item *expr= new Item_func_eq(var, $1);
i= new sp_instr_jump_if_not(ip, expr);
i= new sp_instr_jump_if_not(ip,
ctx,
expr);
lex->variables_used= 1;
lex->variables_used= 1;
}
}
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
sp->push_backpatch(i, ctx->push_label((char *)"", 0));
...
@@ -2122,7 +2130,7 @@ sp_case:
...
@@ -2122,7 +2130,7 @@ sp_case:
sp_head *sp= Lex->sphead;
sp_head *sp= Lex->sphead;
sp_pcontext *ctx= Lex->spcont;
sp_pcontext *ctx= Lex->spcont;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump *i = new sp_instr_jump(ip);
sp_instr_jump *i = new sp_instr_jump(ip
, ctx
);
sp->add_instr(i);
sp->add_instr(i);
sp->backpatch(ctx->pop_label());
sp->backpatch(ctx->pop_label());
...
@@ -2141,7 +2149,8 @@ sp_whens:
...
@@ -2141,7 +2149,8 @@ sp_whens:
{
{
sp_head *sp= Lex->sphead;
sp_head *sp= Lex->sphead;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_error *i= new sp_instr_error(ip, ER_SP_CASE_NOT_FOUND);
sp_instr_error *i= new sp_instr_error(ip, Lex->spcont,
ER_SP_CASE_NOT_FOUND);
sp->add_instr(i);
sp->add_instr(i);
}
}
...
@@ -2166,7 +2175,6 @@ sp_labeled_control:
...
@@ -2166,7 +2175,6 @@ sp_labeled_control:
lab= lex->spcont->push_label($1.str,
lab= lex->spcont->push_label($1.str,
lex->sphead->instructions());
lex->sphead->instructions());
lab->type= SP_LAB_ITER;
lab->type= SP_LAB_ITER;
lab->scopes= ctx->scopes();
}
}
}
}
sp_unlabeled_control sp_opt_label
sp_unlabeled_control sp_opt_label
...
@@ -2204,32 +2212,24 @@ sp_unlabeled_control:
...
@@ -2204,32 +2212,24 @@ sp_unlabeled_control:
sp_label_t *lab= lex->spcont->last_label();
sp_label_t *lab= lex->spcont->last_label();
lab->type= SP_LAB_BEGIN;
lab->type= SP_LAB_BEGIN;
/* Scope duplicate checking */
lex->spcont= lex->spcont->push_context();
lex->spcont->push_scope();
}
}
sp_decls
sp_decls
{
Lex->spcont->push_handlers($3.hndlrs);
}
sp_proc_stmts
sp_proc_stmts
END
END
{
{
LEX *lex= Lex;
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_pcontext *ctx= lex->spcont;
sp_scope_t scope;
sp->backpatch(ctx->last_label()); /* We always have a label */
sp->backpatch(ctx->last_label()); /* We always have a label */
ctx->pop_pvar($3.vars);
ctx->pop_cond($3.conds);
ctx->pop_handlers($3.hndlrs);
ctx->pop_cursor($3.curs);
if ($3.hndlrs)
if ($3.hndlrs)
sp->add_instr(new sp_instr_hpop(sp->instructions(), $3.hndlrs));
sp->add_instr(new sp_instr_hpop(sp->instructions(), ctx,
$3.hndlrs));
if ($3.curs)
if ($3.curs)
sp->add_instr(new sp_instr_cpop(sp->instructions(),
$3.curs));
sp->add_instr(new sp_instr_cpop(sp->instructions(),
ctx,
ctx->pop_scope(&scope
);
$3.curs)
);
ctx->pop_glabel(scope.glab
);
lex->spcont= ctx->pop_context(
);
}
}
| LOOP_SYM
| LOOP_SYM
sp_proc_stmts END LOOP_SYM
sp_proc_stmts END LOOP_SYM
...
@@ -2237,7 +2237,7 @@ sp_unlabeled_control:
...
@@ -2237,7 +2237,7 @@ sp_unlabeled_control:
LEX *lex= Lex;
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lab->ip);
sp_instr_jump *i = new sp_instr_jump(ip, l
ex->spcont, l
ab->ip);
lex->sphead->add_instr(i);
lex->sphead->add_instr(i);
}
}
...
@@ -2246,7 +2246,8 @@ sp_unlabeled_control:
...
@@ -2246,7 +2246,8 @@ sp_unlabeled_control:
LEX *lex= Lex;
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_head *sp= lex->sphead;
uint ip= sp->instructions();
uint ip= sp->instructions();
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, $2);
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$2);
/* Jumping forward */
/* Jumping forward */
sp->push_backpatch(i, lex->spcont->last_label());
sp->push_backpatch(i, lex->spcont->last_label());
...
@@ -2259,7 +2260,7 @@ sp_unlabeled_control:
...
@@ -2259,7 +2260,7 @@ sp_unlabeled_control:
LEX *lex= Lex;
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump *i = new sp_instr_jump(ip, lab->ip);
sp_instr_jump *i = new sp_instr_jump(ip, l
ex->spcont, l
ab->ip);
lex->sphead->add_instr(i);
lex->sphead->add_instr(i);
}
}
...
@@ -2268,7 +2269,8 @@ sp_unlabeled_control:
...
@@ -2268,7 +2269,8 @@ sp_unlabeled_control:
LEX *lex= Lex;
LEX *lex= Lex;
uint ip= lex->sphead->instructions();
uint ip= lex->sphead->instructions();
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, $4, lab->ip);
sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
$4, lab->ip);
i->tables= lex->query_tables;
i->tables= lex->query_tables;
lex->query_tables= 0;
lex->query_tables= 0;
...
@@ -6786,11 +6788,12 @@ option_value:
...
@@ -6786,11 +6788,12 @@ option_value:
}
}
else
else
{ /* An SP local variable */
{ /* An SP local variable */
sp_pcontext *ctx= lex->spcont;
sp_pvar_t *spv;
sp_pvar_t *spv;
sp_instr_set *i;
sp_instr_set *i;
Item *it;
Item *it;
spv=
lex->spcont
->find_pvar(&$1.base_name);
spv=
ctx
->find_pvar(&$1.base_name);
if ($3)
if ($3)
it= $3;
it= $3;
...
@@ -6798,7 +6801,7 @@ option_value:
...
@@ -6798,7 +6801,7 @@ option_value:
it= spv->dflt;
it= spv->dflt;
else
else
it= new Item_null();
it= new Item_null();
i= new sp_instr_set(lex->sphead->instructions(),
i= new sp_instr_set(lex->sphead->instructions(),
ctx,
spv->offset, it, spv->type);
spv->offset, it, spv->type);
i->tables= lex->query_tables;
i->tables= lex->query_tables;
lex->query_tables= 0;
lex->query_tables= 0;
...
...
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