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
f1374951
Commit
f1374951
authored
Apr 25, 2006
by
pem@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Post-merge fixes from 5.0.
parent
0e2d20b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
97 deletions
+71
-97
mysql-test/extra/rpl_tests/rpl_insert_id.test
mysql-test/extra/rpl_tests/rpl_insert_id.test
+70
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-97
No files found.
mysql-test/extra/rpl_tests/rpl_insert_id.test
View file @
f1374951
...
...
@@ -86,3 +86,73 @@ INSERT INTO t1 VALUES (1),(1);
sync_slave_with_master
;
# End of 4.1 tests
#
# BUG#15728: LAST_INSERT_ID function inside a stored function returns 0
#
# The solution is not to reset last_insert_id on enter to sub-statement.
#
connection
master
;
--
disable_warnings
drop
function
if
exists
bug15728
;
drop
function
if
exists
bug15728_insert
;
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
create
table
t1
(
id
int
not
null
auto_increment
,
last_id
int
,
primary
key
(
id
)
);
create
function
bug15728
()
returns
int
(
11
)
return
last_insert_id
();
insert
into
t1
(
last_id
)
values
(
0
);
insert
into
t1
(
last_id
)
values
(
last_insert_id
());
insert
into
t1
(
last_id
)
values
(
bug15728
());
# Check that nested call replicates too.
create
table
t2
(
id
int
not
null
auto_increment
,
last_id
int
,
primary
key
(
id
)
);
delimiter
|
;
create
function
bug15728_insert
()
returns
int
(
11
)
modifies
sql
data
begin
insert
into
t2
(
last_id
)
values
(
bug15728
());
return
bug15728
();
end
|
create
trigger
t1_bi
before
insert
on
t1
for
each
row
begin
declare
res
int
;
select
bug15728_insert
()
into
res
;
set
NEW
.
last_id
=
res
;
end
|
delimiter
;
|
insert
into
t1
(
last_id
)
values
(
0
);
drop
trigger
t1_bi
;
# Check that nested call doesn't affect outer context.
select
last_insert_id
();
select
bug15728_insert
();
select
last_insert_id
();
insert
into
t1
(
last_id
)
values
(
bug15728
());
# This should be exactly one greater than in the previous call.
select
last_insert_id
();
save_master_pos
;
connection
slave
;
sync_with_master
;
select
*
from
t1
;
select
*
from
t2
;
connection
master
;
drop
function
bug15728
;
drop
function
bug15728_insert
;
drop
table
t1
,
t2
;
# End of 5.0 tests
sql/sql_yacc.yy
View file @
f1374951
...
...
@@ -365,7 +365,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token KEYS
%token KEY_SYM
%token KILL_SYM
%token LABEL_SYM
%token LANGUAGE_SYM
%token LAST_INSERT_ID
%token LAST_SYM
...
...
@@ -893,7 +892,7 @@ END_OF_INPUT
%type <NONE> sp_proc_stmt_statement sp_proc_stmt_return
%type <NONE> sp_proc_stmt_if sp_proc_stmt_case_simple sp_proc_stmt_case
%type <NONE> sp_labeled_control sp_proc_stmt_unlabeled sp_proc_stmt_leave
%type <NONE> sp_proc_stmt_iterate
sp_proc_stmt_label sp_proc_stmt_goto
%type <NONE> sp_proc_stmt_iterate
%type <NONE> sp_proc_stmt_open sp_proc_stmt_fetch sp_proc_stmt_close
%type <num> sp_decl_idents sp_opt_inout sp_handler_type sp_hcond_list
...
...
@@ -1554,8 +1553,6 @@ ev_sql_stmt_inner:
| sp_proc_stmt_unlabeled
| sp_proc_stmt_leave
| sp_proc_stmt_iterate
| sp_proc_stmt_label
| sp_proc_stmt_goto
| sp_proc_stmt_open
| sp_proc_stmt_fetch
| sp_proc_stmt_close
...
...
@@ -2242,8 +2239,6 @@ sp_proc_stmt:
| sp_proc_stmt_unlabeled
| sp_proc_stmt_leave
| sp_proc_stmt_iterate
| sp_proc_stmt_label
| sp_proc_stmt_goto
| sp_proc_stmt_open
| sp_proc_stmt_fetch
| sp_proc_stmt_close
...
...
@@ -2446,97 +2441,6 @@ sp_proc_stmt_iterate:
}
;
sp_proc_stmt_label:
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
}
;
sp_proc_stmt_goto:
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
}
;
sp_proc_stmt_open:
OPEN_SYM ident
{
...
...
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