Commit 9372f6e5 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-13419 Cleanup for Sp_handler::show_create_sp

parent c9218ff4
...@@ -862,8 +862,6 @@ Sp_handler::db_load_routine(THD *thd, const Database_qualified_name *name, ...@@ -862,8 +862,6 @@ Sp_handler::db_load_routine(THD *thd, const Database_qualified_name *name,
thd->lex= &newlex; thd->lex= &newlex;
newlex.current_select= NULL; newlex.current_select= NULL;
// Resetting REPLACE and EXIST flags in create_info, for show_create_sp()
newlex.create_info.DDL_options_st::init();
defstr.set_charset(creation_ctx->get_client_cs()); defstr.set_charset(creation_ctx->get_client_cs());
...@@ -873,10 +871,10 @@ Sp_handler::db_load_routine(THD *thd, const Database_qualified_name *name, ...@@ -873,10 +871,10 @@ Sp_handler::db_load_routine(THD *thd, const Database_qualified_name *name,
definition for SHOW CREATE PROCEDURE later. definition for SHOW CREATE PROCEDURE later.
*/ */
if (!show_create_sp(thd, &defstr, if (show_create_sp(thd, &defstr,
null_clex_str, name->m_name, null_clex_str, name->m_name,
params, returns, body, params, returns, body,
chistics, definer, sql_mode)) chistics, definer, DDL_options(), sql_mode))
{ {
ret= SP_INTERNAL_ERROR; ret= SP_INTERNAL_ERROR;
goto end; goto end;
...@@ -1303,12 +1301,14 @@ Sp_handler::sp_create_routine(THD *thd, const sp_head *sp) const ...@@ -1303,12 +1301,14 @@ Sp_handler::sp_create_routine(THD *thd, const sp_head *sp) const
String log_query; String log_query;
log_query.set_charset(system_charset_info); log_query.set_charset(system_charset_info);
if (!show_create_sp(thd, &log_query, if (show_create_sp(thd, &log_query,
sp->m_explicit_name ? sp->m_db : null_clex_str, sp->m_explicit_name ? sp->m_db : null_clex_str,
sp->m_name, sp->m_name,
sp->m_params, returns, sp->m_body, sp->m_params, returns, sp->m_body,
sp->chistics(), thd->lex->definer[0], sp->chistics(),
saved_mode)) thd->lex->definer[0],
thd->lex->create_info,
saved_mode))
{ {
my_error(ER_OUT_OF_RESOURCES, MYF(0)); my_error(ER_OUT_OF_RESOURCES, MYF(0));
goto done; goto done;
...@@ -2176,7 +2176,7 @@ int Sp_handler::sp_cache_routine(THD *thd, ...@@ -2176,7 +2176,7 @@ int Sp_handler::sp_cache_routine(THD *thd,
Generates the CREATE... string from the table information. Generates the CREATE... string from the table information.
@return @return
Returns TRUE on success, FALSE on (alloc) failure. Returns false on success, true on (alloc) failure.
*/ */
bool bool
Sp_handler::show_create_sp(THD *thd, String *buf, Sp_handler::show_create_sp(THD *thd, String *buf,
...@@ -2187,6 +2187,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf, ...@@ -2187,6 +2187,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
const LEX_CSTRING &body, const LEX_CSTRING &body,
const st_sp_chistics &chistics, const st_sp_chistics &chistics,
const AUTHID &definer, const AUTHID &definer,
const DDL_options_st ddl_options,
sql_mode_t sql_mode) const sql_mode_t sql_mode) const
{ {
sql_mode_t old_sql_mode= thd->variables.sql_mode; sql_mode_t old_sql_mode= thd->variables.sql_mode;
...@@ -2195,16 +2196,16 @@ Sp_handler::show_create_sp(THD *thd, String *buf, ...@@ -2195,16 +2196,16 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
params.length + returns.length + params.length + returns.length +
chistics.comment.length + 10 /* length of " DEFINER= "*/ + chistics.comment.length + 10 /* length of " DEFINER= "*/ +
USER_HOST_BUFF_SIZE)) USER_HOST_BUFF_SIZE))
return FALSE; return true;
thd->variables.sql_mode= sql_mode; thd->variables.sql_mode= sql_mode;
buf->append(STRING_WITH_LEN("CREATE ")); buf->append(STRING_WITH_LEN("CREATE "));
if (thd->lex->create_info.or_replace()) if (ddl_options.or_replace())
buf->append(STRING_WITH_LEN("OR REPLACE ")); buf->append(STRING_WITH_LEN("OR REPLACE "));
append_definer(thd, buf, &definer.user, &definer.host); append_definer(thd, buf, &definer.user, &definer.host);
buf->append(type_lex_cstring()); buf->append(type_lex_cstring());
buf->append(STRING_WITH_LEN(" ")); buf->append(STRING_WITH_LEN(" "));
if (thd->lex->create_info.if_not_exists()) if (ddl_options.if_not_exists())
buf->append(STRING_WITH_LEN("IF NOT EXISTS ")); buf->append(STRING_WITH_LEN("IF NOT EXISTS "));
if (db.length > 0) if (db.length > 0)
...@@ -2252,7 +2253,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf, ...@@ -2252,7 +2253,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
} }
buf->append(body); buf->append(body);
thd->variables.sql_mode= old_sql_mode; thd->variables.sql_mode= old_sql_mode;
return TRUE; return false;
} }
...@@ -2300,10 +2301,10 @@ Sp_handler::sp_load_for_information_schema(THD *thd, TABLE *proc_table, ...@@ -2300,10 +2301,10 @@ Sp_handler::sp_load_for_information_schema(THD *thd, TABLE *proc_table,
Stored_program_creation_ctx *creation_ctx= Stored_program_creation_ctx *creation_ctx=
Stored_routine_creation_ctx::load_from_db(thd, &sp_name_obj, proc_table); Stored_routine_creation_ctx::load_from_db(thd, &sp_name_obj, proc_table);
defstr.set_charset(creation_ctx->get_client_cs()); defstr.set_charset(creation_ctx->get_client_cs());
if (!show_create_sp(thd, &defstr, if (show_create_sp(thd, &defstr,
sp_name_obj.m_db, sp_name_obj.m_name, sp_name_obj.m_db, sp_name_obj.m_name,
params, returns, empty_body_lex_cstring(), params, returns, empty_body_lex_cstring(),
Sp_chistics(), definer, sql_mode)) Sp_chistics(), definer, DDL_options(), sql_mode))
return 0; return 0;
thd->lex= &newlex; thd->lex= &newlex;
......
...@@ -150,6 +150,11 @@ class Sp_handler ...@@ -150,6 +150,11 @@ class Sp_handler
sql_mode_t sql_mode, sql_mode_t sql_mode,
bool *free_sp_head) const; bool *free_sp_head) const;
/*
Make a SHOW CREATE statement.
@retval true on error
@retval false on success
*/
bool show_create_sp(THD *thd, String *buf, bool show_create_sp(THD *thd, String *buf,
const LEX_CSTRING &db, const LEX_CSTRING &db,
const LEX_CSTRING &name, const LEX_CSTRING &name,
...@@ -158,6 +163,7 @@ class Sp_handler ...@@ -158,6 +163,7 @@ class Sp_handler
const LEX_CSTRING &body, const LEX_CSTRING &body,
const st_sp_chistics &chistics, const st_sp_chistics &chistics,
const AUTHID &definer, const AUTHID &definer,
const DDL_options_st ddl_options,
sql_mode_t sql_mode) const; sql_mode_t sql_mode) const;
}; };
......
...@@ -2246,13 +2246,14 @@ static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len) ...@@ -2246,13 +2246,14 @@ static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
sp_returns_type(thd, retstr, sp); sp_returns_type(thd, retstr, sp);
returns= retstr.lex_cstring(); returns= retstr.lex_cstring();
} }
if (sp->m_handler->
if (!sp->m_handler-> show_create_sp(thd, &log_query,
show_create_sp(thd, &log_query, sp->m_explicit_name ? sp->m_db : null_clex_str,
sp->m_explicit_name ? sp->m_db : null_clex_str, sp->m_name, sp->m_params, returns,
sp->m_name, sp->m_params, returns, sp->m_body, sp->chistics(),
sp->m_body, sp->chistics(), thd->lex->definer[0], thd->lex->definer[0],
saved_mode)) thd->lex->create_info,
saved_mode))
{ {
WSREP_WARN("SP create string failed: schema: %s, query: %s", WSREP_WARN("SP create string failed: schema: %s, query: %s",
(thd->db ? thd->db : "(null)"), thd->query()); (thd->db ? thd->db : "(null)"), thd->query());
......
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