From 25d0f827ce983a9f95ff17717e3f60649e985c69 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Sat, 13 Nov 2004 23:26:15 +0200 Subject: [PATCH] posmerge fixes --- mysql-test/r/view.result | 4 +- sql/item.cc | 3 -- sql/mysql_priv.h | 2 +- sql/sql_parse.cc | 24 ++++++------ sql/sql_select.cc | 3 -- sql/sql_show.cc | 85 ++++++++++++++++++++++------------------ sql/table.h | 2 +- 7 files changed, 64 insertions(+), 59 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 18fa7c2e37..f41e6c7e16 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1221,11 +1221,11 @@ ERROR 42000: FUNCTION test.x1 does not exist show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL -v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view +v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL FUNCTION test.x1 does not exist show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment t1 MyISAM 9 Fixed 0 0 0 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL -v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL view +v1 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL # # NULL NULL NULL NULL FUNCTION test.x1 does not exist drop view v1; drop table t1; create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1; diff --git a/sql/item.cc b/sql/item.cc index 42e1f23bab..ea721eea83 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1793,9 +1793,6 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) !any_privileges)) == not_found_field) { -#ifdef EMBEDDED_LIBRARY - thd->net.last_errno= 0; -#endif SELECT_LEX *last= 0; TABLE_LIST *table_list; Item **ref= (Item **) not_found_item; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index d3ff1a0ab0..7a49799c7c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -737,7 +737,7 @@ int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond); int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond); int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond); int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond); -int get_schema_tables_result(JOIN *join); +bool get_schema_tables_result(JOIN *join); /* sql_prepare.cc */ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dfd82f2750..11c02dacda 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1877,7 +1877,8 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, switch(schema_table_idx) { case SCH_SCHEMATA: #if defined(DONT_ALLOW_SHOW_COMMANDS) - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, + ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); #else if ((specialflag & SPECIAL_SKIP_SHOW_DB) && @@ -1889,30 +1890,30 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, case SCH_TABLES: case SCH_VIEWS: #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, + ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); #else { char *db= lex->select_lex.db ? lex->select_lex.db : thd->db; if (!db) { - send_error(thd,ER_NO_DB_ERROR); /* purecov: inspected */ + my_message(ER_NO_DB_ERROR, + ER(ER_NO_DB_ERROR), MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } remove_escape(db); // Fix escaped '_' if (check_db_name(db)) { - net_printf(thd,ER_WRONG_DB_NAME, db); + my_error(ER_WRONG_DB_NAME, MYF(0), db); DBUG_RETURN(1); } if (check_access(thd,SELECT_ACL,db,&thd->col_access,0,0)) DBUG_RETURN(1); /* purecov: inspected */ if (!thd->col_access && check_grant_db(thd,db)) { - net_printf(thd, ER_DBACCESS_DENIED_ERROR, - thd->priv_user, - thd->priv_host, - db); + my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), + thd->priv_user, thd->priv_host, db); DBUG_RETURN(1); } lex->select_lex.db= db; @@ -1922,7 +1923,8 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, case SCH_COLUMNS: case SCH_STATISTICS: #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_message(ER_NOT_ALLOWED_COMMAND, + ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); #else if (table_ident) @@ -5238,8 +5240,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->real_name); if (!schema_table) { - net_printf(thd, ER_UNKNOWN_TABLE, ptr->real_name, - information_schema_name.str); + my_error(ER_UNKNOWN_TABLE, MYF(0), + ptr->real_name, information_schema_name.str); DBUG_RETURN(0); } ptr->schema_table= schema_table; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 977e8c5c9c..bb620617db 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9770,9 +9770,6 @@ end_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { Item *item= *group->item; item->save_org_in_field(group->field); -#ifdef EMBEDDED_LIBRARY - join->thd->net.last_errno= 0; -#endif /* Store in the used key if the field was 0 */ if (item->maybe_null) group->buff[-1]=item->null_value ? 1 : 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4af041d1a9..c92369685e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1900,7 +1900,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) TABLE *old_open_tables= thd->open_tables; TABLE_LIST *show_table_list= (TABLE_LIST*) lsel->table_list.first; lex->all_selects_list= lsel; - int res= open_and_lock_tables(thd, show_table_list); + bool res= open_and_lock_tables(thd, show_table_list); if (schema_table->process_table(thd, show_table_list, table, res, show_table_list->db, show_table_list->real_name)) @@ -2060,9 +2060,10 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) } -int get_schema_tables_record(THD *thd, struct st_table_list *tables, - TABLE *table, int res, - const char *base_name, const char *file_name) +static int get_schema_tables_record(THD *thd, struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) { const char *tmp_buff; TIME time; @@ -2070,18 +2071,21 @@ int get_schema_tables_record(THD *thd, struct st_table_list *tables, DBUG_ENTER("get_schema_tables_record"); restore_record(table, default_values); - if (res > 0) - { - DBUG_RETURN(1); - } table->field[1]->store(base_name, strlen(base_name), cs); table->field[2]->store(file_name, strlen(file_name), cs); - if (res < 0 || tables->view) + if (res) + { + /* + there was errors during opening tables + */ + const char *error= thd->net.last_error; + table->field[20]->store(error, strlen(error), cs); + thd->clear_error(); + } + else if (tables->view) { table->field[3]->store("VIEW", 4, cs); table->field[20]->store("view", 4, cs); - if (res) - thd->clear_error(); } else { @@ -2203,9 +2207,10 @@ int get_schema_tables_record(THD *thd, struct st_table_list *tables, } -int get_schema_column_record(THD *thd, struct st_table_list *tables, - TABLE *table, int res, - const char *base_name, const char *file_name) +static int get_schema_column_record(THD *thd, struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) { TIME time; const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; @@ -2538,9 +2543,10 @@ err: } -int get_schema_stat_record(THD *thd, struct st_table_list *tables, - TABLE *table, int res, - const char *base_name, const char *file_name) +static int get_schema_stat_record(THD *thd, struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_stat_record"); @@ -2605,13 +2611,14 @@ int get_schema_stat_record(THD *thd, struct st_table_list *tables, } } } - DBUG_RETURN(0); + DBUG_RETURN(res); } -int get_schema_views_record(THD *thd, struct st_table_list *tables, - TABLE *table, int res, - const char *base_name, const char *file_name) +static int get_schema_views_record(THD *thd, struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_views_record"); @@ -2631,13 +2638,14 @@ int get_schema_views_record(THD *thd, struct st_table_list *tables, table->file->write_row(table->record[0]); } } - DBUG_RETURN(0); + DBUG_RETURN(res); } -int get_schema_constarints_record(THD *thd, struct st_table_list *tables, - TABLE *table, int res, - const char *base_name, const char *file_name) +static int get_schema_constarints_record(THD *thd, struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) { CHARSET_INFO *cs= system_charset_info; DBUG_ENTER("get_schema_constarints_record"); @@ -2684,14 +2692,15 @@ int get_schema_constarints_record(THD *thd, struct st_table_list *tables, table->file->write_row(table->record[0]); } } - DBUG_RETURN(0); + DBUG_RETURN(res); } -int get_schema_key_column_usage_record(THD *thd, struct st_table_list *tables, - TABLE *table, int res, - const char *base_name, - const char *file_name) +static int get_schema_key_column_usage_record(THD *thd, + struct st_table_list *tables, + TABLE *table, bool res, + const char *base_name, + const char *file_name) { DBUG_ENTER("get_schema_key_column_usage_record"); CHARSET_INFO *cs= system_charset_info; @@ -2707,7 +2716,7 @@ int get_schema_key_column_usage_record(THD *thd, struct st_table_list *tables, for (uint i=0 ; i < show_table->keys ; i++, key_info++) { if (i != primary_key && !(key_info->flags & HA_NOSAME)) - continue; + continue; uint f_idx= 0; KEY_PART_INFO *key_part= key_info->key_part; for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) @@ -2762,7 +2771,7 @@ int get_schema_key_column_usage_record(THD *thd, struct st_table_list *tables, } } } - DBUG_RETURN(0); + DBUG_RETURN(res); } @@ -3076,11 +3085,11 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, join join which use schema tables RETURN - 0 success - 1 error + FALSE success + TRUE error */ -int get_schema_tables_result(JOIN *join) +bool get_schema_tables_result(JOIN *join) { DBUG_ENTER("get_schema_tables_result"); JOIN_TAB *tmp_join_tab= join->join_tab+join->tables; @@ -3090,7 +3099,7 @@ int get_schema_tables_result(JOIN *join) if (!tab->table || !tab->table->pos_in_table_list) break; TABLE_LIST *table_list= tab->table->pos_in_table_list; - if (table_list->schema_table && !thd->only_prepare()) + if (table_list->schema_table && thd->fill_derived_tables()) { TABLE *old_derived_tables= thd->derived_tables; thd->derived_tables= 0; @@ -3103,14 +3112,14 @@ int get_schema_tables_result(JOIN *join) { thd->derived_tables= old_derived_tables; thd->lock= sql_lock; - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } thd->lock= sql_lock; thd->lex->sql_command= SQLCOM_SELECT; thd->derived_tables= old_derived_tables; } } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } diff --git a/sql/table.h b/sql/table.h index 86dd30dff6..db3ce63884 100644 --- a/sql/table.h +++ b/sql/table.h @@ -250,7 +250,7 @@ typedef struct st_schema_table /* Handle fileds for old SHOW */ int (*old_format) (THD *thd, struct st_schema_table *schema_table); int (*process_table) (THD *thd, struct st_table_list *tables, - TABLE *table, int res, const char *base_name, + TABLE *table, bool res, const char *base_name, const char *file_name); int idx_field1, idx_field2; } ST_SCHEMA_TABLE; -- 2.30.9