Commit 03da52b0 authored by unknown's avatar unknown

merge

parent 7a307bb0
......@@ -400,6 +400,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
const char *definer, longlong created, longlong modified)
{
LEX *oldlex= thd->lex, newlex;
sp_rcontext *save_spcont= ;thd->spcont;
String defstr;
char olddb[128];
bool dbchanged;
......@@ -430,6 +431,9 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length());
(*sphp)->set_definer((char*) definer, (uint) strlen(definer));
(*sphp)->set_info(created, modified, &chistics, sql_mode);
thd->spcont= 0;
if (yyparse(thd) || thd->is_fatal_error || newlex.sphead == NULL)
{
sp_head *sp= newlex.sphead;
......@@ -442,12 +446,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
else
{
if (dbchanged && (ret= mysql_change_db(thd, olddb, 1)))
goto end;
goto db_end;
*sphp= newlex.sphead;
(*sphp)->set_definer((char*) definer, (uint) strlen(definer));
(*sphp)->set_info((char *)definer, (uint)strlen(definer),
created, modified, &chistics, sql_mode);
(*sphp)->optimize();
}
db_end:
thd->spcont= save_spcont;
thd->variables.sql_mode= old_sql_mode;
thd->variables.select_limit= select_limit;
end:
......@@ -550,12 +557,13 @@ db_create_routine(THD *thd, int type, sp_head *sp)
store(sp->m_chistics->comment.str, sp->m_chistics->comment.length,
system_charset_info);
if (!trust_routine_creators && mysql_bin_log.is_open())
if ((sp->m_type == TYPE_ENUM_FUNCTION) &&
!trust_function_creators && mysql_bin_log.is_open())
{
if (!sp->m_chistics->detistic)
{
/*
Note that for a _function_ this test is not enough; one could use
Note that this test is not perfect; one could use
a non-deterministic read-only function in an update statement.
*/
enum enum_sp_data_access access=
......@@ -1606,30 +1614,30 @@ create_string(THD *thd, String *buf,
chistics->comment.length))
return FALSE;
buf->append("CREATE ", 7);
buf->append(STRING_WITH_LEN("CREATE "));
if (type == TYPE_ENUM_FUNCTION)
buf->append("FUNCTION ", 9);
buf->append(STRING_WITH_LEN("FUNCTION "));
else
buf->append("PROCEDURE ", 10);
buf->append(STRING_WITH_LEN("PROCEDURE "));
append_identifier(thd, buf, name->m_name.str, name->m_name.length);
buf->append('(');
buf->append(params, paramslen);
buf->append(')');
if (type == TYPE_ENUM_FUNCTION)
{
buf->append(" RETURNS ", 9);
buf->append(STRING_WITH_LEN(" RETURNS "));
buf->append(returns, returnslen);
}
buf->append('\n');
switch (chistics->daccess) {
case SP_NO_SQL:
buf->append(" NO SQL\n");
buf->append(STRING_WITH_LEN(" NO SQL\n"));
break;
case SP_READS_SQL_DATA:
buf->append(" READS SQL DATA\n");
buf->append(STRING_WITH_LEN(" READS SQL DATA\n"));
break;
case SP_MODIFIES_SQL_DATA:
buf->append(" MODIFIES SQL DATA\n");
buf->append(STRING_WITH_LEN(" MODIFIES SQL DATA\n"));
break;
case SP_DEFAULT_ACCESS:
case SP_CONTAINS_SQL:
......@@ -1637,12 +1645,12 @@ create_string(THD *thd, String *buf,
break;
}
if (chistics->detistic)
buf->append(" DETERMINISTIC\n", 18);
buf->append(STRING_WITH_LEN(" DETERMINISTIC\n"));
if (chistics->suid == SP_IS_NOT_SUID)
buf->append(" SQL SECURITY INVOKER\n", 25);
buf->append(STRING_WITH_LEN(" SQL SECURITY INVOKER\n"));
if (chistics->comment.length)
{
buf->append(" COMMENT ");
buf->append(STRING_WITH_LEN(" COMMENT "));
append_unescaped(buf, chistics->comment.str, chistics->comment.length);
buf->append('\n');
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment