Commit e6b04edb authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

merge

parent db8f03eb
...@@ -400,6 +400,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, ...@@ -400,6 +400,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
const char *definer, longlong created, longlong modified) const char *definer, longlong created, longlong modified)
{ {
LEX *oldlex= thd->lex, newlex; LEX *oldlex= thd->lex, newlex;
sp_rcontext *save_spcont= ;thd->spcont;
String defstr; String defstr;
char olddb[128]; char olddb[128];
bool dbchanged; bool dbchanged;
...@@ -430,6 +431,9 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, ...@@ -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()); 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) if (yyparse(thd) || thd->is_fatal_error || newlex.sphead == NULL)
{ {
sp_head *sp= newlex.sphead; sp_head *sp= newlex.sphead;
...@@ -442,12 +446,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, ...@@ -442,12 +446,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
else else
{ {
if (dbchanged && (ret= mysql_change_db(thd, olddb, 1))) if (dbchanged && (ret= mysql_change_db(thd, olddb, 1)))
goto end; goto db_end;
*sphp= newlex.sphead; *sphp= newlex.sphead;
(*sphp)->set_definer((char*) definer, (uint) strlen(definer));
(*sphp)->set_info((char *)definer, (uint)strlen(definer), (*sphp)->set_info((char *)definer, (uint)strlen(definer),
created, modified, &chistics, sql_mode); created, modified, &chistics, sql_mode);
(*sphp)->optimize(); (*sphp)->optimize();
} }
db_end:
thd->spcont= save_spcont;
thd->variables.sql_mode= old_sql_mode; thd->variables.sql_mode= old_sql_mode;
thd->variables.select_limit= select_limit; thd->variables.select_limit= select_limit;
end: end:
...@@ -550,12 +557,13 @@ db_create_routine(THD *thd, int type, sp_head *sp) ...@@ -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, store(sp->m_chistics->comment.str, sp->m_chistics->comment.length,
system_charset_info); 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) 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. a non-deterministic read-only function in an update statement.
*/ */
enum enum_sp_data_access access= enum enum_sp_data_access access=
...@@ -1606,30 +1614,30 @@ create_string(THD *thd, String *buf, ...@@ -1606,30 +1614,30 @@ create_string(THD *thd, String *buf,
chistics->comment.length)) chistics->comment.length))
return FALSE; return FALSE;
buf->append("CREATE ", 7); buf->append(STRING_WITH_LEN("CREATE "));
if (type == TYPE_ENUM_FUNCTION) if (type == TYPE_ENUM_FUNCTION)
buf->append("FUNCTION ", 9); buf->append(STRING_WITH_LEN("FUNCTION "));
else else
buf->append("PROCEDURE ", 10); buf->append(STRING_WITH_LEN("PROCEDURE "));
append_identifier(thd, buf, name->m_name.str, name->m_name.length); append_identifier(thd, buf, name->m_name.str, name->m_name.length);
buf->append('('); buf->append('(');
buf->append(params, paramslen); buf->append(params, paramslen);
buf->append(')'); buf->append(')');
if (type == TYPE_ENUM_FUNCTION) if (type == TYPE_ENUM_FUNCTION)
{ {
buf->append(" RETURNS ", 9); buf->append(STRING_WITH_LEN(" RETURNS "));
buf->append(returns, returnslen); buf->append(returns, returnslen);
} }
buf->append('\n'); buf->append('\n');
switch (chistics->daccess) { switch (chistics->daccess) {
case SP_NO_SQL: case SP_NO_SQL:
buf->append(" NO SQL\n"); buf->append(STRING_WITH_LEN(" NO SQL\n"));
break; break;
case SP_READS_SQL_DATA: case SP_READS_SQL_DATA:
buf->append(" READS SQL DATA\n"); buf->append(STRING_WITH_LEN(" READS SQL DATA\n"));
break; break;
case SP_MODIFIES_SQL_DATA: case SP_MODIFIES_SQL_DATA:
buf->append(" MODIFIES SQL DATA\n"); buf->append(STRING_WITH_LEN(" MODIFIES SQL DATA\n"));
break; break;
case SP_DEFAULT_ACCESS: case SP_DEFAULT_ACCESS:
case SP_CONTAINS_SQL: case SP_CONTAINS_SQL:
...@@ -1637,12 +1645,12 @@ create_string(THD *thd, String *buf, ...@@ -1637,12 +1645,12 @@ create_string(THD *thd, String *buf,
break; break;
} }
if (chistics->detistic) if (chistics->detistic)
buf->append(" DETERMINISTIC\n", 18); buf->append(STRING_WITH_LEN(" DETERMINISTIC\n"));
if (chistics->suid == SP_IS_NOT_SUID) 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) if (chistics->comment.length)
{ {
buf->append(" COMMENT "); buf->append(STRING_WITH_LEN(" COMMENT "));
append_unescaped(buf, chistics->comment.str, chistics->comment.length); append_unescaped(buf, chistics->comment.str, chistics->comment.length);
buf->append('\n'); 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