Commit a1e6b80b authored by gluh@gluh.mysql.r18.ru's avatar gluh@gluh.mysql.r18.ru

Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.0

into gluh.mysql.r18.ru:/home/gluh/MySQL-MERGE/mysql-5.0
parents 9fbfa7a9 bbd27199
...@@ -651,6 +651,8 @@ drop table t1, t2; ...@@ -651,6 +651,8 @@ drop table t1, t2;
CREATE TABLE t_crashme ( f1 BIGINT); CREATE TABLE t_crashme ( f1 BIGINT);
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
count(*)
100
drop view a2, a1; drop view a2, a1;
drop table t_crashme; drop table t_crashme;
select table_schema,table_name, column_name from select table_schema,table_name, column_name from
......
...@@ -403,6 +403,7 @@ while ($tab_count) ...@@ -403,6 +403,7 @@ while ($tab_count)
--disable_result_log --disable_result_log
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES; SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES;
--enable_result_log --enable_result_log
SELECT count(*) FROM INFORMATION_SCHEMA.TABLES;
let $tab_count= 65; let $tab_count= 65;
while ($tab_count) while ($tab_count)
{ {
......
...@@ -8714,6 +8714,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, ...@@ -8714,6 +8714,7 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
*table= new_table; *table= new_table;
table->s= &table->share_not_to_be_used; table->s= &table->share_not_to_be_used;
table->file->change_table_ptr(table); table->file->change_table_ptr(table);
if (save_proc_info)
thd->proc_info= (!strcmp(save_proc_info,"Copying to tmp table") ? thd->proc_info= (!strcmp(save_proc_info,"Copying to tmp table") ?
"Copying to tmp table on disk" : save_proc_info); "Copying to tmp table on disk" : save_proc_info);
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -41,6 +41,7 @@ static int ...@@ -41,6 +41,7 @@ static int
store_create_info(THD *thd, TABLE_LIST *table_list, String *packet); store_create_info(THD *thd, TABLE_LIST *table_list, String *packet);
static int static int
view_store_create_info(THD *thd, TABLE_LIST *table, String *packet); view_store_create_info(THD *thd, TABLE_LIST *table, String *packet);
static bool schema_table_store_record(THD *thd, TABLE *table);
/*************************************************************************** /***************************************************************************
...@@ -1550,7 +1551,8 @@ static bool show_status_array(THD *thd, const char *wild, ...@@ -1550,7 +1551,8 @@ static bool show_status_array(THD *thd, const char *wild,
table->field[0]->store(name_buffer, strlen(name_buffer), table->field[0]->store(name_buffer, strlen(name_buffer),
system_charset_info); system_charset_info);
table->field[1]->store(pos, (uint32) (end - pos), system_charset_info); table->field[1]->store(pos, (uint32) (end - pos), system_charset_info);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(TRUE);
} }
} }
} }
...@@ -1606,6 +1608,33 @@ typedef struct st_index_field_values ...@@ -1606,6 +1608,33 @@ typedef struct st_index_field_values
} INDEX_FIELD_VALUES; } INDEX_FIELD_VALUES;
/*
Store record to I_S table, convert HEAP table
to MyISAM if necessary
SYNOPSIS
schema_table_store_record()
thd thread handler
table I_S table
RETURN
1 error
0 success
*/
static bool schema_table_store_record(THD *thd, TABLE *table)
{
int error;
if ((error= table->file->write_row(table->record[0])))
{
if (create_myisam_from_heap(thd, table,
table->pos_in_table_list->schema_table_param,
error, 0))
return 1;
}
return 0;
}
void get_index_field_values(LEX *lex, INDEX_FIELD_VALUES *index_field_values) void get_index_field_values(LEX *lex, INDEX_FIELD_VALUES *index_field_values)
{ {
const char *wild= lex->wild ? lex->wild->ptr() : NullS; const char *wild= lex->wild ? lex->wild->ptr() : NullS;
...@@ -1929,7 +1958,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1929,7 +1958,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
} }
} }
} }
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(error);
} }
else else
{ {
...@@ -1966,13 +1996,13 @@ err: ...@@ -1966,13 +1996,13 @@ err:
} }
void store_schema_shemata(TABLE *table, const char *db_name, bool store_schema_shemata(THD* thd, TABLE *table, const char *db_name,
const char* cs_name) const char* cs_name)
{ {
restore_record(table, s->default_values); restore_record(table, s->default_values);
table->field[1]->store(db_name, strlen(db_name), system_charset_info); table->field[1]->store(db_name, strlen(db_name), system_charset_info);
table->field[2]->store(cs_name, strlen(cs_name), system_charset_info); table->field[2]->store(cs_name, strlen(cs_name), system_charset_info);
table->file->write_row(table->record[0]); return schema_table_store_record(thd, table);
} }
...@@ -2001,7 +2031,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2001,7 +2031,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
{ {
if (with_i_schema) // information schema name is always first in list if (with_i_schema) // information schema name is always first in list
{ {
store_schema_shemata(table, file_name, system_charset_info->csname); if (store_schema_shemata(thd, table, file_name,
system_charset_info->csname))
DBUG_RETURN(1);
with_i_schema= 0; with_i_schema= 0;
continue; continue;
} }
...@@ -2024,8 +2056,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2024,8 +2056,9 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
path[length-1]= FN_LIBCHAR; path[length-1]= FN_LIBCHAR;
strmov(path+length, MY_DB_OPT_FILE); strmov(path+length, MY_DB_OPT_FILE);
load_db_opt(thd, path, &create); load_db_opt(thd, path, &create);
store_schema_shemata(table, file_name, if (store_schema_shemata(thd, table, file_name,
create.default_table_charset->csname); create.default_table_charset->csname))
DBUG_RETURN(1);
} }
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -2210,8 +2243,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables, ...@@ -2210,8 +2243,7 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
} }
} }
} }
table->file->write_row(table->record[0]); DBUG_RETURN(schema_table_store_record(thd, table));
DBUG_RETURN(0);
} }
...@@ -2389,7 +2421,8 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, ...@@ -2389,7 +2421,8 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
#endif #endif
table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs); table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
table->field[18]->store(field->comment.str, field->comment.length, cs); table->field[18]->store(field->comment.str, field->comment.length, cs);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
} }
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -2418,7 +2451,8 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2418,7 +2451,8 @@ int fill_schema_charsets(THD *thd, TABLE_LIST *tables, COND *cond)
strlen(tmp_cs->comment ? tmp_cs->comment : ""), strlen(tmp_cs->comment ? tmp_cs->comment : ""),
scs); scs);
table->field[3]->store((longlong) tmp_cs->mbmaxlen); table->field[3]->store((longlong) tmp_cs->mbmaxlen);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
return 1;
} }
} }
return 0; return 0;
...@@ -2457,7 +2491,8 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2457,7 +2491,8 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond)
tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : ""; tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : "";
table->field[4]->store(tmp_buff, strlen(tmp_buff), scs); table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
table->field[5]->store((longlong) tmp_cl->strxfrm_multiply); table->field[5]->store((longlong) tmp_cl->strxfrm_multiply);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
return 1;
} }
} }
} }
...@@ -2486,14 +2521,15 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2486,14 +2521,15 @@ int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond)
restore_record(table, s->default_values); restore_record(table, s->default_values);
table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs); table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs); table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
return 1;
} }
} }
return 0; return 0;
} }
void store_schema_proc(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) const char *wild, bool full_access, const char *sp_user)
{ {
String tmp_string; String tmp_string;
...@@ -2507,7 +2543,7 @@ void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, ...@@ -2507,7 +2543,7 @@ void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
if (!full_access) if (!full_access)
full_access= !strcmp(sp_user, definer); full_access= !strcmp(sp_user, definer);
if (!full_access && check_some_routine_access(thd, sp_db, sp_name)) if (!full_access && check_some_routine_access(thd, sp_db, sp_name))
return; return 0;
if (lex->orig_sql_command == SQLCOM_SHOW_STATUS_PROC && if (lex->orig_sql_command == SQLCOM_SHOW_STATUS_PROC &&
proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE || proc_table->field[2]->val_int() == TYPE_ENUM_PROCEDURE ||
...@@ -2556,9 +2592,10 @@ void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, ...@@ -2556,9 +2592,10 @@ void store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
get_field(thd->mem_root, proc_table->field[15], &tmp_string); get_field(thd->mem_root, proc_table->field[15], &tmp_string);
table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs); table->field[18]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[19]->store(definer, strlen(definer), cs); table->field[19]->store(definer, strlen(definer), cs);
table->file->write_row(table->record[0]); return schema_table_store_record(thd, table);
} }
} }
return 0;
} }
...@@ -2591,9 +2628,19 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2591,9 +2628,19 @@ int fill_schema_proc(THD *thd, TABLE_LIST *tables, COND *cond)
res= (res == HA_ERR_END_OF_FILE) ? 0 : 1; res= (res == HA_ERR_END_OF_FILE) ? 0 : 1;
goto err; goto err;
} }
store_schema_proc(thd, table, proc_table, wild, full_access, definer); if (store_schema_proc(thd, table, proc_table, wild, full_access, definer))
{
res= 1;
goto err;
}
while (!proc_table->file->index_next(proc_table->record[0])) while (!proc_table->file->index_next(proc_table->record[0]))
store_schema_proc(thd, table, proc_table, wild, full_access, definer); {
if (store_schema_proc(thd, table, proc_table, wild, full_access, definer))
{
res= 1;
goto err;
}
}
err: err:
proc_table->file->ha_index_end(); proc_table->file->ha_index_end();
...@@ -2683,7 +2730,8 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables, ...@@ -2683,7 +2730,8 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
else else
table->field[14]->store("", 0, cs); table->field[14]->store("", 0, cs);
table->field[14]->set_notnull(); table->field[14]->set_notnull();
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
} }
} }
} }
...@@ -2722,7 +2770,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, ...@@ -2722,7 +2770,7 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
table->field[5]->store("YES", 3, cs); table->field[5]->store("YES", 3, cs);
else else
table->field[5]->store("NO", 2, cs); table->field[5]->store("NO", 2, cs);
table->file->write_row(table->record[0]); DBUG_RETURN(schema_table_store_record(thd, table));
} }
} }
else else
...@@ -2736,9 +2784,9 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables, ...@@ -2736,9 +2784,9 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
} }
void store_constraints(TABLE *table, const char*db, const char *tname, bool store_constraints(THD *thd, TABLE *table, const char *db,
const char *key_name, uint key_len, const char *tname, const char *key_name,
const char *con_type, uint con_len) uint key_len, const char *con_type, uint con_len)
{ {
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
restore_record(table, s->default_values); restore_record(table, s->default_values);
...@@ -2747,7 +2795,7 @@ void store_constraints(TABLE *table, const char*db, const char *tname, ...@@ -2747,7 +2795,7 @@ void store_constraints(TABLE *table, const char*db, const char *tname,
table->field[3]->store(db, strlen(db), cs); table->field[3]->store(db, strlen(db), cs);
table->field[4]->store(tname, strlen(tname), cs); table->field[4]->store(tname, strlen(tname), cs);
table->field[5]->store(con_type, con_len, cs); table->field[5]->store(con_type, con_len, cs);
table->file->write_row(table->record[0]); return schema_table_store_record(thd, table);
} }
...@@ -2780,11 +2828,17 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables, ...@@ -2780,11 +2828,17 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
continue; continue;
if (i == primary_key && !strcmp(key_info->name, primary_key_name)) if (i == primary_key && !strcmp(key_info->name, primary_key_name))
store_constraints(table, base_name, file_name, key_info->name, {
strlen(key_info->name), "PRIMARY KEY", 11); if (store_constraints(thd, table, base_name, file_name, key_info->name,
strlen(key_info->name), "PRIMARY KEY", 11))
DBUG_RETURN(1);
}
else if (key_info->flags & HA_NOSAME) else if (key_info->flags & HA_NOSAME)
store_constraints(table, base_name, file_name, key_info->name, {
strlen(key_info->name), "UNIQUE", 6); if (store_constraints(thd, table, base_name, file_name, key_info->name,
strlen(key_info->name), "UNIQUE", 6))
DBUG_RETURN(1);
}
} }
show_table->file->get_foreign_key_list(thd, &f_key_list); show_table->file->get_foreign_key_list(thd, &f_key_list);
...@@ -2792,8 +2846,11 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables, ...@@ -2792,8 +2846,11 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
while ((f_key_info=it++)) while ((f_key_info=it++))
{ {
store_constraints(table, base_name, file_name, f_key_info->forein_id->str, if (store_constraints(thd, table, base_name, file_name,
strlen(f_key_info->forein_id->str), "FOREIGN KEY", 11); f_key_info->forein_id->str,
strlen(f_key_info->forein_id->str),
"FOREIGN KEY", 11))
DBUG_RETURN(1);
} }
} }
DBUG_RETURN(res); DBUG_RETURN(res);
...@@ -2856,7 +2913,8 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2856,7 +2913,8 @@ static int get_schema_key_column_usage_record(THD *thd,
key_part->field->field_name, key_part->field->field_name,
strlen(key_part->field->field_name), strlen(key_part->field->field_name),
(longlong) f_idx); (longlong) f_idx);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
} }
} }
} }
...@@ -2882,7 +2940,8 @@ static int get_schema_key_column_usage_record(THD *thd, ...@@ -2882,7 +2940,8 @@ static int get_schema_key_column_usage_record(THD *thd,
(longlong) f_idx); (longlong) f_idx);
table->field[8]->store((longlong) f_idx); table->field[8]->store((longlong) f_idx);
table->field[8]->set_notnull(); table->field[8]->set_notnull();
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
} }
} }
} }
...@@ -2907,7 +2966,8 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2907,7 +2966,8 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
table->field[1]->store(open_list->table, strlen(open_list->table), cs); table->field[1]->store(open_list->table, strlen(open_list->table), cs);
table->field[2]->store((longlong) open_list->in_use); table->field[2]->store((longlong) open_list->in_use);
table->field[3]->store((longlong) open_list->locked); table->field[3]->store((longlong) open_list->locked);
table->file->write_row(table->record[0]); if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3048,6 +3108,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) ...@@ -3048,6 +3108,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
TMP_TABLE_ALL_COLUMNS), TMP_TABLE_ALL_COLUMNS),
HA_POS_ERROR, table_list->alias))) HA_POS_ERROR, table_list->alias)))
DBUG_RETURN(0); DBUG_RETURN(0);
table_list->schema_table_param= tmp_table_param;
DBUG_RETURN(table); DBUG_RETURN(table);
} }
......
...@@ -322,6 +322,7 @@ typedef struct st_schema_table ...@@ -322,6 +322,7 @@ typedef struct st_schema_table
struct st_lex; struct st_lex;
class select_union; class select_union;
class TMP_TABLE_PARAM;
struct Field_translator struct Field_translator
{ {
...@@ -370,6 +371,7 @@ typedef struct st_table_list ...@@ -370,6 +371,7 @@ typedef struct st_table_list
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */ ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex; st_select_lex *schema_select_lex;
bool schema_table_reformed; bool schema_table_reformed;
TMP_TABLE_PARAM *schema_table_param;
/* link to select_lex where this table was used */ /* link to select_lex where this table was used */
st_select_lex *select_lex; st_select_lex *select_lex;
st_lex *view; /* link on VIEW lex for merging */ st_lex *view; /* link on VIEW lex for merging */
......
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