summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorpem@mysql.com <>2006-01-19 11:48:07 +0100
committerpem@mysql.com <>2006-01-19 11:48:07 +0100
commit3a753667ddddb8438cdef8a3d870ac6d08f1a1b4 (patch)
tree77998d0059ac8f7e597b7ada28b273f939d4a8d5 /sql
parent82f96a4a4f20d004652eb45a5ad563de188be34a (diff)
parent0cc1acd51c35ec44a874ffa53f1df77d01e669b9 (diff)
downloadmariadb-git-3a753667ddddb8438cdef8a3d870ac6d08f1a1b4.tar.gz
Merge mysql.com:/extern/mysql/bk/mysql-5.0
into mysql.com:/extern/mysql/work/bug15658/mysql-5.0
Diffstat (limited to 'sql')
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sp_head.cc17
-rw-r--r--sql/sp_head.h2
-rw-r--r--sql/sql_yacc.yy15
4 files changed, 36 insertions, 0 deletions
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 577173a36a1..8017ba3ef9f 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5605,3 +5605,5 @@ ER_SP_RECURSION_LIMIT
ger "Rekursionsgrenze %d (durch Variable max_sp_recursion_depth gegeben) wurde für Routine %.64s überschritten"
ER_SP_PROC_TABLE_CORRUPT
eng "Failed to load routine %s. The table mysql.proc is missing, corrupt, or contains bad data (internal code %d)"
+ER_SP_WRONG_NAME 42000
+ eng "Incorrect routine name '%-.64s'"
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 8853ee97e98..9c86ebfddf4 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -386,6 +386,23 @@ sp_name_current_db_new(THD *thd, LEX_STRING name)
return qname;
}
+/*
+ * Check that the name 'ident' is ok. It's assumed to be an 'ident'
+ * from the parser, so we only have to check length and trailing spaces.
+ * The former is a standard requirement (and 'show status' assumes a
+ * non-empty name), the latter is a mysql:ism as trailing spaces are
+ * removed by get_field().
+ *
+ * RETURN
+ * TRUE - bad name
+ * FALSE - name is ok
+ */
+
+bool
+sp_name_check(LEX_STRING ident)
+{
+ return (!ident.str || !ident.str[0] || ident.str[ident.length-1] == ' ');
+}
/* ------------------------------------------------------------------ */
diff --git a/sql/sp_head.h b/sql/sp_head.h
index bd50afebde7..d912cfeaac3 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -103,6 +103,8 @@ public:
sp_name *
sp_name_current_db_new(THD *thd, LEX_STRING name);
+bool
+sp_name_check(LEX_STRING name);
class sp_head :private Query_arena
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 714be26887c..2face8238b8 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1288,11 +1288,26 @@ clear_privileges:
sp_name:
ident '.' ident
{
+ if (!$1.str || check_db_name($1.str))
+ {
+ my_error(ER_WRONG_DB_NAME, MYF(0), $1.str);
+ YYABORT;
+ }
+ if (sp_name_check($3))
+ {
+ my_error(ER_SP_WRONG_NAME, MYF(0), $3.str);
+ YYABORT;
+ }
$$= new sp_name($1, $3);
$$->init_qname(YYTHD);
}
| ident
{
+ if (sp_name_check($1))
+ {
+ my_error(ER_SP_WRONG_NAME, MYF(0), $1.str);
+ YYABORT;
+ }
$$= sp_name_current_db_new(YYTHD, $1);
}
;