| 7174 | |
| 7175 | |
| 7176 | int store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, |
| 7177 | LOOKUP_FIELD_VALUES *lookup, bool full_access, |
| 7178 | const char *sp_user) |
| 7179 | { |
| 7180 | LEX *lex= thd->lex; |
| 7181 | CHARSET_INFO *cs= system_charset_info; |
| 7182 | const Sp_handler *sph; |
| 7183 | LEX_CSTRING db, name, definer, returns= empty_clex_str; |
| 7184 | const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; |
| 7185 | int rc; |
| 7186 | |
| 7187 | proc_table->field[MYSQL_PROC_FIELD_DB]->val_str_nopad(thd->mem_root, &db); |
| 7188 | proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str_nopad(thd->mem_root, &name); |
| 7189 | |
| 7190 | CHARSET_INFO *name_cs= proc_table->field[MYSQL_PROC_FIELD_NAME]->charset(); |
| 7191 | if ((rc= check_proc_record(name_cs, lookup, db, name)) != -1) |
| 7192 | return rc; /* either HA_ERR_END_OF_FILE or 0 if name didn't match */ |
| 7193 | |
| 7194 | proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str_nopad(thd->mem_root, &definer); |
| 7195 | sph= Sp_handler::handler_mysql_proc((enum_sp_type) |
| 7196 | proc_table->field[MYSQL_PROC_MYSQL_TYPE]-> |
| 7197 | val_int()); |
| 7198 | if (!sph) |
| 7199 | return 0; |
| 7200 | |
| 7201 | if (!full_access) |
| 7202 | full_access= !strcmp(sp_user, definer.str) || |
| 7203 | !check_db_routine_access(thd, SHOW_CREATE_ROUTINE_ACL, |
| 7204 | db.str, name.str, sph, TRUE); |
| 7205 | if (!full_access && |
| 7206 | check_some_routine_access(thd, db.str, name.str, sph)) |
| 7207 | return 0; |
| 7208 | |
| 7209 | if (!is_show_command(thd) || |
| 7210 | sph == Sp_handler::handler(lex->sql_command)) |
| 7211 | { |
| 7212 | restore_record(table, s->default_values); |
| 7213 | if (!wild || !wild[0] || !wild_case_compare(system_charset_info, |
| 7214 | name.str, wild)) |
| 7215 | { |
| 7216 | int enum_idx= (int) proc_table->field[MYSQL_PROC_FIELD_ACCESS]->val_int(); |
| 7217 | table->field[3]->store(name, cs); |
| 7218 | |
| 7219 | copy_field_as_string(table->field[0], |
| 7220 | proc_table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]); |
| 7221 | table->field[1]->store(STRING_WITH_LEN("def"), cs); |
| 7222 | table->field[2]->store(db, cs); |
| 7223 | copy_field_as_string(table->field[4], |
| 7224 | proc_table->field[MYSQL_PROC_MYSQL_TYPE]); |
| 7225 | |
| 7226 | if (sph->type() == SP_TYPE_FUNCTION) |
| 7227 | { |
| 7228 | sp_head *sp; |
| 7229 | bool free_sp_head; |
| 7230 | proc_table->field[MYSQL_PROC_FIELD_RETURNS]->val_str_nopad(thd->mem_root, |
| 7231 | &returns); |
| 7232 | sp= sph->sp_load_for_information_schema(thd, proc_table, |
| 7233 | db, name, |
no test coverage detected