Skip to content

Commit 9372f6e

Browse files
author
Alexander Barkov
committed
MDEV-13419 Cleanup for Sp_handler::show_create_sp
1 parent c9218ff commit 9372f6e

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

sql/sp.cc

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,6 @@ Sp_handler::db_load_routine(THD *thd, const Database_qualified_name *name,
862862

863863
thd->lex= &newlex;
864864
newlex.current_select= NULL;
865-
// Resetting REPLACE and EXIST flags in create_info, for show_create_sp()
866-
newlex.create_info.DDL_options_st::init();
867865

868866
defstr.set_charset(creation_ctx->get_client_cs());
869867

@@ -873,10 +871,10 @@ Sp_handler::db_load_routine(THD *thd, const Database_qualified_name *name,
873871
definition for SHOW CREATE PROCEDURE later.
874872
*/
875873

876-
if (!show_create_sp(thd, &defstr,
877-
null_clex_str, name->m_name,
878-
params, returns, body,
879-
chistics, definer, sql_mode))
874+
if (show_create_sp(thd, &defstr,
875+
null_clex_str, name->m_name,
876+
params, returns, body,
877+
chistics, definer, DDL_options(), sql_mode))
880878
{
881879
ret= SP_INTERNAL_ERROR;
882880
goto end;
@@ -1303,12 +1301,14 @@ Sp_handler::sp_create_routine(THD *thd, const sp_head *sp) const
13031301
String log_query;
13041302
log_query.set_charset(system_charset_info);
13051303

1306-
if (!show_create_sp(thd, &log_query,
1307-
sp->m_explicit_name ? sp->m_db : null_clex_str,
1308-
sp->m_name,
1309-
sp->m_params, returns, sp->m_body,
1310-
sp->chistics(), thd->lex->definer[0],
1311-
saved_mode))
1304+
if (show_create_sp(thd, &log_query,
1305+
sp->m_explicit_name ? sp->m_db : null_clex_str,
1306+
sp->m_name,
1307+
sp->m_params, returns, sp->m_body,
1308+
sp->chistics(),
1309+
thd->lex->definer[0],
1310+
thd->lex->create_info,
1311+
saved_mode))
13121312
{
13131313
my_error(ER_OUT_OF_RESOURCES, MYF(0));
13141314
goto done;
@@ -2176,7 +2176,7 @@ int Sp_handler::sp_cache_routine(THD *thd,
21762176
Generates the CREATE... string from the table information.
21772177
21782178
@return
2179-
Returns TRUE on success, FALSE on (alloc) failure.
2179+
Returns false on success, true on (alloc) failure.
21802180
*/
21812181
bool
21822182
Sp_handler::show_create_sp(THD *thd, String *buf,
@@ -2187,6 +2187,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
21872187
const LEX_CSTRING &body,
21882188
const st_sp_chistics &chistics,
21892189
const AUTHID &definer,
2190+
const DDL_options_st ddl_options,
21902191
sql_mode_t sql_mode) const
21912192
{
21922193
sql_mode_t old_sql_mode= thd->variables.sql_mode;
@@ -2195,16 +2196,16 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
21952196
params.length + returns.length +
21962197
chistics.comment.length + 10 /* length of " DEFINER= "*/ +
21972198
USER_HOST_BUFF_SIZE))
2198-
return FALSE;
2199+
return true;
21992200

22002201
thd->variables.sql_mode= sql_mode;
22012202
buf->append(STRING_WITH_LEN("CREATE "));
2202-
if (thd->lex->create_info.or_replace())
2203+
if (ddl_options.or_replace())
22032204
buf->append(STRING_WITH_LEN("OR REPLACE "));
22042205
append_definer(thd, buf, &definer.user, &definer.host);
22052206
buf->append(type_lex_cstring());
22062207
buf->append(STRING_WITH_LEN(" "));
2207-
if (thd->lex->create_info.if_not_exists())
2208+
if (ddl_options.if_not_exists())
22082209
buf->append(STRING_WITH_LEN("IF NOT EXISTS "));
22092210

22102211
if (db.length > 0)
@@ -2252,7 +2253,7 @@ Sp_handler::show_create_sp(THD *thd, String *buf,
22522253
}
22532254
buf->append(body);
22542255
thd->variables.sql_mode= old_sql_mode;
2255-
return TRUE;
2256+
return false;
22562257
}
22572258

22582259

@@ -2300,10 +2301,10 @@ Sp_handler::sp_load_for_information_schema(THD *thd, TABLE *proc_table,
23002301
Stored_program_creation_ctx *creation_ctx=
23012302
Stored_routine_creation_ctx::load_from_db(thd, &sp_name_obj, proc_table);
23022303
defstr.set_charset(creation_ctx->get_client_cs());
2303-
if (!show_create_sp(thd, &defstr,
2304-
sp_name_obj.m_db, sp_name_obj.m_name,
2305-
params, returns, empty_body_lex_cstring(),
2306-
Sp_chistics(), definer, sql_mode))
2304+
if (show_create_sp(thd, &defstr,
2305+
sp_name_obj.m_db, sp_name_obj.m_name,
2306+
params, returns, empty_body_lex_cstring(),
2307+
Sp_chistics(), definer, DDL_options(), sql_mode))
23072308
return 0;
23082309

23092310
thd->lex= &newlex;

sql/sp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ class Sp_handler
150150
sql_mode_t sql_mode,
151151
bool *free_sp_head) const;
152152

153+
/*
154+
Make a SHOW CREATE statement.
155+
@retval true on error
156+
@retval false on success
157+
*/
153158
bool show_create_sp(THD *thd, String *buf,
154159
const LEX_CSTRING &db,
155160
const LEX_CSTRING &name,
@@ -158,6 +163,7 @@ class Sp_handler
158163
const LEX_CSTRING &body,
159164
const st_sp_chistics &chistics,
160165
const AUTHID &definer,
166+
const DDL_options_st ddl_options,
161167
sql_mode_t sql_mode) const;
162168
};
163169

sql/wsrep_mysqld.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,13 +2246,14 @@ static int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len)
22462246
sp_returns_type(thd, retstr, sp);
22472247
returns= retstr.lex_cstring();
22482248
}
2249-
2250-
if (!sp->m_handler->
2251-
show_create_sp(thd, &log_query,
2252-
sp->m_explicit_name ? sp->m_db : null_clex_str,
2253-
sp->m_name, sp->m_params, returns,
2254-
sp->m_body, sp->chistics(), thd->lex->definer[0],
2255-
saved_mode))
2249+
if (sp->m_handler->
2250+
show_create_sp(thd, &log_query,
2251+
sp->m_explicit_name ? sp->m_db : null_clex_str,
2252+
sp->m_name, sp->m_params, returns,
2253+
sp->m_body, sp->chistics(),
2254+
thd->lex->definer[0],
2255+
thd->lex->create_info,
2256+
saved_mode))
22562257
{
22572258
WSREP_WARN("SP create string failed: schema: %s, query: %s",
22582259
(thd->db ? thd->db : "(null)"), thd->query());

0 commit comments

Comments
 (0)