summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <jani@a193-229-222-105.elisa-laajakaista.fi>2005-11-23 14:57:00 +0200
committerunknown <jani@a193-229-222-105.elisa-laajakaista.fi>2005-11-23 14:57:00 +0200
commit33a2716a8539d9189622a6a5deef0d798c01b427 (patch)
treeee73c0781d75c64d0c74007e2d2a68f9de4b9a29 /sql/sql_parse.cc
parent817ee181c34d53caf2179a978c35c685437fb756 (diff)
parent056d7266c7f3b10b2a054cb5bb534981e49408ee (diff)
downloadmariadb-git-33a2716a8539d9189622a6a5deef0d798c01b427.tar.gz
Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.0
into a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-new Makefile.am: Auto merged client/mysqltest.c: Auto merged configure.in: Auto merged extra/Makefile.am: Auto merged include/Makefile.am: Auto merged include/my_global.h: Auto merged libmysqld/examples/Makefile.am: Auto merged mysql-test/Makefile.am: Auto merged mysql-test/r/ndb_alter_table.result: Auto merged mysql-test/t/ndb_alter_table.test: Auto merged scripts/Makefile.am: Auto merged sql/Makefile.am: Auto merged sql/field.cc: Auto merged sql/ha_federated.cc: Auto merged sql/ha_federated.h: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item.cc: Auto merged sql/item_subselect.cc: Auto merged sql/key.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_lex.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged sql/structs.h: Auto merged sql/table.cc: Auto merged sql/tztime.cc: Auto merged storage/myisam/myisamchk.c: Auto merged storage/myisam/myisampack.c: Auto merged storage/ndb/docs/Makefile.am: Auto merged support-files/mysql.spec.sh: Auto merged libmysqld/Makefile.am: Merged from 5.0 to 5.1. sql/ha_berkeley.cc: Merged from 5.0 to 5.1. sql/lex.h: Merged from 5.0 to 5.1. sql/set_var.cc: Merged from 5.0 to 5.1. sql/share/errmsg.txt: Merged from 5.0 to 5.1. sql/sql_lex.h: Merged from 5.0 to 5.1. sql/sql_show.cc: Merged from 5.0 to 5.1. sql/sql_yacc.yy: Merged from 5.0 to 5.1.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc53
1 files changed, 43 insertions, 10 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index cb2efe43615..74e4b094bbe 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3671,7 +3671,8 @@ end_with_restore_list:
if (check_access(thd,INSERT_ACL,"mysql",0,1,0,0))
break;
#ifdef HAVE_DLOPEN
- if (sp_find_function(thd, lex->spname))
+ if (sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname,
+ &thd->sp_func_cache, FALSE))
{
my_error(ER_UDF_EXISTS, MYF(0), lex->spname->m_name.str);
goto error;
@@ -4022,8 +4023,8 @@ end_with_restore_list:
break;
}
case SQLCOM_SAVEPOINT:
- if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) ||
- !opt_using_transactions)
+ if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
+ thd->in_sub_stmt) || !opt_using_transactions)
send_ok(thd);
else
{
@@ -4205,7 +4206,8 @@ end_with_restore_list:
By this moment all needed SPs should be in cache so no need to look
into DB.
*/
- if (!(sp= sp_find_procedure(thd, lex->spname, TRUE)))
+ if (!(sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname,
+ &thd->sp_proc_cache, TRUE)))
{
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PROCEDURE",
lex->spname->m_qname.str);
@@ -4329,9 +4331,11 @@ end_with_restore_list:
memcpy(&chistics, &lex->sp_chistics, sizeof(chistics));
if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
- sp= sp_find_procedure(thd, lex->spname);
+ sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname,
+ &thd->sp_proc_cache, FALSE);
else
- sp= sp_find_function(thd, lex->spname);
+ sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname,
+ &thd->sp_func_cache, FALSE);
mysql_reset_errors(thd, 0);
if (! sp)
{
@@ -4407,9 +4411,11 @@ end_with_restore_list:
char *db, *name;
if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
- sp= sp_find_procedure(thd, lex->spname);
+ sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname,
+ &thd->sp_proc_cache, FALSE);
else
- sp= sp_find_function(thd, lex->spname);
+ sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname,
+ &thd->sp_func_cache, FALSE);
mysql_reset_errors(thd, 0);
if (sp)
{
@@ -4537,6 +4543,33 @@ end_with_restore_list:
lex->wild->ptr() : NullS));
break;
}
+#ifndef DBUG_OFF
+ case SQLCOM_SHOW_PROC_CODE:
+ case SQLCOM_SHOW_FUNC_CODE:
+ {
+ sp_head *sp;
+
+ if (lex->spname->m_name.length > NAME_LEN)
+ {
+ my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str);
+ goto error;
+ }
+ if (lex->sql_command == SQLCOM_SHOW_PROC_CODE)
+ sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname,
+ &thd->sp_proc_cache, FALSE);
+ else
+ sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname,
+ &thd->sp_func_cache, FALSE);
+ if (!sp || !sp->show_routine_code(thd))
+ {
+ /* We don't distinguish between errors for now */
+ my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
+ SP_COM_STRING(lex), lex->spname->m_name.str);
+ goto error;
+ }
+ break;
+ }
+#endif // ifndef DBUG_OFF
case SQLCOM_CREATE_VIEW:
{
if (end_active_trans(thd))
@@ -4555,7 +4588,7 @@ end_with_restore_list:
buff.append(command[thd->lex->create_view_mode].str,
command[thd->lex->create_view_mode].length);
view_store_options(thd, first_table, &buff);
- buff.append("VIEW ", 5);
+ buff.append(STRING_WITH_LEN("VIEW "));
/* Test if user supplied a db (ie: we did not use thd->db) */
if (first_table->db != thd->db && first_table->db[0])
{
@@ -4565,7 +4598,7 @@ end_with_restore_list:
}
append_identifier(thd, &buff, first_table->table_name,
first_table->table_name_length);
- buff.append(" AS ", 4);
+ buff.append(STRING_WITH_LEN(" AS "));
buff.append(first_table->source.str, first_table->source.length);
Query_log_event qinfo(thd, buff.ptr(), buff.length(), 0, FALSE);