1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.

Conflicts:

   conflict      Makefile.am
   conflict      mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
   conflict      mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test
   conflict      sql/opt_sum.cc
   conflict      sql/set_var.cc
   conflict      sql/sql_base.cc
   conflict      sql/sql_priv.h
   conflict      sql/sql_show.cc
This commit is contained in:
Alexey Kopytov
2010-05-24 00:41:18 +04:00
38 changed files with 784 additions and 269 deletions

View File

@ -4348,6 +4348,15 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond)
}
static inline void copy_field_as_string(Field *to_field, Field *from_field)
{
char buff[MAX_FIELD_WIDTH];
String tmp_str(buff, sizeof(buff), system_charset_info);
from_field->val_str(&tmp_str);
to_field->store(tmp_str.ptr(), tmp_str.length(), system_charset_info);
}
/**
@brief Store record into I_S.PARAMETERS table
@ -4514,18 +4523,26 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
const char *wild, bool full_access, const char *sp_user)
{
String tmp_string;
String sp_db, sp_name, definer;
MYSQL_TIME time;
LEX *lex= thd->lex;
CHARSET_INFO *cs= system_charset_info;
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_DB], &sp_db);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_NAME], &sp_name);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_DEFINER],&definer);
char sp_db_buff[NAME_LEN + 1], sp_name_buff[NAME_LEN + 1],
definer_buff[USERNAME_LENGTH + HOSTNAME_LENGTH + 2],
returns_buff[MAX_FIELD_WIDTH];
String sp_db(sp_db_buff, sizeof(sp_db_buff), cs);
String sp_name(sp_name_buff, sizeof(sp_name_buff), cs);
String definer(definer_buff, sizeof(definer_buff), cs);
String returns(returns_buff, sizeof(returns_buff), cs);
proc_table->field[MYSQL_PROC_FIELD_DB]->val_str(&sp_db);
proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str(&sp_name);
proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str(&definer);
if (!full_access)
full_access= !strcmp(sp_user, definer.ptr());
if (!full_access &&
check_some_routine_access(thd, sp_db.ptr(), sp_name.ptr(),
full_access= !strcmp(sp_user, definer.c_ptr_safe());
if (!full_access &&
check_some_routine_access(thd, sp_db.c_ptr_safe(), sp_name.c_ptr_safe(),
proc_table->field[MYSQL_PROC_MYSQL_TYPE]->
val_int() == TYPE_ENUM_PROCEDURE))
return 0;
@ -4539,32 +4556,30 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
(sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0)
{
restore_record(table, s->default_values);
if (!wild || !wild[0] || !wild_compare(sp_name.ptr(), wild, 0))
if (!wild || !wild[0] || !wild_compare(sp_name.c_ptr_safe(), wild, 0))
{
int enum_idx= (int) proc_table->field[MYSQL_PROC_FIELD_ACCESS]->val_int();
table->field[3]->store(sp_name.ptr(), sp_name.length(), cs);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME],
&tmp_string);
table->field[0]->store(tmp_string.ptr(), tmp_string.length(), cs);
copy_field_as_string(table->field[0],
proc_table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]);
table->field[1]->store(STRING_WITH_LEN("def"), cs);
table->field[2]->store(sp_db.ptr(), sp_db.length(), cs);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_MYSQL_TYPE],
&tmp_string);
table->field[4]->store(tmp_string.ptr(), tmp_string.length(), cs);
copy_field_as_string(table->field[4],
proc_table->field[MYSQL_PROC_MYSQL_TYPE]);
if (proc_table->field[MYSQL_PROC_MYSQL_TYPE]->val_int() ==
TYPE_ENUM_FUNCTION)
{
sp_head *sp;
bool free_sp_head;
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_RETURNS],
&tmp_string);
proc_table->field[MYSQL_PROC_FIELD_RETURNS]->val_str(&returns);
sp= sp_load_for_information_schema(thd, proc_table, &sp_db, &sp_name,
(ulong) proc_table->
field[MYSQL_PROC_FIELD_SQL_MODE]->
val_int(),
TYPE_ENUM_FUNCTION,
tmp_string.c_ptr_safe(),
returns.c_ptr_safe(),
"", &free_sp_head);
if (sp)
@ -4595,24 +4610,19 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
if (full_access)
{
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_BODY_UTF8],
&tmp_string);
table->field[14]->store(tmp_string.ptr(), tmp_string.length(), cs);
copy_field_as_string(table->field[14],
proc_table->field[MYSQL_PROC_FIELD_BODY_UTF8]);
table->field[14]->set_notnull();
}
table->field[13]->store(STRING_WITH_LEN("SQL"), cs);
table->field[17]->store(STRING_WITH_LEN("SQL"), cs);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_DETERMINISTIC],
&tmp_string);
table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
copy_field_as_string(table->field[18],
proc_table->field[MYSQL_PROC_FIELD_DETERMINISTIC]);
table->field[19]->store(sp_data_access_name[enum_idx].str,
sp_data_access_name[enum_idx].length , cs);
copy_field_as_string(table->field[21],
proc_table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_SECURITY_TYPE],
&tmp_string);
table->field[21]->store(tmp_string.ptr(), tmp_string.length(), cs);
bzero((char *)&time, sizeof(time));
((Field_timestamp *) proc_table->field[MYSQL_PROC_FIELD_CREATED])->
get_time(&time);
@ -4621,29 +4631,20 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
((Field_timestamp *) proc_table->field[MYSQL_PROC_FIELD_MODIFIED])->
get_time(&time);
table->field[23]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
copy_field_as_string(table->field[24],
proc_table->field[MYSQL_PROC_FIELD_SQL_MODE]);
copy_field_as_string(table->field[25],
proc_table->field[MYSQL_PROC_FIELD_COMMENT]);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_SQL_MODE],
&tmp_string);
table->field[24]->store(tmp_string.ptr(), tmp_string.length(), cs);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_COMMENT],
&tmp_string);
table->field[25]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[26]->store(definer.ptr(), definer.length(), cs);
get_field(thd->mem_root,
proc_table->field[MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT],
&tmp_string);
table->field[27]->store(tmp_string.ptr(), tmp_string.length(), cs);
get_field(thd->mem_root,
proc_table->field[ MYSQL_PROC_FIELD_COLLATION_CONNECTION],
&tmp_string);
table->field[28]->store(tmp_string.ptr(), tmp_string.length(), cs);
get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_DB_COLLATION],
&tmp_string);
table->field[29]->store(tmp_string.ptr(), tmp_string.length(), cs);
copy_field_as_string(table->field[27],
proc_table->
field[MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT]);
copy_field_as_string(table->field[28],
proc_table->
field[MYSQL_PROC_FIELD_COLLATION_CONNECTION]);
copy_field_as_string(table->field[29],
proc_table->field[MYSQL_PROC_FIELD_DB_COLLATION]);
return schema_table_store_record(thd, table);
}