diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-04-14 01:56:19 +0400 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-04-14 01:56:19 +0400 |
commit | 4288e329dd9676494a9e3927e61492e975277112 (patch) | |
tree | 7a87035df6e8d664a8301574158d57d8305c65cf /sql/sp_head.cc | |
parent | 71799f6f972d3ba5508c62d8d8ac3e33b25b0f1a (diff) | |
download | mariadb-git-4288e329dd9676494a9e3927e61492e975277112.tar.gz |
A fix for Bug#11918 "SP does not accept variables in LIMIT clause"
Allow stored procedure variables in LIMIT clause.
Only allow variables of INTEGER types.
Handle negative values by means of an implicit cast to UNSIGNED
(similarly to prepared statement placeholders).
Add tests.
Make sure replication works by not doing NAME_CONST substitution
for variables in LIMIT clause.
Add replication tests.
mysql-test/r/sp.result:
Update results (Bug#11918).
mysql-test/suite/rpl/r/rpl_sp.result:
Update results (Bug#11918).
mysql-test/suite/rpl/t/rpl_sp.test:
Add a test case for Bug#11918.
mysql-test/t/sp.test:
Add a test case for Bug#11918.
sql/item.cc:
Mark sp variables in LIMIT clause (a hack for replication).
sql/item.h:
Mark sp variables in LIMIT clause (a hack for replication).
sql/share/errmsg-utf8.txt:
Add a new error message (a type mismatch for LIMIT
clause parameter).
sql/sp_head.cc:
Binlog rewrite sp variables in LIMIT clause without NAME_CONST
substitution.
sql/sql_string.cc:
Implement append_ulonglong method.
sql/sql_string.h:
Declare append_ulonglong().
sql/sql_yacc.yy:
Support stored procedure variables in LIMIT.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 62d53888149..c91ba2a68b4 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -978,11 +978,20 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str) res|= qbuf.append(cur + prev_pos, (*splocal)->pos_in_query - prev_pos); prev_pos= (*splocal)->pos_in_query + (*splocal)->len_in_query; + res|= (*splocal)->fix_fields(thd, (Item **) splocal); + if (res) + break; + + if ((*splocal)->limit_clause_param) + { + res|= qbuf.append_ulonglong((*splocal)->val_uint()); + continue; + } + /* append the spvar substitute */ res|= qbuf.append(STRING_WITH_LEN(" NAME_CONST('")); res|= qbuf.append((*splocal)->m_name.str, (*splocal)->m_name.length); res|= qbuf.append(STRING_WITH_LEN("',")); - res|= (*splocal)->fix_fields(thd, (Item **) splocal); if (res) break; |