diff options
author | unknown <bell@sanja.is.com.ua> | 2004-10-20 04:04:37 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-10-20 04:04:37 +0300 |
commit | 066c90563a9fd6151461a5d54d879079acffe279 (patch) | |
tree | 55e6ec4a0a572c0be2ba69da166ea204bf96502e /sql | |
parent | 65ed693681b17414fc001099ee734f36de847f13 (diff) | |
download | mariadb-git-066c90563a9fd6151461a5d54d879079acffe279.tar.gz |
errors without code removed
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
(WL#2133)
include/mysqld_error.h:
new errors added.
mysql-test/r/rpl_charset.result:
new error
mysql-test/r/rpl_timezone.result:
new error
mysql-test/r/sp-security.result:
more clean error message
mysql-test/r/sp.result:
now error state intercepted correctly
mysql-test/t/connect.test:
new error message
mysql-test/t/rpl_charset.test:
new error message
mysql-test/t/rpl_timezone.test:
new error
mysql-test/t/sp-security.test:
more correct error handling
mysql-test/t/sp.test:
now error state intercepted correctly
sql/ha_innodb.cc:
-1/1 (sent/unsent) error reporting removed
sql/ha_innodb.h:
-1/1 (sent/unsent) error reporting removed
sql/item.cc:
only boolean values should be returned by fix_fields()
sql/item_cmpfunc.cc:
only boolean values should be returned by fix_fields()
sql/item_func.cc:
only boolean values should be returned by fix_fields()
net_printf/send_error calls replaced by my_error family functions
sql/item_row.cc:
only boolean values should be returned by fix_fields()
sql/item_subselect.cc:
only boolean values should be returned by fix_fields()
-1/1 (sent/unsent) error reporting removed
sql/item_subselect.h:
-1/1 (sent/unsent) error reporting removed
sql/item_sum.cc:
only boolean values should be returned by fix_fields()
sql/item_timefunc.cc:
only boolean values should be returned by fix_fields()
sql/item_uniq.h:
only boolean values should be returned by fix_fields()
sql/mysql_priv.h:
-1/1 (sent/unsent) error reporting removed
sql/mysqld.cc:
net_printf/send_error calls replaced by my_error family functions
changes in my_message_sql to support error handling correctly
sql/protocol.cc:
net_printf/send_error calls replaced by my_error family functions
sql/protocol_cursor.cc:
net_printf/send_error calls replaced by my_error family functions
sql/repl_failsafe.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/repl_failsafe.h:
-1/1 (sent/unsent) error reporting removed
sql/set_var.cc:
net_printf/send_error calls replaced by my_error family functions
sql/share/czech/errmsg.txt:
new error messages
sql/share/danish/errmsg.txt:
new error messages
sql/share/dutch/errmsg.txt:
new error messages
sql/share/english/errmsg.txt:
new error messages
sql/share/estonian/errmsg.txt:
new error messages
sql/share/french/errmsg.txt:
new error messages
sql/share/german/errmsg.txt:
new error messages
sql/share/greek/errmsg.txt:
new error messages
sql/share/hungarian/errmsg.txt:
new error messages
sql/share/italian/errmsg.txt:
new error messages
sql/share/japanese/errmsg.txt:
new error messages
sql/share/korean/errmsg.txt:
new error messages
sql/share/norwegian-ny/errmsg.txt:
new error messages
sql/share/norwegian/errmsg.txt:
new error messages
sql/share/polish/errmsg.txt:
new error messages
sql/share/portuguese/errmsg.txt:
new error messages
sql/share/romanian/errmsg.txt:
new error messages
sql/share/russian/errmsg.txt:
new error messages
sql/share/serbian/errmsg.txt:
new error messages
sql/share/slovak/errmsg.txt:
new error messages
sql/share/spanish/errmsg.txt:
new error messages
sql/share/swedish/errmsg.txt:
new error messages
sql/share/ukrainian/errmsg.txt:
new error messages
sql/slave.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/slave.h:
-1/1 (sent/unsent) error reporting removed
sql/sp.cc:
net_printf/send_error calls replaced by my_error family functions
sql/sp_head.cc:
new eror handling support
net_printf/send_error calls replaced by my_error family functions
sql/sp_rcontext.cc:
net_printf/send_error calls replaced by my_error family functions
sql/sql_acl.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/sql_acl.h:
-1/1 (sent/unsent) error reporting removed
sql/sql_base.cc:
-1/1 (sent/unsent) error reporting removed
net_printf/send_error calls replaced by my_error family functions
sql/sql_class.cc:
net_printf/send_error calls replaced by my_error family functions
sql/sql_class.h:
my_messhage_sql now set/reset query_error flag
sql/sql_db.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_delete.cc:
-1/1 (sent/unsent) error reporting removed
net_printf/send_error calls replaced by my_error family functions
sql/sql_do.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_error.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_handler.cc:
-1/1 (sent/unsent) error reporting removed
net_printf/send_error calls replaced by my_error family functions
sql/sql_help.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/sql_insert.cc:
-1/1 (sent/unsent) error reporting removed
net_printf/send_error calls replaced by my_error family functions
sql/sql_lex.h:
-1/1 (sent/unsent) error reporting removed
sql/sql_load.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_map.cc:
errors without code removed
sql/sql_parse.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed from mysql_execute_command
sql/sql_prepare.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/sql_repl.cc:
error messages fixed
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/sql_repl.h:
-1/1 (sent/unsent) error reporting removed
sql/sql_select.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_select.h:
-1/1 (sent/unsent) error reporting removed
sql/sql_show.cc:
-1/1 (sent/unsent) error reporting removed
net_printf/send_error calls replaced by my_error family functions
sql/sql_table.cc:
net_printf/send_error calls replaced by my_error family functions
-1/1 (sent/unsent) error reporting removed
sql/sql_trigger.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_udf.cc:
net_printf/send_error calls replaced by my_error family functions
sql/sql_union.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_update.cc:
-1/1 (sent/unsent) error reporting removed
net_printf/send_error calls replaced by my_error family functions
sql/sql_view.cc:
-1/1 (sent/unsent) error reporting removed
sql/sql_view.h:
-1/1 (sent/unsent) error reporting removed
sql/sql_yacc.yy:
net_printf/send_error calls replaced by my_error family functions
Diffstat (limited to 'sql')
76 files changed, 1825 insertions, 1549 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 4d068cfc0ce..7c911ca60bd 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4821,7 +4821,7 @@ ha_innobase::external_lock( Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB Monitor to the client. */ -int +bool innodb_show_status( /*===============*/ THD* thd) /* in: the MySQL query thread of the caller */ @@ -4835,7 +4835,7 @@ innodb_show_status( my_message(ER_NOT_SUPPORTED_YET, "Cannot call SHOW INNODB STATUS because skip-innodb is defined", MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } trx = check_trx_exists(thd); @@ -4864,7 +4864,7 @@ innodb_show_status( if (!(str = my_malloc(flen + 1, MYF(0)))) { mutex_exit_noninline(&srv_monitor_file_mutex); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } rewind(srv_monitor_file); @@ -4881,7 +4881,7 @@ innodb_show_status( my_free(str, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } protocol->prepare_for_resend(); @@ -4889,10 +4889,10 @@ innodb_show_status( my_free(str, MYF(0)); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } /**************************************************************************** diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index fa3e9f012e8..a2017d59cc3 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -222,7 +222,7 @@ int innobase_savepoint( my_off_t binlog_cache_pos); int innobase_close_connection(THD *thd); int innobase_drop_database(char *path); -int innodb_show_status(THD* thd); +bool innodb_show_status(THD* thd); my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, uint full_name_len); diff --git a/sql/item.cc b/sql/item.cc index 267560b0709..813eaf41b45 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1279,7 +1279,7 @@ bool Item::fix_fields(THD *thd, // We do not check fields which are fixed during construction DBUG_ASSERT(fixed == 0 || basic_const_item()); fixed= 1; - return 0; + return FALSE; } double Item_ref_null_helper::val() @@ -1447,9 +1447,9 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } } if (!tmp) - return -1; + return TRUE; if (!refer) - return 1; + return TRUE; if (tmp == not_found_field && refer == (Item **)not_found_item) { if (upward_lookup) @@ -1463,7 +1463,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) // Call to report error find_field_in_tables(thd, this, tables, ref, 1, 1); } - return -1; + return TRUE; } else if (refer != (Item **)not_found_item) { @@ -1471,7 +1471,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, "forward reference in item list"); - return -1; + return TRUE; } Item_ref *rf; @@ -1481,16 +1481,16 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) (char *)field_name); register_item_tree_changing(ref); if (!rf) - return 1; + return TRUE; /* rf is Item_ref => never substitute other items (in this case) during fix_fields() => we can use rf after fix_fields() */ if (rf->fix_fields(thd, tables, ref) || rf->check_cols(1)) - return 1; + return TRUE; mark_as_dependent(thd, last, cursel, rf); - return 0; + return FALSE; } else { @@ -1503,7 +1503,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) (char *)cached_table->alias, (char *)field_name); if (!rf) - return 1; + return TRUE; /* rf is Item_ref => never substitute other items (in this case) during fix_fields() => we can use rf after fix_fields() @@ -1513,7 +1513,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } } else if (!tmp) - return -1; + return TRUE; /* if it is not expression from merged VIEW we will set this field. @@ -1564,12 +1564,12 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) thd->host_or_ip, field_name, tab); - return 1; + return TRUE; } } #endif fixed= 1; - return 0; + return FALSE; } void Item_field::cleanup() @@ -2209,9 +2209,9 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) } if (!ref) - return 1; + return TRUE; else if (!tmp) - return -1; + return TRUE; else if (ref == (Item **)not_found_item && tmp == not_found_field) { if (upward_lookup) @@ -2229,7 +2229,7 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) REPORT_ALL_ERRORS); } ref= 0; - return 1; + return TRUE; } else if (tmp != not_found_field) { @@ -2238,10 +2238,10 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) { Item_field* fld; if (!((*reference)= fld= new Item_field(tmp))) - return 1; + return TRUE; mark_as_dependent(thd, last, thd->lex->current_select, fld); register_item_tree_changing(reference); - return 0; + return FALSE; } /* We can leave expression substituted from view for next PS/SP @@ -2261,7 +2261,7 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) { my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, "forward reference in item list"); - return -1; + return TRUE; } mark_as_dependent(thd, last, thd->lex->current_select, this); @@ -2269,14 +2269,14 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) } } else if (!ref) - return 1; + return TRUE; else { if (!(*ref)->fixed) { my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, "forward reference in item list"); - return -1; + return TRUE; } ref= thd->lex->current_select->ref_pointer_array + counter; } @@ -2299,7 +2299,7 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) ((*ref)->with_sum_func? "reference on group function": "forward reference in item list")); - return 1; + return TRUE; } max_length= (*ref)->max_length; maybe_null= (*ref)->maybe_null; @@ -2309,8 +2309,8 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) fixed= 1; if (ref && (*ref)->check_cols(1)) - return 1; - return 0; + return TRUE; + return FALSE; } @@ -2416,17 +2416,17 @@ bool Item_default_value::fix_fields(THD *thd, if (!arg) { fixed= 1; - return 0; + return FALSE; } if (arg->fix_fields(thd, table_list, &arg)) - return 1; + return TRUE; if (arg->type() == REF_ITEM) { Item_ref *ref= (Item_ref *)arg; if (ref->ref[0]->type() != FIELD_ITEM) { - return 1; + return TRUE; } arg= ref->ref[0]; } @@ -2435,16 +2435,16 @@ bool Item_default_value::fix_fields(THD *thd, { my_printf_error(ER_NO_DEFAULT_FOR_FIELD, ER(ER_NO_DEFAULT_FOR_FIELD), MYF(0), field_arg->field->field_name); - return 1; + return TRUE; } if (!(def_field= (Field*) sql_alloc(field_arg->field->size_of()))) - return 1; + return TRUE; memcpy(def_field, field_arg->field, field_arg->field->size_of()); def_field->move_field(def_field->table->default_values - def_field->table->record[0]); set_field(def_field); fixed= 1; - return 0; + return FALSE; } void Item_default_value::print(String *str) @@ -2472,14 +2472,14 @@ bool Item_insert_value::fix_fields(THD *thd, { DBUG_ASSERT(fixed == 0); if (arg->fix_fields(thd, table_list, &arg)) - return 1; + return TRUE; if (arg->type() == REF_ITEM) { Item_ref *ref= (Item_ref *)arg; if (ref->ref[0]->type() != FIELD_ITEM) { - return 1; + return TRUE; } arg= ref->ref[0]; } @@ -2488,7 +2488,7 @@ bool Item_insert_value::fix_fields(THD *thd, { Field *def_field= (Field*) sql_alloc(field_arg->field->size_of()); if (!def_field) - return 1; + return TRUE; memcpy(def_field, field_arg->field, field_arg->field->size_of()); def_field->move_field(def_field->table->insert_values - def_field->table->record[0]); @@ -2502,7 +2502,7 @@ bool Item_insert_value::fix_fields(THD *thd, tmp_field->table, &my_charset_bin)); } fixed= 1; - return 0; + return FALSE; } void Item_insert_value::print(String *str) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 582277cd142..252c6d29f5e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -631,17 +631,17 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables, { DBUG_ASSERT(fixed == 0); if (fix_left(thd, tables, ref)) - return 1; + return TRUE; if (args[0]->maybe_null) maybe_null=1; if (!args[1]->fixed && args[1]->fix_fields(thd, tables, args+1)) - return 1; + return TRUE; Item_in_subselect * sub= (Item_in_subselect *)args[1]; if (args[0]->cols() != sub->engine->cols()) { my_error(ER_OPERAND_COLUMNS, MYF(0), args[0]->cols()); - return 1; + return TRUE; } if (args[1]->maybe_null) maybe_null=1; @@ -650,7 +650,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables, not_null_tables_cache|= args[1]->not_null_tables(); const_item_cache&= args[1]->const_item(); fixed= 1; - return 0; + return FALSE; } @@ -1964,7 +1964,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) and_tables_cache= ~(table_map) 0; if (check_stack_overrun(thd, buff)) - return 1; // Fatal error flag is set! + return TRUE; // Fatal error flag is set! while ((item=li++)) { table_map tmp_table_map; @@ -1982,7 +1982,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if ((!item->fixed && item->fix_fields(thd, tables, li.ref())) || (item= *li.ref())->check_cols(1)) - return 1; /* purecov: inspected */ + return TRUE; /* purecov: inspected */ used_tables_cache|= item->used_tables(); tmp_table_map= item->not_null_tables(); not_null_tables_cache|= tmp_table_map; @@ -1995,7 +1995,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) thd->lex->current_select->cond_count+= list.elements; fix_length_and_dec(); fixed= 1; - return 0; + return FALSE; } bool Item_cond::walk(Item_processor processor, byte *arg) @@ -2306,12 +2306,12 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) DBUG_ASSERT(fixed == 0); if (Item_bool_func2::fix_fields(thd, tlist, ref) || escape_item->fix_fields(thd, tlist, &escape_item)) - return 1; + return TRUE; if (!escape_item->const_during_execution()) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE"); - return 1; + return TRUE; } if (escape_item->const_item()) @@ -2329,7 +2329,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) { String* res2 = args[1]->val_str(&tmp_value2); if (!res2) - return 0; // Null argument + return FALSE; // Null argument const size_t len = res2->length(); const char* first = res2->ptr(); @@ -2362,7 +2362,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) } } } - return 0; + return FALSE; } #ifdef USE_REGEX @@ -2373,13 +2373,13 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); if (args[0]->fix_fields(thd, tables, args) || args[0]->check_cols(1) || args[1]->fix_fields(thd,tables, args + 1) || args[1]->check_cols(1)) - return 1; /* purecov: inspected */ + return TRUE; /* purecov: inspected */ with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func; max_length= 1; decimals= 0; if (agg_arg_collations(cmp_collation, args, 2)) - return 1; + return TRUE; used_tables_cache=args[0]->used_tables() | args[1]->used_tables(); not_null_tables_cache= (args[0]->not_null_tables() | @@ -2393,7 +2393,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (args[1]->null_value) { // Will always return NULL maybe_null=1; - return 0; + return FALSE; } int error; if ((error=regcomp(&preg,res->c_ptr(), @@ -2404,7 +2404,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { (void) regerror(error,&preg,buff,sizeof(buff)); my_printf_error(ER_REGEXP_ERROR,ER(ER_REGEXP_ERROR),MYF(0),buff); - return 1; + return TRUE; } regex_compiled=regex_is_const=1; maybe_null=args[0]->maybe_null; @@ -2412,7 +2412,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) else maybe_null=1; fixed= 1; - return 0; + return FALSE; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 4aec7fea2d4..38f0d514314 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -199,8 +199,8 @@ Item_func::Item_func(THD *thd, Item_func *item) item. RETURN VALUES - 0 ok - 1 Got error. Stored with my_error(). + FALSE ok + TRUE Got error. Stored with my_error(). */ bool @@ -216,7 +216,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) const_item_cache=1; if (check_stack_overrun(thd, buff)) - return 1; // Fatal error if flag is set! + return TRUE; // Fatal error if flag is set! if (arg_count) { // Print purify happy for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++) @@ -228,7 +228,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) */ if ((!(*arg)->fixed && (*arg)->fix_fields(thd, tables, arg)) || (*arg)->check_cols(allowed_arg_cols)) - return 1; /* purecov: inspected */ + return TRUE; /* purecov: inspected */ item= *arg; if (item->maybe_null) maybe_null=1; @@ -240,10 +240,10 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } } fix_length_and_dec(); - if (thd->net.last_errno) // An error inside fix_length_and_dec occured - return 1; + if (thd->net.report_error) // An error inside fix_length_and_dec occured + return TRUE; fixed= 1; - return 0; + return FALSE; } bool Item_func::walk (Item_processor processor, byte *argument) @@ -1568,7 +1568,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, DBUG_ENTER("Item_udf_func::fix_fields"); if (check_stack_overrun(thd, buff)) - DBUG_RETURN(1); // Fatal error flag is set! + DBUG_RETURN(TRUE); // Fatal error flag is set! udf_func *tmp_udf=find_udf(u_d->name.str,(uint) u_d->name.length,1); @@ -1576,7 +1576,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, { my_printf_error(ER_CANT_FIND_UDF,ER(ER_CANT_FIND_UDF),MYF(0),u_d->name.str, errno); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } u_d=tmp_udf; args=arguments; @@ -1593,7 +1593,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, { free_udf(u_d); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } uint i; Item **arg,**arg_end; @@ -1606,7 +1606,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, // we can't assign 'item' before, because fix_fields() can change arg Item *item= *arg; if (item->check_cols(1)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); /* TODO: We should think about this. It is not always right way just to set an UDF result to return my_charset_bin @@ -1639,7 +1639,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, sizeof(long)))) { free_udf(u_d); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } func->fix_length_and_dec(); @@ -1698,7 +1698,7 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, my_printf_error(ER_CANT_INITIALIZE_UDF,ER(ER_CANT_INITIALIZE_UDF),MYF(0), u_d->name.str, thd->net.last_error); free_udf(u_d); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } func->max_length=min(initid.max_length,MAX_BLOB_WIDTH); func->maybe_null=initid.maybe_null; @@ -1710,9 +1710,9 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, { my_printf_error(ER_CANT_INITIALIZE_UDF,ER(ER_CANT_INITIALIZE_UDF),MYF(0), u_d->name.str, ER(ER_UNKNOWN_ERROR)); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -2322,7 +2322,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables, /* fix_fields will call Item_func_set_user_var::fix_length_and_dec */ if (Item_func::fix_fields(thd, tables, ref) || !(entry= get_variable(&thd->user_vars, name, 1))) - return 1; + return TRUE; /* Remember the last query which updated it, this way a query can later know if this variable is a constant item in the query (it is if update_query_id @@ -2331,7 +2331,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables, entry->update_query_id= thd->query_id; entry->collation.set(args[0]->collation); cached_result_type= args[0]->result_type(); - return 0; + return FALSE; } @@ -2490,7 +2490,7 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, will be catched by thd->net.report_error check in sql_set_variables(). RETURN - 0 - OK. + FALSE OK. */ bool @@ -2520,7 +2520,7 @@ Item_func_set_user_var::check() DBUG_ASSERT(0); break; } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -2968,7 +2968,7 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) !args[0]->const_during_execution()) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"AGAINST"); - return 1; + return TRUE; } const_item_cache=0; @@ -2991,7 +2991,7 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) if (key == NO_SUCH_KEY && !(flags & FT_BOOL)) { my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH"); - return 1; + return TRUE; } table=((Item_field *)item)->field->table; table->fulltext_searched=1; @@ -3202,7 +3202,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, { if (!var->is_struct()) { - net_printf(thd, ER_VARIABLE_IS_NOT_STRUCT, base_name->str); + my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), base_name->str); return 0; } } diff --git a/sql/item_row.cc b/sql/item_row.cc index f6623e80734..0cfe8287dcb 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -62,7 +62,7 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++) { if ((*arg)->fix_fields(thd, tabl, arg)) - return 1; + return TRUE; // we can't assign 'item' before, because fix_fields() can change arg Item *item= *arg; used_tables_cache |= item->used_tables(); @@ -81,7 +81,7 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) with_sum_func= with_sum_func || item->with_sum_func; } fixed= 1; - return 0; + return FALSE; } void Item_row::split_sum_func(Item **ref_pointer_array, List<Item> &fields) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 25bb2701101..8fe6e5c81dd 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -66,7 +66,7 @@ void Item_subselect::init(st_select_lex *select_lex, parsing_place= unit->item->parsing_place; unit->item->engine= 0; unit->item= this; - engine->change_item(this, result); + engine->change_result(this, result); } else { @@ -133,13 +133,13 @@ Item_subselect::select_transformer(JOIN *join) bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) { char const *save_where= thd_param->where; - int res; + bool res; DBUG_ASSERT(fixed == 0); engine->set_thd((thd= thd_param)); if (check_stack_overrun(thd, (gptr)&res)) - return 1; + return TRUE; res= engine->prepare(); @@ -168,7 +168,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) if (substype() == SINGLEROW_SUBS && (*ref)->with_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0)); - return 1; + return TRUE; } return ret; } @@ -176,7 +176,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) if (engine->cols() > max_columns) { my_error(ER_OPERAND_COLUMNS, MYF(0), 1); - return 1; + return TRUE; } fix_length_and_dec(); } @@ -1493,12 +1493,12 @@ void subselect_indexsubquery_engine::print(String *str) res new select_result object RETURN - 0 OK - -1 error + FALSE OK + TRUE error */ -int subselect_single_select_engine::change_item(Item_subselect *si, - select_subselect *res) +bool subselect_single_select_engine::change_result(Item_subselect *si, + select_subselect *res) { item= si; result= res; @@ -1515,12 +1515,12 @@ int subselect_single_select_engine::change_item(Item_subselect *si, res new select_result object RETURN - 0 OK - -1 error + FALSE OK + TRUE error */ -int subselect_union_engine::change_item(Item_subselect *si, - select_subselect *res) +bool subselect_union_engine::change_result(Item_subselect *si, + select_subselect *res) { item= si; int rc= unit->change_result(res, result); @@ -1538,12 +1538,13 @@ int subselect_union_engine::change_item(Item_subselect *si, res new select_result object RETURN - -1 error + FALSE OK + TRUE error */ -int subselect_uniquesubquery_engine::change_item(Item_subselect *si, - select_subselect *res) +bool subselect_uniquesubquery_engine::change_result(Item_subselect *si, + select_subselect *res) { DBUG_ASSERT(0); - return -1; + return TRUE; } diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 4a325c4b224..e45cd6911e9 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -290,7 +290,7 @@ public: virtual table_map upper_select_const_tables()= 0; static table_map calc_const_tables(TABLE_LIST *); virtual void print(String *str)= 0; - virtual int change_item(Item_subselect *si, select_subselect *result)= 0; + virtual bool change_result(Item_subselect *si, select_subselect *result)= 0; }; @@ -314,7 +314,7 @@ public: void exclude(); table_map upper_select_const_tables(); void print (String *str); - int change_item(Item_subselect *si, select_subselect *result); + bool change_result(Item_subselect *si, select_subselect *result); }; @@ -334,7 +334,7 @@ public: void exclude(); table_map upper_select_const_tables(); void print (String *str); - int change_item(Item_subselect *si, select_subselect *result); + bool change_result(Item_subselect *si, select_subselect *result); }; @@ -363,7 +363,7 @@ public: void exclude(); table_map upper_select_const_tables() { return 0; } void print (String *str); - int change_item(Item_subselect *si, select_subselect *result); + bool change_result(Item_subselect *si, select_subselect *result); }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index d400c198828..bf3601931ca 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -215,12 +215,12 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); if (save_args_for_prepared_statement(thd)) - return 1; + return TRUE; if (!thd->allow_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); - return 1; + return TRUE; } thd->allow_sum_func=0; // No included group funcs decimals=0; @@ -228,7 +228,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) for (uint i=0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) - return 1; + return TRUE; if (decimals < args[i]->decimals) decimals=args[i]->decimals; maybe_null |= args[i]->maybe_null; @@ -239,7 +239,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) fix_length_and_dec(); thd->allow_sum_func=1; // Allow group functions fixed= 1; - return 0; + return FALSE; } @@ -249,13 +249,13 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); if (save_args_for_prepared_statement(thd)) - return 1; + return TRUE; Item *item= args[0]; if (!thd->allow_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); - return 1; + return TRUE; } thd->allow_sum_func=0; // No included group funcs @@ -263,7 +263,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (!item->fixed && item->fix_fields(thd, tables, args) || (item= args[0])->check_cols(1)) - return 1; + return TRUE; hybrid_type= item->result_type(); if (hybrid_type == INT_RESULT) @@ -294,7 +294,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) else hybrid_field_type= Item::field_type(); fixed= 1; - return 0; + return FALSE; } @@ -2060,12 +2060,12 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); if (save_args_for_prepared_statement(thd)) - return 1; + return TRUE; if (!thd->allow_sum_func) { my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0)); - return 1; + return TRUE; } thd->allow_sum_func= 0; @@ -2079,7 +2079,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) for (i=0 ; i < arg_count ; i++) { if (args[i]->fix_fields(thd, tables, args + i) || args[i]->check_cols(1)) - return 1; + return TRUE; if (i < arg_count_field) maybe_null|= args[i]->maybe_null; } @@ -2089,10 +2089,10 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) max_length= group_concat_max_len; thd->allow_sum_func= 1; if (!(tmp_table_param= new TMP_TABLE_PARAM)) - return 1; + return TRUE; tables_list= tables; fixed= 1; - return 0; + return FALSE; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 988529c845c..76aa06bf7cc 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1671,7 +1671,7 @@ Item_func_convert_tz::fix_fields(THD *thd_arg, TABLE_LIST *tables_arg, Item **re { String str; if (Item_date_func::fix_fields(thd_arg, tables_arg, ref)) - return 1; + return TRUE; tz_tables= thd_arg->lex->time_zone_tables_used; @@ -1681,7 +1681,7 @@ Item_func_convert_tz::fix_fields(THD *thd_arg, TABLE_LIST *tables_arg, Item **re if (args[2]->const_item()) to_tz= my_tz_find(args[2]->val_str(&str), tz_tables); - return 0; + return FALSE; } diff --git a/sql/item_uniq.h b/sql/item_uniq.h index 5582537bdbb..c69bd02ae5b 100644 --- a/sql/item_uniq.h +++ b/sql/item_uniq.h @@ -50,7 +50,7 @@ public: { DBUG_ASSERT(fixed == 0); fixed= 1; - return 0; + return FALSE; } Item *copy_or_same(THD* thd) { diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index b4fba907fbf..99fc54fd73b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -418,17 +418,17 @@ bool check_one_table_access(THD *thd, ulong privilege, bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table); bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list); -int multi_update_precheck(THD *thd, TABLE_LIST *tables); -int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count); -int mysql_multi_update_prepare(THD *thd); -int mysql_multi_delete_prepare(THD *thd); -int mysql_insert_select_prepare(THD *thd); -int insert_select_precheck(THD *thd, TABLE_LIST *tables); -int update_precheck(THD *thd, TABLE_LIST *tables); -int delete_precheck(THD *thd, TABLE_LIST *tables); -int insert_precheck(THD *thd, TABLE_LIST *tables, bool update); -int create_table_precheck(THD *thd, TABLE_LIST *tables, - TABLE_LIST *create_table); +bool multi_update_precheck(THD *thd, TABLE_LIST *tables); +bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count); +bool mysql_multi_update_prepare(THD *thd); +bool mysql_multi_delete_prepare(THD *thd); +bool mysql_insert_select_prepare(THD *thd); +bool insert_select_precheck(THD *thd, TABLE_LIST *tables); +bool update_precheck(THD *thd, TABLE_LIST *tables); +bool delete_precheck(THD *thd, TABLE_LIST *tables); +bool insert_precheck(THD *thd, TABLE_LIST *tables, bool update); +bool create_table_precheck(THD *thd, TABLE_LIST *tables, + TABLE_LIST *create_table); Item *negate_expression(THD *thd, Item *expr); #include "sql_class.h" #include "opt_range.h" @@ -475,12 +475,12 @@ struct Query_cache_query_flags #define prepare_execute(A) ((A)->command == COM_EXECUTE) -int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); -int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create); -int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent); +bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); +bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create); +bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent); void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags); -int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, - my_bool drop_temporary); +bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, + my_bool drop_temporary); int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, bool drop_temporary, bool drop_view, bool log_query); int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, @@ -507,7 +507,7 @@ extern "C" pthread_handler_decl(handle_one_connection,arg); extern "C" pthread_handler_decl(handle_bootstrap,arg); void end_thread(THD *thd,bool put_in_cache); void flush_thread_cache(); -int mysql_execute_command(THD *thd); +bool mysql_execute_command(THD *thd); bool do_command(THD *thd); bool dispatch_command(enum enum_server_command command, THD *thd, char* packet, uint packet_length); @@ -526,22 +526,22 @@ bool check_table_access(THD *thd, ulong want_access, TABLE_LIST *tables, bool no_errors); bool check_global_access(THD *thd, ulong want_access); -int mysql_backup_table(THD* thd, TABLE_LIST* table_list); -int mysql_restore_table(THD* thd, TABLE_LIST* table_list); - -int mysql_checksum_table(THD* thd, TABLE_LIST* table_list, - HA_CHECK_OPT* check_opt); -int mysql_check_table(THD* thd, TABLE_LIST* table_list, - HA_CHECK_OPT* check_opt); -int mysql_repair_table(THD* thd, TABLE_LIST* table_list, - HA_CHECK_OPT* check_opt); -int mysql_analyze_table(THD* thd, TABLE_LIST* table_list, - HA_CHECK_OPT* check_opt); -int mysql_optimize_table(THD* thd, TABLE_LIST* table_list, - HA_CHECK_OPT* check_opt); -int mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, - LEX_STRING *key_cache_name); -int mysql_preload_keys(THD* thd, TABLE_LIST* table_list); +bool mysql_backup_table(THD* thd, TABLE_LIST* table_list); +bool mysql_restore_table(THD* thd, TABLE_LIST* table_list); + +bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list, + HA_CHECK_OPT* check_opt); +bool mysql_check_table(THD* thd, TABLE_LIST* table_list, + HA_CHECK_OPT* check_opt); +bool mysql_repair_table(THD* thd, TABLE_LIST* table_list, + HA_CHECK_OPT* check_opt); +bool mysql_analyze_table(THD* thd, TABLE_LIST* table_list, + HA_CHECK_OPT* check_opt); +bool mysql_optimize_table(THD* thd, TABLE_LIST* table_list, + HA_CHECK_OPT* check_opt); +bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, + LEX_STRING *key_cache_name); +bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list); int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, KEY_CACHE *dst_cache); @@ -554,20 +554,20 @@ int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List<Item> &fields, List<Item> &all_fields, ORDER *order, bool *hidden_group_fields); -int handle_select(THD *thd, LEX *lex, select_result *result); -int mysql_select(THD *thd, Item ***rref_pointer_array, - TABLE_LIST *tables, uint wild_num, List<Item> &list, - COND *conds, uint og_num, ORDER *order, ORDER *group, - Item *having, ORDER *proc_param, ulong select_type, - select_result *result, SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex); +bool handle_select(THD *thd, LEX *lex, select_result *result); +bool mysql_select(THD *thd, Item ***rref_pointer_array, + TABLE_LIST *tables, uint wild_num, List<Item> &list, + COND *conds, uint og_num, ORDER *order, ORDER *group, + Item *having, ORDER *proc_param, ulong select_type, + select_result *result, SELECT_LEX_UNIT *unit, + SELECT_LEX *select_lex); void free_underlaid_joins(THD *thd, SELECT_LEX *select); -int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, - select_result *result); +bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, + select_result *result); int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type, select_result *result); -int mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit); +bool mysql_union(THD *thd, LEX *lex, select_result *result, + SELECT_LEX_UNIT *unit); int mysql_handle_derived(LEX *lex); Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, @@ -577,61 +577,61 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, List<Key> &keys, uint &db_options, handler *file, KEY *&key_info_buffer, uint &key_count, int select_field_count); -int mysql_create_table(THD *thd,const char *db, const char *table_name, - HA_CREATE_INFO *create_info, - List<create_field> &fields, List<Key> &keys, - bool tmp_table, uint select_field_count); +bool mysql_create_table(THD *thd,const char *db, const char *table_name, + HA_CREATE_INFO *create_info, + List<create_field> &fields, List<Key> &keys, + bool tmp_table, uint select_field_count); TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, TABLE_LIST *create_table, List<create_field> *extra_fields, List<Key> *keys, List<Item> *items, - MYSQL_LOCK **lock); -int mysql_alter_table(THD *thd, char *new_db, char *new_name, - HA_CREATE_INFO *create_info, - TABLE_LIST *table_list, - List<create_field> &fields, - List<Key> &keys, - uint order_num, ORDER *order, - enum enum_duplicates handle_duplicates, - ALTER_INFO *alter_info, bool do_send_ok=1); -int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok); -int mysql_create_like_table(THD *thd, TABLE_LIST *table, - HA_CREATE_INFO *create_info, - Table_ident *src_table); + MYSQL_LOCK **lock); +bool mysql_alter_table(THD *thd, char *new_db, char *new_name, + HA_CREATE_INFO *create_info, + TABLE_LIST *table_list, + List<create_field> &fields, + List<Key> &keys, + uint order_num, ORDER *order, + enum enum_duplicates handle_duplicates, + ALTER_INFO *alter_info, bool do_send_ok=1); +bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok); +bool mysql_create_like_table(THD *thd, TABLE_LIST *table, + HA_CREATE_INFO *create_info, + Table_ident *src_table); bool mysql_rename_table(enum db_type base, const char *old_db, const char * old_name, const char *new_db, const char * new_name); -int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys); -int mysql_drop_index(THD *thd, TABLE_LIST *table_list, - ALTER_INFO *alter_info); +bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys); +bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, + ALTER_INFO *alter_info); int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, Item **conds, uint order_num, ORDER *order); -int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields, - List<Item> &values,COND *conds, - uint order_num, ORDER *order, ha_rows limit, - enum enum_duplicates handle_duplicates); -int mysql_multi_update(THD *thd, TABLE_LIST *table_list, - List<Item> *fields, List<Item> *values, - COND *conds, ulong options, - enum enum_duplicates handle_duplicates, - SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); -int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, - List<Item> &fields, List_item *values, - List<Item> &update_fields, - List<Item> &update_values, enum_duplicates duplic); -int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, - List<List_item> &values, List<Item> &update_fields, - List<Item> &update_values, enum_duplicates flag); +bool mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields, + List<Item> &values,COND *conds, + uint order_num, ORDER *order, ha_rows limit, + enum enum_duplicates handle_duplicates); +bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, + List<Item> *fields, List<Item> *values, + COND *conds, ulong options, + enum enum_duplicates handle_duplicates, + SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); +bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, + List<Item> &fields, List_item *values, + List<Item> &update_fields, + List<Item> &update_values, enum_duplicates duplic); +bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, + List<List_item> &values, List<Item> &update_fields, + List<Item> &update_values, enum_duplicates flag); int check_that_all_fields_are_given_values(THD *thd, TABLE *entry); -int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds); -int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order, - ha_rows rows, ulong options); -int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok); -int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create); +bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds); +bool mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order, + ha_rows rows, ulong options); +bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok); +bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create); TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update); TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem, bool *refresh); @@ -683,45 +683,45 @@ void free_des_key_file(); #endif /* HAVE_OPENSSL */ /* sql_do.cc */ -int mysql_do(THD *thd, List<Item> &values); +bool mysql_do(THD *thd, List<Item> &values); /* sql_show.cc */ -int mysqld_show_dbs(THD *thd,const char *wild); -int mysqld_show_open_tables(THD *thd,const char *wild); -int mysqld_show_tables(THD *thd, const char *db, const char *wild, - bool verbose); -int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild); -int mysqld_show_fields(THD *thd,TABLE_LIST *table, const char *wild, - bool verbose); -int mysqld_show_keys(THD *thd, TABLE_LIST *table); -int mysqld_show_logs(THD *thd); +bool mysqld_show_dbs(THD *thd,const char *wild); +bool mysqld_show_open_tables(THD *thd,const char *wild); +bool mysqld_show_tables(THD *thd, const char *db, const char *wild, + bool verbose); +bool mysqld_extend_show_tables(THD *thd,const char *db,const char *wild); +bool mysqld_show_fields(THD *thd,TABLE_LIST *table, const char *wild, + bool verbose); +bool mysqld_show_keys(THD *thd, TABLE_LIST *table); +bool mysqld_show_logs(THD *thd); void append_identifier(THD *thd, String *packet, const char *name, uint length); void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1); -int mysqld_show_create(THD *thd, TABLE_LIST *table_list); -int mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); +bool mysqld_show_create(THD *thd, TABLE_LIST *table_list); +bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); void mysqld_list_processes(THD *thd,const char *user,bool verbose); int mysqld_show_status(THD *thd); int mysqld_show_variables(THD *thd,const char *wild); -int mysqld_show(THD *thd, const char *wild, show_var_st *variables, +bool mysqld_show(THD *thd, const char *wild, show_var_st *variables, enum enum_var_type value_type, pthread_mutex_t *mutex, struct system_status_var *status_var); int mysql_find_files(THD *thd,List<char> *files, const char *db, const char *path, const char *wild, bool dir); -int mysqld_show_charsets(THD *thd,const char *wild); -int mysqld_show_collations(THD *thd,const char *wild); -int mysqld_show_storage_engines(THD *thd); -int mysqld_show_privileges(THD *thd); -int mysqld_show_column_types(THD *thd); -int mysqld_help (THD *thd, const char *text); +bool mysqld_show_charsets(THD *thd,const char *wild); +bool mysqld_show_collations(THD *thd,const char *wild); +bool mysqld_show_storage_engines(THD *thd); +bool mysqld_show_privileges(THD *thd); +bool mysqld_show_column_types(THD *thd); +bool mysqld_help (THD *thd, const char *text); void calc_sum_of_all_status(STATUS_VAR *to); /* sql_prepare.cc */ -int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, - LEX_STRING *name=NULL); +bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, + LEX_STRING *name=NULL); void mysql_stmt_execute(THD *thd, char *packet, uint packet_length); void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name); void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length); @@ -736,15 +736,15 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, const char *format, ...); void mysql_reset_errors(THD *thd); -my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show); +bool mysqld_show_warnings(THD *thd, ulong levels_to_show); /* sql_handler.cc */ -int mysql_ha_open(THD *thd, TABLE_LIST *tables); -int mysql_ha_close(THD *thd, TABLE_LIST *tables, - bool dont_send_ok=0, bool dont_lock=0, bool no_alias=0); +bool mysql_ha_open(THD *thd, TABLE_LIST *tables); +bool mysql_ha_close(THD *thd, TABLE_LIST *tables, + bool dont_send_ok=0, bool dont_lock=0, bool no_alias=0); int mysql_ha_close_list(THD *thd, TABLE_LIST *tables, bool flushed=0); -int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, - List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows); +bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, + List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows); /* sql_base.cc */ void set_item_name(Item *item,char *pos,uint length); @@ -778,16 +778,16 @@ bool insert_fields(THD *thd,TABLE_LIST *tables, bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds); int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, List<Item> *sum_func_list, uint wild_num); -int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, - List<Item> &item, bool set_query_id, - List<Item> *sum_func_list, bool allow_sum_func); +bool setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, + List<Item> &item, bool set_query_id, + List<Item> *sum_func_list, bool allow_sum_func); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); int setup_ftfuncs(SELECT_LEX* select); int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order); void wait_for_refresh(THD *thd); int open_tables(THD *thd, TABLE_LIST *tables, uint *counter); int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables); -int open_and_lock_tables(THD *thd,TABLE_LIST *tables); +bool open_and_lock_tables(THD *thd,TABLE_LIST *tables); int lock_tables(THD *thd, TABLE_LIST *tables, uint counter); TABLE *open_temporary_table(THD *thd, const char *path, const char *db, const char *table_name, bool link_in_list); @@ -837,9 +837,9 @@ inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table, bool eval_const_cond(COND *cond); /* sql_load.cc */ -int mysql_load(THD *thd,sql_exchange *ex, TABLE_LIST *table_list, - List<Item> &fields, enum enum_duplicates handle_duplicates, - bool local_file,thr_lock_type lock_type); +bool mysql_load(THD *thd,sql_exchange *ex, TABLE_LIST *table_list, + List<Item> &fields, enum enum_duplicates handle_duplicates, + bool local_file,thr_lock_type lock_type); int write_record(THD *thd, TABLE *table, COPY_INFO *info); /* sql_manager.cc */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index db81b14c9c9..c408478cb15 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1145,7 +1145,7 @@ static void server_init(void) WSADATA WsaData; if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData)) { - my_message(0,"WSAStartup Failed\n",MYF(0)); + my_error(ER_WSAS_FAILED, MYF(0)); unireg_abort(1); } } @@ -1298,8 +1298,9 @@ void yyerror(const char *s) /* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */ if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0) s=ER(ER_SYNTAX_ERROR); - net_printf(thd,ER_PARSE_ERROR, s, yytext ? (char*) yytext : "", - thd->lex->yylineno); + my_printf_error(ER_PARSE_ERROR, ER(ER_PARSE_ERROR), MYF(0), s, + (yytext ? (char*) yytext : ""), + thd->lex->yylineno); } @@ -2091,6 +2092,11 @@ extern "C" int my_message_sql(uint error, const char *str, THD *thd; DBUG_ENTER("my_message_sql"); DBUG_PRINT("error", ("error: %u message: '%s'", error, str)); + /* + Put here following assertion when situation with EE_* error codes + will be fixed + DBUG_ASSERT(error != 0); + */ if ((thd= current_thd)) { if (thd->spcont && @@ -2098,6 +2104,9 @@ extern "C" int my_message_sql(uint error, const char *str, { DBUG_RETURN(0); } + + thd->query_error= 1; // needed to catch query errors during replication + /* thd->lex->current_select == 0 if lex structure is not inited (not query command (COM_QUERY)) @@ -2112,6 +2121,9 @@ extern "C" int my_message_sql(uint error, const char *str, { NET *net= &thd->net; net->report_error= 1; +#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/ + query_cache_abort(net); +#endif if (!net->last_error[0]) // Return only first message { strmake(net->last_error, str, sizeof(net->last_error)-1); @@ -3381,7 +3393,7 @@ static void create_new_thread(THD *thd) ("Can't create thread to handle request (error %d)", error)); thread_count--; - thd->killed= THD::KILL_CONNECTION; // Safety + thd->killed= THD::KILL_CONNECTION; // Safety (void) pthread_mutex_unlock(&LOCK_thread_count); statistic_increment(aborted_connects,&LOCK_status); net_printf(thd,ER_CANT_CREATE_THREAD,error); diff --git a/sql/protocol.cc b/sql/protocol.cc index 187989158df..c92d25f3f4d 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -70,9 +70,6 @@ void send_error(THD *thd, uint sql_errno, const char *err) { DBUG_VOID_RETURN; } -#ifndef EMBEDDED_LIBRARY /* TODO query cache in embedded library*/ - query_cache_abort(net); -#endif thd->query_error= 1; // needed to catch query errors during replication if (!err) { @@ -614,7 +611,7 @@ bool Protocol::send_fields(List<Item> *list, int flags) DBUG_RETURN(prepare_for_send(list)); err: - send_error(thd,ER_OUT_OF_RESOURCES); /* purecov: inspected */ + my_error(ER_OUT_OF_RESOURCES, MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 8904aba7b88..0954bb5466f 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -85,7 +85,7 @@ bool Protocol_cursor::send_fields(List<Item> *list, int flags) DBUG_RETURN(FALSE); err: - send_error(thd, ER_OUT_OF_RESOURCES); /* purecov: inspected */ + my_error(ER_OUT_OF_RESOURCES, MYF(0)); /* purecov: inspected */ DBUG_RETURN(TRUE); /* purecov: inspected */ } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 10ff5fa3596..6ba1ce6267f 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -196,7 +196,6 @@ err: my_message(ER_UNKNOWN_ERROR, "Wrong parameters to function register_slave", MYF(0)); err2: - send_error(thd); return 1; } @@ -440,7 +439,7 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, This function is broken now. See comment for translate_master(). */ -int show_new_master(THD* thd) +bool show_new_master(THD* thd) { Protocol *protocol= thd->protocol; DBUG_ENTER("show_new_master"); @@ -454,7 +453,7 @@ int show_new_master(THD* thd) if (errmsg[0]) my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0), "SHOW NEW MASTER", errmsg); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } else { @@ -463,14 +462,14 @@ int show_new_master(THD* thd) MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); protocol->prepare_for_resend(); protocol->store(lex_mi->log_file_name, &my_charset_bin); protocol->store((ulonglong) lex_mi->pos); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } } @@ -633,7 +632,7 @@ err: } -int show_slave_hosts(THD* thd) +bool show_slave_hosts(THD* thd) { List<Item> field_list; Protocol *protocol= thd->protocol; @@ -655,7 +654,7 @@ int show_slave_hosts(THD* thd) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); pthread_mutex_lock(&LOCK_slave_list); @@ -676,12 +675,12 @@ int show_slave_hosts(THD* thd) if (protocol->write()) { pthread_mutex_unlock(&LOCK_slave_list); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } pthread_mutex_unlock(&LOCK_slave_list); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -762,7 +761,7 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db, - No active transaction (flush_relay_log_info would not work in this case) */ -int load_master_data(THD* thd) +bool load_master_data(THD* thd) { MYSQL mysql; MYSQL_RES* master_status_res = 0; @@ -784,16 +783,15 @@ int load_master_data(THD* thd) (error=terminate_slave_threads(active_mi,restart_thread_mask, 1 /*skip lock*/))) { - send_error(thd,error); + my_error(error, MYF(0)); unlock_slave_threads(active_mi); pthread_mutex_unlock(&LOCK_active_mi); - return 1; + return TRUE; } if (connect_to_master(thd, &mysql, active_mi)) { - net_printf(thd, error= ER_CONNECT_TO_MASTER, - mysql_error(&mysql)); + my_error(error= ER_CONNECT_TO_MASTER, MYF(0), mysql_error(&mysql)); goto err; } @@ -805,8 +803,7 @@ int load_master_data(THD* thd) if (mysql_real_query(&mysql, "SHOW DATABASES", 14) || !(db_res = mysql_store_result(&mysql))) { - net_printf(thd, error = ER_QUERY_ON_MASTER, - mysql_error(&mysql)); + my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); goto err; } @@ -819,7 +816,7 @@ int load_master_data(THD* thd) if (!(table_res = (MYSQL_RES**)thd->alloc(num_dbs * sizeof(MYSQL_RES*)))) { - net_printf(thd, error = ER_OUTOFMEMORY); + my_error(error = ER_OUTOFMEMORY, MYF(0)); goto err; } @@ -833,8 +830,7 @@ int load_master_data(THD* thd) mysql_real_query(&mysql, "SHOW MASTER STATUS",18) || !(master_status_res = mysql_store_result(&mysql))) { - net_printf(thd, error = ER_QUERY_ON_MASTER, - mysql_error(&mysql)); + my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); goto err; } @@ -879,7 +875,6 @@ int load_master_data(THD* thd) if (mysql_create_db(thd, db, &create_info, 1)) { - send_error(thd, 0, 0); cleanup_mysql_results(db_res, cur_table_res - 1, table_res); goto err; } @@ -888,8 +883,7 @@ int load_master_data(THD* thd) mysql_real_query(&mysql, "SHOW TABLES", 11) || !(*cur_table_res = mysql_store_result(&mysql))) { - net_printf(thd, error = ER_QUERY_ON_MASTER, - mysql_error(&mysql)); + my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); cleanup_mysql_results(db_res, cur_table_res - 1, table_res); goto err; } @@ -927,7 +921,7 @@ int load_master_data(THD* thd) if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0)) - send_error(thd, ER_MASTER_INFO); + my_error(ER_MASTER_INFO, MYF(0)); strmake(active_mi->master_log_name, row[0], sizeof(active_mi->master_log_name)); active_mi->master_log_pos= my_strtoll10(row[1], (char**) 0, &error); @@ -946,8 +940,7 @@ int load_master_data(THD* thd) if (mysql_real_query(&mysql, "UNLOCK TABLES", 13)) { - net_printf(thd, error = ER_QUERY_ON_MASTER, - mysql_error(&mysql)); + my_error(error = ER_QUERY_ON_MASTER, MYF(0), mysql_error(&mysql)); goto err; } } @@ -956,10 +949,10 @@ int load_master_data(THD* thd) 0 /* not only reset, but also reinit */, &errmsg)) { - send_error(thd, 0, "Failed purging old relay logs"); + my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg); unlock_slave_threads(active_mi); pthread_mutex_unlock(&LOCK_active_mi); - return 1; + return TRUE; } pthread_mutex_lock(&active_mi->rli.data_lock); active_mi->rli.group_master_log_pos = active_mi->master_log_pos; diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index a9c504330ab..1ced69fdc3c 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -24,11 +24,11 @@ int update_slave_list(MYSQL* mysql, MASTER_INFO* mi); extern HASH slave_list; -int load_master_data(THD* thd); +bool load_master_data(THD* thd); int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi); -int show_new_master(THD* thd); -int show_slave_hosts(THD* thd); +bool show_new_master(THD* thd); +bool show_slave_hosts(THD* thd); int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg); void init_slave_list(); void end_slave_list(); diff --git a/sql/set_var.cc b/sql/set_var.cc index 33c6a380223..e08a65c793a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1520,8 +1520,8 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) { if (var_type != OPT_DEFAULT) { - net_printf(thd, ER_INCORRECT_GLOBAL_LOCAL_VAR, - name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); + my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), + name, var_type == OPT_GLOBAL ? "SESSION" : "GLOBAL"); return 0; } /* As there was no local variable, return the global value */ @@ -1564,7 +1564,7 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) return tmp; } default: - net_printf(thd, ER_VAR_CANT_BE_READ, name); + my_error(ER_VAR_CANT_BE_READ, MYF(0), name); } return 0; } @@ -1950,8 +1950,8 @@ bool sys_var_character_set_server::check(THD *thd, set_var *var) (mysql_bin_log.is_open() || active_mi->slave_running || active_mi->rli.slave_running)) { - my_printf_error(0, "Binary logging and replication forbid changing \ -the global server character set or collation", MYF(0)); + my_error(ER_LOGING_PROHIBIT_CHANGING_OF, MYF(0), + "character set, collation"); return 1; } return sys_var_character_set::check(thd,var); @@ -2057,8 +2057,8 @@ bool sys_var_collation_server::check(THD *thd, set_var *var) (mysql_bin_log.is_open() || active_mi->slave_running || active_mi->rli.slave_running)) { - my_printf_error(0, "Binary logging and replication forbid changing \ -the global server character set or collation", MYF(0)); + my_error(ER_LOGING_PROHIBIT_CHANGING_OF, MYF(0), + "character set, collation"); return 1; } return sys_var_collation::check(thd,var); @@ -2407,8 +2407,7 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var) (mysql_bin_log.is_open() || active_mi->slave_running || active_mi->rli.slave_running)) { - my_printf_error(0, "Binary logging and replication forbid changing " - "of the global server time zone", MYF(0)); + my_error(ER_LOGING_PROHIBIT_CHANGING_OF, MYF(0), "time zone"); return 1; } #endif @@ -2686,9 +2685,6 @@ void set_var_free() length Length of variable. zero means that we should use strlen() on the variable - NOTE - We have to use net_printf() as this is called during the parsing stage - RETURN VALUES pointer pointer to variable definitions 0 Unknown variable (error message is given) @@ -2701,7 +2697,7 @@ sys_var *find_sys_var(const char *str, uint length) length ? length : strlen(str)); if (!var) - net_printf(current_thd, ER_UNKNOWN_SYSTEM_VARIABLE, (char*) str); + my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); return var; } diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 301ac6133ca..3f5814df575 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -398,3 +398,22 @@ character-set=latin2 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 128859a5505..fa5d8f8a8c7 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -389,3 +389,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 3ad8d91bba7..7dbd32c9db4 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -398,3 +398,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 1878d6e2da2..8fe08ddc7a7 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -386,3 +386,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index af14aeac85c..b52aa6154ec 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -391,3 +391,22 @@ character-set=latin7 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index b731f398a2f..43a77fdec42 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -386,3 +386,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index ff797119971..1b3a916c777 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -399,3 +399,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index f5db8296d14..baf88d7fead 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -386,3 +386,22 @@ character-set=greek "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 0b410dc1ac7..2c1efa97e30 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -391,3 +391,22 @@ character-set=latin2 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 0c0ccdc0a74..5859e5380ef 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -386,3 +386,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index bd9dd98d525..c58acde49cd 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -390,3 +390,22 @@ character-set=ujis "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 9ab305bc2d8..74e42b09fc7 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -386,3 +386,22 @@ character-set=euckr "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index c8166a777bf..1bce2767784 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -388,3 +388,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 07f7381091d..c09aa257ead 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -388,3 +388,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 43cf08666ac..96985de759d 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -391,3 +391,22 @@ character-set=latin2 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 827c49d3f1f..c9dac302f5e 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -388,3 +388,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index a3c16ea5023..25c06397d7c 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -391,3 +391,22 @@ character-set=latin2 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index c5988fca6d5..71b21268dba 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -391,3 +391,22 @@ character-set=koi8r "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION ÄÌÑ ÎÅÏÂÎÏ×ÌÑÅÍÏÇÏ VIEW '%-.64s.%-.64s'" "ÐÒÏ×ÅÒËÁ CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÐÒÏ×ÁÌÉÌÁÓØ" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 5a08ae4ba54..4228f3a3a4e 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -379,3 +379,22 @@ character-set=cp1250 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index a6bab89d689..9b9508eeca9 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -394,3 +394,22 @@ character-set=latin2 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 11bc53cde16..5af6d647fd3 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -390,3 +390,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 6d9a6b98204..85866007367 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -386,3 +386,22 @@ character-set=latin1 "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION on non-updatable view '%-.64s.%-.64s'" "CHECK OPTION failed '%-.64s.%-.64s'" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 03f3172c2fb..4bb3a6a1aab 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -392,3 +392,22 @@ character-set=koi8u "Illegal %s '%-.64s' value found during parsing", "CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÝÏ ÎÅ ÍÏÖÅ ÂÕÔÉ ÏÎÏ×ÌÅÎÎÉÍ" "ÐÅÒÅצÒËÁ CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÎÅ ÐÒÏÊÛÌÁ" +"Failed purging old relay logs: %s" +"Password hash should be a %d-digit hexadecimal number" +"Target log not found in binlog index" +"I/O error reading log index file" +"Server configuration does not permit binlog purge" +"Failed on fseek()" +"Fatal error during log purge" +"A purgeable log is in use, will not purge" +"Unknown error during log purge" +"Failed initializing relay log position: %s" +"You are not using binary logging" +"The '%-.64s' syntax is reserved for purposes internal to the MySQL server" +"WSAStartup Failed" +"Can't handle procedures with differents groups yet" +"Select must have a group with this procedure" +"Can't use ORDER clause with this procedure" +"Binary logging and replication forbid changing the global server %s" +"Can't map file: %-.64s, errno: %d" +"Wrong magic in %-.64s" diff --git a/sql/slave.cc b/sql/slave.cc index 2c6fb06b7cb..2ed554e65c8 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1489,7 +1489,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, packet_len= my_net_read(net); // read create table statement if (packet_len == packet_error) { - send_error(thd, ER_MASTER_NET_READ); + my_error(ER_MASTER_NET_READ, MYF(0)); DBUG_RETURN(1); } if (net->read_pos[0] == 255) // error from master @@ -1498,7 +1498,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, err_msg= (char*) net->read_pos + ((mysql->server_capabilities & CLIENT_PROTOCOL_41) ? 3+SQLSTATE_LENGTH+1 : 3); - net_printf(thd, ER_MASTER, err_msg); + my_error(ER_MASTER, MYF(0), err_msg); DBUG_RETURN(1); } thd->command = COM_TABLE_DUMP; @@ -1507,7 +1507,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, if (!(query = thd->strmake((char*) net->read_pos, packet_len))) { sql_print_error("create_table_from_dump: out of memory"); - net_printf(thd, ER_GET_ERRNO, "Out of memory"); + my_error(ER_GET_ERRNO, MYF(0), "Out of memory"); DBUG_RETURN(1); } thd->query= query; @@ -1521,7 +1521,6 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, /* Drop the table if 'overwrite' is true */ if (overwrite && mysql_rm_table(thd,&tables,1,0)) /* drop if exists */ { - send_error(thd); sql_print_error("create_table_from_dump: failed to drop the table"); goto err; } @@ -1544,7 +1543,6 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, tables.lock_type = TL_WRITE; if (!open_ltable(thd, &tables, TL_WRITE)) { - send_error(thd,0,0); // Send error from open_ltable sql_print_error("create_table_from_dump: could not open created table"); goto err; } @@ -1554,7 +1552,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, /* Copy the data file */ if (file->net_read_dump(net)) { - net_printf(thd, ER_MASTER_NET_READ); + my_error(ER_MASTER_NET_READ, MYF(0)); sql_print_error("create_table_from_dump: failed in\ handler::net_read_dump()"); goto err; @@ -1574,7 +1572,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, error=file->repair(thd,&check_opt) != 0; thd->net.vio = save_vio; if (error) - net_printf(thd, ER_INDEX_REBUILD,tables.table->real_name); + my_error(ER_INDEX_REBUILD, MYF(0), tables.table->real_name); err: close_thread_tables(thd); @@ -1597,12 +1595,11 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, { if (!(mysql = mysql_init(NULL))) { - send_error(thd); // EOM DBUG_RETURN(1); } if (connect_to_master(thd, mysql, mi)) { - net_printf(thd, ER_CONNECT_TO_MASTER, mysql_error(mysql)); + my_error(ER_CONNECT_TO_MASTER, MYF(0), mysql_error(mysql)); mysql_close(mysql); DBUG_RETURN(1); } @@ -1626,7 +1623,7 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, if (!called_connected) mysql_close(mysql); if (errmsg && thd->vio_ok()) - send_error(thd, error, errmsg); + my_message(error, errmsg, MYF(0)); DBUG_RETURN(test(error)); // Return 1 on error } @@ -2263,7 +2260,7 @@ void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a) } } -int show_master_info(THD* thd, MASTER_INFO* mi) +bool show_master_info(THD* thd, MASTER_INFO* mi) { // TODO: fix this for multi-master List<Item> field_list; @@ -2327,7 +2324,7 @@ int show_master_info(THD* thd, MASTER_INFO* mi) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); if (mi->host[0]) { @@ -2426,10 +2423,10 @@ int show_master_info(THD* thd, MASTER_INFO* mi) pthread_mutex_unlock(&mi->data_lock); if (my_net_write(&thd->net, (char*)thd->packet.ptr(), packet->length())) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } diff --git a/sql/slave.h b/sql/slave.h index 46fe58e1976..e0383b6ebe8 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -474,8 +474,8 @@ int fetch_master_table(THD* thd, const char* db_name, const char* table_name, void table_rule_ent_hash_to_str(String* s, HASH* h); void table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a); -int show_master_info(THD* thd, MASTER_INFO* mi); -int show_binlog_info(THD* thd); +bool show_master_info(THD* thd, MASTER_INFO* mi); +bool show_binlog_info(THD* thd); /* See if the query uses any tables that should not be replicated */ int tables_ok(THD* thd, TABLE_LIST* tables); diff --git a/sql/sp.cc b/sql/sp.cc index 6475b64eb18..2fae2addf2a 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -983,7 +983,7 @@ sp_cache_functions(THD *thd, LEX *lex) { delete newlex; thd->lex= oldlex; - net_printf(thd, ER_SP_DOES_NOT_EXIST, "FUNCTION", ls->str); + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", ls->str); ret= 1; break; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 6a17bc189c3..1f1cf8ac4cd 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -494,16 +494,17 @@ sp_head::execute(THD *thd) case SP_HANDLER_CONTINUE: ctx->save_variables(hf); ctx->push_hstack(ip); - // Fall through + // Fall through default: ip= hip; ret= 0; ctx->clear_handler(); ctx->in_handler= TRUE; + thd->clear_error(); continue; } } - } while (ret == 0 && !thd->killed && !thd->query_error); + } while (ret == 0 && !thd->killed); cleanup_items(thd->current_arena->free_list); thd->current_arena= old_arena; @@ -512,7 +513,7 @@ sp_head::execute(THD *thd) DBUG_PRINT("info", ("ret=%d killed=%d query_error=%d", ret, thd->killed, thd->query_error)); - if (thd->killed || thd->query_error) + if (thd->killed) ret= -1; /* If the DB has changed, the pointer has changed too, but the original thd->db will then have been freed */ @@ -622,8 +623,8 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (args->elements != params) { - net_printf(thd, ER_SP_WRONG_NO_OF_ARGS, "PROCEDURE", m_name.str, - params, args->elements); + my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0), + "PROCEDURE", m_name.str, params, args->elements); DBUG_RETURN(-1); } @@ -694,13 +695,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (! ret) ret= execute(thd); - // Don't copy back OUT values if we got an error - if (ret) - { - if (thd->net.report_error) - send_error(thd, 0, NullS); - } - else if (csize > 0) + if (!ret && csize > 0) { List_iterator_fast<Item> li(*args); Item *it; @@ -898,7 +893,7 @@ sp_head::check_backpatch(THD *thd) { if (bp->lab->type == SP_LAB_REF) { - net_printf(thd, ER_SP_LILABEL_MISMATCH, "GOTO", bp->lab->name); + my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name); return -1; } } diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 169c9809383..3f9ab39e358 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -148,7 +148,7 @@ sp_cursor::pre_open(THD *thd) { if (m_isopen) { - send_error(thd, ER_SP_CURSOR_ALREADY_OPEN); + my_error(ER_SP_CURSOR_ALREADY_OPEN, MYF(0)); return NULL; } @@ -182,7 +182,7 @@ sp_cursor::close(THD *thd) { if (! m_isopen) { - send_error(thd, ER_SP_CURSOR_NOT_OPEN); + my_error(ER_SP_CURSOR_NOT_OPEN, MYF(0)); return -1; } destroy(); @@ -212,12 +212,12 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) if (! m_isopen) { - send_error(thd, ER_SP_CURSOR_NOT_OPEN); + my_error(ER_SP_CURSOR_NOT_OPEN, MYF(0)); return -1; } if (m_current_row == NULL) { - send_error(thd, ER_SP_FETCH_NO_DATA); + my_error(ER_SP_FETCH_NO_DATA, MYF(0)); return -1; } @@ -229,7 +229,7 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) if (fldcount >= m_prot->get_field_count()) { - send_error(thd, ER_SP_WRONG_NO_OF_FETCH_ARGS); + my_error(ER_SP_WRONG_NO_OF_FETCH_ARGS, MYF(0)); return -1; } s= row[fldcount]; @@ -255,7 +255,7 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars) } if (fldcount < m_prot->get_field_count()) { - send_error(thd, ER_SP_WRONG_NO_OF_FETCH_ARGS); + my_error(ER_SP_WRONG_NO_OF_FETCH_ARGS, MYF(0)); return -1; } m_current_row= m_current_row->next; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 51768922f6d..bb5f1d0949d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1225,8 +1225,7 @@ bool check_change_password(THD *thd, const char *host, const char *user, { if (!initialized) { - net_printf(thd,ER_OPTION_PREVENTS_STATEMENT, - "--skip-grant-tables"); + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); return(1); } if (!thd->slave_thread && @@ -1238,16 +1237,14 @@ bool check_change_password(THD *thd, const char *host, const char *user, } if (!thd->slave_thread && !thd->user[0]) { - send_error(thd, ER_PASSWORD_ANONYMOUS_USER); + my_error(ER_PASSWORD_ANONYMOUS_USER, MYF(0)); return(1); } uint len=strlen(new_password); if (len && len != SCRAMBLED_PASSWORD_CHAR_LENGTH && len != SCRAMBLED_PASSWORD_CHAR_LENGTH_323) { - net_printf(thd, 0, - "Password hash should be a %d-digit hexadecimal number", - SCRAMBLED_PASSWORD_CHAR_LENGTH); + my_error(ER_PASSWD_LENGTH, MYF(0), SCRAMBLED_PASSWORD_CHAR_LENGTH); return -1; } return(0); @@ -1285,7 +1282,7 @@ bool change_password(THD *thd, const char *host, const char *user, if (!(acl_user= find_acl_user(host, user))) { VOID(pthread_mutex_unlock(&acl_cache->lock)); - send_error(thd, ER_PASSWORD_NO_MATCH); + my_error(ER_PASSWORD_NO_MATCH, MYF(0)); DBUG_RETURN(1); } /* update loaded acl entry: */ @@ -1298,7 +1295,6 @@ bool change_password(THD *thd, const char *host, const char *user, new_password, new_password_len)) { VOID(pthread_mutex_unlock(&acl_cache->lock)); /* purecov: deadcode */ - send_error(thd,0); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */ } @@ -2290,11 +2286,11 @@ table_error: revoke_grant Set to 1 if this is a REVOKE command RETURN - 0 ok - 1 error + FALSE ok + TRUE error */ -int mysql_table_grant(THD *thd, TABLE_LIST *table_list, +bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, List <LEX_USER> &user_list, List <LEX_COLUMN> &columns, ulong rights, bool revoke_grant) @@ -2311,12 +2307,12 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); /* purecov: inspected */ - DBUG_RETURN(-1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ } if (rights & ~TABLE_ACLS) { my_error(ER_ILLEGAL_GRANT_FOR_TABLE,MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (columns.elements && !revoke_grant) @@ -2325,8 +2321,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, List_iterator <LEX_COLUMN> column_iter(columns); int res; - if ((res= open_and_lock_tables(thd, table_list))) - DBUG_RETURN(res); + if (open_and_lock_tables(thd, table_list)) + DBUG_RETURN(TRUE); while ((column = column_iter++)) { @@ -2338,7 +2334,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { my_error(ER_BAD_FIELD_ERROR, MYF(0), column->column.c_ptr(), table_list->alias); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } column_priv|= column->rights; } @@ -2353,7 +2349,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, if (access(buf,F_OK)) { my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } @@ -2386,19 +2382,19 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, */ tables[0].updating= tables[1].updating= tables[2].updating= 1; if (!tables_ok(0, tables)) - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } #endif if (simple_open_n_lock_tables(thd,tables)) { // Should never happen close_thread_tables(thd); /* purecov: deadcode */ - DBUG_RETURN(-1); /* purecov: deadcode */ + DBUG_RETURN(TRUE); /* purecov: deadcode */ } if (!revoke_grant) create_new_users= test_if_create_new_users(thd); - int result=0; + bool result= FALSE; rw_wrlock(&LOCK_grant); MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC); my_pthread_setspecific_ptr(THR_MALLOC,&memex); @@ -2411,7 +2407,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, Str->user.length > USERNAME_LENGTH) { my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0)); - result= -1; + result= TRUE; continue; } /* Create user if needed */ @@ -2421,7 +2417,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, pthread_mutex_unlock(&acl_cache->lock); if (error) { - result= -1; // Remember error + result= TRUE; // Remember error continue; // Add next user } @@ -2441,7 +2437,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, { my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0), Str->user.str, Str->host.str, table_list->real_name); - result= -1; + result= TRUE; continue; } grant_table = new GRANT_TABLE (Str->host.str, db_name, @@ -2450,7 +2446,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, column_priv); if (!grant_table) // end of memory { - result= -1; /* purecov: deadcode */ + result= TRUE; /* purecov: deadcode */ continue; /* purecov: deadcode */ } my_hash_insert(&column_priv_hash,(byte*) grant_table); @@ -2494,7 +2490,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, db_name, real_name, rights, column_priv, revoke_grant)) { // Crashend table ?? - result= -1; /* purecov: deadcode */ + result= TRUE; /* purecov: deadcode */ } else if (tables[2].table) { @@ -2503,7 +2499,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, db_name, real_name, rights, revoke_grant))) { - result= -1; + result= TRUE; } } } @@ -2517,8 +2513,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list, } -int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, - ulong rights, bool revoke_grant) +bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, + ulong rights, bool revoke_grant) { List_iterator <LEX_USER> str_list (list); LEX_USER *Str; @@ -2530,7 +2526,7 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, { my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); /* purecov: tested */ - DBUG_RETURN(-1); /* purecov: tested */ + DBUG_RETURN(TRUE); /* purecov: tested */ } if (lower_case_table_names && db) @@ -2561,14 +2557,14 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, */ tables[0].updating= tables[1].updating= 1; if (!tables_ok(0, tables)) - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } #endif if (simple_open_n_lock_tables(thd,tables)) { // This should never happen close_thread_tables(thd); /* purecov: deadcode */ - DBUG_RETURN(-1); /* purecov: deadcode */ + DBUG_RETURN(TRUE); /* purecov: deadcode */ } if (!revoke_grant) @@ -2880,11 +2876,11 @@ err: command= "create view"; else if (want_access & SHOW_VIEW_ACL) command= "show create view"; - net_printf(thd,ER_TABLEACCESS_DENIED_ERROR, - command, - thd->priv_user, - thd->host_or_ip, - table ? table->real_name : "unknown"); + my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), + command, + thd->priv_user, + thd->host_or_ip, + table ? table->real_name : "unknown"); } DBUG_RETURN(1); } @@ -3146,7 +3142,7 @@ static uint command_lengths[]= Send to client grant-like strings depicting user@host privileges */ -int mysql_show_grants(THD *thd,LEX_USER *lex_user) +bool mysql_show_grants(THD *thd,LEX_USER *lex_user) { ulong want_access; uint counter,index; @@ -3161,7 +3157,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) if (!initialized) { my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!lex_user->host.str) @@ -3173,7 +3169,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) lex_user->user.length > USERNAME_LENGTH) { my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } for (counter=0 ; counter < acl_users.elements ; counter++) @@ -3192,7 +3188,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) { my_error(ER_NONEXISTING_GRANT, MYF(0), lex_user->user.str, lex_user->host.str); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } Item_string *field=new Item_string("",0,&my_charset_latin1); @@ -3204,7 +3200,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) field_list.push_back(field); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); rw_wrlock(&LOCK_grant); VOID(pthread_mutex_lock(&acl_cache->lock)); @@ -3526,7 +3522,7 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables) if (!initialized) { - net_printf(thd,ER_OPTION_PREVENTS_STATEMENT, "--skip-grant-tables"); + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); DBUG_RETURN(-1); } @@ -3595,7 +3591,7 @@ ACL_USER *check_acl_user(LEX_USER *user_name, } -int mysql_drop_user(THD *thd, List <LEX_USER> &list) +bool mysql_drop_user(THD *thd, List <LEX_USER> &list) { uint counter, acl_userd; int result; @@ -3606,7 +3602,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) DBUG_ENTER("mysql_drop_user"); if ((result= open_grant_tables(thd, tables))) - DBUG_RETURN(result == 1 ? 0 : 1); + DBUG_RETURN(result != 1); rw_wrlock(&LOCK_grant); VOID(pthread_mutex_lock(&acl_cache->lock)); @@ -3694,7 +3690,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) record[0]))) { tables[0].table->file->print_error(error, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } delete_dynamic_element(&acl_users, acl_userd); } @@ -3708,7 +3704,7 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list) DBUG_RETURN(result); } -int mysql_revoke_all(THD *thd, List <LEX_USER> &list) +bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) { uint counter; int result; @@ -3717,7 +3713,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list) DBUG_ENTER("mysql_revoke_all"); if ((result= open_grant_tables(thd, tables))) - DBUG_RETURN(result == 1 ? 0 : 1); + DBUG_RETURN(result != 1); rw_wrlock(&LOCK_grant); VOID(pthread_mutex_lock(&acl_cache->lock)); diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 390106c1546..f6074da5279 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -158,11 +158,11 @@ bool check_change_password(THD *thd, const char *host, const char *user, char *password); bool change_password(THD *thd, const char *host, const char *user, char *password); -int mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list, - ulong rights, bool revoke); -int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list, - List <LEX_COLUMN> &column_list, ulong rights, - bool revoke); +bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list, + ulong rights, bool revoke); +bool mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list, + List <LEX_COLUMN> &column_list, ulong rights, + bool revoke); my_bool grant_init(THD *thd); void grant_free(void); void grant_reload(THD *thd); @@ -179,11 +179,11 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table); ulong get_column_grant(THD *thd, GRANT_INFO *grant, const char *db_name, const char *table_name, const char *field_name); -int mysql_show_grants(THD *thd, LEX_USER *user); +bool mysql_show_grants(THD *thd, LEX_USER *user); void get_privilege_desc(char *to, uint max_length, ulong access); void get_mqh(const char *user, const char *host, USER_CONN *uc); -int mysql_drop_user(THD *thd, List <LEX_USER> &list); -int mysql_revoke_all(THD *thd, List <LEX_USER> &list); +bool mysql_drop_user(THD *thd, List <LEX_USER> &list); +bool mysql_revoke_all(THD *thd, List <LEX_USER> &list); void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, const char *db, const char *table); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8199c6fcdce..9a45660c45b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1815,21 +1815,20 @@ int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables) tables - list of tables for open&locking RETURN - 0 - ok - -1 - error - 1 - error reported to user + FALSE - ok + TRUE - error NOTE The lock will automaticly be freed by close_thread_tables() */ -int open_and_lock_tables(THD *thd, TABLE_LIST *tables) +bool open_and_lock_tables(THD *thd, TABLE_LIST *tables) { DBUG_ENTER("open_and_lock_tables"); uint counter; if (open_tables(thd, tables, &counter) || lock_tables(thd, tables, counter) || mysql_handle_derived(thd->lex)) - DBUG_RETURN(thd->net.report_error ? -1 : 1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ /* Let us propagate pointers to open tables from global table list to table lists in particular selects if needed. @@ -1850,7 +1849,7 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables) } } } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -2609,9 +2608,9 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, ** Check that all given fields exists and fill struct with current data ****************************************************************************/ -int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, - List<Item> &fields, bool set_query_id, - List<Item> *sum_func_list, bool allow_sum_func) +bool setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, + List<Item> &fields, bool set_query_id, + List<Item> *sum_func_list, bool allow_sum_func) { reg2 Item *item; List_iterator<Item> it(fields); @@ -2629,7 +2628,7 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, (item= *(it.ref()))->check_cols(1)) { select_lex->no_wrap_view_item= 0; - DBUG_RETURN(-1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ } if (ref) *(ref++)= item; @@ -2958,7 +2957,6 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name, my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name); err: - send_error(thd); DBUG_RETURN(1); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 392534492df..a543222a4a1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -762,7 +762,7 @@ select_result::select_result() void select_result::send_error(uint errcode,const char *err) { - ::send_error(thd, errcode, err); + my_message(errcode, err, MYF(0)); } @@ -865,7 +865,7 @@ bool select_send::send_eof() void select_to_file::send_error(uint errcode,const char *err) { - ::send_error(thd,errcode,err); + my_message(errcode, err, MYF(0)); if (file > 0) { (void) end_io_cache(&cache); diff --git a/sql/sql_class.h b/sql/sql_class.h index 32f156fbee8..f014a597169 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1112,6 +1112,7 @@ public: net.last_error[0]= 0; net.last_errno= 0; net.report_error= 0; + query_error= 0; } inline bool vio_ok() const { return net.vio != 0; } #else diff --git a/sql/sql_db.cc b/sql/sql_db.cc index f41e03b0602..df3c27b9b72 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -379,13 +379,13 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) In this case the entry should not be logged. RETURN VALUES - 0 ok - -1 Error + FALSE ok + TRUE Error */ -int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, - bool silent) +bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, + bool silent) { char path[FN_REFLEN+16]; long result= 1; @@ -489,7 +489,7 @@ exit2: /* db-name is already validated when we come here */ -int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) +bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) { char path[FN_REFLEN+16]; long result=1; @@ -532,7 +532,7 @@ exit: start_waiting_global_read_lock(thd); exit2: VOID(pthread_mutex_unlock(&LOCK_mysql_create_db)); - DBUG_RETURN(error ? -1 : 0); /* -1 to delegate send_error() */ + DBUG_RETURN(error); } @@ -548,11 +548,11 @@ exit2: silent Don't generate errors RETURN - 0 ok (Database dropped) - -1 Error generated + FALSE ok (Database dropped) + ERROR Error */ -int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) +bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { long deleted=0; int error= 0; @@ -985,12 +985,12 @@ bool mysql_change_db(THD *thd, const char *name) if (!dbname || !(db_length= strlen(dbname))) { x_free(dbname); /* purecov: inspected */ - send_error(thd,ER_NO_DB_ERROR); /* purecov: inspected */ + my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } if (check_db_name(dbname)) { - net_printf(thd, ER_WRONG_DB_NAME, dbname); + my_error(ER_WRONG_DB_NAME, MYF(0), dbname); x_free(dbname); DBUG_RETURN(1); } @@ -1003,10 +1003,10 @@ bool mysql_change_db(THD *thd, const char *name) thd->master_access); if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname))) { - net_printf(thd,ER_DBACCESS_DENIED_ERROR, - thd->priv_user, - thd->priv_host, - dbname); + my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), + thd->priv_user, + thd->priv_host, + dbname); mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR), thd->priv_user, thd->priv_host, @@ -1021,7 +1021,7 @@ bool mysql_change_db(THD *thd, const char *name) path[length-1]=0; // remove ending '\' if (access(path,F_OK)) { - net_printf(thd,ER_BAD_DB_ERROR,dbname); + my_error(ER_BAD_DB_ERROR, MYF(0), dbname); my_free(dbname,MYF(0)); DBUG_RETURN(1); } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f9dba49d2e3..54c6cd1ebc5 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -29,8 +29,8 @@ #include "sp_head.h" #include "sql_trigger.h" -int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, - ha_rows limit, ulong options) +bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, + SQL_LIST *order, ha_rows limit, ulong options) { int error; TABLE *table; @@ -41,22 +41,22 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, ha_rows deleted; DBUG_ENTER("mysql_delete"); - if ((error= open_and_lock_tables(thd, table_list))) - DBUG_RETURN(error); + if (open_and_lock_tables(thd, table_list)) + DBUG_RETURN(TRUE); table= table_list->table; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); thd->proc_info="init"; table->map=1; - if ((error= mysql_prepare_delete(thd, table_list, &conds))) - DBUG_RETURN(error); + if (mysql_prepare_delete(thd, table_list, &conds)) + DBUG_RETURN(TRUE); const_cond= (!conds || conds->const_item()); safe_update=test(thd->options & OPTION_SAFE_UPDATES); if (safe_update && const_cond) { - send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE); - DBUG_RETURN(1); + my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, MYF(0)); + DBUG_RETURN(TRUE); } if (thd->lex->duplicates == DUP_IGNORE) @@ -85,7 +85,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, table->quick_keys.clear_all(); // Can't use 'only index' select=make_select(table,0,0,conds,&error); if (error) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); if ((select && select->check_quick(thd, safe_update, limit)) || !limit) { delete select; @@ -103,8 +103,8 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, { delete select; free_underlaid_joins(thd, &thd->lex->select_lex); - send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE); - DBUG_RETURN(1); + my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, MYF(0)); + DBUG_RETURN(TRUE); } } if (options & OPTION_QUICK) @@ -135,7 +135,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, { delete select; free_underlaid_joins(thd, &thd->lex->select_lex); - DBUG_RETURN(-1); // This will force out message + DBUG_RETURN(TRUE); } /* Filesort has already found and selected the rows we want to delete, @@ -150,7 +150,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, { delete select; free_underlaid_joins(thd, &thd->lex->select_lex); - DBUG_RETURN(-1); // This will force out message + DBUG_RETURN(TRUE); } init_read_record(&info,thd,table,select,1,1); deleted=0L; @@ -253,15 +253,13 @@ cleanup: thd->lock=0; } free_underlaid_joins(thd, &thd->lex->select_lex); - if (error >= 0 || thd->net.report_error) - send_error(thd,thd->killed_errno()); - else + if (error < 0) { thd->row_count_func= deleted; send_ok(thd,deleted); DBUG_PRINT("info",("%d records deleted",deleted)); } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -275,11 +273,10 @@ cleanup: conds - conditions RETURN VALUE - 0 - OK - 1 - error (message is sent to user) - -1 - error (message is not sent to user) + FALSE OK + TRUE error */ -int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) +bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) { SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_prepare_delete"); @@ -287,19 +284,19 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) if (setup_tables(thd, table_list, conds) || setup_conds(thd, table_list, conds) || setup_ftfuncs(select_lex)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); if (!table_list->updatable || check_key_in_view(thd, table_list)) { my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (unique_table(table_list, table_list->next_independent())) { my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } select_lex->fix_prepare_information(thd, conds); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -323,16 +320,15 @@ extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b) thd thread handler RETURN - 0 OK - -1 Error + FALSE OK + TRUE Error */ -int mysql_multi_delete_prepare(THD *thd) +bool mysql_multi_delete_prepare(THD *thd) { LEX *lex= thd->lex; TABLE_LIST *aux_tables= (TABLE_LIST *)lex->auxilliary_table_list.first; TABLE_LIST *target_tbl; - int res= 0; DBUG_ENTER("mysql_multi_delete_prepare"); /* @@ -342,7 +338,7 @@ int mysql_multi_delete_prepare(THD *thd) lex->query_tables also point on local list of DELETE SELECT_LEX */ if (setup_tables(thd, lex->query_tables, &lex->select_lex.where)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); /* Fix tables-to-be-deleted-from list to point at opened tables */ for (target_tbl= (TABLE_LIST*) aux_tables; @@ -355,7 +351,7 @@ int mysql_multi_delete_prepare(THD *thd) { my_error(ER_NON_UPDATABLE_TABLE, MYF(0), target_tbl->real_name, "DELETE"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* Check are deleted table used somewhere inside subqueries. @@ -373,12 +369,11 @@ int mysql_multi_delete_prepare(THD *thd) { my_error(ER_UPDATE_TABLE_USED, MYF(0), target_tbl->correspondent_table->real_name); - res= -1; - break; + DBUG_RETURN(TRUE); } } } - DBUG_RETURN(res); + DBUG_RETURN(FALSE); } @@ -522,7 +517,7 @@ void multi_delete::send_error(uint errcode,const char *err) DBUG_ENTER("multi_delete::send_error"); /* First send error what ever it is ... */ - ::send_error(thd,errcode,err); + my_message(errcode, err, MYF(0)); /* If nothing deleted return */ if (!deleted) @@ -668,9 +663,7 @@ bool multi_delete::send_eof() if (ha_autocommit_or_rollback(thd,local_error > 0)) local_error=1; - if (local_error) - ::send_error(thd); - else + if (!local_error) { thd->row_count_func= deleted; ::send_ok(thd, deleted); @@ -695,12 +688,12 @@ bool multi_delete::send_eof() - If we want to have a name lock on the table on exit without errors. */ -int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) +bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) { HA_CREATE_INFO create_info; char path[FN_REFLEN]; TABLE **table_ptr; - int error; + bool error; DBUG_ENTER("mysql_truncate"); bzero((char*) &create_info,sizeof(create_info)); @@ -738,7 +731,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) { my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->real_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!ha_supports_generate(table_type)) { @@ -748,11 +741,11 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) HA_POS_ERROR, 0)); } if (lock_and_wait_for_table_name(thd, table_list)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } *fn_ext(path)=0; // Remove the .frm extension - error= ha_create_table(path,&create_info,1) ? -1 : 0; + error= ha_create_table(path,&create_info,1); query_cache_invalidate3(thd, table_list, 0); end: @@ -779,5 +772,5 @@ end: unlock_table_name(thd, table_list); VOID(pthread_mutex_unlock(&LOCK_open)); } - DBUG_RETURN(error ? -1 : 0); + DBUG_RETURN(error); } diff --git a/sql/sql_do.cc b/sql/sql_do.cc index 25a8359f3d2..3ca3bea743a 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -20,16 +20,16 @@ #include "mysql_priv.h" #include "sql_acl.h" -int mysql_do(THD *thd, List<Item> &values) +bool mysql_do(THD *thd, List<Item> &values) { List_iterator<Item> li(values); Item *value; DBUG_ENTER("mysql_do"); if (setup_fields(thd, 0, 0, values, 0, 0, 0)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); while ((value = li++)) value->val_int(); thd->clear_error(); // DO always is OK send_ok(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } diff --git a/sql/sql_error.cc b/sql/sql_error.cc index c0f76ab0388..e4b9e615db6 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -184,14 +184,14 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, Takes into account the current LIMIT RETURN VALUES - 0 ok - 1 Error sending data to client + FALSE ok + TRUE Error sending data to client */ static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"}; static int warning_level_length[]= { 4, 7, 5, 1 }; -my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) +bool mysqld_show_warnings(THD *thd, ulong levels_to_show) { List<Item> field_list; DBUG_ENTER("mysqld_show_warnings"); @@ -202,7 +202,7 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) if (thd->protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); MYSQL_ERROR *err; SELECT_LEX *sel= &thd->lex->select_lex; @@ -226,10 +226,10 @@ my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show) protocol->store((uint32) err->code); protocol->store(err->msg, strlen(err->msg), system_charset_info); if (protocol->write()) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); if (!--limit) break; } - send_eof(thd); - DBUG_RETURN(0); + send_eof(thd); + DBUG_RETURN(FALSE); } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 1443f9f9d5f..bb872b2c39b 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -47,7 +47,7 @@ static TABLE **find_table_ptr_by_name(THD *thd,const char *db, bool is_alias, bool dont_lock, bool *was_flushed); -int mysql_ha_open(THD *thd, TABLE_LIST *tables) +bool mysql_ha_open(THD *thd, TABLE_LIST *tables) { HANDLER_TABLES_HACK(thd); uint counter; @@ -58,18 +58,18 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables) HANDLER_TABLES_HACK(thd); if (err) - return -1; + return TRUE; // there can be only one table in *tables if (!(tables->table->file->table_flags() & HA_CAN_SQL_HANDLER)) { my_printf_error(ER_ILLEGAL_HA,ER(ER_ILLEGAL_HA),MYF(0), tables->alias); mysql_ha_close(thd, tables,1); - return -1; + return TRUE; } send_ok(thd); - return 0; + return FALSE; } @@ -98,11 +98,11 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables) is suppressed. RETURN - 0 ok - -1 error + FALSE OK + TRUE Error */ -int mysql_ha_close(THD *thd, TABLE_LIST *tables, +bool mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok, bool dont_lock, bool no_alias) { TABLE **table_ptr; @@ -127,11 +127,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, { my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0), tables->alias, "HANDLER"); - return -1; + return TRUE; } if (!dont_send_ok) send_ok(thd); - return 0; + return FALSE; } @@ -201,11 +201,11 @@ static enum enum_ha_read_modes rkey_to_rnext[]= { RNEXT_SAME, RNEXT, RPREV, RNEXT, RPREV, RNEXT, RPREV, RPREV }; -int mysql_ha_read(THD *thd, TABLE_LIST *tables, - enum enum_ha_read_modes mode, char *keyname, - List<Item> *key_expr, - enum ha_rkey_function ha_rkey_mode, Item *cond, - ha_rows select_limit,ha_rows offset_limit) +bool mysql_ha_read(THD *thd, TABLE_LIST *tables, + enum enum_ha_read_modes mode, char *keyname, + List<Item> *key_expr, + enum ha_rkey_function ha_rkey_mode, Item *cond, + ha_rows select_limit,ha_rows offset_limit) { int err, keyno=-1; bool was_flushed; @@ -216,12 +216,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, { my_printf_error(ER_UNKNOWN_TABLE,ER(ER_UNKNOWN_TABLE),MYF(0), tables->alias,"HANDLER"); - return -1; + return TRUE; } tables->table=table; if (cond && (cond->fix_fields(thd, tables, &cond) || cond->check_cols(1))) - return -1; + return TRUE; /* InnoDB needs to know that this table handle is used in the HANDLER */ @@ -233,7 +233,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, { my_printf_error(ER_KEY_DOES_NOT_EXITS,ER(ER_KEY_DOES_NOT_EXITS),MYF(0), keyname,tables->alias); - return -1; + return TRUE; } table->file->ha_index_or_rnd_end(); table->file->ha_index_init(keyno); @@ -333,10 +333,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, key_len+=key_part->store_length; } if (!(key= (byte*) thd->calloc(ALIGN_SIZE(key_len)))) - { - send_error(thd,ER_OUTOFMEMORY); goto err; - } key_copy(key, table, keyno, key_len); err=table->file->index_read(table->record[0], key,key_len,ha_rkey_mode); @@ -344,7 +341,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, break; } default: - send_error(thd,ER_ILLEGAL_HA); + my_error(ER_ILLEGAL_HA, MYF(0)); goto err; } @@ -384,11 +381,11 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ok: mysql_unlock_tables(thd,lock); send_eof(thd); - return 0; + return FALSE; err: mysql_unlock_tables(thd,lock); err0: - return -1; + return TRUE; } diff --git a/sql/sql_help.cc b/sql/sql_help.cc index cba74c93a6a..d108f6f69b4 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -276,7 +276,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, (iindex_relations= find_type((char*) primary_key_name, &relations->keynames, 1+2)-1)<0) { - send_error(thd,ER_CORRUPT_HELP_DB); + my_error(ER_CORRUPT_HELP_DB, 0); DBUG_RETURN(-1); } rtopic_id= find_fields[help_relation_help_topic_id].field; @@ -607,12 +607,11 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen, thd Thread handler RETURN VALUES - 0 Success - 1 Error and send_error already commited - -1 error && send_error should be issued (normal case) + FALSE Success + TRUE Error and send_error already commited */ -int mysqld_help(THD *thd, const char *mask) +bool mysqld_help(THD *thd, const char *mask) { Protocol *protocol= thd->protocol; SQL_SELECT *select; @@ -640,8 +639,8 @@ int mysqld_help(THD *thd, const char *mask) uint mlen= strlen(mask); MEM_ROOT *mem_root= &thd->mem_root; - if ((res= open_and_lock_tables(thd, tables))) - goto end; + if (open_and_lock_tables(thd, tables)) + goto error; /* Init tables and fields to be usable from items @@ -650,10 +649,7 @@ int mysqld_help(THD *thd, const char *mask) setup_tables(thd, tables, 0); memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); if (init_fields(thd, tables, used_fields, array_elements(used_fields))) - { - res= -1; - goto end; - } + goto error; size_t i; for (i=0; i<sizeof(tables)/sizeof(TABLE_LIST); i++) tables[i].table->file->init_table_handle_for_HANDLER(); @@ -661,12 +657,8 @@ int mysqld_help(THD *thd, const char *mask) if (!(select= prepare_select_for_name(thd,mask,mlen,tables,tables[0].table, used_fields[help_topic_name].field,&error))) - { - res= -1; - goto end; - } + goto error; - res= 1; count_topics= search_topics(thd,tables[0].table,used_fields, select,&topics_list, &name, &description, &example); @@ -678,10 +670,8 @@ int mysqld_help(THD *thd, const char *mask) if (!(select= prepare_select_for_name(thd,mask,mlen,tables,tables[3].table, used_fields[help_keyword_name].field,&error))) - { - res= -1; - goto end; - } + goto error; + count_topics=search_keyword(thd,tables[3].table,used_fields,select,&key_id); delete select; count_topics= (count_topics != 1) ? 0 : @@ -697,10 +687,7 @@ int mysqld_help(THD *thd, const char *mask) if (!(select= prepare_select_for_name(thd,mask,mlen,tables,tables[1].table, used_fields[help_category_name].field,&error))) - { - res= -1; - goto end; - } + goto error; count_categories= search_categories(thd, tables[1].table, used_fields, select, @@ -709,13 +696,13 @@ int mysqld_help(THD *thd, const char *mask) if (!count_categories) { if (send_header_2(protocol,FALSE)) - goto end; + goto error; } else if (count_categories > 1) { if (send_header_2(protocol,FALSE) || send_variant_2_list(mem_root,protocol,&categories_list,"Y",0)) - goto end; + goto error; } else { @@ -728,20 +715,14 @@ int mysqld_help(THD *thd, const char *mask) new Item_int((int32)category_id)); if (!(select= prepare_simple_select(thd,cond_topic_by_cat, tables,tables[0].table,&error))) - { - res= -1; - goto end; - } + goto error; get_all_items_for_category(thd,tables[0].table, used_fields[help_topic_name].field, select,&topics_list); delete select; if (!(select= prepare_simple_select(thd,cond_cat_by_cat,tables, tables[1].table,&error))) - { - res= -1; - goto end; - } + goto error; get_all_items_for_category(thd,tables[1].table, used_fields[help_category_name].field, select,&subcategories_list); @@ -750,39 +731,36 @@ int mysqld_help(THD *thd, const char *mask) if (send_header_2(protocol, true) || send_variant_2_list(mem_root,protocol,&topics_list, "N",cat) || send_variant_2_list(mem_root,protocol,&subcategories_list,"Y",cat)) - goto end; + goto error; } } else if (count_topics == 1) { if (send_answer_1(protocol,&name,&description,&example)) - goto end; + goto error; } else { /* First send header and functions */ if (send_header_2(protocol, FALSE) || send_variant_2_list(mem_root,protocol, &topics_list, "N", 0)) - goto end; + goto error; if (!(select= prepare_select_for_name(thd,mask,mlen,tables,tables[1].table, used_fields[help_category_name].field,&error))) - { - res= -1; - goto end; - } + goto error; search_categories(thd, tables[1].table, used_fields, select,&categories_list, 0); delete select; /* Then send categories */ if (send_variant_2_list(mem_root,protocol, &categories_list, "Y", 0)) - goto end; + goto error; } - res= 0; - send_eof(thd); end: - DBUG_RETURN(res); + DBUG_RETURN(FALSE); +error: + DBUG_RETURN(TRUE); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 787774e3236..04d7bf5d5ab 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -115,12 +115,12 @@ check_insert_fields(THD *thd, TABLE_LIST *table_list, List<Item> &fields, } -int mysql_insert(THD *thd,TABLE_LIST *table_list, - List<Item> &fields, - List<List_item> &values_list, - List<Item> &update_fields, - List<Item> &update_values, - enum_duplicates duplic) +bool mysql_insert(THD *thd,TABLE_LIST *table_list, + List<Item> &fields, + List<List_item> &values_list, + List<Item> &update_fields, + List<Item> &update_values, + enum_duplicates duplic) { int error, res; /* @@ -174,7 +174,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, my_printf_error(ER_DELAYED_INSERT_TABLE_LOCKED, ER(ER_DELAYED_INSERT_TABLE_LOCKED), MYF(0), table_list->real_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } if ((table= delayed_get_table(thd,table_list)) && !thd->is_fatal_error) @@ -200,7 +200,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, #endif /* EMBEDDED_LIBRARY */ res= open_and_lock_tables(thd, table_list); if (res || thd->is_fatal_error) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); table= table_list->table; thd->proc_info="init"; @@ -298,6 +298,15 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, info.records++; continue; } + /* + Field::store methods can't send errors + + TODO: set thd->abort_on_warning if values_list.elements == 1 + and check that all items return warning in case of problem with + storing field. + */ + if (!thd->net.report_error) + my_error(ER_UNKNOWN_ERROR, MYF(0)); error=1; break; } @@ -315,6 +324,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, info.records++; continue; } + /* Field::store methods can't send errors */ + if (!thd->net.report_error) + my_error(ER_UNKNOWN_ERROR, MYF(0)); error=1; break; } @@ -465,7 +477,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, free_underlaid_joins(thd, &thd->lex->select_lex); table->insert_values=0; thd->abort_on_warning= 0; - DBUG_RETURN(0); + DBUG_RETURN(FALSE); abort: #ifndef EMBEDDED_LIBRARY @@ -475,7 +487,7 @@ abort: free_underlaid_joins(thd, &thd->lex->select_lex); table->insert_values=0; thd->abort_on_warning= 0; - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } @@ -609,11 +621,11 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list, table_list Global/local table list RETURN VALUE - 0 OK - -1 error (message is not sent to user) + FALSE OK + TRUE error */ -int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, +bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, List<Item> &fields, List_item *values, List<Item> &update_fields, List<Item> &update_values, enum_duplicates duplic) @@ -621,7 +633,7 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, bool insert_into_view= (table_list->view != 0); /* TODO: use this condition for 'WITH CHECK OPTION' */ Item *unused_conds= 0; - int res; + bool res; DBUG_ENTER("mysql_prepare_insert"); if (mysql_prepare_insert_check_table(thd, table_list, fields, &unused_conds)) @@ -636,15 +648,15 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, thd->lex->select_lex.no_wrap_view_item= 0, res) || setup_fields(thd, 0, table_list, update_values, 0, 0, 0)))) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); if (unique_table(table_list, table_list->next_independent())) { my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } thd->lex->select_lex.first_execution= 0; - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -737,7 +749,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) store_record(table,insert_values); restore_record(table,record[1]); if (fill_record(*info->update_fields, *info->update_values, 0)) + { + /* Field::store methods can't send errors */ + if (!thd->net.report_error) + my_error(ER_UNKNOWN_ERROR, MYF(0)); goto err; + } /* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */ if (info->view && @@ -1018,7 +1035,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) delete tmp; thd->fatal_error(); pthread_mutex_unlock(&LOCK_delayed_create); - net_printf(thd,ER_CANT_CREATE_THREAD,error); + my_error(ER_CANT_CREATE_THREAD, MYF(0), error); DBUG_RETURN(0); } @@ -1648,11 +1665,11 @@ bool delayed_insert::handle_inserts(void) thd thread handler RETURN - 0 OK - -1 Error + FALSE OK + TRUE Error */ -int mysql_insert_select_prepare(THD *thd) +bool mysql_insert_select_prepare(THD *thd) { LEX *lex= thd->lex; DBUG_ENTER("mysql_insert_select_prepare"); @@ -1664,8 +1681,8 @@ int mysql_insert_select_prepare(THD *thd) if (mysql_prepare_insert_check_table(thd, lex->query_tables, lex->field_list, &lex->select_lex.where)) - DBUG_RETURN(-1); - DBUG_RETURN(0); + DBUG_RETURN(TRUE); + DBUG_RETURN(FALSE); } @@ -1768,8 +1785,7 @@ void select_insert::send_error(uint errcode,const char *err) { DBUG_ENTER("select_insert::send_error"); - /* TODO error should be sent at the query processing end */ - ::send_error(thd,errcode,err); + my_message(errcode, err, MYF(0)); if (!table) { @@ -1845,8 +1861,6 @@ bool select_insert::send_eof() if (error) { table->file->print_error(error,MYF(0)); - //TODO error should be sent at the query processing end - ::send_error(thd); DBUG_RETURN(1); } char buff[160]; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 72d28aa4526..8536bcb5c3e 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -328,8 +328,8 @@ protected: TABLE *table; /* temporary table using for appending UNION results */ select_result *result; - int res; ulong found_rows_for_union; + bool res; bool prepared, // prepare phase already performed for UNION (unit) optimized, // optimize phase already performed for UNION (unit) executed, // already executed @@ -388,9 +388,9 @@ public: void exclude_tree(); /* UNION methods */ - int prepare(THD *thd, select_result *result, ulong additional_options); - int exec(); - int cleanup(); + bool prepare(THD *thd, select_result *result, ulong additional_options); + bool exec(); + bool cleanup(); inline void unclean() { cleaned= 0; } void reinit_exec_mechanism(); @@ -398,7 +398,7 @@ public: void print(String *str); ulong init_prepare_fake_select_lex(THD *thd); - int change_result(select_subselect *result, select_subselect *old_result); + bool change_result(select_subselect *result, select_subselect *old_result); void set_limit(st_select_lex *values, st_select_lex *sl); friend void mysql_init_query(THD *thd, uchar *buf, uint length, bool lexonly); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 28de2b9d116..353a3b2c83c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -78,7 +78,7 @@ static int read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, List<Item> &fields, READ_INFO &read_info, String &enclosed, ulong skip_lines); -int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, +bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, List<Item> &fields, enum enum_duplicates handle_duplicates, bool read_file_from_client,thr_lock_type lock_type) { @@ -112,16 +112,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS), MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } table_list->lock_type= lock_type; - if ((res= open_and_lock_tables(thd, table_list))) - DBUG_RETURN(res); + if (open_and_lock_tables(thd, table_list)) + DBUG_RETURN(TRUE); /* TODO: add key check when we will support VIEWs in LOAD */ if (!table_list->updatable) { my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } table= table_list->table; transactional_table= table->file->has_transactions(); @@ -140,14 +140,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, Item *unused_conds= 0; if (setup_tables(thd, table_list, &unused_conds) || setup_fields(thd, 0, table_list, fields, 1, 0, 0)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); if (thd->dupp_field) { my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), thd->dupp_field->field_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (check_that_all_fields_are_given_values(thd, table)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } uint tot_length=0; @@ -173,7 +173,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { my_message(ER_BLOBS_AND_NO_TERMINATED,ER(ER_BLOBS_AND_NO_TERMINATED), MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* We can't give an error in the middle when using LOCAL files */ @@ -206,7 +206,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, #if !defined(__WIN__) && !defined(OS2) && ! defined(__NETWARE__) MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(MY_WME))) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); // if we are not in slave thread, the file must be: if (!thd->slave_thread && @@ -218,14 +218,14 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, (stat_info.st_mode & S_IFIFO) == S_IFIFO))) { my_error(ER_TEXTFILE_NOT_READABLE,MYF(0),name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if ((stat_info.st_mode & S_IFIFO) == S_IFIFO) is_fifo = 1; #endif } if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } COPY_INFO info; @@ -240,7 +240,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { if (file >= 0) my_close(file,MYF(0)); // no files in net reading - DBUG_RETURN(-1); // Can't allocate buffers + DBUG_RETURN(TRUE); // Can't allocate buffers } #ifndef EMBEDDED_LIBRARY diff --git a/sql/sql_map.cc b/sql/sql_map.cc index e7e24f957c6..c6637474908 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -47,13 +47,12 @@ mapped_files::mapped_files(const my_string filename,byte *magic,uint magic_lengt 0L))) { error=errno; - my_printf_error(0,"Can't map file: %s, errno: %d",MYF(0), - (my_string) name,error); + my_error(ER_NO_FILE_MAPPING,MYF(0), (my_string) name, error); } } if (map && memcmp(map,magic,magic_length)) { - my_printf_error(0,"Wrong magic in %s",MYF(0),name); + my_error(ER_WRONG_MAGIC, MYF(0), name); VOID(munmap(map,size)); map=0; } @@ -112,8 +111,7 @@ mapped_files *map_file(const my_string name,byte *magic,uint magic_length) { map->use_count++; if (!map->map) - my_printf_error(0,"Can't map file: %s, error: %d",MYF(0),path, - map->error); + my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error); } VOID(pthread_mutex_unlock(&LOCK_mapped_file)); return map; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f93aaf09933..8817a29a705 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1191,7 +1191,7 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) if (!db || check_db_name(db)) { - net_printf(thd,ER_WRONG_DB_NAME, db ? db : "NULL"); + my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); goto err; } if (lower_case_table_names) @@ -1370,8 +1370,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, db= thd->alloc(db_len + tbl_len + 2); tbl_name= strmake(db, packet + 1, db_len)+1; strmake(tbl_name, packet + db_len + 2, tbl_len); - if (mysql_table_dump(thd, db, tbl_name, -1)) - send_error(thd); // dump to NET + mysql_table_dump(thd, db, tbl_name, -1); break; } case COM_CHANGE_USER: @@ -1396,7 +1395,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Small check for incoming packet */ if ((uint) ((uchar*) db - net->read_pos) > packet_length) { - send_error(thd, ER_UNKNOWN_COM_ERROR); + my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); break; } #endif @@ -1418,7 +1417,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (!(thd->user= my_strdup(user, MYF(0)))) { thd->user= save_user; - send_error(thd, ER_OUT_OF_RESOURCES); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); break; } @@ -1430,7 +1429,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { /* authentication failure, we shall restore old user */ if (res > 0) - send_error(thd, ER_UNKNOWN_COM_ERROR); + my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); x_free(thd->user); thd->user= save_user; thd->priv_user= save_priv_user; @@ -1538,7 +1537,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } case COM_FIELD_LIST: // This isn't actually needed #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ break; #else { @@ -1551,7 +1550,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, bzero((char*) &table_list,sizeof(table_list)); if (!(table_list.db=thd->db)) { - send_error(thd,ER_NO_DB_ERROR); + my_error(ER_NO_DB_ERROR, MYF(0)); break; } pend= strend(packet); @@ -1604,7 +1603,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, // null test to handle EOM if (!db || !(alias= thd->strdup(db)) || check_db_name(db)) { - net_printf(thd,ER_WRONG_DB_NAME, db ? db : "NULL"); + my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); break; } if (check_access(thd,CREATE_ACL,db,0,1,0)) @@ -1621,14 +1620,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* null test to handle EOM */ if (!db || !(alias= thd->strdup(db)) || check_db_name(db)) { - net_printf(thd,ER_WRONG_DB_NAME, db ? db : "NULL"); + my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); break; } if (check_access(thd,DROP_ACL,db,0,1,0)) break; if (thd->locked_tables || thd->active_transaction()) { - send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); break; } mysql_log.write(thd,command,db); @@ -1670,9 +1669,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (check_global_access(thd,RELOAD_ACL)) break; mysql_log.write(thd,command,NullS); - if (reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, NULL)) - send_error(thd, 0); - else + if (!reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, NULL)) send_ok(thd); break; } @@ -1696,7 +1693,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, else if (level != SHUTDOWN_WAIT_ALL_BUFFERS) { my_error(ER_NOT_SUPPORTED_YET, MYF(0), "this shutdown level"); - send_error(thd); break; } DBUG_PRINT("quit",("Got shutdown command for level %u", level)); @@ -1780,7 +1776,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, send_eof(thd); break; default: - send_error(thd, ER_UNKNOWN_COM_ERROR); + my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); break; } break; @@ -1799,7 +1795,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, case COM_DELAYED_INSERT: case COM_END: default: - send_error(thd, ER_UNKNOWN_COM_ERROR); + my_error(ER_UNKNOWN_COM_ERROR, MYF(0)); break; } if (thd->lock || thd->open_tables || thd->derived_tables) @@ -1808,8 +1804,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd, close_thread_tables(thd); /* Free tables */ } - if (thd->is_fatal_error) - send_error(thd,0); // End of memory ? + /* report error issued during command execution */ + if (thd->killed_errno() && !thd->net.report_error) + thd->send_kill_message(); + if (thd->is_fatal_error || thd->net.report_error) + send_error(thd); time_t start_of_query=thd->start_time; thd->end_time(); // Set start time @@ -1854,8 +1853,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, query_length RETURN VALUES - 0 ok - 1 error; In this case thd->fatal_error is set + FALSE ok + TRUE error; In this case thd->fatal_error is set */ bool alloc_query(THD *thd, char *packet, ulong packet_length) @@ -1880,7 +1879,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length) packet_length, thd->db_length+ 1 + QUERY_CACHE_FLAGS_SIZE))) - return 1; + return TRUE; thd->query[packet_length]=0; thd->query_length= packet_length; @@ -1890,7 +1889,7 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length) if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(),QUERY_PRIOR); - return 0; + return FALSE; } /**************************************************************************** @@ -1898,10 +1897,10 @@ bool alloc_query(THD *thd, char *packet, ulong packet_length) ** Execute command saved in thd and current_lex->sql_command ****************************************************************************/ -int +bool mysql_execute_command(THD *thd) { - int res= 0; + bool res= FALSE; LEX *lex= thd->lex; /* first table of first SELECT_LEX */ TABLE_LIST *first_table= (TABLE_LIST*) lex->select_lex.table_list.first; @@ -1982,7 +1981,6 @@ mysql_execute_command(THD *thd) if ((tmp= my_tz_get_table_list(thd, &lex->query_tables_last)) == &fake_time_zone_tables_list) { - send_error(thd, 0); DBUG_RETURN(-1); } lex->time_zone_tables_used= tmp; @@ -1998,7 +1996,7 @@ mysql_execute_command(THD *thd) !(thd->slave_thread || (thd->master_access & SUPER_ACL)) && (uc_update_queries[lex->sql_command] > 0)) { - net_printf(thd, ER_OPTION_PREVENTS_STATEMENT, "--read-only"); + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); DBUG_RETURN(-1); } @@ -2027,20 +2025,14 @@ mysql_execute_command(THD *thd) lex->exchange ? SELECT_ACL | FILE_ACL : SELECT_ACL, any_db, 0, 0, 0); if (res) - { - res=0; - break; // Error message is given - } + goto error; if (!(res= open_and_lock_tables(thd, all_tables))) { if (lex->describe) { if (!(result= new select_send())) - { - send_error(thd, ER_OUT_OF_RESOURCES); goto error; - } else thd->send_explain_fields(result); res= mysql_explain_union(thd, &thd->lex->unit, result); @@ -2060,10 +2052,7 @@ mysql_execute_command(THD *thd) else { if (!result && !(result= new select_send())) - { - res= -1; - break; - } + goto error; query_cache_store_query(thd, all_tables); res= handle_select(thd, lex, result); if (result != lex->result) @@ -2083,6 +2072,7 @@ mysql_execute_command(THD *thd) CHARSET_INFO *to_cs= thd->variables.collation_connection; bool need_conversion; user_var_entry *entry; + String *pstr= &str; uint32 unused; /* Convert @var contents to string in connection character set. Although @@ -2098,26 +2088,37 @@ mysql_execute_command(THD *thd) String *pstr; my_bool is_var_null; pstr= entry->val_str(&is_var_null, &str, NOT_FIXED_DEC); + /* + NULL value of variable checked early as entry->value so here + we can't get NULL in normal conditions + */ DBUG_ASSERT(!is_var_null); if (!pstr) - send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_ASSERT(pstr == &str); + goto error; } else + { + /* + variable absent or equal to NULL, so we need to set variable to + something reasonable to get readable error message during parsing + */ str.set("NULL", 4, &my_charset_latin1); + } + need_conversion= - String::needs_conversion(str.length(), str.charset(), to_cs, &unused); + String::needs_conversion(pstr->length(), pstr->charset(), + to_cs, &unused); - query_len= need_conversion? (str.length() * to_cs->mbmaxlen) : - str.length(); + query_len= need_conversion? (pstr->length() * to_cs->mbmaxlen) : + pstr->length(); if (!(query_str= alloc_root(&thd->mem_root, query_len+1))) - send_error(thd, ER_OUT_OF_RESOURCES); + goto error; if (need_conversion) - query_len= copy_and_convert(query_str, query_len, to_cs, str.ptr(), - str.length(), str.charset()); + query_len= copy_and_convert(query_str, query_len, to_cs, pstr->ptr(), + pstr->length(), pstr->charset()); else - memcpy(query_str, str.ptr(), str.length()); + memcpy(query_str, pstr->ptr(), pstr->length()); query_str[query_len]= 0; } else @@ -2130,8 +2131,8 @@ mysql_execute_command(THD *thd) query_len, query_str)); } thd->command= COM_PREPARE; - if (!mysql_stmt_prepare(thd, query_str, query_len + 1, - &lex->prepared_stmt_name)) + if (!(res= mysql_stmt_prepare(thd, query_str, query_len + 1, + &lex->prepared_stmt_name))) send_ok(thd, 0L, 0L, "Statement prepared"); break; } @@ -2157,22 +2158,20 @@ mysql_execute_command(THD *thd) } else { - res= -1; my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), lex->prepared_stmt_name.length, lex->prepared_stmt_name.str, "DEALLOCATE PREPARE"); + goto error; } break; } case SQLCOM_DO: if (all_tables && - ((res= check_table_access(thd, SELECT_ACL, all_tables, 0)) || - (res= open_and_lock_tables(thd, all_tables)))) - break; + (check_table_access(thd, SELECT_ACL, all_tables, 0) || + open_and_lock_tables(thd, all_tables))) + goto error; res= mysql_do(thd, *lex->insert_list); - if (thd->net.report_error) - res= -1; break; case SQLCOM_EMPTY_QUERY: @@ -2222,12 +2221,12 @@ mysql_execute_command(THD *thd) goto error; /* This query don't work now. See comment in repl_failsafe.cc */ #ifndef WORKING_NEW_MASTER - net_printf(thd, ER_NOT_SUPPORTED_YET, "SHOW NEW MASTER"); - res= 1; + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "SHOW NEW MASTER"); + goto error; #else res = show_new_master(thd); -#endif break; +#endif } #ifdef HAVE_REPLICATION @@ -2323,7 +2322,7 @@ mysql_execute_command(THD *thd) if (check_global_access(thd, SUPER_ACL)) goto error; if (end_active_trans(thd)) - res= -1; + goto error; else res = load_master_data(thd); break; @@ -2354,7 +2353,7 @@ mysql_execute_command(THD *thd) } if (strlen(first_table->real_name) > NAME_LEN) { - net_printf(thd, ER_WRONG_TABLE_NAME, first_table->real_name); + my_error(ER_WRONG_TABLE_NAME, MYF(0), first_table->real_name); break; } pthread_mutex_lock(&LOCK_active_mi); @@ -2381,7 +2380,7 @@ mysql_execute_command(THD *thd) TABLE_LIST *select_tables= lex->query_tables; if ((res= create_table_precheck(thd, select_tables, create_table))) - goto unsent_create_error; + goto create_error; #ifndef HAVE_READLINK lex->create_info.data_file_name=lex->create_info.index_file_name=0; @@ -2391,10 +2390,7 @@ mysql_execute_command(THD *thd) create_table->real_name) || append_file_to_dir(thd, &lex->create_info.index_file_name, create_table->real_name)) - { - res=-1; - goto unsent_create_error; - } + goto create_error; #endif /* If we are using SET CHARSET without DEFAULT, add an implicit @@ -2428,7 +2424,7 @@ mysql_execute_command(THD *thd) if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && unique_table(create_table, select_tables)) { - net_printf(thd, ER_UPDATE_TABLE_USED, create_table->real_name); + my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->real_name); goto create_error; } /* If we create merge table, we have to test tables in merge, too */ @@ -2441,7 +2437,7 @@ mysql_execute_command(THD *thd) { if (unique_table(tab, select_tables)) { - net_printf(thd, ER_UPDATE_TABLE_USED, tab->real_name); + my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->real_name); goto create_error; } } @@ -2488,11 +2484,9 @@ mysql_execute_command(THD *thd) break; create_error: - res= 1; //error reported -unsent_create_error: /* put tables back for PS rexecuting */ lex->link_first_table_back(create_table, link_to_local); - break; + goto error; } case SQLCOM_CREATE_INDEX: DBUG_ASSERT(first_table == all_tables && first_table != 0); @@ -2500,7 +2494,7 @@ unsent_create_error: goto error; /* purecov: inspected */ thd->slow_command=TRUE; if (end_active_trans(thd)) - res= -1; + goto error; else res = mysql_create_index(thd, first_table, lex->key_list); break; @@ -2529,7 +2523,7 @@ unsent_create_error: */ if (thd->locked_tables || thd->active_transaction()) { - send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); goto error; } { @@ -2543,16 +2537,15 @@ unsent_create_error: case SQLCOM_ALTER_TABLE: DBUG_ASSERT(first_table == all_tables && first_table != 0); #if defined(DONT_ALLOW_SHOW_COMMANDS) - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { ulong priv=0; if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN)) { - net_printf(thd, ER_WRONG_TABLE_NAME, lex->name); - res=0; - break; + my_error(ER_WRONG_TABLE_NAME, MYF(0), lex->name); + goto error; } if (!select_lex->db) select_lex->db= first_table->db; @@ -2583,7 +2576,7 @@ unsent_create_error: lex->create_info.data_file_name=lex->create_info.index_file_name=0; /* ALTER TABLE ends previous transaction */ if (end_active_trans(thd)) - res= -1; + goto error; else { thd->slow_command=TRUE; @@ -2628,16 +2621,14 @@ unsent_create_error: } } query_cache_invalidate3(thd, first_table, 0); - if (end_active_trans(thd)) - res= -1; - else if (mysql_rename_tables(thd, first_table)) - res= -1; + if (end_active_trans(thd) || mysql_rename_tables(thd, first_table)) + goto error; break; } #ifndef EMBEDDED_LIBRARY case SQLCOM_SHOW_BINLOGS: #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { @@ -2651,7 +2642,7 @@ unsent_create_error: case SQLCOM_SHOW_CREATE: DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { @@ -2754,8 +2745,6 @@ unsent_create_error: (ORDER *) select_lex->order_list.first, select_lex->select_limit, lex->duplicates); - if (thd->net.report_error) - res= -1; break; case SQLCOM_UPDATE_MULTI: { @@ -2780,8 +2769,6 @@ unsent_create_error: res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values, select_lex->item_list, lex->value_list, (update ? DUP_UPDATE : lex->duplicates)); - if (thd->net.report_error) - res= -1; if (first_table->view && !first_table->contain_auto_increment) thd->last_insert_id= 0; // do not show last insert ID if VIEW have not it break; @@ -2834,11 +2821,9 @@ unsent_create_error: lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE; delete result; } - if (thd->net.report_error) - res= -1; } else - res= -1; + res= TRUE; if (first_table->view && !first_table->contain_auto_increment) thd->last_insert_id= 0; // do not show last insert ID if VIEW have not it @@ -2855,7 +2840,7 @@ unsent_create_error: */ if (thd->locked_tables || thd->active_transaction()) { - send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION,NullS); + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); goto error; } @@ -2869,8 +2854,6 @@ unsent_create_error: res = mysql_delete(thd, all_tables, select_lex->where, &select_lex->order_list, select_lex->select_limit, select_lex->options); - if (thd->net.report_error) - res= -1; break; } case SQLCOM_DELETE_MULTI: @@ -2888,14 +2871,11 @@ unsent_create_error: if (select_lex->item_list.elements != 0) select_lex->item_list.empty(); if (add_item_to_list(thd, new Item_null())) - { - res= -1; - break; - } + goto error; thd->proc_info="init"; - if ((res= open_and_lock_tables(thd, all_tables))) - break; + if (open_and_lock_tables(thd, all_tables)) + goto error; if ((res= mysql_multi_delete_prepare(thd))) break; @@ -2913,12 +2893,10 @@ unsent_create_error: select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, result, unit, select_lex); - if (thd->net.report_error) - res= -1; delete result; } else - res= -1; // Error is not sent + res= TRUE; close_thread_tables(thd); break; } @@ -2930,10 +2908,7 @@ unsent_create_error: if (check_table_access(thd, DROP_ACL, all_tables, 0)) goto error; /* purecov: inspected */ if (end_active_trans(thd)) - { - res= -1; - break; - } + goto error; } else { @@ -2957,13 +2932,13 @@ unsent_create_error: if (check_one_table_access(thd, INDEX_ACL, all_tables)) goto error; /* purecov: inspected */ if (end_active_trans(thd)) - res= -1; + goto error; else res = mysql_drop_index(thd, first_table, &lex->alter_info); break; case SQLCOM_SHOW_DATABASES: #if defined(DONT_ALLOW_SHOW_COMMANDS) - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else if ((specialflag & SPECIAL_SKIP_SHOW_DB) && @@ -3009,7 +2984,7 @@ unsent_create_error: break; case SQLCOM_SHOW_LOGS: #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { @@ -3022,30 +2997,30 @@ unsent_create_error: case SQLCOM_SHOW_TABLES: /* FALL THROUGH */ #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { char *db=select_lex->db ? select_lex->db : thd->db; if (!db) { - send_error(thd,ER_NO_DB_ERROR); /* purecov: inspected */ + my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: inspected */ goto error; /* 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); goto error; } if (check_access(thd,SELECT_ACL,db,&thd->col_access,0,0)) goto error; /* 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); goto error; } /* grant is checked in mysqld_show_tables */ @@ -3071,7 +3046,7 @@ unsent_create_error: case SQLCOM_SHOW_FIELDS: DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { @@ -3092,7 +3067,7 @@ unsent_create_error: case SQLCOM_SHOW_KEYS: DBUG_ASSERT(first_table == all_tables && first_table != 0); #ifdef DONT_ALLOW_SHOW_COMMANDS - send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); /* purecov: inspected */ goto error; #else { @@ -3128,7 +3103,7 @@ unsent_create_error: if (!(thd->client_capabilities & CLIENT_LOCAL_FILES) || ! opt_local_infile) { - send_error(thd,ER_NOT_ALLOWED_COMMAND); + my_error(ER_NOT_ALLOWED_COMMAND, MYF(0)); goto error; } if (check_one_table_access(thd, privilege, all_tables)) @@ -3143,15 +3118,13 @@ unsent_create_error: { List<set_var_base> *lex_var_list= &lex->var_list; if (all_tables && - ((res= check_table_access(thd, SELECT_ACL, all_tables, 0)) || - (res= open_and_lock_tables(thd, all_tables)))) - break; + (check_table_access(thd, SELECT_ACL, all_tables, 0) || + open_and_lock_tables(thd, all_tables))) + goto error; if (lex->one_shot_set && not_all_support_one_shot(lex_var_list)) { - my_printf_error(0, "The SET ONE_SHOT syntax is reserved for \ -purposes internal to the MySQL server", MYF(0)); - res= -1; - break; + my_error(ER_RESERVED_SYNTAX, MYF(0), "SET ONE_SHOT"); + goto error; } if (!(res= sql_set_variables(thd, lex_var_list))) { @@ -3162,8 +3135,6 @@ purposes internal to the MySQL server", MYF(0)); thd->one_shot_set|= lex->one_shot_set; send_ok(thd); } - if (thd->net.report_error) - res= -1; break; } @@ -3206,7 +3177,7 @@ purposes internal to the MySQL server", MYF(0)); char *alias; if (!(alias=thd->strdup(lex->name)) || check_db_name(lex->name)) { - net_printf(thd,ER_WRONG_DB_NAME, lex->name); + my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); break; } /* @@ -3236,7 +3207,7 @@ purposes internal to the MySQL server", MYF(0)); char *alias; if (!(alias=thd->strdup(lex->name)) || check_db_name(lex->name)) { - net_printf(thd, ER_WRONG_DB_NAME, lex->name); + my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); break; } /* @@ -3259,7 +3230,7 @@ purposes internal to the MySQL server", MYF(0)); break; if (thd->locked_tables || thd->active_transaction()) { - send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); goto error; } res=mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : lex->name), @@ -3270,7 +3241,7 @@ purposes internal to the MySQL server", MYF(0)); { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - net_printf(thd, ER_WRONG_DB_NAME, lex->name); + my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); break; } /* @@ -3293,7 +3264,7 @@ purposes internal to the MySQL server", MYF(0)); break; if (thd->locked_tables || thd->active_transaction()) { - send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); goto error; } res=mysql_alter_db(thd,lex->name,&lex->create_info); @@ -3303,14 +3274,14 @@ purposes internal to the MySQL server", MYF(0)); { if (!strip_sp(lex->name) || check_db_name(lex->name)) { - net_printf(thd,ER_WRONG_DB_NAME, lex->name); + my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); break; } if (check_access(thd,SELECT_ACL,lex->name,0,1,0)) break; if (thd->locked_tables || thd->active_transaction()) { - send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION); + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); goto error; } res=mysqld_show_create_db(thd,lex->name,&lex->create_info); @@ -3324,13 +3295,13 @@ purposes internal to the MySQL server", MYF(0)); #ifdef HAVE_DLOPEN if ((sph= sp_find_function(thd, lex->spname))) { - net_printf(thd, ER_UDF_EXISTS, lex->spname->m_name.str); + my_error(ER_UDF_EXISTS, MYF(0), lex->spname->m_name.str); goto error; } if (!(res = mysql_create_function(thd,&lex->udf))) send_ok(thd); #else - res= -1; + res= TRUE; #endif break; } @@ -3432,8 +3403,8 @@ purposes internal to the MySQL server", MYF(0)); { if (lex->columns.elements) { - send_error(thd,ER_ILLEGAL_GRANT_FOR_TABLE); - res=1; + my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); + goto error; } else res = mysql_grant(thd, select_lex->db, lex->users_list, lex->grant, @@ -3473,9 +3444,7 @@ purposes internal to the MySQL server", MYF(0)); binlog or not. */ bool write_to_binlog; - if (reload_acl_and_cache(thd, lex->type, first_table, &write_to_binlog)) - send_error(thd, 0); - else + if (!reload_acl_and_cache(thd, lex->type, first_table, &write_to_binlog)) { /* We WANT to write and we CAN write. @@ -3498,7 +3467,6 @@ purposes internal to the MySQL server", MYF(0)); break; #ifndef NO_EMBEDDED_ACCESS_CHECKS case SQLCOM_SHOW_GRANTS: - res=0; if ((thd->priv_user && !strcmp(thd->priv_user,lex->grant_user->user.str)) || !check_access(thd, SELECT_ACL, "mysql",0,1,0)) @@ -3542,9 +3510,7 @@ purposes internal to the MySQL server", MYF(0)); close_thread_tables(thd); // Free tables } if (end_active_trans(thd)) - { - res= -1; - } + goto error; else { thd->options= ((thd->options & (ulong) ~(OPTION_STATUS_NO_TRANS_UPDATE)) | @@ -3567,7 +3533,7 @@ purposes internal to the MySQL server", MYF(0)); send_ok(thd); } else - res= -1; + goto error; break; } case SQLCOM_ROLLBACK: @@ -3589,7 +3555,7 @@ purposes internal to the MySQL server", MYF(0)); send_ok(thd); } else - res= -1; + res= TRUE; thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE); break; case SQLCOM_ROLLBACK_TO_SAVEPOINT: @@ -3601,29 +3567,26 @@ purposes internal to the MySQL server", MYF(0)); send_ok(thd); } else - res= -1; + goto error; break; case SQLCOM_SAVEPOINT: if (!ha_savepoint(thd, lex->savepoint_name)) send_ok(thd); else - res= -1; + goto error; break; case SQLCOM_CREATE_PROCEDURE: case SQLCOM_CREATE_SPFUNCTION: { uint namelen; char *name; + int result; - if (!lex->sphead) - { - res= -1; // Shouldn't happen - break; - } + DBUG_ASSERT(lex->sphead); if (! lex->sphead->m_db.str) { - send_error(thd,ER_NO_DB_ERROR); + my_error(ER_NO_DB_ERROR, MYF(0)); delete lex->sphead; lex->sphead= 0; goto error; @@ -3637,7 +3600,7 @@ purposes internal to the MySQL server", MYF(0)); if (udf) { - net_printf(thd, ER_UDF_EXISTS, name); + my_error(ER_UDF_EXISTS, MYF(0), name); delete lex->sphead; lex->sphead= 0; goto error; @@ -3647,14 +3610,14 @@ purposes internal to the MySQL server", MYF(0)); if (lex->sphead->m_type == TYPE_ENUM_FUNCTION && !lex->sphead->m_has_return) { - net_printf(thd, ER_SP_NORETURN, name); + my_error(ER_SP_NORETURN, MYF(0), name); delete lex->sphead; lex->sphead= 0; goto error; } - res= lex->sphead->create(thd); - switch (res) { + res= (result= lex->sphead->create(thd)); + switch (result) { case SP_OK: send_ok(thd); lex->unit.cleanup(); @@ -3662,19 +3625,19 @@ purposes internal to the MySQL server", MYF(0)); lex->sphead= 0; break; case SP_WRITE_ROW_FAILED: - net_printf(thd, ER_SP_ALREADY_EXISTS, SP_TYPE_STRING(lex), name); + my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); lex->unit.cleanup(); delete lex->sphead; lex->sphead= 0; goto error; case SP_NO_DB_ERROR: - net_printf(thd, ER_BAD_DB_ERROR, lex->sphead->m_db.str); + my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); lex->unit.cleanup(); delete lex->sphead; lex->sphead= 0; goto error; default: - net_printf(thd, ER_SP_STORE_FAILED, SP_TYPE_STRING(lex), name); + my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name); lex->unit.cleanup(); delete lex->sphead; lex->sphead= 0; @@ -3688,8 +3651,8 @@ purposes internal to the MySQL server", MYF(0)); if (!(sp= sp_find_procedure(thd, lex->spname))) { - net_printf(thd, ER_SP_DOES_NOT_EXIST, "PROCEDURE", - lex->spname->m_qname.str); + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PROCEDURE", + lex->spname->m_qname.str); goto error; } else @@ -3703,11 +3666,9 @@ purposes internal to the MySQL server", MYF(0)); /* In case the arguments are subselects... */ if (all_tables && - ((res= check_table_access(thd, SELECT_ACL, all_tables, 0)) || - (res= open_and_lock_tables(thd, all_tables)))) - { - break; - } + (check_table_access(thd, SELECT_ACL, all_tables, 0) || + open_and_lock_tables(thd, all_tables))) + goto error; #ifndef EMBEDDED_LIBRARY /* @@ -3721,7 +3682,7 @@ purposes internal to the MySQL server", MYF(0)); { if (! (thd->client_capabilities & CLIENT_MULTI_RESULTS)) { - send_error(thd, ER_SP_BADSELECT); + my_error(ER_SP_BADSELECT, MYF(0)); #ifndef EMBEDDED_LIBRARY thd->net.no_send_ok= nsok; #endif @@ -3754,7 +3715,7 @@ purposes internal to the MySQL server", MYF(0)); thd->server_status &= ~SERVER_MORE_RESULTS_EXISTS; } - if (res == 0) + if (!res) send_ok(thd, (ulong) (thd->row_count_func < 0 ? 0 : thd->row_count_func)); else goto error; // Substatement should already have sent error @@ -3764,32 +3725,33 @@ purposes internal to the MySQL server", MYF(0)); case SQLCOM_ALTER_PROCEDURE: case SQLCOM_ALTER_FUNCTION: { - res= -1; + int result; uint newname_len= 0; if (lex->name) newname_len= strlen(lex->name); if (newname_len > NAME_LEN) { - net_printf(thd, ER_TOO_LONG_IDENT, lex->name); - goto error; + my_error(ER_TOO_LONG_IDENT, MYF(0), lex->name); + goto error; } if (lex->sql_command == SQLCOM_ALTER_PROCEDURE) - res= sp_update_procedure(thd, lex->spname, - lex->name, newname_len, &lex->sp_chistics); + result= sp_update_procedure(thd, lex->spname, + lex->name, newname_len, &lex->sp_chistics); else - res= sp_update_function(thd, lex->spname, - lex->name, newname_len, &lex->sp_chistics); - switch (res) + result= sp_update_function(thd, lex->spname, + lex->name, newname_len, &lex->sp_chistics); + res= result; + switch (result) { case SP_OK: send_ok(thd); break; case SP_KEY_NOT_FOUND: - net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex), + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), SP_COM_STRING(lex), lex->spname->m_qname.str); goto error; default: - net_printf(thd, ER_SP_CANT_ALTER, SP_COM_STRING(lex), + my_error(ER_SP_CANT_ALTER, MYF(0), SP_COM_STRING(lex), lex->spname->m_qname.str); goto error; } @@ -3798,13 +3760,14 @@ purposes internal to the MySQL server", MYF(0)); case SQLCOM_DROP_PROCEDURE: case SQLCOM_DROP_FUNCTION: { + int result; if (lex->sql_command == SQLCOM_DROP_PROCEDURE) - res= sp_drop_procedure(thd, lex->spname); + result= sp_drop_procedure(thd, lex->spname); else { - res= sp_drop_function(thd, lex->spname); + result= sp_drop_function(thd, lex->spname); #ifdef HAVE_DLOPEN - if (res == SP_KEY_NOT_FOUND) + if (result == SP_KEY_NOT_FOUND) { udf_func *udf = find_udf(lex->spname->m_name.str, lex->spname->m_name.length); @@ -3812,7 +3775,7 @@ purposes internal to the MySQL server", MYF(0)); { if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0)) goto error; - if (!(res = mysql_drop_function(thd,&lex->spname->m_name))) + if (!(result = mysql_drop_function(thd,&lex->spname->m_name))) { send_ok(thd); break; @@ -3821,7 +3784,8 @@ purposes internal to the MySQL server", MYF(0)); } #endif } - switch (res) + res= result; + switch (result) { case SP_OK: send_ok(thd); @@ -3832,34 +3796,31 @@ purposes internal to the MySQL server", MYF(0)); push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), SP_COM_STRING(lex), lex->spname->m_name.str); - res= 0; + res= FALSE; send_ok(thd); break; } - net_printf(thd, ER_SP_DOES_NOT_EXIST, SP_COM_STRING(lex), - lex->spname->m_qname.str); + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), SP_COM_STRING(lex), + lex->spname->m_qname.str); goto error; default: - net_printf(thd, ER_SP_DROP_FAILED, SP_COM_STRING(lex), - lex->spname->m_qname.str); + my_error(ER_SP_DROP_FAILED, MYF(0), SP_COM_STRING(lex), + lex->spname->m_qname.str); goto error; } break; } case SQLCOM_SHOW_CREATE_PROC: { - res= -1; if (lex->spname->m_name.length > NAME_LEN) { - net_printf(thd, ER_TOO_LONG_IDENT, lex->spname->m_name.str); + my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str); goto error; } - res= sp_show_create_procedure(thd, lex->spname); - if (res != SP_OK) + if (sp_show_create_procedure(thd, lex->spname) != SP_OK) { /* We don't distinguish between errors for now */ - net_printf(thd, ER_SP_DOES_NOT_EXIST, - SP_COM_STRING(lex), lex->spname->m_name.str); - res= 0; + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), + SP_COM_STRING(lex), lex->spname->m_name.str); goto error; } break; @@ -3868,18 +3829,15 @@ purposes internal to the MySQL server", MYF(0)); { if (lex->spname->m_name.length > NAME_LEN) { - net_printf(thd, ER_TOO_LONG_IDENT, lex->spname->m_name.str); + my_error(ER_TOO_LONG_IDENT, MYF(0), lex->spname->m_name.str); goto error; } - res= sp_show_create_function(thd, lex->spname); - if (res != SP_OK) + if (sp_show_create_function(thd, lex->spname) != SP_OK) { /* We don't distinguish between errors for now */ - net_printf(thd, ER_SP_DOES_NOT_EXIST, - SP_COM_STRING(lex), lex->spname->m_name.str); - res= 0; + my_error(ER_SP_DOES_NOT_EXIST, MYF(0), + SP_COM_STRING(lex), lex->spname->m_name.str); goto error; } - res= 0; break; } case SQLCOM_SHOW_STATUS_PROC: @@ -3901,13 +3859,9 @@ purposes internal to the MySQL server", MYF(0)); } case SQLCOM_DROP_VIEW: { - if (check_table_access(thd, DROP_ACL, all_tables, 0)) - goto error; - if (end_active_trans(thd)) - { - res= -1; - break; - } + if (check_table_access(thd, DROP_ACL, all_tables, 0) || + end_active_trans(thd)) + goto error; res= mysql_drop_view(thd, first_table, thd->lex->drop_mode); break; } @@ -3975,17 +3929,11 @@ purposes internal to the MySQL server", MYF(0)); thd->row_count_func= -1; } - /* - We end up here if res == 0 and send_ok() has been done, - or res != 0 and no send_error() has yet been done. - */ - if (res < 0) - send_error(thd,thd->killed_errno()); - DBUG_RETURN(res); + DBUG_RETURN(res || thd->net.report_error); error: /* We end up here if send_error() has already been done. */ - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } @@ -4064,7 +4012,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, { DBUG_PRINT("error",("No database")); if (!no_errors) - send_error(thd,ER_NO_DB_ERROR); /* purecov: tested */ + my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ } @@ -4091,10 +4039,10 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, { // We can never grant this DBUG_PRINT("error",("No possible access")); if (!no_errors) - net_printf(thd,ER_ACCESS_DENIED_ERROR, - thd->priv_user, - thd->priv_host, - thd->password ? ER(ER_YES) : ER(ER_NO));/* purecov: tested */ + my_error(ER_ACCESS_DENIED_ERROR, MYF(0), + thd->priv_user, + thd->priv_host, + thd->password ? ER(ER_YES) : ER(ER_NO));/* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ } @@ -4120,10 +4068,10 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv, DBUG_PRINT("error",("Access denied")); if (!no_errors) - net_printf(thd,ER_DBACCESS_DENIED_ERROR, - thd->priv_user, - thd->priv_host, - db ? db : thd->db ? thd->db : "unknown"); /* purecov: tested */ + my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), + thd->priv_user, + thd->priv_host, + db ? db : thd->db ? thd->db : "unknown"); /* purecov: tested */ DBUG_RETURN(TRUE); /* purecov: tested */ #endif /* NO_EMBEDDED_ACCESS_CHECKS */ } @@ -4157,8 +4105,7 @@ bool check_global_access(THD *thd, ulong want_access) if ((thd->master_access & want_access)) return 0; get_privilege_desc(command, sizeof(command), want_access); - net_printf(thd,ER_SPECIFIC_ACCESS_DENIED_ERROR, - command); + my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command); return 1; #endif /* NO_EMBEDDED_ACCESS_CHECKS */ } @@ -4270,7 +4217,7 @@ static bool check_db_used(THD *thd,TABLE_LIST *tables) { if (!(tables->db=thd->db)) { - send_error(thd,ER_NO_DB_ERROR); /* purecov: tested */ + my_error(ER_NO_DB_ERROR, MYF(0)); /* purecov: tested */ return TRUE; /* purecov: tested */ } } @@ -4449,7 +4396,7 @@ mysql_new_select(LEX *lex, bool move_down) { if (lex->current_select->order_list.first && !lex->current_select->braces) { - net_printf(lex->thd, ER_WRONG_USAGE, "UNION", "ORDER BY"); + my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY"); return 1; } select_lex->include_neighbour(lex->current_select); @@ -4549,7 +4496,6 @@ void mysql_parse(THD *thd, char *inBuf, uint length) { if (thd->net.report_error) { - send_error(thd, 0, NullS); if (thd->lex->sphead) { if (lex != thd->lex) @@ -4638,7 +4584,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, if (strlen(field_name) > NAME_LEN) { - net_printf(thd, ER_TOO_LONG_IDENT, field_name); /* purecov: inspected */ + my_error(ER_TOO_LONG_IDENT, MYF(0), field_name); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } if (type_modifier & PRI_KEY_FLAG) @@ -4669,7 +4615,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, !(((Item_func*)default_value)->functype() == Item_func::NOW_FUNC && type == FIELD_TYPE_TIMESTAMP)) { - net_printf(thd, ER_INVALID_DEFAULT, field_name); + my_error(ER_INVALID_DEFAULT, MYF(0), field_name); DBUG_RETURN(1); } else if (default_value->type() == Item::NULL_ITEM) @@ -4678,20 +4624,20 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG) { - net_printf(thd,ER_INVALID_DEFAULT,field_name); + my_error(ER_INVALID_DEFAULT, MYF(0), field_name); DBUG_RETURN(1); } } else if (type_modifier & AUTO_INCREMENT_FLAG) { - net_printf(thd, ER_INVALID_DEFAULT, field_name); + my_error(ER_INVALID_DEFAULT, MYF(0), field_name); DBUG_RETURN(1); } } if (on_update_value && type != FIELD_TYPE_TIMESTAMP) { - net_printf(thd, ER_INVALID_ON_UPDATE, field_name); + my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name); DBUG_RETURN(1); } @@ -4817,7 +4763,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, res=default_value->val_str(&str); if (res->length()) { - net_printf(thd,ER_BLOB_CANT_HAVE_DEFAULT,field_name); /* purecov: inspected */ + my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), + field_name); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } new_field->def=0; @@ -4837,7 +4784,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, uint tmp_length=new_field->length; if (tmp_length > PRECISION_FOR_DOUBLE) { - net_printf(thd,ER_WRONG_FIELD_SPEC,field_name); + my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name); DBUG_RETURN(1); } else if (tmp_length > PRECISION_FOR_FLOAT) @@ -4923,7 +4870,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, { if (interval->count > sizeof(longlong)*8) { - net_printf(thd,ER_TOO_BIG_SET,field_name); /* purecov: inspected */ + my_error(ER_TOO_BIG_SET, MYF(0), field_name); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } new_field->pack_length=(interval->count+7)/8; @@ -4953,7 +4900,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, ¬_used2, ¬_used3); if (thd->cuted_fields) { - net_printf(thd,ER_INVALID_DEFAULT,field_name); + my_error(ER_INVALID_DEFAULT, MYF(0), field_name); DBUG_RETURN(1); } } @@ -4979,7 +4926,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, res->strip_sp(); if (!find_type(interval, res->ptr(), res->length(), 0)) { - net_printf(thd,ER_INVALID_DEFAULT,field_name); + my_error(ER_INVALID_DEFAULT, MYF(0), field_name); DBUG_RETURN(1); } } @@ -4993,14 +4940,14 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING && type != FIELD_TYPE_GEOMETRY)) { - net_printf(thd,ER_TOO_BIG_FIELDLENGTH,field_name, - MAX_FIELD_CHARLENGTH); /* purecov: inspected */ + my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name, + MAX_FIELD_CHARLENGTH); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } type_modifier&= AUTO_INCREMENT_FLAG; if ((~allowed_type_modifier) & type_modifier) { - net_printf(thd,ER_WRONG_FIELD_SPEC,field_name); + my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name); DBUG_RETURN(1); } if (!new_field->pack_length) @@ -5130,7 +5077,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (check_table_name(table->table.str,table->table.length) || table->db.str && check_db_name(table->db.str)) { - net_printf(thd, ER_WRONG_TABLE_NAME, table->table.str); + my_error(ER_WRONG_TABLE_NAME, MYF(0), table->table.str); DBUG_RETURN(0); } @@ -5138,7 +5085,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, { if (table->sel) { - net_printf(thd,ER_DERIVED_MUST_HAVE_ALIAS); + my_error(ER_DERIVED_MUST_HAVE_ALIAS, MYF(0)); DBUG_RETURN(0); } if (!(alias_str=thd->memdup(alias_str,table->table.length+1))) @@ -5192,7 +5139,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, if (!my_strcasecmp(table_alias_charset, alias_str, tables->alias) && !strcmp(ptr->db, tables->db)) { - net_printf(thd,ER_NONUNIQ_TABLE,alias_str); /* purecov: tested */ + my_error(ER_NONUNIQ_TABLE, MYF(0), alias_str); /* purecov: tested */ DBUG_RETURN(0); /* purecov: tested */ } } @@ -5688,7 +5635,7 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query) if (!error) send_ok(thd); else - net_printf(thd,error,id); + my_error(error, MYF(0), id); } /* Clear most status variables */ @@ -5769,7 +5716,7 @@ bool check_simple_select() char command[80]; strmake(command, thd->lex->yylval->symbol.str, min(thd->lex->yylval->symbol.length, sizeof(command)-1)); - net_printf(thd, ER_CANT_USE_OPTION_HERE, command); + my_error(ER_CANT_USE_OPTION_HERE, MYF(0), command); return 1; } return 0; @@ -5857,7 +5804,7 @@ Item * all_any_subquery_creator(Item *left_expr, One should normally create all indexes with CREATE TABLE or ALTER TABLE. */ -int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) +bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) { List<create_field> fields; ALTER_INFO alter_info; @@ -5875,7 +5822,7 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) } -int mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info) +bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info) { List<create_field> fields; List<Key> keys; @@ -5903,12 +5850,11 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info) tables Global/local table list (have to be the same) RETURN VALUE - 0 OK - 1 Error (message is sent to user) - -1 Error (message is not sent to user) + FALSE OK + TRUE Error */ -int multi_update_precheck(THD *thd, TABLE_LIST *tables) +bool multi_update_precheck(THD *thd, TABLE_LIST *tables) { const char *msg= 0; TABLE_LIST *table; @@ -5919,7 +5865,7 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) if (select_lex->item_list.elements != lex->value_list.elements) { my_error(ER_WRONG_VALUE_COUNT, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* Ensure that we have UPDATE or SELECT privilege for each table @@ -5933,7 +5879,7 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) (check_access(thd, SELECT_ACL, table->db, &table->grant.privilege, 0, 0) || grant_option && check_grant(thd, SELECT_ACL, table, 0, 1, 0))) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); table->table_in_first_from_clause= 1; } @@ -5949,7 +5895,7 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) if (check_access(thd, SELECT_ACL, table->db, &table->grant.privilege, 0, 0) || grant_option && check_grant(thd, SELECT_ACL, table, 0, 1, 0)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } } @@ -5962,9 +5908,9 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) if (msg) { my_error(ER_WRONG_USAGE, MYF(0), "UPDATE", msg); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } /* @@ -5977,11 +5923,11 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) table_count Pointer to table counter RETURN VALUE - 0 OK - 1 error (message is sent to user) - -1 error (message is not sent to user) + FALSE OK + TRUE error */ -int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) + +bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) { SELECT_LEX *select_lex= &thd->lex->select_lex; TABLE_LIST *aux_tables= @@ -5996,11 +5942,11 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) if (check_db_used(thd, tables) || check_db_used(thd,aux_tables) || check_table_access(thd,SELECT_ACL, tables,0) || check_table_access(thd,DELETE_ACL, aux_tables,0)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); if ((thd->options & OPTION_SAFE_UPDATES) && !select_lex->where) { my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } for (target_tbl= aux_tables; target_tbl; target_tbl= target_tbl->next_local) { @@ -6018,12 +5964,12 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) { my_error(ER_UNKNOWN_TABLE, MYF(0), target_tbl->real_name, "MULTI DELETE"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } walk->lock_type= target_tbl->lock_type; target_tbl->correspondent_table= walk; // Remember corresponding table } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -6036,12 +5982,11 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) tables Global table list RETURN VALUE - 0 OK - 1 Error (message is sent to user) - -1 Error (message is not sent to user) + FALSE OK + TRUE Error */ -int insert_select_precheck(THD *thd, TABLE_LIST *tables) +bool insert_select_precheck(THD *thd, TABLE_LIST *tables) { DBUG_ENTER("insert_select_precheck"); /* @@ -6050,7 +5995,7 @@ int insert_select_precheck(THD *thd, TABLE_LIST *tables) */ ulong privilege= (thd->lex->duplicates == DUP_REPLACE ? INSERT_ACL | DELETE_ACL : INSERT_ACL); - DBUG_RETURN(check_one_table_access(thd, privilege, tables) ? 1 : 0); + DBUG_RETURN(check_one_table_access(thd, privilege, tables)); } @@ -6063,21 +6008,20 @@ int insert_select_precheck(THD *thd, TABLE_LIST *tables) tables Global table list RETURN VALUE - 0 OK - 1 Error (message is sent to user) - -1 Error (message is not sent to user) + FALSE OK + TRUE Error */ -int update_precheck(THD *thd, TABLE_LIST *tables) +bool update_precheck(THD *thd, TABLE_LIST *tables) { DBUG_ENTER("update_precheck"); if (thd->lex->select_lex.item_list.elements != thd->lex->value_list.elements) { my_error(ER_WRONG_VALUE_COUNT, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } - DBUG_RETURN((check_db_used(thd, tables) || - check_one_table_access(thd, UPDATE_ACL, tables)) ? 1 : 0); + DBUG_RETURN(check_db_used(thd, tables) || + check_one_table_access(thd, UPDATE_ACL, tables)); } @@ -6090,19 +6034,18 @@ int update_precheck(THD *thd, TABLE_LIST *tables) tables Global table list RETURN VALUE - 0 OK - 1 error (message is sent to user) - -1 error (message is not sent to user) + FALSE OK + TRUE error */ -int delete_precheck(THD *thd, TABLE_LIST *tables) +bool delete_precheck(THD *thd, TABLE_LIST *tables) { DBUG_ENTER("delete_precheck"); if (check_one_table_access(thd, DELETE_ACL, tables)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); /* Set privilege for the WHERE clause */ tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -6115,12 +6058,11 @@ int delete_precheck(THD *thd, TABLE_LIST *tables) tables Global table list RETURN VALUE - 0 OK - 1 error (message is sent to user) - -1 error (message is not sent to user) + FALSE OK + TRUE error */ -int insert_precheck(THD *thd, TABLE_LIST *tables, bool update) +bool insert_precheck(THD *thd, TABLE_LIST *tables, bool update) { LEX *lex= thd->lex; DBUG_ENTER("insert_precheck"); @@ -6129,14 +6071,14 @@ int insert_precheck(THD *thd, TABLE_LIST *tables, bool update) INSERT_ACL | DELETE_ACL : INSERT_ACL | update); if (check_one_table_access(thd, privilege, tables)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); if (lex->select_lex.item_list.elements != lex->value_list.elements) { my_error(ER_WRONG_VALUE_COUNT, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -6150,13 +6092,12 @@ int insert_precheck(THD *thd, TABLE_LIST *tables, bool update) create_table Table which will be created RETURN VALUE - 0 OK - 1 Error (message is sent to user) - -1 Error (message is not sent to user) + FALSE OK + TRUE Error */ -int create_table_precheck(THD *thd, TABLE_LIST *tables, - TABLE_LIST *create_table) +bool create_table_precheck(THD *thd, TABLE_LIST *tables, + TABLE_LIST *create_table) { LEX *lex= thd->lex; DBUG_ENTER("create_table_precheck"); @@ -6168,10 +6109,9 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables, check_merge_table_access(thd, create_table->db, (TABLE_LIST *) lex->create_info.merge_list.first)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); DBUG_RETURN((grant_option && want_priv != CREATE_TMP_ACL && - check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0)) ? - 1 : 0); + check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0))); } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 982e00391ef..aa5da98f56f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -122,16 +122,13 @@ inline bool is_param_null(const uchar *pos, ulong param_no) enum { STMT_QUERY_LOG_LENGTH= 8192 }; -enum enum_send_error { DONT_SEND_ERROR= 0, SEND_ERROR }; - /* Seek prepared statement in statement map by id: returns zero if statement was not found, pointer otherwise. */ static Prepared_statement * -find_prepared_statement(THD *thd, ulong id, const char *where, - enum enum_send_error se) +find_prepared_statement(THD *thd, ulong id, const char *where) { Statement *stmt= thd->stmt_map.find(id); @@ -139,8 +136,6 @@ find_prepared_statement(THD *thd, ulong id, const char *where, { char llbuf[22]; my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), 22, llstr(id, llbuf), where); - if (se == SEND_ERROR) - send_error(thd); return 0; } return (Prepared_statement *) stmt; @@ -180,7 +175,7 @@ static bool send_prep_stmt(Prepared_statement *stmt, thd->client_stmt_id= stmt->id; thd->client_param_count= stmt->param_count; - thd->net.last_errno= 0; + thd->clear_error(); return 0; } @@ -881,24 +876,23 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt, tables global/local table list RETURN VALUE - 0 ok - 1 error, sent to the client - -1 error, not sent to client + FALSE OK + TRUE error */ -static int mysql_test_insert(Prepared_statement *stmt, - TABLE_LIST *table_list, - List<Item> &fields, - List<List_item> &values_list, - List<Item> &update_fields, - List<Item> &update_values, - enum_duplicates duplic) +static bool mysql_test_insert(Prepared_statement *stmt, + TABLE_LIST *table_list, + List<Item> &fields, + List<List_item> &values_list, + List<Item> &update_fields, + List<Item> &update_values, + enum_duplicates duplic) { THD *thd= stmt->thd; LEX *lex= stmt->lex; List_iterator_fast<List_item> its(values_list); List_item *values; - int res; + bool res; my_bool update= (lex->value_list.elements ? UPDATE_ACL : 0); DBUG_ENTER("mysql_test_insert"); @@ -909,9 +903,9 @@ static int mysql_test_insert(Prepared_statement *stmt, open temporary memory pool for temporary data allocated by derived tables & preparation procedure */ - if ((res= open_and_lock_tables(thd, table_list))) + if (open_and_lock_tables(thd, table_list)) { - DBUG_RETURN(res); + DBUG_RETURN(TRUE); } if ((values= its++)) @@ -958,14 +952,13 @@ error: tables list of tables queries RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error */ -static int mysql_test_update(Prepared_statement *stmt, - TABLE_LIST *table_list) +static bool mysql_test_update(Prepared_statement *stmt, + TABLE_LIST *table_list) { - int res; + bool res; THD *thd= stmt->thd; SELECT_LEX *select= &stmt->lex->select_lex; DBUG_ENTER("mysql_test_update"); @@ -1010,28 +1003,27 @@ static int mysql_test_update(Prepared_statement *stmt, tables list of tables queries RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error */ static int mysql_test_delete(Prepared_statement *stmt, TABLE_LIST *table_list) { - int res; THD *thd= stmt->thd; LEX *lex= stmt->lex; DBUG_ENTER("mysql_test_delete"); - if ((res= delete_precheck(thd, table_list))) - DBUG_RETURN(res); + if (delete_precheck(thd, table_list)) + DBUG_RETURN(TRUE); - if (!(res=open_and_lock_tables(thd, table_list))) + if (!open_and_lock_tables(thd, table_list)) { - res= mysql_prepare_delete(thd, table_list, &lex->select_lex.where); + mysql_prepare_delete(thd, table_list, &lex->select_lex.where); lex->unit.cleanup(); + DBUG_RETURN(FALSE) } /* TODO: here we should send types of placeholders to the client. */ - DBUG_RETURN(res); + DBUG_RETURN(TRUE); } @@ -1046,9 +1038,8 @@ static int mysql_test_delete(Prepared_statement *stmt, tables list of tables queries RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error, sent to client */ static int mysql_test_select(Prepared_statement *stmt, @@ -1057,7 +1048,7 @@ static int mysql_test_select(Prepared_statement *stmt, THD *thd= stmt->thd; LEX *lex= stmt->lex; SELECT_LEX_UNIT *unit= &lex->unit; - int result; + bool result; DBUG_ENTER("mysql_test_select"); #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -1065,26 +1056,21 @@ static int mysql_test_select(Prepared_statement *stmt, if (tables) { if (check_table_access(thd, privilege, tables,0)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } else if (check_access(thd, privilege, any_db,0,0,0)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); #endif if ((result= open_and_lock_tables(thd, tables))) - { - result= 1; // Error sent - send_error(thd); goto err; - } - result= 1; + result= TRUE; thd->used_tables= 0; // Updated by setup_fields // JOIN::prepare calls if (unit->prepare(thd, 0, 0)) { - send_error(thd); goto err_prep; } if (!text_protocol) @@ -1106,7 +1092,7 @@ static int mysql_test_select(Prepared_statement *stmt, goto err_prep; } } - result= 0; // ok + result= FALSE; // ok err_prep: unit->cleanup(); @@ -1125,30 +1111,27 @@ err: values list of expressions RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error, sent to client */ -static int mysql_test_do_fields(Prepared_statement *stmt, +static bool mysql_test_do_fields(Prepared_statement *stmt, TABLE_LIST *tables, List<Item> *values) { DBUG_ENTER("mysql_test_do_fields"); THD *thd= stmt->thd; - int res= 0; - if (tables && (res= check_table_access(thd, SELECT_ACL, tables, 0))) - DBUG_RETURN(res); + bool res; + if (tables && check_table_access(thd, SELECT_ACL, tables, 0)) + DBUG_RETURN(TRUE); - if (tables && (res= open_and_lock_tables(thd, tables))) + if (tables && open_and_lock_tables(thd, tables)) { - DBUG_RETURN(res); + DBUG_RETURN(TRUE); } res= setup_fields(thd, 0, 0, *values, 0, 0, 0); stmt->lex->unit.cleanup(); - if (res) - DBUG_RETURN(-1); - DBUG_RETURN(0); + DBUG_RETURN(res); } @@ -1162,22 +1145,21 @@ static int mysql_test_do_fields(Prepared_statement *stmt, values list of expressions RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error */ -static int mysql_test_set_fields(Prepared_statement *stmt, - TABLE_LIST *tables, - List<set_var_base> *var_list) +static bool mysql_test_set_fields(Prepared_statement *stmt, + TABLE_LIST *tables, + List<set_var_base> *var_list) { DBUG_ENTER("mysql_test_set_fields"); List_iterator_fast<set_var_base> it(*var_list); THD *thd= stmt->thd; set_var_base *var; - int res= 0; + bool res= 0; - if (tables && (res= check_table_access(thd, SELECT_ACL, tables, 0))) - DBUG_RETURN(res); + if (tables && check_table_access(thd, SELECT_ACL, tables, 0)) + DBUG_RETURN(TRUE); if (tables && (res= open_and_lock_tables(thd, tables))) goto error; @@ -1186,7 +1168,7 @@ static int mysql_test_set_fields(Prepared_statement *stmt, if (var->light_check(thd)) { stmt->lex->unit.cleanup(); - res= -1; + res= TRUE; goto error; } } @@ -1206,18 +1188,17 @@ error: specific_prepare - function of command specific prepare RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error */ -static int select_like_statement_test(Prepared_statement *stmt, - TABLE_LIST *tables, - int (*specific_prepare)(THD *thd)) +static bool select_like_statement_test(Prepared_statement *stmt, + TABLE_LIST *tables, + bool (*specific_prepare)(THD *thd)) { DBUG_ENTER("select_like_statement_test"); THD *thd= stmt->thd; LEX *lex= stmt->lex; - int res= 0; + bool res= 0; if (tables && (res= open_and_lock_tables(thd, tables))) goto end; @@ -1230,7 +1211,7 @@ static int select_like_statement_test(Prepared_statement *stmt, // JOIN::prepare calls if (lex->unit.prepare(thd, 0, 0)) { - res= thd->net.report_error ? -1 : 1; + res= TRUE; } end: lex->unit.cleanup(); @@ -1287,16 +1268,15 @@ static int mysql_test_create_table(Prepared_statement *stmt) tables list of tables queries RETURN VALUE - 0 success - 1 error, sent to client - -1 error, not sent to client + FALSE success + TRUE error */ -static int mysql_test_multiupdate(Prepared_statement *stmt, + +static bool mysql_test_multiupdate(Prepared_statement *stmt, TABLE_LIST *tables) { - int res; - if ((res= multi_update_precheck(stmt->thd, tables))) - return res; + if (multi_update_precheck(stmt->thd, tables)) + return TRUE; return select_like_statement_test(stmt, tables, &mysql_multi_update_prepare); } @@ -1477,8 +1457,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) if (res == 0) DBUG_RETURN(text_protocol? 0 : send_prep_stmt(stmt, 0)); error: - if (res < 0) - send_error(thd,thd->killed_errno()); DBUG_RETURN(1); } @@ -1500,10 +1478,7 @@ static bool init_param_array(Prepared_statement *stmt) alloc_root(&stmt->thd->mem_root, sizeof(Item_param*) * stmt->param_count); if (!stmt->param_array) - { - send_error(stmt->thd, ER_OUT_OF_RESOURCES); return 1; - } for (to= stmt->param_array; to < stmt->param_array + stmt->param_count; ++to) @@ -1527,10 +1502,10 @@ static bool init_param_array(Prepared_statement *stmt) name NULL or statement name. For unnamed statements binary PS protocol is used, for named statements text protocol is used. - RETURN - 0 OK, statement prepared successfully - other Error - + RETURN + FALSE OK, statement prepared successfully + TRUE Error + NOTES This function parses the query and sends the total number of parameters and resultset metadata information back to client (if any), without @@ -1544,21 +1519,18 @@ static bool init_param_array(Prepared_statement *stmt) */ -int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, - LEX_STRING *name) +bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, + LEX_STRING *name) { LEX *lex; Prepared_statement *stmt= new Prepared_statement(thd); - int error; + bool error; DBUG_ENTER("mysql_stmt_prepare"); DBUG_PRINT("prep_query", ("%s", packet)); if (stmt == 0) - { - send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_RETURN(1); - } + DBUG_RETURN(TRUE); if (name) { @@ -1567,16 +1539,14 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, name->length))) { delete stmt; - send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } if (thd->stmt_map.insert(stmt)) { delete stmt; - send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } thd->set_n_backup_statement(stmt, &thd->stmt_backup); @@ -1588,8 +1558,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, thd->restore_backup_item_arena(stmt, &thd->stmt_backup); /* Statement map deletes statement on erase */ thd->stmt_map.erase(stmt); - send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } mysql_log.write(thd, COM_PREPARE, "%s", packet); @@ -1768,8 +1737,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) packet+= 9; /* stmt_id + 5 bytes of flags */ - if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute", - SEND_ERROR))) + if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute"))) DBUG_VOID_RETURN; DBUG_PRINT("exec_query:", ("%s", stmt->query)); @@ -1777,7 +1745,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) /* Check if we got an error when sending long data */ if (stmt->state == Item_arena::ERROR) { - send_error(thd, stmt->last_errno, stmt->last_error); + my_message(stmt->last_errno, stmt->last_error, MYF(0)); DBUG_VOID_RETURN; } @@ -1795,10 +1763,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) { if (!stmt->cursor && !(stmt->cursor= new (&stmt->mem_root) Cursor())) - { - send_error(thd, ER_OUT_OF_RESOURCES); DBUG_VOID_RETURN; - } /* If lex->result is set, mysql_execute_command will use it */ stmt->lex->result= &stmt->cursor->result; } @@ -1866,7 +1831,6 @@ set_params_data_err: reset_stmt_params(stmt); my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute"); err: - send_error(thd); DBUG_VOID_RETURN; } @@ -1892,14 +1856,12 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name) { my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), stmt_name->length, stmt_name->str, "EXECUTE"); - send_error(thd); DBUG_VOID_RETURN; } if (stmt->param_count != thd->lex->prepared_stmt_params.elements) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "EXECUTE"); - send_error(thd); DBUG_VOID_RETURN; } @@ -1910,7 +1872,6 @@ void mysql_sql_stmt_execute(THD *thd, LEX_STRING *stmt_name) &expanded_query)) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "EXECUTE"); - send_error(thd); } execute_stmt(thd, stmt, &expanded_query); DBUG_VOID_RETURN; @@ -1994,7 +1955,6 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) !stmt->cursor->is_open()) { my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), stmt_id, "fetch"); - send_error(thd); DBUG_VOID_RETURN; } @@ -2018,9 +1978,6 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) thd->set_statement(&thd->stmt_backup); thd->set_item_arena(&thd->stmt_backup); - if (error && error != -4) - send_error(thd, ER_OUT_OF_RESOURCES); - DBUG_VOID_RETURN; } @@ -2050,8 +2007,7 @@ void mysql_stmt_reset(THD *thd, char *packet) DBUG_ENTER("mysql_stmt_reset"); - if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset", - SEND_ERROR))) + if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset"))) DBUG_VOID_RETURN; stmt->state= Item_arena::PREPARED; @@ -2081,8 +2037,7 @@ void mysql_stmt_free(THD *thd, char *packet) DBUG_ENTER("mysql_stmt_free"); - if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_close", - DONT_SEND_ERROR))) + if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_close"))) DBUG_VOID_RETURN; /* Statement map deletes statement on erase */ @@ -2132,8 +2087,8 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) stmt_id= uint4korr(packet); packet+= 4; - if (!(stmt=find_prepared_statement(thd, stmt_id, "mysql_stmt_send_long_data", - DONT_SEND_ERROR))) + if (!(stmt=find_prepared_statement(thd, stmt_id, + "mysql_stmt_send_long_data"))) DBUG_VOID_RETURN; param_number= uint2korr(packet); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 9e38a65d412..fe7e8432ec6 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -278,41 +278,39 @@ bool log_in_use(const char* log_name) return result; } -int purge_error_message(THD* thd, int res) +bool purge_error_message(THD* thd, int res) { - const char *errmsg= 0; + uint errmsg= 0; switch (res) { case 0: break; - case LOG_INFO_EOF: errmsg= "Target log not found in binlog index"; break; - case LOG_INFO_IO: errmsg= "I/O error reading log index file"; break; - case LOG_INFO_INVALID: - errmsg= "Server configuration does not permit binlog purge"; break; - case LOG_INFO_SEEK: errmsg= "Failed on fseek()"; break; - case LOG_INFO_MEM: errmsg= "Out of memory"; break; - case LOG_INFO_FATAL: errmsg= "Fatal error during purge"; break; - case LOG_INFO_IN_USE: errmsg= "A purgeable log is in use, will not purge"; - break; - default: errmsg= "Unknown error during purge"; break; + case LOG_INFO_EOF: errmsg= ER_UNKNOWN_TARGET_BINLOG; break; + case LOG_INFO_IO: errmsg= ER_IO_ERR_LOG_INDEX_READ; break; + case LOG_INFO_INVALID:errmsg= ER_BINLOG_PURGE_PROHIBITED; break; + case LOG_INFO_SEEK: errmsg= ER_FSEEK_FAIL; break; + case LOG_INFO_MEM: errmsg= ER_OUT_OF_RESOURCES; break; + case LOG_INFO_FATAL: errmsg= ER_BINLOG_PURGE_FATAL_ERR; break; + case LOG_INFO_IN_USE: errmsg= ER_LOG_IN_USE; break; + default: errmsg= ER_LOG_PURGE_UNKNOWN_ERR; break; } if (errmsg) { - send_error(thd, 0, errmsg); - return 1; + my_error(errmsg, MYF(0)); + return TRUE; } send_ok(thd); - return 0; + return FALSE; } -int purge_master_logs(THD* thd, const char* to_log) +bool purge_master_logs(THD* thd, const char* to_log) { char search_file_name[FN_REFLEN]; if (!mysql_bin_log.is_open()) { send_ok(current_thd); - return 0; + return FALSE; } mysql_bin_log.make_log_name(search_file_name, to_log); @@ -322,10 +320,10 @@ int purge_master_logs(THD* thd, const char* to_log) } -int purge_master_logs_before_date(THD* thd, time_t purge_time) +bool purge_master_logs_before_date(THD* thd, time_t purge_time) { - int res = mysql_bin_log.purge_logs_before_date(purge_time); - return purge_error_message(thd ,res); + return purge_error_message(thd, + mysql_bin_log.purge_logs_before_date(purge_time)); } int test_for_non_eof_log_read_errors(int error, const char **errmsg) @@ -753,7 +751,7 @@ err: pthread_mutex_unlock(&LOCK_thread_count); if (file >= 0) (void) my_close(file, MYF(MY_WME)); - send_error(thd, my_errno, errmsg); + my_message(my_errno, errmsg, MYF(0)); DBUG_VOID_RETURN; } @@ -1054,7 +1052,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id) } -int change_master(THD* thd, MASTER_INFO* mi) +bool change_master(THD* thd, MASTER_INFO* mi) { int thread_mask; const char* errmsg= 0; @@ -1065,9 +1063,9 @@ int change_master(THD* thd, MASTER_INFO* mi) init_thread_mask(&thread_mask,mi,0 /*not inverse*/); if (thread_mask) // We refuse if any slave thread is running { - net_printf(thd,ER_SLAVE_MUST_STOP); + my_error(ER_SLAVE_MUST_STOP, MYF(0)); unlock_slave_threads(mi); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } thd->proc_info = "Changing master"; @@ -1075,9 +1073,9 @@ int change_master(THD* thd, MASTER_INFO* mi) // TODO: see if needs re-write if (init_master_info(mi, master_info_file, relay_log_info_file, 0)) { - send_error(thd, ER_MASTER_INFO); + my_error(ER_MASTER_INFO, MYF(0)); unlock_slave_threads(mi); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } /* @@ -1194,9 +1192,9 @@ int change_master(THD* thd, MASTER_INFO* mi) 0 /* not only reset, but also reinit */, &errmsg)) { - net_printf(thd, 0, "Failed purging old relay logs: %s",errmsg); + my_error(ER_RELAY_LOG_FAIL, MYF(0), errmsg); unlock_slave_threads(mi); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } else @@ -1210,9 +1208,9 @@ int change_master(THD* thd, MASTER_INFO* mi) 0 /*no data lock*/, &msg, 0)) { - net_printf(thd,0,"Failed initializing relay log position: %s",msg); + my_error(ER_RELAY_LOG_INIT, MYF(0), msg); unlock_slave_threads(mi); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } mi->rli.group_master_log_pos = mi->master_log_pos; @@ -1254,7 +1252,7 @@ int change_master(THD* thd, MASTER_INFO* mi) unlock_slave_threads(mi); thd->proc_info = 0; send_ok(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } int reset_master(THD* thd) @@ -1285,7 +1283,7 @@ int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1, } -int show_binlog_events(THD* thd) +bool show_binlog_events(THD* thd) { Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlog_events"); @@ -1299,7 +1297,7 @@ int show_binlog_events(THD* thd) Log_event::init_show_field_list(&field_list); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); if (mysql_bin_log.is_open()) { @@ -1405,18 +1403,18 @@ err: { my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0), "SHOW BINLOG EVENTS", errmsg); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); pthread_mutex_lock(&LOCK_thread_count); thd->current_linfo = 0; pthread_mutex_unlock(&LOCK_thread_count); - DBUG_RETURN(0); + DBUG_RETURN(TRUE); } -int show_binlog_info(THD* thd) +bool show_binlog_info(THD* thd) { Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlog_info"); @@ -1429,7 +1427,7 @@ int show_binlog_info(THD* thd) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); protocol->prepare_for_resend(); if (mysql_bin_log.is_open()) @@ -1442,10 +1440,10 @@ int show_binlog_info(THD* thd) protocol->store(&binlog_do_db); protocol->store(&binlog_ignore_db); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -1457,11 +1455,11 @@ int show_binlog_info(THD* thd) thd Thread specific variable RETURN VALUES - 0 ok - 1 error (Error message sent to client) + FALSE OK + TRUE error */ -int show_binlogs(THD* thd) +bool show_binlogs(THD* thd) { IO_CACHE *index_file; char fname[FN_REFLEN]; @@ -1472,15 +1470,14 @@ int show_binlogs(THD* thd) if (!mysql_bin_log.is_open()) { - //TODO: Replace with ER() error message - send_error(thd, 0, "You are not using binary logging"); + my_error(ER_NO_BINARY_LOGGING, MYF(0)); return 1; } field_list.push_back(new Item_empty_string("Log_name", 255)); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); mysql_bin_log.lock_index(); index_file=mysql_bin_log.get_index_file(); @@ -1498,11 +1495,11 @@ int show_binlogs(THD* thd) } mysql_bin_log.unlock_index(); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: mysql_bin_log.unlock_index(); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } diff --git a/sql/sql_repl.h b/sql/sql_repl.h index c39ef90114d..3f457a060cb 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -27,17 +27,17 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, int start_slave(THD* thd, MASTER_INFO* mi, bool net_report); int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report); -int change_master(THD* thd, MASTER_INFO* mi); -int show_binlog_events(THD* thd); +bool change_master(THD* thd, MASTER_INFO* mi); +bool show_binlog_events(THD* thd); int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1, const char* log_file_name2, ulonglong log_pos2); int reset_slave(THD *thd, MASTER_INFO* mi); int reset_master(THD* thd); -int purge_master_logs(THD* thd, const char* to_log); -int purge_master_logs_before_date(THD* thd, time_t purge_time); +bool purge_master_logs(THD* thd, const char* to_log); +bool purge_master_logs_before_date(THD* thd, time_t purge_time); bool log_in_use(const char* log_name); void adjust_linfo_offsets(my_off_t purge_offset); -int show_binlogs(THD* thd); +bool show_binlogs(THD* thd); extern int init_master_info(MASTER_INFO* mi); void kill_zombie_dump_threads(uint32 slave_server_id); int check_binlog_magic(IO_CACHE* log, const char** errmsg); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e104ac1ca38..8cbc7589d26 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -194,9 +194,9 @@ static Item *remove_additional_cond(Item* conds); This handles SELECT with and without UNION */ -int handle_select(THD *thd, LEX *lex, select_result *result) +bool handle_select(THD *thd, LEX *lex, select_result *result) { - int res; + bool res; register SELECT_LEX *select_lex = &lex->select_lex; DBUG_ENTER("handle_select"); @@ -223,14 +223,14 @@ int handle_select(THD *thd, LEX *lex, select_result *result) /* Don't set res if it's -1 as we may want this later */ DBUG_PRINT("info",("res: %d report_error: %d", res, thd->net.report_error)); - if (thd->net.report_error) - res= 1; + res|= thd->net.report_error; if (unlikely(res)) { - if (res > 0) - result->send_error(0, NullS); + /* + If we have real error reported erly then this will be ignored + */ + result->send_error(ER_UNKNOWN_ERROR, NullS); result->abort(); - res= 1; // Error sent to client } DBUG_RETURN(res); } @@ -395,21 +395,20 @@ JOIN::prepare(Item ***rref_pointer_array, { if (!test_if_subpart(procedure->group,group_list)) { /* purecov: inspected */ - my_message(0,"Can't handle procedures with differents groups yet", - MYF(0)); /* purecov: inspected */ + my_error(ER_DIFF_GROUPS_PROC, MYF(0)); /* purecov: inspected */ goto err; /* purecov: inspected */ } } #ifdef NOT_NEEDED else if (!group_list && procedure->flags & PROC_GROUP) { - my_message(0,"Select must have a group with this procedure",MYF(0)); + my_message(ER_NO_GROUP_FOR_PROC, MYF(0)); goto err; } #endif if (order && (procedure->flags & PROC_NO_SORT)) { /* purecov: inspected */ - my_message(0,"Can't use order with this procedure",MYF(0)); /* purecov: inspected */ + my_error(ER_ORDER_WITH_PROC, MYF(0)); /* purecov: inspected */ goto err; /* purecov: inspected */ } } @@ -1890,7 +1889,7 @@ Cursor::~Cursor() /*********************************************************************/ -int +bool mysql_select(THD *thd, Item ***rref_pointer_array, TABLE_LIST *tables, uint wild_num, List<Item> &fields, COND *conds, uint og_num, ORDER *order, ORDER *group, @@ -1898,7 +1897,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, select_result *result, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) { - int err; + bool err; bool free_join= 1; DBUG_ENTER("mysql_select"); @@ -1906,7 +1905,10 @@ mysql_select(THD *thd, Item ***rref_pointer_array, if (select_lex->join != 0) { join= select_lex->join; - // is it single SELECT in derived table, called in derived table creation + /* + is it single SELECT in derived table, called in derived table + creation + */ if (select_lex->linkage != DERIVED_TABLE_TYPE || (select_options & SELECT_DESCRIBE)) { @@ -1915,7 +1917,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, //here is EXPLAIN of subselect or derived table if (join->change_result(result)) { - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } else @@ -1934,7 +1936,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array, else { if (!(join= new JOIN(thd, fields, select_options, result))) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); thd->proc_info="init"; thd->used_tables=0; // Updated by setup_fields if (join->prepare(rref_pointer_array, tables, wild_num, @@ -1982,10 +1984,8 @@ err: { thd->proc_info="end"; err= join->cleanup(); - if (thd->net.report_error) - err= -1; delete join; - DBUG_RETURN(err); + DBUG_RETURN(err || thd->net.report_error); } DBUG_RETURN(join->error); } @@ -11557,10 +11557,10 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, } -int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) +bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) { DBUG_ENTER("mysql_explain_union"); - int res= 0; + bool res= 0; SELECT_LEX *first= unit->first_select(); for (SELECT_LEX *sl= first; @@ -11611,9 +11611,7 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) first->options | thd->options | SELECT_DESCRIBE, result, unit, first); } - if (res > 0 || thd->net.report_error) - res= -1; // mysql_explain_select do not report error - DBUG_RETURN(res); + DBUG_RETURN(res || thd->net.report_error); } @@ -11824,17 +11822,17 @@ void st_select_lex::print(THD *thd, String *str) res new select_result object RETURN - 0 - OK - -1 - error + FALSE - OK + TRUE - error */ -int JOIN::change_result(select_result *res) +bool JOIN::change_result(select_result *res) { DBUG_ENTER("JOIN::change_result"); result= res; if (!procedure && result->prepare(fields_list, select_lex->master_unit())) { - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } diff --git a/sql/sql_select.h b/sql/sql_select.h index eb80f3ee608..e1f98059618 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -330,7 +330,7 @@ class JOIN :public Sql_alloc return (do_send_rows && tmp_table_param.sum_func_count != 0 && !group_list); } - int change_result(select_result *result); + bool change_result(select_result *result); }; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 14bef9d2236..b9c2a5d8e18 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -48,7 +48,7 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *packet); A database is a directory in the mysql_data_home directory */ -int +bool mysqld_show_dbs(THD *thd,const char *wild) { Item_string *field=new Item_string("",0,thd->charset()); @@ -68,9 +68,9 @@ mysqld_show_dbs(THD *thd,const char *wild) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); if (mysql_find_files(thd,&files,NullS,mysql_data_home,wild,1)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); List_iterator_fast<char> it(files); while ((file_name=it++)) @@ -84,11 +84,11 @@ mysqld_show_dbs(THD *thd,const char *wild) protocol->prepare_for_resend(); protocol->store(file_name, system_charset_info); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -96,7 +96,7 @@ mysqld_show_dbs(THD *thd,const char *wild) List all open tables in a database ***************************************************************************/ -int mysqld_show_open_tables(THD *thd,const char *wild) +bool mysqld_show_open_tables(THD *thd,const char *wild) { List<Item> field_list; OPEN_TABLE_LIST *open_list; @@ -110,10 +110,10 @@ int mysqld_show_open_tables(THD *thd,const char *wild) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); if (!(open_list=list_open_tables(thd,wild)) && thd->is_fatal_error) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); for (; open_list ; open_list=open_list->next) { @@ -124,11 +124,11 @@ int mysqld_show_open_tables(THD *thd,const char *wild) protocol->store_tiny((longlong) open_list->locked); if (protocol->write()) { - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -137,7 +137,7 @@ int mysqld_show_open_tables(THD *thd,const char *wild) ** A table is a .frm file in the current databasedir ***************************************************************************/ -int mysqld_show_tables(THD *thd, const char *db, const char *wild, +bool mysqld_show_tables(THD *thd, const char *db, const char *wild, bool show_type) { Item_string *field=new Item_string("",0,thd->charset()); @@ -162,10 +162,9 @@ int mysqld_show_tables(THD *thd, const char *db, const char *wild, if (show_type) field_list.push_back(new Item_empty_string("table_type", 10)); if (protocol->send_fields(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); - if (mysql_find_files(thd,&files,db,path,wild,0)) - DBUG_RETURN(-1); + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF) || + mysql_find_files(thd,&files,db,path,wild,0)) + DBUG_RETURN(TRUE); List_iterator_fast<char> it(files); while ((file_name=it++)) { @@ -190,17 +189,17 @@ int mysqld_show_tables(THD *thd, const char *db, const char *wild, } } if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } /*************************************************************************** ** List all table types supported ***************************************************************************/ -int mysqld_show_storage_engines(THD *thd) +bool mysqld_show_storage_engines(THD *thd) { List<Item> field_list; Protocol *protocol= thd->protocol; @@ -212,7 +211,7 @@ int mysqld_show_storage_engines(THD *thd) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); const char *default_type_name= ha_get_storage_engine((enum db_type)thd->variables.table_type); @@ -230,10 +229,10 @@ int mysqld_show_storage_engines(THD *thd) protocol->store(option_name, system_charset_info); protocol->store(types->comment, system_charset_info); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -275,7 +274,7 @@ static struct show_privileges_st sys_privileges[]= {NullS, NullS, NullS} }; -int mysqld_show_privileges(THD *thd) +bool mysqld_show_privileges(THD *thd) { List<Item> field_list; Protocol *protocol= thd->protocol; @@ -287,7 +286,7 @@ int mysqld_show_privileges(THD *thd) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); show_privileges_st *privilege= sys_privileges; for (privilege= sys_privileges; privilege->privilege ; privilege++) @@ -297,10 +296,10 @@ int mysqld_show_privileges(THD *thd) protocol->store(privilege->context, system_charset_info); protocol->store(privilege->comment, system_charset_info); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -340,7 +339,7 @@ static struct show_column_type_st sys_column_types[]= "A very small integer"}, }; -int mysqld_show_column_types(THD *thd) +bool mysqld_show_column_types(THD *thd) { List<Item> field_list; Protocol *protocol= thd->protocol; @@ -363,7 +362,7 @@ int mysqld_show_column_types(THD *thd) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); /* TODO: Change the loop to not use 'i' */ for (uint i=0; i < sizeof(sys_column_types)/sizeof(sys_column_types[0]); i++) @@ -384,10 +383,10 @@ int mysqld_show_column_types(THD *thd) protocol->store(sys_column_types[i].default_value, system_charset_info); protocol->store(sys_column_types[i].comment, system_charset_info); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -486,7 +485,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, Extended version of mysqld_show_tables ***************************************************************************/ -int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) +bool mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) { Item *item; List<char> files; @@ -496,7 +495,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) TABLE *table; Protocol *protocol= thd->protocol; TIME time; - int res; + bool res; DBUG_ENTER("mysqld_extend_show_tables"); (void) sprintf(path,"%s/%s",mysql_data_home,db); @@ -537,11 +536,9 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) field_list.push_back(item=new Item_empty_string("Comment",80)); item->maybe_null=1; if (protocol->send_fields(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); - - if (mysql_find_files(thd,&files,db,path,wild,0)) - DBUG_RETURN(-1); + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF) || + mysql_find_files(thd,&files,db,path,wild,0)) + DBUG_RETURN(TRUE); List_iterator_fast<char> it(files); while ((file_name=it++)) { @@ -558,14 +555,12 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) { for (uint i=2 ; i < field_list.elements ; i++) protocol->store_null(); - // Send error to Comment field if possible - if (res < 0) + // Send error to Comment field + if (res) { protocol->store(thd->net.last_error, system_charset_info); thd->clear_error(); } - else - DBUG_RETURN(1); } else if (table_list.view) { @@ -680,10 +675,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) } close_thread_tables(thd, 0); if (protocol->write()) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -691,7 +686,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) ** List all columns in a table_list->real_name ***************************************************************************/ -int +bool mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, bool verbose) { @@ -707,11 +702,9 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, table_list->real_name)); table_list->lock_type= TL_UNLOCK; - if ((res= open_and_lock_tables(thd, table_list))) + if (open_and_lock_tables(thd, table_list)) { - if (res < 0) - send_error(thd); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } table= table_list->table; file=table->file; @@ -737,7 +730,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, // Send first number of fields and records if (protocol->send_records_num(&field_list, (ulonglong)file->records) || protocol->send_fields(&field_list, Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); restore_record(table,default_values); // Get empty record Field **ptr,*field; @@ -844,16 +837,16 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, system_charset_info); } if (protocol->write()) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } -int +bool mysqld_show_create(THD *thd, TABLE_LIST *table_list) { TABLE *table; @@ -866,18 +859,16 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) table_list->real_name)); /* Only one table for now, but VIEW can involve several tables */ - if ((res= open_and_lock_tables(thd, table_list))) + if (open_and_lock_tables(thd, table_list)) { - if (res < 0) - send_error(thd); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } /* TODO: add environment variables show when it become possible */ if (thd->lex->only_view && !table_list->view) { my_error(ER_WRONG_OBJECT, MYF(0), table_list->db, table_list->real_name, "VIEW"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } table= table_list->table; @@ -885,7 +876,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if ((table_list->view ? view_store_create_info(thd, table_list, &buffer) : store_create_info(thd, table, &buffer))) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); List<Item> field_list; if (table_list->view) @@ -904,31 +895,31 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); protocol->prepare_for_resend(); buffer.length(0); if (table_list->view) { protocol->store(table_list->view_name.str, system_charset_info); if (view_store_create_info(thd, table_list, &buffer)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } else { protocol->store(table->table_name, system_charset_info); if (store_create_info(thd, table, &buffer)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } protocol->store(buffer.ptr(), buffer.length(), buffer.charset()); if (protocol->write()) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } -int mysqld_show_create_db(THD *thd, char *dbname, - HA_CREATE_INFO *create_info) +bool mysqld_show_create_db(THD *thd, char *dbname, + HA_CREATE_INFO *create_info) { int length; char path[FN_REFLEN]; @@ -945,8 +936,8 @@ int mysqld_show_create_db(THD *thd, char *dbname, if (check_db_name(dbname)) { - net_printf(thd,ER_WRONG_DB_NAME, dbname); - DBUG_RETURN(1); + my_error(ER_WRONG_DB_NAME, MYF(0), dbname); + DBUG_RETURN(TRUE); } #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -957,11 +948,11 @@ int mysqld_show_create_db(THD *thd, char *dbname, thd->master_access); if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname))) { - net_printf(thd,ER_DBACCESS_DENIED_ERROR, - thd->priv_user, thd->host_or_ip, dbname); + my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), + thd->priv_user, thd->host_or_ip, dbname); mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR), thd->priv_user, thd->host_or_ip, dbname); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } #endif @@ -975,8 +966,8 @@ int mysqld_show_create_db(THD *thd, char *dbname, } if (access(path,F_OK)) { - net_printf(thd,ER_BAD_DB_ERROR,dbname); - DBUG_RETURN(1); + my_error(ER_BAD_DB_ERROR, MYF(0), dbname); + DBUG_RETURN(TRUE); } if (found_libchar) path[length-1]= FN_LIBCHAR; @@ -989,7 +980,7 @@ int mysqld_show_create_db(THD *thd, char *dbname, if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); protocol->prepare_for_resend(); protocol->store(dbname, strlen(dbname), system_charset_info); @@ -1014,12 +1005,12 @@ int mysqld_show_create_db(THD *thd, char *dbname, protocol->store(buffer.ptr(), buffer.length(), buffer.charset()); if (protocol->write()) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } -int +bool mysqld_show_logs(THD *thd) { List<Item> field_list; @@ -1032,19 +1023,19 @@ mysqld_show_logs(THD *thd) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); #ifdef HAVE_BERKELEY_DB if ((have_berkeley_db == SHOW_OPTION_YES) && berkeley_show_logs(protocol)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); #endif send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } -int +bool mysqld_show_keys(THD *thd, TABLE_LIST *table_list) { TABLE *table; @@ -1055,8 +1046,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (!(table = open_ltable(thd, table_list, TL_UNLOCK))) { - send_error(thd); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } List<Item> field_list; @@ -1082,7 +1072,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); @@ -1133,11 +1123,11 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) else protocol->store("", 0, system_charset_info); if (protocol->write()) - DBUG_RETURN(1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ } } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -1155,12 +1145,8 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) DBUG_PRINT("enter",("table: %s",table_list->real_name)); table_list->lock_type= TL_UNLOCK; - if ((res= open_and_lock_tables(thd, table_list))) - { - if (res < 0) - send_error(thd); + if (open_and_lock_tables(thd, table_list)) DBUG_VOID_RETURN; - } table= table_list->table; List<Item> field_list; @@ -1805,7 +1791,7 @@ static bool write_collation(Protocol *protocol, CHARSET_INFO *cs) return protocol->write(); } -int mysqld_show_collations(THD *thd, const char *wild) +bool mysqld_show_collations(THD *thd, const char *wild) { char buff[8192]; String packet2(buff,sizeof(buff),thd->charset()); @@ -1813,7 +1799,7 @@ int mysqld_show_collations(THD *thd, const char *wild) CHARSET_INFO **cs; Protocol *protocol= thd->protocol; - DBUG_ENTER("mysqld_show_charsets"); + DBUG_ENTER(" mysqld_show_collations"); field_list.push_back(new Item_empty_string("Collation",30)); field_list.push_back(new Item_empty_string("Charset",30)); @@ -1824,7 +1810,7 @@ int mysqld_show_collations(THD *thd, const char *wild) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ ) { @@ -1845,10 +1831,10 @@ int mysqld_show_collations(THD *thd, const char *wild) } } } - send_eof(thd); - DBUG_RETURN(0); + send_eof(thd); + DBUG_RETURN(FALSE); err: - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } static bool write_charset(Protocol *protocol, CHARSET_INFO *cs) @@ -1861,7 +1847,7 @@ static bool write_charset(Protocol *protocol, CHARSET_INFO *cs) return protocol->write(); } -int mysqld_show_charsets(THD *thd, const char *wild) +bool mysqld_show_charsets(THD *thd, const char *wild) { char buff[8192]; String packet2(buff,sizeof(buff),thd->charset()); @@ -1878,7 +1864,7 @@ int mysqld_show_charsets(THD *thd, const char *wild) if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ ) { @@ -1891,18 +1877,18 @@ int mysqld_show_charsets(THD *thd, const char *wild) goto err; } } - send_eof(thd); - DBUG_RETURN(0); + send_eof(thd); + DBUG_RETURN(FALSE); err: - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } -int mysqld_show(THD *thd, const char *wild, show_var_st *variables, - enum enum_var_type value_type, - pthread_mutex_t *mutex, - struct system_status_var *status_var) +bool mysqld_show(THD *thd, const char *wild, show_var_st *variables, + enum enum_var_type value_type, + pthread_mutex_t *mutex, + struct system_status_var *status_var) { char buff[1024]; List<Item> field_list; @@ -1914,7 +1900,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, field_list.push_back(new Item_empty_string("Value",256)); if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ null_lex_str.str= 0; // For sys_var->value_ptr() null_lex_str.length= 0; @@ -2206,11 +2192,11 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, } pthread_mutex_unlock(mutex); send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: pthread_mutex_unlock(mutex); - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 399fed00040..d84611ae496 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -57,15 +57,15 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, Wait if global_read_lock (FLUSH TABLES WITH READ LOCK) is set. RETURN - 0 ok. In this case ok packet is sent to user - -1 Error (Error message given but not sent to user) + FALSE OK. In this case ok packet is sent to user + TRUE Error */ -int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, - my_bool drop_temporary) +bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, + my_bool drop_temporary) { - int error= 0; + bool error= FALSE; DBUG_ENTER("mysql_rm_table"); /* mark for close and remove all cached entries */ @@ -80,7 +80,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, { my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), tables->real_name); - error= 1; + error= TRUE; goto err; } while (global_read_lock && ! thd->killed) @@ -100,9 +100,9 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, pthread_mutex_unlock(&thd->mysys_var->mutex); if (error) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); send_ok(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } @@ -1101,22 +1101,22 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, and must be zero for standard create of table. RETURN VALUES - 0 ok - -1 error + FALSE OK + TRUE error */ -int mysql_create_table(THD *thd,const char *db, const char *table_name, - HA_CREATE_INFO *create_info, - List<create_field> &fields, - List<Key> &keys,bool tmp_table, - uint select_field_count) +bool mysql_create_table(THD *thd,const char *db, const char *table_name, + HA_CREATE_INFO *create_info, + List<create_field> &fields, + List<Key> &keys,bool tmp_table, + uint select_field_count) { char path[FN_REFLEN]; const char *alias; - int error= -1; uint db_options, key_count; KEY *key_info_buffer; handler *file; + bool error= TRUE; enum db_type new_db_type; DBUG_ENTER("mysql_create_table"); @@ -1124,7 +1124,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (!fields.elements) { my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if ((new_db_type= ha_checktype(create_info->db_type)) != create_info->db_type) @@ -1154,7 +1154,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, (file->table_flags() & HA_NO_TEMP_TABLES)) { my_error(ER_ILLEGAL_HA,MYF(0),table_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } #endif @@ -1179,7 +1179,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, keys, tmp_table, db_options, file, key_info_buffer, &key_count, select_field_count)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); /* Check if table exists */ if (create_info->options & HA_LEX_CREATE_TMP_TABLE) @@ -1202,10 +1202,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) { create_info->table_existed= 1; // Mark that table existed - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (wait_if_global_read_lock(thd, 0, 1)) DBUG_RETURN(error); @@ -1217,7 +1217,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) { create_info->table_existed= 1; // Mark that table existed - error= 0; + error= FALSE; } else my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); @@ -1246,7 +1246,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (create_if_not_exists) { create_info->table_existed= 1; // Mark that table existed - error= 0; + error= FALSE; } else my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); @@ -1285,7 +1285,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, HA_LEX_CREATE_TMP_TABLE)); mysql_bin_log.write(&qinfo); } - error=0; + error= FALSE; end: VOID(pthread_mutex_unlock(&LOCK_open)); start_waiting_global_read_lock(thd); @@ -1547,7 +1547,7 @@ static int send_check_errmsg(THD *thd, TABLE_LIST* table, protocol->store((char*) operator_name, system_charset_info); protocol->store("error", 5, system_charset_info); protocol->store(errmsg, system_charset_info); - thd->net.last_error[0]=0; + thd->clear_error(); if (protocol->write()) return -1; return 1; @@ -1722,16 +1722,16 @@ end: } -static int mysql_admin_table(THD* thd, TABLE_LIST* tables, - HA_CHECK_OPT* check_opt, - const char *operator_name, - thr_lock_type lock_type, - bool open_for_modify, - uint extra_open_options, - int (*prepare_func)(THD *, TABLE_LIST *, - HA_CHECK_OPT *), - int (handler::*operator_func) - (THD *, HA_CHECK_OPT *)) +static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, + HA_CHECK_OPT* check_opt, + const char *operator_name, + thr_lock_type lock_type, + bool open_for_modify, + uint extra_open_options, + int (*prepare_func)(THD *, TABLE_LIST *, + HA_CHECK_OPT *), + int (handler::*operator_func) + (THD *, HA_CHECK_OPT *)) { TABLE_LIST *table; List<Item> field_list; @@ -1749,7 +1749,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, item->maybe_null = 1; if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); mysql_ha_close(thd, tables, /*dont_send_ok*/ 1, /*dont_lock*/ 1); for (table= tables; table; table= table->next_local) @@ -1761,9 +1761,6 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, thd->open_options|= extra_open_options; table->table = open_ltable(thd, table, lock_type); -#ifdef EMBEDDED_LIBRARY - thd->net.last_errno= 0; // these errors shouldn't get client -#endif thd->open_options&= ~extra_open_options; if (prepare_func) @@ -1785,7 +1782,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, if (!(err_msg=thd->net.last_error)) err_msg=ER(ER_CHECK_NO_SUCH_TABLE); protocol->store(err_msg, system_charset_info); - thd->net.last_error[0]=0; + thd->clear_error(); if (protocol->write()) goto err; continue; @@ -1829,9 +1826,7 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, } int result_code = (table->table->file->*operator_func)(thd, check_opt); -#ifdef EMBEDDED_LIBRARY - thd->net.last_errno= 0; // these errors shouldn't get client -#endif + thd->clear_error(); // these errors shouldn't get client protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); protocol->store(operator_name, system_charset_info); @@ -1932,16 +1927,16 @@ send_result_message: } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: close_thread_tables(thd); // Shouldn't be needed if (table) table->table=0; - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } -int mysql_backup_table(THD* thd, TABLE_LIST* table_list) +bool mysql_backup_table(THD* thd, TABLE_LIST* table_list) { DBUG_ENTER("mysql_backup_table"); DBUG_RETURN(mysql_admin_table(thd, table_list, 0, @@ -1950,7 +1945,7 @@ int mysql_backup_table(THD* thd, TABLE_LIST* table_list) } -int mysql_restore_table(THD* thd, TABLE_LIST* table_list) +bool mysql_restore_table(THD* thd, TABLE_LIST* table_list) { DBUG_ENTER("mysql_restore_table"); DBUG_RETURN(mysql_admin_table(thd, table_list, 0, @@ -1960,7 +1955,7 @@ int mysql_restore_table(THD* thd, TABLE_LIST* table_list) } -int mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) +bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { DBUG_ENTER("mysql_repair_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, @@ -1970,7 +1965,7 @@ int mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) } -int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) +bool mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { DBUG_ENTER("mysql_optimize_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, @@ -1988,11 +1983,11 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) tables Table list (one table only) RETURN VALUES - 0 ok - -1 error + FALSE ok + TRUE error */ -int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, +bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, LEX_STRING *key_cache_name) { HA_CHECK_OPT check_opt; @@ -2005,7 +2000,7 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, { pthread_mutex_unlock(&LOCK_global_system_variables); my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } pthread_mutex_unlock(&LOCK_global_system_variables); check_opt.key_cache= key_cache; @@ -2063,11 +2058,11 @@ int reassign_keycache_tables(THD *thd, KEY_CACHE *src_cache, tables Table list (one table only) RETURN VALUES - 0 ok - -1 error + FALSE ok + TRUE error */ -int mysql_preload_keys(THD* thd, TABLE_LIST* tables) +bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) { DBUG_ENTER("mysql_preload_keys"); DBUG_RETURN(mysql_admin_table(thd, tables, 0, @@ -2087,13 +2082,13 @@ int mysql_preload_keys(THD* thd, TABLE_LIST* tables) table_ident Src table_ident RETURN VALUES - 0 ok - -1 error + FALSE OK + TRUE error */ -int mysql_create_like_table(THD* thd, TABLE_LIST* table, - HA_CREATE_INFO *create_info, - Table_ident *table_ident) +bool mysql_create_like_table(THD* thd, TABLE_LIST* table, + HA_CREATE_INFO *create_info, + Table_ident *table_ident) { TABLE **tmp_table; char src_path[FN_REFLEN], dst_path[FN_REFLEN]; @@ -2101,7 +2096,8 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, char *table_name= table->real_name; char *src_db= thd->db; char *src_table= table_ident->table.str; - int err, res= -1; + int err; + bool res= TRUE; TABLE_LIST src_tables_list; DBUG_ENTER("mysql_create_like_table"); @@ -2114,7 +2110,7 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, table_ident->db.str && check_db_name((src_db= table_ident->db.str))) { my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } bzero((gptr)&src_tables_list, sizeof(src_tables_list)); @@ -2201,7 +2197,7 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table, HA_LEX_CREATE_TMP_TABLE)); mysql_bin_log.write(&qinfo); } - res= 0; + res= FALSE; goto err; table_exists: @@ -2212,7 +2208,7 @@ table_exists: ER(ER_TABLE_EXISTS_ERROR), table_name); push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_TABLE_EXISTS_ERROR,warn_buff); - res= 0; + res= FALSE; } else my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name); @@ -2225,7 +2221,7 @@ err: } -int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) +bool mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { #ifdef OS2 thr_lock_type lock_type = TL_WRITE; @@ -2240,7 +2236,7 @@ int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) } -int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) +bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) { #ifdef OS2 thr_lock_type lock_type = TL_WRITE; @@ -2528,13 +2524,13 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, Alter table */ -int mysql_alter_table(THD *thd,char *new_db, char *new_name, - HA_CREATE_INFO *create_info, - TABLE_LIST *table_list, - List<create_field> &fields, List<Key> &keys, - uint order_num, ORDER *order, - enum enum_duplicates handle_duplicates, - ALTER_INFO *alter_info, bool do_send_ok) +bool mysql_alter_table(THD *thd,char *new_db, char *new_name, + HA_CREATE_INFO *create_info, + TABLE_LIST *table_list, + List<create_field> &fields, List<Key> &keys, + uint order_num, ORDER *order, + enum enum_duplicates handle_duplicates, + ALTER_INFO *alter_info, bool do_send_ok) { TABLE *table,*new_table; int error; @@ -2563,7 +2559,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list, alter_info->tablespace_op)); if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ))) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); /* Check that we are not trying to rename to an existing table */ if (new_name) @@ -2595,7 +2591,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (find_temporary_table(thd,new_db,new_name_buff)) { my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } else @@ -2605,7 +2601,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { /* Table will be closed in do_command() */ my_error(ER_TABLE_EXISTS_ERROR,MYF(0), new_alias); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } } @@ -2788,7 +2784,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (def->sql_type == FIELD_TYPE_BLOB) { my_error(ER_BLOB_CANT_HAVE_DEFAULT,MYF(0),def->change); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } def->def=alter->def; // Use new default alter_it.remove(); @@ -2802,7 +2798,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (def->change && ! def->field) { my_error(ER_BAD_FIELD_ERROR,MYF(0),def->change,table_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!def->after) create_list.push_back(def); @@ -2820,7 +2816,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (!find) { my_error(ER_BAD_FIELD_ERROR,MYF(0),def->after,table_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } find_it.after(def); // Put element after this } @@ -2829,12 +2825,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { my_error(ER_BAD_FIELD_ERROR,MYF(0),alter_info->alter_list.head()->name, table_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!create_list.elements) { my_error(ER_CANT_REMOVE_ALL_FIELDS,MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* @@ -2923,7 +2919,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, !my_strcasecmp(system_charset_info,key->name,primary_key_name)) { my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } } @@ -3261,10 +3257,10 @@ end_temporary: if (do_send_ok) send_ok(thd,copied+deleted,0L,tmp_name); thd->some_tables_deleted=0; - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } @@ -3433,8 +3429,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, RETURN Like mysql_alter_table(). */ -int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, - bool do_send_ok) +bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, + bool do_send_ok) { DBUG_ENTER("mysql_recreate_table"); LEX *lex= thd->lex; @@ -3455,7 +3451,7 @@ int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, } -int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) +bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) { TABLE_LIST *table; List<Item> field_list; @@ -3469,7 +3465,7 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) item->maybe_null= 1; if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); for (table= tables; table; table= table->next_local) { @@ -3488,7 +3484,7 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) { /* Table didn't exist */ protocol->store_null(); - thd->net.last_error[0]=0; + thd->clear_error(); } else { @@ -3550,11 +3546,11 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) } send_eof(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: close_thread_tables(thd); // Shouldn't be needed if (table) table->table=0; - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index add4078ce8e..b71bb4ba42a 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -38,12 +38,13 @@ static File_option triggers_file_parameters[]= methods. RETURN VALUE - 0 - Success, non-0 in case of error. + FALSE Success + TRUE error */ -int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) +bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) { TABLE *table; - int result= 0; + bool result= 0; DBUG_ENTER("mysql_create_or_drop_trigger"); @@ -53,7 +54,7 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) */ if (open_and_lock_tables(thd, tables)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); /* TODO: We should check if user has TRIGGER privilege for table here. @@ -61,7 +62,7 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) we don't have proper privilege checking for triggers in place yet. */ if (check_global_access(thd, SUPER_ACL)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); table= tables->table; @@ -74,7 +75,7 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (tables->view || table->tmp_table != NO_TMP_TABLE) { my_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE, MYF(0), tables->alias); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!table->triggers) @@ -82,11 +83,11 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (!create) { my_error(ER_TRG_DOES_NOT_EXIST, MYF(0)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!(table->triggers= new (&table->mem_root) Table_triggers_list())) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* @@ -96,12 +97,12 @@ int mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) global read lock is held without helding LOCK_open). */ if (wait_if_global_read_lock(thd, 0, 0)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); VOID(pthread_mutex_lock(&LOCK_open)); - if ((create ? table->triggers->create_trigger(thd, tables): - table->triggers->drop_trigger(thd, tables))) - result= -1; + result= (create ? + table->triggers->create_trigger(thd, tables): + table->triggers->drop_trigger(thd, tables)); /* It is sensible to invalidate table in any case */ close_cached_table(thd, table); diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 561f79f9de1..d27b72c02a7 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -369,7 +369,7 @@ int mysql_create_function(THD *thd,udf_func *udf) if (!initialized) { - send_error(thd, ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES)); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); DBUG_RETURN(1); } @@ -380,19 +380,19 @@ int mysql_create_function(THD *thd,udf_func *udf) */ if (strchr(udf->dl, '/')) { - send_error(thd, ER_UDF_NO_PATHS,ER(ER_UDF_NO_PATHS)); + my_error(ER_UDF_NO_PATHS, MYF(0)); DBUG_RETURN(1); } if (udf->name.length > NAME_LEN) { - net_printf(thd, ER_TOO_LONG_IDENT,udf->name); + my_error(ER_TOO_LONG_IDENT, MYF(0), udf->name); DBUG_RETURN(1); } rw_wrlock(&THR_LOCK_udf); if ((hash_search(&udf_hash,(byte*) udf->name.str, udf->name.length))) { - net_printf(thd, ER_UDF_EXISTS, udf->name); + my_error(ER_UDF_EXISTS, MYF(0), udf->name); goto err; } if (!(dl = find_udf_dl(udf->dl))) @@ -401,7 +401,7 @@ int mysql_create_function(THD *thd,udf_func *udf) { DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)", udf->dl,errno,dlerror())); - net_printf(thd, ER_CANT_OPEN_LIBRARY, udf->dl, errno, dlerror()); + my_error(ER_CANT_OPEN_LIBRARY, MYF(0), udf->dl, errno, dlerror()); goto err; } new_dl=1; @@ -411,16 +411,13 @@ int mysql_create_function(THD *thd,udf_func *udf) if (udf->func == NULL) { - net_printf(thd, ER_CANT_FIND_DL_ENTRY, udf->name); + my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), udf->name); goto err; } udf->name.str=strdup_root(&mem,udf->name.str); udf->dl=strdup_root(&mem,udf->dl); if (!(u_d=add_udf(&udf->name,udf->returns,udf->dl,udf->type))) - { - send_error(thd,0); // End of memory goto err; - } u_d->dlhandle = dl; u_d->func=udf->func; u_d->func_init=udf->func_init; @@ -448,7 +445,7 @@ int mysql_create_function(THD *thd,udf_func *udf) close_thread_tables(thd); if (error) { - net_printf(thd, ER_ERROR_ON_WRITE, "func@mysql",error); + my_error(ER_ERROR_ON_WRITE, MYF(0), "func@mysql", error); del_udf(u_d); goto err; } @@ -471,14 +468,14 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) DBUG_ENTER("mysql_drop_function"); if (!initialized) { - send_error(thd, ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES)); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); DBUG_RETURN(1); } rw_wrlock(&THR_LOCK_udf); if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name->str, (uint) udf_name->length))) { - net_printf(thd, ER_FUNCTION_NOT_DEFINED, udf_name->str); + my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str); goto err; } del_udf(udf); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index cf4203bf5b8..6a2d11ba7f5 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -24,21 +24,20 @@ #include "mysql_priv.h" #include "sql_select.h" -int mysql_union(THD *thd, LEX *lex, select_result *result, - SELECT_LEX_UNIT *unit) +bool mysql_union(THD *thd, LEX *lex, select_result *result, + SELECT_LEX_UNIT *unit) { DBUG_ENTER("mysql_union"); - int res, res_cln; + bool res; if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK))) res= unit->exec(); - if (res == 0 && thd->cursor && thd->cursor->is_open()) + if (!res && thd->cursor && thd->cursor->is_open()) { thd->cursor->set_unit(unit); - res_cln= 0; } else - res_cln= unit->cleanup(); - DBUG_RETURN(res?res:res_cln); + res|= unit->cleanup(); + DBUG_RETURN(res); } @@ -104,8 +103,7 @@ bool select_union::flush() int error; if ((error=table->file->extra(HA_EXTRA_NO_CACHE))) { - table->file->print_error(error,MYF(0)); - ::send_error(thd); + table->file->print_error(error, MYF(0)); return 1; } return 0; @@ -147,8 +145,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) } -int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, - ulong additional_options) +bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, + ulong additional_options) { SELECT_LEX *lex_select_save= thd_arg->lex->current_select; SELECT_LEX *sl, *first_select; @@ -176,16 +174,16 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, if (!sl->join->procedure && result->prepare(sl->join->fields_list, this)) { - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } sl->join->select_options|= SELECT_DESCRIBE; sl->join->reinit(); } } - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } prepared= 1; - res= 0; + res= FALSE; thd_arg->lex->current_select= sl= first_select= first_select_in_union(); found_rows_for_union= first_select->options & OPTION_FOUND_ROWS; @@ -232,7 +230,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, sl->having, (ORDER*) NULL, sl, this); - if (res || thd_arg->is_fatal_error) + if ((res= (res || thd_arg->is_fatal_error))) goto err; if (sl == first_select) { @@ -262,7 +260,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, while ((type= tp++, item_tmp= it++)) { if (((Item_type_holder*)type)->join_types(thd_arg, item_tmp)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } } @@ -305,7 +303,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, { if (arena) thd->restore_backup_item_arena(arena, &backup); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } if (arena) @@ -323,7 +321,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, result))) { fake_select_lex->table_list.empty(); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } fake_select_lex->item_list= item_list; @@ -345,15 +343,15 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, thd_arg->lex->current_select= lex_select_save; - DBUG_RETURN(res || thd_arg->is_fatal_error ? 1 : 0); + DBUG_RETURN(res || thd_arg->is_fatal_error); err: thd_arg->lex->current_select= lex_select_save; - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } -int st_select_lex_unit::exec() +bool st_select_lex_unit::exec() { SELECT_LEX *lex_select_save= thd->lex->current_select; SELECT_LEX *select_cursor=first_select_in_union(); @@ -361,7 +359,7 @@ int st_select_lex_unit::exec() DBUG_ENTER("st_select_lex_unit::exec"); if (executed && !uncacheable && !describe) - DBUG_RETURN(0); + DBUG_RETURN(FALSE); executed= 1; if (uncacheable || !item || !item->assigned() || describe) @@ -376,7 +374,7 @@ int st_select_lex_unit::exec() } /* re-enabling indexes for next subselect iteration */ if (union_distinct && table->file->enable_indexes(HA_KEY_SWITCH_ALL)) - DBUG_ASSERT(1); + DBUG_ASSERT(TRUE); } for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select()) { @@ -431,7 +429,7 @@ int st_select_lex_unit::exec() if (sl == union_distinct) { if (table->file->disable_indexes(HA_KEY_SWITCH_ALL)) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); table->no_keyread=1; } res= sl->join->error; @@ -439,7 +437,7 @@ int st_select_lex_unit::exec() if (!res && union_result->flush()) { thd->lex->current_select= lex_select_save; - DBUG_RETURN(1); + DBUG_RETURN(TRUE); } } if (res) @@ -465,7 +463,7 @@ int st_select_lex_unit::exec() optimized= 1; /* Send result to 'result' */ - res= -1; + res= TRUE; { List<Item_func_match> empty_list; empty_list.empty(); @@ -484,7 +482,7 @@ int st_select_lex_unit::exec() fake_select_lex->options, result))) { fake_select_lex->table_list.empty(); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* @@ -528,7 +526,7 @@ int st_select_lex_unit::exec() } -int st_select_lex_unit::cleanup() +bool st_select_lex_unit::cleanup() { int error= 0; JOIN *join; @@ -536,7 +534,7 @@ int st_select_lex_unit::cleanup() if (cleaned) { - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } cleaned= 1; @@ -610,19 +608,19 @@ void st_select_lex_unit::reinit_exec_mechanism() old_result old select_result object RETURN - 0 - OK - -1 - error + FALSE - OK + TRUE - error */ -int st_select_lex_unit::change_result(select_subselect *result, - select_subselect *old_result) +bool st_select_lex_unit::change_result(select_subselect *result, + select_subselect *old_result) { - int res= 0; + bool res= FALSE; for (SELECT_LEX *sl= first_select_in_union(); sl; sl= sl->next_select()) { if (sl->join && sl->join->result == old_result) - if ((res= sl->join->change_result(result))) - return (res); + if (sl->join->change_result(result)) + return TRUE; } if (fake_select_lex && fake_select_lex->join) res= fake_select_lex->join->change_result(result); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 00e70ccb484..8d64d30a9e0 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -87,21 +87,21 @@ static bool check_fields(THD *thd, List<Item> &items) } -int mysql_update(THD *thd, - TABLE_LIST *table_list, - List<Item> &fields, - List<Item> &values, - COND *conds, - uint order_num, ORDER *order, - ha_rows limit, - enum enum_duplicates handle_duplicates) +bool mysql_update(THD *thd, + TABLE_LIST *table_list, + List<Item> &fields, + List<Item> &values, + COND *conds, + uint order_num, ORDER *order, + ha_rows limit, + enum enum_duplicates handle_duplicates) { bool using_limit= limit != HA_POS_ERROR; bool safe_update= thd->options & OPTION_SAFE_UPDATES; bool used_key_is_modified, transactional_table, log_delayed; bool ignore_err= (thd->lex->duplicates == DUP_IGNORE); + bool res; int error=0; - int res; uint used_index; #ifndef NO_EMBEDDED_ACCESS_CHECKS uint want_privilege; @@ -117,8 +117,8 @@ int mysql_update(THD *thd, LINT_INIT(used_index); LINT_INIT(timestamp_query_id); - if ((error= open_and_lock_tables(thd, table_list))) - DBUG_RETURN(error); + if (open_and_lock_tables(thd, table_list)) + DBUG_RETURN(TRUE); thd->proc_info="init"; table= table_list->table; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); @@ -156,16 +156,16 @@ int mysql_update(THD *thd, res= setup_fields(thd, 0, table_list, fields, 1, 0, 0); thd->lex->select_lex.no_wrap_view_item= 0; if (res) - DBUG_RETURN(-1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ } if (table_list->view && check_fields(thd, fields)) { - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (!table_list->updatable || check_key_in_view(thd, table_list)) { my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } if (table->timestamp_field) { @@ -184,7 +184,7 @@ int mysql_update(THD *thd, if (setup_fields(thd, 0, table_list, values, 0, 0, 0)) { free_underlaid_joins(thd, &thd->lex->select_lex); - DBUG_RETURN(-1); /* purecov: inspected */ + DBUG_RETURN(TRUE); /* purecov: inspected */ } // Don't count on usage of 'only index' when calculating which key to use @@ -197,10 +197,10 @@ int mysql_update(THD *thd, free_underlaid_joins(thd, &thd->lex->select_lex); if (error) { - DBUG_RETURN(-1); // Error in where + DBUG_RETURN(TRUE); // Error in where } send_ok(thd); // No matching records - DBUG_RETURN(0); + DBUG_RETURN(FALSE); } /* If running in safe sql mode, don't allow updates without keys */ if (table->quick_keys.is_clear_all()) @@ -363,7 +363,15 @@ int mysql_update(THD *thd, { store_record(table,record[1]); if (fill_record(fields,values, 0) || thd->net.report_error) + { + /* Field::store methods can't send errors */ + if (!thd->net.report_error) + { + /* TODO: convert last warning to error */ + my_error(ER_UNKNOWN_ERROR, MYF(0)); + } break; /* purecov: inspected */ + } found++; if (table->triggers) @@ -456,9 +464,7 @@ int mysql_update(THD *thd, } free_underlaid_joins(thd, &thd->lex->select_lex); - if (error >= 0) - send_error(thd,thd->killed_errno()); /* purecov: inspected */ - else + if (error < 0) { char buff[80]; sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated, @@ -472,7 +478,7 @@ int mysql_update(THD *thd, thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */ thd->abort_on_warning= 0; free_io_cache(table); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: delete select; @@ -483,7 +489,7 @@ err: table->file->extra(HA_EXTRA_NO_KEYREAD); } thd->abort_on_warning= 0; - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* @@ -555,11 +561,11 @@ int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, thd thread handler RETURN - 0 OK - -1 Error + FALSE OK + TRUE Error */ -int mysql_multi_update_prepare(THD *thd) +bool mysql_multi_update_prepare(THD *thd) { LEX *lex= thd->lex; TABLE_LIST *table_list= lex->query_tables; @@ -597,7 +603,7 @@ int mysql_multi_update_prepare(THD *thd) res= setup_fields(thd, 0, table_list, *fields, 1, 0, 0), thd->lex->select_lex.no_wrap_view_item= 0, res)) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); for (tl= table_list; tl ; tl= tl->next_local) { @@ -610,7 +616,7 @@ int mysql_multi_update_prepare(THD *thd) if (update_view && check_fields(thd, *fields)) { - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } { @@ -650,36 +656,36 @@ int mysql_multi_update_prepare(THD *thd) (tables_for_update & tl->table->map)) { my_error(ER_NON_UPDATABLE_TABLE, MYF(0), tl->alias, "UPDATE"); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } } - DBUG_RETURN (0); + DBUG_RETURN(FALSE); } -int mysql_multi_update(THD *thd, - TABLE_LIST *table_list, - List<Item> *fields, - List<Item> *values, - COND *conds, - ulong options, - enum enum_duplicates handle_duplicates, - SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) +bool mysql_multi_update(THD *thd, + TABLE_LIST *table_list, + List<Item> *fields, + List<Item> *values, + COND *conds, + ulong options, + enum enum_duplicates handle_duplicates, + SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) { - int res; + bool res; multi_update *result; DBUG_ENTER("mysql_multi_update"); - if ((res= open_and_lock_tables(thd, table_list))) - DBUG_RETURN(res); + if (open_and_lock_tables(thd, table_list)) + DBUG_RETURN(TRUE); if ((res= mysql_multi_update_prepare(thd))) DBUG_RETURN(res); if (!(result= new multi_update(thd, table_list, fields, values, handle_duplicates))) - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); thd->no_trans_update= 0; thd->abort_on_warning= test(thd->variables.sql_mode & @@ -696,7 +702,7 @@ int mysql_multi_update(THD *thd, result, unit, select_lex); delete result; thd->abort_on_warning= 0; - DBUG_RETURN(res); + DBUG_RETURN(TRUE); } @@ -1023,7 +1029,15 @@ bool multi_update::send_data(List<Item> ¬_used_values) table->status|= STATUS_UPDATED; store_record(table,record[1]); if (fill_record(*fields_for_table[offset], *values_for_table[offset], 0)) + { + /* Field::store methods can't send errors */ + if (!thd->net.report_error) + { + /* TODO: convert last warning to error */ + my_error(ER_UNKNOWN_ERROR, MYF(0)); + } DBUG_RETURN(1); + } found++; if (compare_record(table, thd->query_id)) { @@ -1087,7 +1101,7 @@ bool multi_update::send_data(List<Item> ¬_used_values) void multi_update::send_error(uint errcode,const char *err) { /* First send error what ever it is ... */ - ::send_error(thd,errcode,err); + my_error(errcode, MYF(0), err); /* If nothing updated return */ if (!updated) @@ -1278,7 +1292,6 @@ bool multi_update::send_eof() /* Safety: If we haven't got an error before (should not happen) */ my_message(ER_UNKNOWN_ERROR, "An error occured in multi-table update", MYF(0)); - ::send_error(thd); return 1; } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 4cdbfe9728b..7894287aee4 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -41,13 +41,12 @@ TYPELIB updatable_views_with_limit_typelib= mode - VIEW_CREATE_NEW, VIEW_ALTER, VIEW_CREATE_OR_REPLACE RETURN VALUE - 0 OK - -1 Error - 1 Error and error message given + FALSE OK + TRUE Error */ -int mysql_create_view(THD *thd, - enum_view_create_mode mode) +bool mysql_create_view(THD *thd, + enum_view_create_mode mode) { LEX *lex= thd->lex; bool link_to_local; @@ -57,7 +56,7 @@ int mysql_create_view(THD *thd, TABLE_LIST *tbl; SELECT_LEX *select_lex= &lex->select_lex, *sl; SELECT_LEX_UNIT *unit= &lex->unit; - int res= 0; + bool res= FALSE; DBUG_ENTER("mysql_create_view"); if (lex->proc_list.first || @@ -66,7 +65,7 @@ int mysql_create_view(THD *thd, my_error(ER_VIEW_SELECT_CLAUSE, MYF(0), (lex->result ? "INTO" : "PROCEDURE")); - res= -1; + res= TRUE; goto err; } if (lex->derived_tables || @@ -75,7 +74,7 @@ int mysql_create_view(THD *thd, my_error((lex->derived_tables ? ER_VIEW_SELECT_DERIVED : ER_VIEW_SELECT_VARIABLE), MYF(0)); - res= -1; + res= TRUE; goto err; } @@ -101,7 +100,7 @@ int mysql_create_view(THD *thd, (check_access(thd, DELETE_ACL, view->db, &view->grant.privilege, 0, 0) || grant_option && check_grant(thd, DELETE_ACL, view, 0, 1, 0)))) - DBUG_RETURN(1); + DBUG_RETURN(TRUE); for (sl= select_lex; sl; sl= sl->next_select()) { for (tbl= sl->get_table_list(); tbl; tbl= tbl->next_local) @@ -119,7 +118,7 @@ int mysql_create_view(THD *thd, thd->priv_user, thd->host_or_ip, tbl->real_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } /* Mark this table as a table which will be checked after the prepare @@ -155,7 +154,7 @@ int mysql_create_view(THD *thd, &tbl->grant.privilege, 0, 0) || grant_option && check_grant(thd, SELECT_ACL, tbl, 0, 1, 0)) { - res= 1; + res= TRUE; goto err; } } @@ -177,8 +176,8 @@ int mysql_create_view(THD *thd, } #endif - if ((res= open_and_lock_tables(thd, tables))) - DBUG_RETURN(res); + if (open_and_lock_tables(thd, tables)) + DBUG_RETURN(TRUE); /* check that tables are not temporary and this VIEW do not used in query @@ -190,7 +189,7 @@ int mysql_create_view(THD *thd, if (tbl->table->tmp_table != NO_TMP_TABLE && !tbl->view) { my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias); - res= -1; + res= TRUE; goto err; } @@ -200,7 +199,7 @@ int mysql_create_view(THD *thd, strcmp(tbl->view_name.str, view->real_name) == 0) { my_error(ER_NO_SUCH_TABLE, MYF(0), tbl->view_db.str, tbl->view_name.str); - res= -1; + res= TRUE; goto err; } @@ -220,7 +219,7 @@ int mysql_create_view(THD *thd, some errors from prepare are reported to user, if is not then it will be checked after err: label */ - res= 1; + res= TRUE; goto err; } @@ -255,7 +254,7 @@ int mysql_create_view(THD *thd, if (strcmp(item->name, check->name) == 0) { my_error(ER_DUP_FIELDNAME, MYF(0), item->name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } } @@ -294,7 +293,7 @@ int mysql_create_view(THD *thd, thd->host_or_ip, item->name, view->real_name); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } } } @@ -303,7 +302,7 @@ int mysql_create_view(THD *thd, if (wait_if_global_read_lock(thd, 0, 0)) { - res= -1; + res= TRUE; goto err; } VOID(pthread_mutex_lock(&LOCK_open)); @@ -321,9 +320,7 @@ err: thd->proc_info= "end"; lex->link_first_table_back(view, link_to_local); unit->cleanup(); - if (thd->net.report_error) - res= -1; - DBUG_RETURN(res); + DBUG_RETURN(res || thd->net.report_error); } @@ -824,12 +821,11 @@ err: drop_mode - cascade/check RETURN VALUE - 0 OK - -1 Error - 1 Error and error message given + FALSE OK + TRUE Error */ -int mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) +bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) { DBUG_ENTER("mysql_drop_view"); char path[FN_REFLEN]; @@ -865,11 +861,11 @@ int mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) VOID(pthread_mutex_unlock(&LOCK_open)); } send_ok(thd); - DBUG_RETURN(0); + DBUG_RETURN(FALSE); err: VOID(pthread_mutex_unlock(&LOCK_open)); - DBUG_RETURN(-1); + DBUG_RETURN(TRUE); } diff --git a/sql/sql_view.h b/sql/sql_view.h index 538f548d97b..4cb2514f5b9 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -16,12 +16,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -int mysql_create_view(THD *thd, - enum_view_create_mode mode); +bool mysql_create_view(THD *thd, + enum_view_create_mode mode); my_bool mysql_make_view(File_parser *parser, TABLE_LIST *table); -int mysql_drop_view(THD *thd, TABLE_LIST *view, enum_drop_mode drop_mode); +bool mysql_drop_view(THD *thd, TABLE_LIST *view, enum_drop_mode drop_mode); bool check_key_in_view(THD *thd, TABLE_LIST * view); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 31016b59c6f..fe25d689b4b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -810,7 +810,7 @@ query: if (!thd->bootstrap && (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))) { - send_error(thd,ER_EMPTY_QUERY); + my_error(ER_EMPTY_QUERY, MYF(0)); YYABORT; } else @@ -1146,7 +1146,7 @@ create: if (lex->sphead) { - net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "PROCEDURE"); + my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "PROCEDURE"); YYABORT; } /* Order is important here: new - reset - init */ @@ -1219,7 +1219,7 @@ create: if (lex->sphead) { - net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "TRIGGER"); + my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER"); YYABORT; } @@ -1300,7 +1300,7 @@ create_function_tail: if (lex->sphead) { - net_printf(YYTHD, ER_SP_NO_RECURSIVE_CREATE, "FUNCTION"); + my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "FUNCTION"); YYABORT; } /* Order is important here: new - reset - init */ @@ -1455,7 +1455,7 @@ sp_fdparam: if (spc->find_pvar(&$1, TRUE)) { - net_printf(YYTHD, ER_SP_DUP_PARAM, $1.str); + my_error(ER_SP_DUP_PARAM, MYF(0), $1.str); YYABORT; } spc->push_pvar(&$1, (enum enum_field_types)$2, sp_param_in); @@ -1481,7 +1481,7 @@ sp_pdparam: if (spc->find_pvar(&$2, TRUE)) { - net_printf(YYTHD, ER_SP_DUP_PARAM, $2.str); + my_error(ER_SP_DUP_PARAM, MYF(0), $2.str); YYABORT; } spc->push_pvar(&$2, (enum enum_field_types)$3, @@ -1515,12 +1515,12 @@ sp_decls: better error handling this way.) */ if (($2.vars || $2.conds) && ($1.curs || $1.hndlrs)) { /* Variable or condition following cursor or handler */ - send_error(YYTHD, ER_SP_VARCOND_AFTER_CURSHNDLR); + my_error(ER_SP_VARCOND_AFTER_CURSHNDLR, MYF(0)); YYABORT; } if ($2.curs && $1.hndlrs) { /* Cursor following handler */ - send_error(YYTHD, ER_SP_CURSOR_AFTER_HANDLER); + my_error(ER_SP_CURSOR_AFTER_HANDLER, MYF(0)); YYABORT; } $$.vars= $1.vars + $2.vars; @@ -1568,7 +1568,7 @@ sp_decl: if (spc->find_cond(&$2, TRUE)) { - net_printf(YYTHD, ER_SP_DUP_COND, $2.str); + my_error(ER_SP_DUP_COND, MYF(0), $2.str); YYABORT; } YYTHD->lex->spcont->push_cond(&$2, $5); @@ -1625,7 +1625,7 @@ sp_decl: if (ctx->find_cursor(&$2, &offp, TRUE)) { - net_printf(YYTHD, ER_SP_DUP_CURS, $2.str); + my_error(ER_SP_DUP_CURS, MYF(0), $2.str); delete $5; YYABORT; } @@ -1652,12 +1652,12 @@ sp_cursor_stmt: if (lex->sql_command != SQLCOM_SELECT) { - send_error(YYTHD, ER_SP_BAD_CURSOR_QUERY); + my_error(ER_SP_BAD_CURSOR_QUERY, MYF(0)); YYABORT; } if (lex->result) { - send_error(YYTHD, ER_SP_BAD_CURSOR_SELECT); + my_error(ER_SP_BAD_CURSOR_SELECT, MYF(0)); YYABORT; } lex->sp_lex_in_use= TRUE; @@ -1727,7 +1727,7 @@ sp_hcond: $$= Lex->spcont->find_cond(&$1); if ($$ == NULL) { - net_printf(YYTHD, ER_SP_COND_MISMATCH, $1.str); + my_error(ER_SP_COND_MISMATCH, MYF(0), $1.str); YYABORT; } } @@ -1756,7 +1756,7 @@ sp_decl_idents: if (spc->find_pvar(&$1, TRUE)) { - net_printf(YYTHD, ER_SP_DUP_VAR, $1.str); + my_error(ER_SP_DUP_VAR, MYF(0), $1.str); YYABORT; } spc->push_pvar(&$1, (enum_field_types)0, sp_param_in); @@ -1769,7 +1769,7 @@ sp_decl_idents: if (spc->find_pvar(&$3, TRUE)) { - net_printf(YYTHD, ER_SP_DUP_VAR, $3.str); + my_error(ER_SP_DUP_VAR, MYF(0), $3.str); YYABORT; } spc->push_pvar(&$3, (enum_field_types)0, sp_param_in); @@ -1802,7 +1802,7 @@ sp_proc_stmt: } if (lex->sql_command == SQLCOM_CHANGE_DB) { /* "USE db" doesn't work in a procedure */ - send_error(YYTHD, ER_SP_NO_USE); + my_error(ER_SP_NO_USE, MYF(0)); YYABORT; } /* Don't add an instruction for empty SET statements. @@ -1821,7 +1821,7 @@ sp_proc_stmt: */ if (sp->m_type != TYPE_ENUM_PROCEDURE) { - send_error(YYTHD, ER_SP_BADSTATEMENT); + my_error(ER_SP_BADSTATEMENT, MYF(0)); YYABORT; } else @@ -1851,7 +1851,7 @@ sp_proc_stmt: if (lex->sphead->m_type == TYPE_ENUM_PROCEDURE) { - send_error(YYTHD, ER_SP_BADRETURN); + my_error(ER_SP_BADRETURN, MYF(0)); YYABORT; } else @@ -1860,7 +1860,7 @@ sp_proc_stmt: if ($2->type() == Item::SUBSELECT_ITEM) { /* QQ For now, just disallow subselects as values */ - send_error(lex->thd, ER_SP_BADSTATEMENT); + my_error(ER_SP_BADSTATEMENT, MYF(0)); YYABORT; } i= new sp_instr_freturn(lex->sphead->instructions(), @@ -1923,7 +1923,7 @@ sp_proc_stmt: if (! lab) { - net_printf(YYTHD, ER_SP_LILABEL_MISMATCH, "LEAVE", $2.str); + my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "LEAVE", $2.str); YYABORT; } else @@ -1953,7 +1953,7 @@ sp_proc_stmt: if (! lab || lab->type != SP_LAB_ITER) { - net_printf(YYTHD, ER_SP_LILABEL_MISMATCH, "ITERATE", $2.str); + my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "ITERATE", $2.str); YYABORT; } else @@ -1981,7 +1981,7 @@ sp_proc_stmt: if (lab) { - net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $2.str); + my_error(ER_SP_LABEL_REDEFINE, MYF(0), $2.str); YYABORT; } else @@ -2005,7 +2005,7 @@ sp_proc_stmt: if (sp->m_in_handler) { - send_error(lex->thd, ER_SP_GOTO_IN_HNDLR); + my_error(ER_SP_GOTO_IN_HNDLR, MYF(0)); YYABORT; } lab= ctx->find_label($2.str); @@ -2056,7 +2056,7 @@ sp_proc_stmt: if (! lex->spcont->find_cursor(&$2, &offset)) { - net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str); + my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str); YYABORT; } i= new sp_instr_copen(sp->instructions(), lex->spcont, offset); @@ -2071,7 +2071,7 @@ sp_proc_stmt: if (! lex->spcont->find_cursor(&$2, &offset)) { - net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str); + my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str); YYABORT; } i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset); @@ -2088,7 +2088,7 @@ sp_proc_stmt: if (! lex->spcont->find_cursor(&$2, &offset)) { - net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str); + my_error(ER_SP_CURSOR_MISMATCH, MYF(0), $2.str); YYABORT; } i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset); @@ -2106,7 +2106,7 @@ sp_fetch_list: if (!spc || !(spv = spc->find_pvar(&$1))) { - net_printf(YYTHD, ER_SP_UNDECLARED_VAR, $1.str); + my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str); YYABORT; } else @@ -2128,7 +2128,7 @@ sp_fetch_list: if (!spc || !(spv = spc->find_pvar(&$3))) { - net_printf(YYTHD, ER_SP_UNDECLARED_VAR, $3.str); + my_error(ER_SP_UNDECLARED_VAR, MYF(0), $3.str); YYABORT; } else @@ -2252,7 +2252,7 @@ sp_labeled_control: if (lab) { - net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $1.str); + my_error(ER_SP_LABEL_REDEFINE, MYF(0), $1.str); YYABORT; } else @@ -2273,7 +2273,7 @@ sp_labeled_control: if (!lab || my_strcasecmp(system_charset_info, $5.str, lab->name) != 0) { - net_printf(YYTHD, ER_SP_LABEL_MISMATCH, $5.str); + my_error(ER_SP_LABEL_MISMATCH, MYF(0), $5.str); YYABORT; } } @@ -2531,9 +2531,9 @@ default_charset: cinfo->default_table_charset && $4 && !my_charset_same(cinfo->default_table_charset,$4)) { - net_printf(YYTHD, ER_CONFLICTING_DECLARATIONS, - "CHARACTER SET ", cinfo->default_table_charset->csname, - "CHARACTER SET ", $4->csname); + my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), + "CHARACTER SET ", cinfo->default_table_charset->csname, + "CHARACTER SET ", $4->csname); YYABORT; } Lex->create_info.default_table_charset= $4; @@ -2548,8 +2548,8 @@ default_collation: cinfo->default_table_charset && $4 && !my_charset_same(cinfo->default_table_charset,$4)) { - net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, - $4->name, cinfo->default_table_charset->csname); + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + $4->name, cinfo->default_table_charset->csname); YYABORT; } Lex->create_info.default_table_charset= $4; @@ -2561,7 +2561,7 @@ storage_engines: { $$ = ha_resolve_by_name($1.str,$1.length); if ($$ == DB_TYPE_UNKNOWN) { - net_printf(YYTHD, ER_UNKNOWN_STORAGE_ENGINE, $1.str); + my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str); YYABORT; } }; @@ -2740,18 +2740,19 @@ type: $$=FIELD_TYPE_TINY_BLOB; } | BLOB_SYM opt_len { Lex->charset=&my_charset_bin; $$=FIELD_TYPE_BLOB; } - | spatial_type { + | spatial_type + { #ifdef HAVE_SPATIAL - Lex->charset=&my_charset_bin; - Lex->uint_geom_type= (uint)$1; - $$=FIELD_TYPE_GEOMETRY; + Lex->charset=&my_charset_bin; + Lex->uint_geom_type= (uint)$1; + $$=FIELD_TYPE_GEOMETRY; #else - net_printf(Lex->thd, ER_FEATURE_DISABLED, - sym_group_geom.name, - sym_group_geom.needed_define); - YYABORT; + my_error(ER_FEATURE_DISABLED, MYF(0) + sym_group_geom.name, + sym_group_geom.needed_define); + YYABORT; #endif - } + } | MEDIUMBLOB { Lex->charset=&my_charset_bin; $$=FIELD_TYPE_MEDIUM_BLOB; } | LONGBLOB { Lex->charset=&my_charset_bin; @@ -2915,8 +2916,8 @@ attribute: { if (Lex->charset && !my_charset_same(Lex->charset,$2)) { - net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, - $2->name,Lex->charset->csname); + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + $2->name,Lex->charset->csname); YYABORT; } else @@ -2941,7 +2942,7 @@ charset_name: { if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0)))) { - net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,$1.str); + my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str); YYABORT; } } @@ -2959,7 +2960,7 @@ old_or_new_charset_name: if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) && !($$=get_old_charset_by_name($1.str))) { - net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,$1.str); + my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), $1.str); YYABORT; } } @@ -2975,7 +2976,7 @@ collation_name: { if (!($$=get_charset_by_name($1.str,MYF(0)))) { - net_printf(YYTHD,ER_UNKNOWN_COLLATION,$1.str); + my_error(ER_UNKNOWN_COLLATION, MYF(0), $1.str); YYABORT; } }; @@ -2999,9 +3000,10 @@ opt_binary: | BYTE_SYM { Lex->charset=&my_charset_bin; } | UNICODE_SYM { - if (!(Lex->charset=get_charset_by_csname("ucs2",MY_CS_PRIMARY,MYF(0)))) + if (!(Lex->charset=get_charset_by_csname("ucs2", + MY_CS_PRIMARY,MYF(0)))) { - net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,"ucs2"); + my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "ucs2"); YYABORT; } } @@ -3063,8 +3065,8 @@ key_type: #ifdef HAVE_SPATIAL $$= Key::SPATIAL; #else - net_printf(Lex->thd, ER_FEATURE_DISABLED, - sym_group_geom.name, sym_group_geom.needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif }; @@ -3096,8 +3098,8 @@ opt_unique_or_fulltext: #ifdef HAVE_SPATIAL $$= Key::SPATIAL; #else - net_printf(Lex->thd, ER_FEATURE_DISABLED, - sym_group_geom.name, sym_group_geom.needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif } @@ -3324,7 +3326,7 @@ alter_list_item: if (check_table_name($3->table.str,$3->table.length) || $3->db.str && check_db_name($3->db.str)) { - net_printf(lex->thd,ER_WRONG_TABLE_NAME,$3->table.str); + my_error(ER_WRONG_TABLE_NAME, MYF(0), $3->table.str); YYABORT; } lex->alter_info.flags|= ALTER_RENAME; @@ -3339,8 +3341,8 @@ alter_list_item: $5= $5 ? $5 : $4; if (!my_charset_same($4,$5)) { - net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, - $5->name,$4->csname); + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + $5->name, $4->csname); YYABORT; } LEX *lex= Lex; @@ -3462,7 +3464,7 @@ slave_until: !((lex->mi.log_file_name && lex->mi.pos) || (lex->mi.relay_log_name && lex->mi.relay_log_pos))) { - send_error(lex->thd, ER_BAD_SLAVE_UNTIL_COND); + my_error(ER_BAD_SLAVE_UNTIL_COND, MYF(0)); YYABORT; } @@ -4175,9 +4177,9 @@ simple_expr: { if (!$1.symbol->create_func) { - net_printf(Lex->thd, ER_FEATURE_DISABLED, - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(void))($1.symbol->create_func))(); @@ -4186,9 +4188,9 @@ simple_expr: { if (!$1.symbol->create_func) { - net_printf(Lex->thd, ER_FEATURE_DISABLED, - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(Item*))($1.symbol->create_func))($3); @@ -4197,9 +4199,9 @@ simple_expr: { if (!$1.symbol->create_func) { - net_printf(Lex->thd, ER_FEATURE_DISABLED, - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(Item*,Item*))($1.symbol->create_func))($3,$5); @@ -4208,9 +4210,9 @@ simple_expr: { if (!$1.symbol->create_func) { - net_printf(Lex->thd, ER_FEATURE_DISABLED, - $1.symbol->group->name, - $1.symbol->group->needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + $1.symbol->group->name, + $1.symbol->group->needed_define); YYABORT; } $$= ((Item*(*)(Item*,Item*,Item*))($1.symbol->create_func))($3,$5,$7); @@ -4311,8 +4313,8 @@ simple_expr: #ifdef HAVE_SPATIAL $$= $1; #else - net_printf(Lex->thd, ER_FEATURE_DISABLED, - sym_group_geom.name, sym_group_geom.needed_define); + my_error(ER_FEATURE_DISABLED, MYF(0), + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif } @@ -5168,12 +5170,12 @@ olap_opt: LEX *lex=Lex; if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { - net_printf(lex->thd, ER_WRONG_USAGE, "WITH CUBE", + my_error(ER_WRONG_USAGE, MYF(0), "WITH CUBE", "global union parameters"); YYABORT; } lex->current_select->olap= CUBE_TYPE; - net_printf(lex->thd, ER_NOT_SUPPORTED_YET, "CUBE"); + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "CUBE"); YYABORT; /* To be deleted in 5.1 */ } | WITH ROLLUP_SYM @@ -5181,7 +5183,7 @@ olap_opt: LEX *lex= Lex; if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { - net_printf(lex->thd, ER_WRONG_USAGE, "WITH ROLLUP", + my_error(ER_WRONG_USAGE, MYF(0), "WITH ROLLUP", "global union parameters"); YYABORT; } @@ -5205,9 +5207,8 @@ order_clause: lex->current_select->olap != UNSPECIFIED_OLAP_TYPE) { - net_printf(lex->thd, ER_WRONG_USAGE, - "CUBE/ROLLUP", - "ORDER BY"); + my_error(ER_WRONG_USAGE, MYF(0), + "CUBE/ROLLUP", "ORDER BY"); YYABORT; } } order_list; @@ -5305,9 +5306,7 @@ procedure_clause: LEX *lex=Lex; if (&lex->select_lex != lex->current_select) { - net_printf(lex->thd, ER_WRONG_USAGE, - "PROCEDURE", - "subquery"); + my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "subquery"); YYABORT; } lex->proc_list.elements=0; @@ -5371,7 +5370,7 @@ select_var_ident: if (!lex->spcont || !(t=lex->spcont->find_pvar(&$1))) { - net_printf(YYTHD, ER_SP_UNDECLARED_VAR, $1.str); + my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str); YYABORT; } if (! lex->result) @@ -5466,7 +5465,7 @@ drop: LEX *lex=Lex; if (lex->sphead) { - net_printf(YYTHD, ER_SP_NO_DROP_SP, "FUNCTION"); + my_error(ER_SP_NO_DROP_SP, MYF(0), "FUNCTION"); YYABORT; } lex->sql_command = SQLCOM_DROP_FUNCTION; @@ -5478,7 +5477,7 @@ drop: LEX *lex=Lex; if (lex->sphead) { - net_printf(YYTHD, ER_SP_NO_DROP_SP, "PROCEDURE"); + my_error(ER_SP_NO_DROP_SP, MYF(0), "PROCEDURE"); YYABORT; } lex->sql_command = SQLCOM_DROP_PROCEDURE; @@ -5726,8 +5725,8 @@ update: else if (lex->select_lex.get_table_list()->derived) { /* it is single table update and it is update of derived table */ - net_printf(lex->thd, ER_NON_UPDATABLE_TABLE, - lex->select_lex.get_table_list()->alias, "UPDATE"); + my_error(ER_NON_UPDATABLE_TABLE, MYF(0), + lex->select_lex.get_table_list()->alias, "UPDATE"); YYABORT; } } @@ -6049,7 +6048,7 @@ show_engine_param: Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS; break; default: - net_printf(YYTHD, ER_NOT_SUPPORTED_YET, "STATUS"); + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "STATUS"); YYABORT; } } @@ -6060,7 +6059,7 @@ show_engine_param: Lex->sql_command = SQLCOM_SHOW_LOGS; break; default: - net_printf(YYTHD, ER_NOT_SUPPORTED_YET, "LOGS"); + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "LOGS"); YYABORT; } }; @@ -6212,7 +6211,7 @@ purge_option: { if ($2->check_cols(1) || $2->fix_fields(Lex->thd, 0, &$2)) { - net_printf(Lex->thd, ER_WRONG_ARGUMENTS, "PURGE LOGS BEFORE"); + my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE"); YYABORT; } Item *tmp= new Item_func_unix_timestamp($2); @@ -6234,7 +6233,7 @@ kill: LEX *lex=Lex; if ($3->fix_fields(lex->thd, 0, &$3) || $3->check_cols(1)) { - send_error(lex->thd, ER_SET_CONSTANTS_ONLY); + my_error(ER_SET_CONSTANTS_ONLY, MYF(0)); YYABORT; } lex->sql_command=SQLCOM_KILL; @@ -6381,7 +6380,7 @@ param_marker: (uchar *) thd->query)); if (!($$= item) || lex->param_list.push_back(item)) { - send_error(thd, ER_OUT_OF_RESOURCES); + my_error(ER_OUT_OF_RESOURCES, MYF(0)); YYABORT; } } @@ -6437,7 +6436,6 @@ NUM_literal: $$= new Item_real($1.str, $1.length); if (YYTHD->net.report_error) { - send_error(YYTHD, 0, NullS); YYABORT; } } @@ -6446,7 +6444,6 @@ NUM_literal: $$ = new Item_float($1.str, $1.length); if (YYTHD->net.report_error) { - send_error(YYTHD, 0, NullS); YYABORT; } } @@ -6541,16 +6538,14 @@ simple_ident_q: if (lex->trg_chistics.event == TRG_EVENT_INSERT && !new_row) { - net_printf(YYTHD, ER_TRG_NO_SUCH_ROW_IN_TRG, "OLD", - "on INSERT"); + my_error(ER_TRG_NO_SUCH_ROW_IN_TRG, MYF(0), "OLD", "on INSERT"); YYABORT; } if (lex->trg_chistics.event == TRG_EVENT_DELETE && new_row) { - net_printf(YYTHD, ER_TRG_NO_SUCH_ROW_IN_TRG, "NEW", - "on DELETE"); + my_error(ER_TRG_NO_SUCH_ROW_IN_TRG, MYF(0), "NEW", "on DELETE"); YYABORT; } @@ -6567,8 +6562,8 @@ simple_ident_q: FIXME. Far from perfect solution. See comment for "SET NEW.field_name:=..." for more info. */ - net_printf(YYTHD, ER_BAD_FIELD_ERROR, $3.str, - new_row ? "NEW": "OLD"); + my_error(ER_BAD_FIELD_ERROR, MYF(0), $3.str, + new_row ? "NEW": "OLD"); YYABORT; } @@ -6655,8 +6650,8 @@ IDENT_sys: $1.length); if (wlen < $1.length) { - net_printf(YYTHD, ER_INVALID_CHARACTER_STRING, cs->csname, - $1.str + wlen); + my_error(ER_INVALID_CHARACTER_STRING, MYF(0), cs->csname, + $1.str + wlen); YYABORT; } $$= $1; @@ -7034,7 +7029,7 @@ option_value: */ if (lex->query_tables) { - send_error(YYTHD, ER_SP_SUBSELECT_NYI); + my_error(ER_SP_SUBSELECT_NYI, MYF(0)); YYABORT; } sp_instr_set_user_var *i= @@ -7057,7 +7052,7 @@ option_value: sp_instr_set_trigger_field *i; if (lex->query_tables) { - send_error(YYTHD, ER_SP_SUBSELECT_NYI); + my_error(ER_SP_SUBSELECT_NYI, MYF(0)); YYABORT; } if ($3) @@ -7086,7 +7081,7 @@ option_value: Error message also should be improved. */ - net_printf(YYTHD, ER_BAD_FIELD_ERROR, $1.base_name, "NEW"); + my_error(ER_BAD_FIELD_ERROR, MYF(0), $1.base_name, "NEW"); YYABORT; } lex->sphead->add_instr(i); @@ -7152,7 +7147,8 @@ option_value: $3= $3 ? $3 : $2; if (!my_charset_same($2,$3)) { - net_printf(thd,ER_COLLATION_CHARSET_MISMATCH,$3->name,$2->csname); + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + $3->name, $2->csname); YYABORT; } lex->var_list.push_back(new set_var_collation_client($3,$3,$3)); @@ -7218,18 +7214,18 @@ internal_variable_name: { if ($1.str[0]=='O' || $1.str[0]=='o') { - net_printf(YYTHD, ER_TRG_CANT_CHANGE_ROW, "OLD", ""); + my_error(ER_TRG_CANT_CHANGE_ROW, MYF(0), "OLD", ""); YYABORT; } if (lex->trg_chistics.event == TRG_EVENT_DELETE) { - net_printf(YYTHD, ER_TRG_NO_SUCH_ROW_IN_TRG, "NEW", - "on DELETE"); + my_error(ER_TRG_NO_SUCH_ROW_IN_TRG, MYF(0), + "NEW", "on DELETE"); YYABORT; } if (lex->trg_chistics.action_time == TRG_ACTION_AFTER) { - net_printf(YYTHD, ER_TRG_CANT_CHANGE_ROW, "NEW", "after "); + my_error(ER_TRG_CANT_CHANGE_ROW, MYF(0), "NEW", "after "); YYABORT; } /* This special combination will denote field of NEW row */ @@ -7242,7 +7238,7 @@ internal_variable_name: if (!tmp) YYABORT; if (!tmp->is_struct()) - net_printf(YYTHD, ER_VARIABLE_IS_NOT_STRUCT, $3.str); + my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str); $$.var= tmp; $$.base_name= $1; } @@ -7253,7 +7249,7 @@ internal_variable_name: if (!tmp) YYABORT; if (!tmp->is_struct()) - net_printf(YYTHD, ER_VARIABLE_IS_NOT_STRUCT, $3.str); + my_error(ER_VARIABLE_IS_NOT_STRUCT, MYF(0), $3.str); $$.var= tmp; $$.base_name.str= (char*) "default"; $$.base_name.length= 7; @@ -7498,7 +7494,7 @@ require_list_element: LEX *lex=Lex; if (lex->x509_subject) { - net_printf(lex->thd,ER_DUP_ARGUMENT, "SUBJECT"); + my_error(ER_DUP_ARGUMENT, MYF(0), "SUBJECT"); YYABORT; } lex->x509_subject=$2.str; @@ -7508,7 +7504,7 @@ require_list_element: LEX *lex=Lex; if (lex->x509_issuer) { - net_printf(lex->thd,ER_DUP_ARGUMENT, "ISSUER"); + my_error(ER_DUP_ARGUMENT, MYF(0), "ISSUER"); YYABORT; } lex->x509_issuer=$2.str; @@ -7518,7 +7514,7 @@ require_list_element: LEX *lex=Lex; if (lex->ssl_cipher) { - net_printf(lex->thd,ER_DUP_ARGUMENT, "CIPHER"); + my_error(ER_DUP_ARGUMENT, MYF(0), "CIPHER"); YYABORT; } lex->ssl_cipher=$2.str; @@ -7534,7 +7530,7 @@ opt_table: lex->grant = DB_ACLS & ~GRANT_ACL; else if (lex->columns.elements) { - send_error(lex->thd,ER_ILLEGAL_GRANT_FOR_TABLE); + my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); YYABORT; } } @@ -7546,7 +7542,7 @@ opt_table: lex->grant = DB_ACLS & ~GRANT_ACL; else if (lex->columns.elements) { - send_error(lex->thd,ER_ILLEGAL_GRANT_FOR_TABLE); + my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); YYABORT; } } @@ -7558,7 +7554,7 @@ opt_table: lex->grant= GLOBAL_ACLS & ~GRANT_ACL; else if (lex->columns.elements) { - send_error(lex->thd,ER_ILLEGAL_GRANT_FOR_TABLE); + my_error(ER_ILLEGAL_GRANT_FOR_TABLE, MYF(0)); YYABORT; } } @@ -7743,7 +7739,7 @@ union_list: if (lex->exchange) { /* Only the last SELECT can have INTO...... */ - net_printf(lex->thd, ER_WRONG_USAGE, "UNION", "INTO"); + my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO"); YYABORT; } if (lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) |