summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2005-11-11 18:12:40 +0100
committerunknown <pem@mysql.com>2005-11-11 18:12:40 +0100
commit5ae3b47cd9a7736bf407bc94d056b5bc1615a2f8 (patch)
treeca58132fac02137a5fcb0751c91d8bfe29380b41 /sql/sp_head.cc
parentb10c7d60bd46135760c59291415c49db6e8d8f71 (diff)
parent425207c938447c209756351a3e4a00d66eb9c3c1 (diff)
downloadmariadb-git-5ae3b47cd9a7736bf407bc94d056b5bc1615a2f8.tar.gz
Merge mysql.com:/usr/local/bk/mysql-5.0
into mysql.com:/usr/home/pem/bug14723/mysql-5.0 sql/sp_head.cc: Auto merged
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc25
1 files changed, 14 insertions, 11 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 08a189165b5..facd984cc50 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -476,7 +476,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 */
+ uchar *endp; /* Used to trim the end */
/* During parsing, we must use thd->mem_root */
MEM_ROOT *root= thd->mem_root;
@@ -509,17 +509,20 @@ sp_head::init_strings(THD *thd, LEX *lex, sp_name *name)
(char *)m_param_begin, m_params.length);
}
- 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;
- }
+ /* If ptr has overrun end_of_query then end_of_query is the end */
+ endp= (lex->ptr > lex->end_of_query ? lex->end_of_query : lex->ptr);
+ /*
+ Trim "garbage" at the end. This is sometimes needed with the
+ "/ * ! VERSION... * /" wrapper in dump files.
+ */
+ while (m_body_begin < endp &&
+ (endp[-1] <= ' ' || endp[-1] == '*' ||
+ endp[-1] == '/' || endp[-1] == ';'))
+ endp-= 1;
+
+ m_body.length= endp - m_body_begin;
m_body.str= strmake_root(root, (char *)m_body_begin, m_body.length);
- m_defstr.length= lex->ptr - lex->buf;
- m_defstr.length-= n;
+ m_defstr.length= endp - lex->buf;
m_defstr.str= strmake_root(root, (char *)lex->buf, m_defstr.length);
DBUG_VOID_RETURN;
}