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
2dc3026c
Commit
2dc3026c
authored
Apr 20, 2006
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/extern/mysql/bk/mysql-5.0-runtime
into mysql.com:/extern/mysql/5.0/bug18949/mysql-5.0-runtime
parents
19e558a0
a6fbde9d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
6 additions
and
588 deletions
+6
-588
mysql-test/r/sp-goto.result
mysql-test/r/sp-goto.result
+0
-205
mysql-test/t/disabled.def
mysql-test/t/disabled.def
+0
-1
mysql-test/t/sp-goto.test
mysql-test/t/sp-goto.test
+0
-238
sql/lex.h
sql/lex.h
+0
-7
sql/sp_head.cc
sql/sp_head.cc
+2
-35
sql/sp_head.h
sql/sp_head.h
+0
-7
sql/sp_pcontext.cc
sql/sp_pcontext.cc
+1
-1
sql/sp_pcontext.h
sql/sp_pcontext.h
+3
-4
sql/sql_yacc.yy
sql/sql_yacc.yy
+0
-90
No files found.
mysql-test/r/sp-goto.result
deleted
100644 → 0
View file @
19e558a0
drop table if exists t1;
create table t1 (
id char(16) not null default '',
data int not null
);
drop procedure if exists goto1//
create procedure goto1()
begin
declare y int;
label a;
select * from t1;
select count(*) into y from t1;
if y > 2 then
goto b;
end if;
insert into t1 values ("j", y);
goto a;
label b;
end//
call goto1()//
id data
id data
j 0
id data
j 0
j 1
id data
j 0
j 1
j 2
drop procedure goto1//
drop procedure if exists goto2//
create procedure goto2(a int)
begin
declare x int default 0;
declare continue handler for sqlstate '42S98' set x = 1;
label a;
select * from t1;
b:
while x < 2 do
begin
declare continue handler for sqlstate '42S99' set x = 2;
if a = 0 then
set x = x + 1;
iterate b;
elseif a = 1 then
leave b;
elseif a = 2 then
set a = 1;
goto a;
end if;
end;
end while b;
select * from t1;
end//
call goto2(0)//
id data
j 0
j 1
j 2
id data
j 0
j 1
j 2
call goto2(1)//
id data
j 0
j 1
j 2
id data
j 0
j 1
j 2
call goto2(2)//
id data
j 0
j 1
j 2
id data
j 0
j 1
j 2
id data
j 0
j 1
j 2
drop procedure goto2//
delete from t1//
drop procedure if exists goto3//
create procedure goto3()
begin
label L1;
begin
end;
goto L1;
end//
drop procedure goto3//
drop procedure if exists goto4//
create procedure goto4()
begin
begin
label lab1;
begin
goto lab1;
end;
end;
end//
drop procedure goto4//
drop procedure if exists goto5//
create procedure goto5()
begin
begin
begin
goto lab1;
end;
label lab1;
end;
end//
drop procedure goto5//
drop procedure if exists goto6//
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//
create procedure foo()
begin
goto foo;
end//
ERROR 42000: GOTO with no matching label: 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 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
drop procedure if exists bug6898//
create procedure bug6898()
begin
goto label1;
label label1;
begin end;
goto label1;
end//
drop procedure bug6898//
drop table t1;
mysql-test/t/disabled.def
View file @
2dc3026c
...
...
@@ -10,6 +10,5 @@
#
##############################################################################
sp-goto : GOTO is currently is disabled - will be fixed in the future
ndb_load : Bug#17233
udf : Bug#18564 (Permission by Brian)
mysql-test/t/sp-goto.test
deleted
100644 → 0
View file @
19e558a0
#
# The non-standard GOTO, for compatibility
#
# QQQ The "label" syntax is temporary, it will (hopefully)
# change to the more common "L:" syntax soon.
# For the time being, this feature is disabled, until
# the syntax (and some other known bugs) can be fixed.
#
# Test cases for bugs are added at the end. See template there.
#
--
disable_warnings
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
(
id
char
(
16
)
not
null
default
''
,
data
int
not
null
);
delimiter
//;
--
disable_warnings
drop
procedure
if
exists
goto1
//
--
enable_warnings
create
procedure
goto1
()
begin
declare
y
int
;
label
a
;
select
*
from
t1
;
select
count
(
*
)
into
y
from
t1
;
if
y
>
2
then
goto
b
;
end
if
;
insert
into
t1
values
(
"j"
,
y
);
goto
a
;
label
b
;
end
//
call
goto1
()
//
drop
procedure
goto1
//
# With dummy handlers, just to test restore of contexts with jumps
--
disable_warnings
drop
procedure
if
exists
goto2
//
--
enable_warnings
create
procedure
goto2
(
a
int
)
begin
declare
x
int
default
0
;
declare
continue
handler
for
sqlstate
'42S98'
set
x
=
1
;
label
a
;
select
*
from
t1
;
b
:
while
x
<
2
do
begin
declare
continue
handler
for
sqlstate
'42S99'
set
x
=
2
;
if
a
=
0
then
set
x
=
x
+
1
;
iterate
b
;
elseif
a
=
1
then
leave
b
;
elseif
a
=
2
then
set
a
=
1
;
goto
a
;
end
if
;
end
;
end
while
b
;
select
*
from
t1
;
end
//
call
goto2
(
0
)
//
call
goto2
(
1
)
//
call
goto2
(
2
)
//
drop
procedure
goto2
//
delete
from
t1
//
# Check label visibility for some more cases. We don't call these.
--
disable_warnings
drop
procedure
if
exists
goto3
//
--
enable_warnings
create
procedure
goto3
()
begin
label
L1
;
begin
end
;
goto
L1
;
end
//
drop
procedure
goto3
//
--
disable_warnings
drop
procedure
if
exists
goto4
//
--
enable_warnings
create
procedure
goto4
()
begin
begin
label
lab1
;
begin
goto
lab1
;
end
;
end
;
end
//
drop
procedure
goto4
//
--
disable_warnings
drop
procedure
if
exists
goto5
//
--
enable_warnings
create
procedure
goto5
()
begin
begin
begin
goto
lab1
;
end
;
label
lab1
;
end
;
end
//
drop
procedure
goto5
//
--
disable_warnings
drop
procedure
if
exists
goto6
//
--
enable_warnings
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
//
# Mismatching labels
--
error
1308
create
procedure
foo
()
begin
goto
foo
;
end
//
--
error
1308
create
procedure
foo
()
begin
begin
label
foo
;
end
;
goto
foo
;
end
//
--
error
1308
create
procedure
foo
()
begin
goto
foo
;
begin
label
foo
;
end
;
end
//
--
error
1308
create
procedure
foo
()
begin
begin
goto
foo
;
end
;
begin
label
foo
;
end
;
end
//
--
error
1308
create
procedure
foo
()
begin
begin
label
foo
;
end
;
begin
goto
foo
;
end
;
end
//
# No goto in a handler
--
error
1358
create
procedure
p
()
begin
declare
continue
handler
for
sqlexception
begin
goto
L1
;
end
;
select
field
from
t1
;
label
L1
;
end
//
#
# Test cases for old bugs
#
#
# BUG#6898: Stored procedure crash if GOTO statements exist
#
--
disable_warnings
drop
procedure
if
exists
bug6898
//
--
enable_warnings
create
procedure
bug6898
()
begin
goto
label1
;
label
label1
;
begin
end
;
goto
label1
;
end
//
drop
procedure
bug6898
//
#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
#drop procedure if exists bugNNNN//
#--enable_warnings
#create procedure bugNNNN...
# Add bugs above this line. Use existing tables t1 and t2 when
# practical, or create table t3, t4 etc temporarily (and drop them).
delimiter
;
//
drop
table
t1
;
sql/lex.h
View file @
2dc3026c
...
...
@@ -215,9 +215,6 @@ static SYMBOL symbols[] = {
{
"GEOMETRYCOLLECTION"
,
SYM
(
GEOMETRYCOLLECTION
)},
{
"GET_FORMAT"
,
SYM
(
GET_FORMAT
)},
{
"GLOBAL"
,
SYM
(
GLOBAL_SYM
)},
#ifdef SP_GOTO
{
"GOTO"
,
SYM
(
GOTO_SYM
)},
#endif
{
"GRANT"
,
SYM
(
GRANT
)},
{
"GRANTS"
,
SYM
(
GRANTS
)},
{
"GROUP"
,
SYM
(
GROUP
)},
...
...
@@ -265,10 +262,6 @@ static SYMBOL symbols[] = {
{
"KEY"
,
SYM
(
KEY_SYM
)},
{
"KEYS"
,
SYM
(
KEYS
)},
{
"KILL"
,
SYM
(
KILL_SYM
)},
#ifdef SP_GOTO
/* QQ This will go away when the GOTO label syntax is fixed */
{
"LABEL"
,
SYM
(
LABEL_SYM
)},
#endif
{
"LANGUAGE"
,
SYM
(
LANGUAGE_SYM
)},
{
"LAST"
,
SYM
(
LAST_SYM
)},
{
"LEADING"
,
SYM
(
LEADING
)},
...
...
sql/sp_head.cc
View file @
2dc3026c
...
...
@@ -1670,44 +1670,11 @@ sp_head::backpatch(sp_label_t *lab)
while
((
bp
=
li
++
))
{
if
(
bp
->
lab
==
lab
||
(
bp
->
lab
->
type
==
SP_LAB_REF
&&
my_strcasecmp
(
system_charset_info
,
bp
->
lab
->
name
,
lab
->
name
)
==
0
))
{
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
(
dstlab
)
{
bp
->
lab
=
lab
;
bp
->
instr
->
backpatch
(
dest
,
dstlab
->
ctx
);
}
}
}
}
}
int
sp_head
::
check_backpatch
(
THD
*
thd
)
{
bp_t
*
bp
;
List_iterator_fast
<
bp_t
>
li
(
m_backpatch
);
while
((
bp
=
li
++
))
{
if
(
bp
->
lab
->
type
==
SP_LAB_REF
)
{
my_error
(
ER_SP_LILABEL_MISMATCH
,
MYF
(
0
),
"GOTO"
,
bp
->
lab
->
name
);
return
-
1
;
}
if
(
bp
->
lab
==
lab
)
bp
->
instr
->
backpatch
(
dest
,
lab
->
ctx
);
}
return
0
;
}
/*
Prepare an instance of create_field for field creation (fill all necessary
attributes).
...
...
sql/sp_head.h
View file @
2dc3026c
...
...
@@ -263,13 +263,6 @@ public:
void
backpatch
(
struct
sp_label
*
);
// Check that no unresolved references exist.
// If none found, 0 is returned, otherwise errors have been issued
// and -1 is returned.
// This is called by the parser at the end of a create procedure/function.
int
check_backpatch
(
THD
*
thd
);
// Start a new cont. backpatch level. If 'i' is NULL, the level is just incr.
void
new_cont_backpatch
(
sp_instr_opt_meta
*
i
);
...
...
sql/sp_pcontext.cc
View file @
2dc3026c
...
...
@@ -241,7 +241,7 @@ sp_pcontext::push_label(char *name, uint ip)
{
lab
->
name
=
name
;
lab
->
ip
=
ip
;
lab
->
type
=
SP_LAB_
GOTO
;
lab
->
type
=
SP_LAB_
IMPL
;
lab
->
ctx
=
this
;
m_label
.
push_front
(
lab
);
}
...
...
sql/sp_pcontext.h
View file @
2dc3026c
...
...
@@ -48,10 +48,9 @@ typedef struct sp_variable
}
sp_variable_t
;
#define SP_LAB_REF 0 // Unresolved reference (for goto)
#define SP_LAB_GOTO 1 // Free goto label
#define SP_LAB_BEGIN 2 // Label at BEGIN
#define SP_LAB_ITER 3 // Label at iteration control
#define SP_LAB_IMPL 0 // Implicit label generated by parser
#define SP_LAB_BEGIN 1 // Label at BEGIN
#define SP_LAB_ITER 2 // Label at iteration control
/*
An SQL/PSM label. Can refer to the identifier used with the
...
...
sql/sql_yacc.yy
View file @
2dc3026c
...
...
@@ -301,7 +301,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token GEOMFROMWKB
%token GET_FORMAT
%token GLOBAL_SYM
%token GOTO_SYM
%token GRANT
%token GRANTS
%token GREATEST_SYM
...
...
@@ -1332,8 +1331,6 @@ create_function_tail:
if (sp->is_not_allowed_in_function("function"))
YYABORT;
if (sp->check_backpatch(YYTHD))
YYABORT;
lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
sp->init_strings(YYTHD, lex, lex->spname);
if (!(sp->m_flags & sp_head::HAS_RETURN))
...
...
@@ -2054,91 +2051,6 @@ sp_proc_stmt:
sp->add_instr(i);
}
}
| LABEL_SYM IDENT
{
#ifdef SP_GOTO
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
sp_label_t *lab= ctx->find_label($2.str);
if (lab)
{
my_error(ER_SP_LABEL_REDEFINE, MYF(0), $2.str);
YYABORT;
}
else
{
lab= ctx->push_label($2.str, sp->instructions());
lab->type= SP_LAB_GOTO;
lab->ctx= ctx;
sp->backpatch(lab);
}
#else
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
#endif
}
| GOTO_SYM IDENT
{
#ifdef SP_GOTO
LEX *lex= Lex;
sp_head *sp= lex->sphead;
sp_pcontext *ctx= lex->spcont;
uint ip= lex->sphead->instructions();
sp_label_t *lab;
sp_instr_jump *i;
sp_instr_hpop *ih;
sp_instr_cpop *ic;
if (sp->m_in_handler)
{
my_message(ER_SP_GOTO_IN_HNDLR, ER(ER_SP_GOTO_IN_HNDLR), MYF(0));
YYABORT;
}
lab= ctx->find_label($2.str);
if (! lab)
{
lab= (sp_label_t *)YYTHD->alloc(sizeof(sp_label_t));
lab->name= $2.str;
lab->ip= 0;
lab->type= SP_LAB_REF;
lab->ctx= ctx;
ih= new sp_instr_hpop(ip++, ctx, 0);
sp->push_backpatch(ih, lab);
sp->add_instr(ih);
ic= new sp_instr_cpop(ip++, ctx, 0);
sp->add_instr(ic);
sp->push_backpatch(ic, lab);
i= new sp_instr_jump(ip, ctx);
sp->push_backpatch(i, lab); /* Jumping forward */
sp->add_instr(i);
}
else
{
uint n;
n= ctx->diff_handlers(lab->ctx);
if (n)
{
ih= new sp_instr_hpop(ip++, ctx, n);
sp->add_instr(ih);
}
n= ctx->diff_cursors(lab->ctx);
if (n)
{
ic= new sp_instr_cpop(ip++, ctx, n);
sp->add_instr(ic);
}
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
sp->add_instr(i);
}
#else
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
#endif
}
| OPEN_SYM ident
{
LEX *lex= Lex;
...
...
@@ -9228,8 +9140,6 @@ sp_tail:
LEX *lex= Lex;
sp_head *sp= lex->sphead;
if (sp->check_backpatch(YYTHD))
YYABORT;
sp->init_strings(YYTHD, lex, $3);
lex->sql_command= SQLCOM_CREATE_PROCEDURE;
/* Restore flag if it was cleared above */
...
...
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