summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2004-09-02 19:14:34 +0200
committerunknown <pem@mysql.comhem.se>2004-09-02 19:14:34 +0200
commit2c3f49a64d773395cc0e41fb35c5b6e3b5a56871 (patch)
tree058e4788337ece81174bba85a669cfe2871a25ed /sql/sp_head.cc
parent339859d261ffaf3d588da247284680a3d4ec3104 (diff)
downloadmariadb-git-2c3f49a64d773395cc0e41fb35c5b6e3b5a56871.tar.gz
Fixed BUG#5307: Stored procedure allows statement after BEGIN ... END.
mysql-test/r/sp.result: New test case for BUG#5307 mysql-test/t/sp.test: New test case for BUG#5307 sql/sp_head.cc: Use the correct end-of-query pointer when extracting the body in the case of a create procedure compound with another statement.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index b2d3b8202c8..16d13154263 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -288,6 +288,7 @@ void
sp_head::init_strings(THD *thd, LEX *lex, sp_name *name)
{
DBUG_ENTER("sp_head::init_strings");
+ uint n; /* Counter for nul trimming */
/* During parsing, we must use thd->mem_root */
MEM_ROOT *root= &thd->mem_root;
@@ -351,9 +352,17 @@ sp_head::init_strings(THD *thd, LEX *lex, sp_name *name)
(char *)m_returns_begin, m_retstr.length);
}
}
- m_body.length= lex->end_of_query - m_body_begin;
+ m_body.length= lex->ptr - m_body_begin;
+ /* Trim nuls at the end */
+ n= 0;
+ while (m_body.length && m_body_begin[m_body.length-1] == '\0')
+ {
+ m_body.length-= 1;
+ n+= 1;
+ }
m_body.str= strmake_root(root, (char *)m_body_begin, m_body.length);
- m_defstr.length= lex->end_of_query - lex->buf;
+ m_defstr.length= lex->ptr - lex->buf;
+ m_defstr.length-= n;
m_defstr.str= strmake_root(root, (char *)lex->buf, m_defstr.length);
DBUG_VOID_RETURN;
}