summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mysqld_error.h23
-rw-r--r--libmysqld/lib_sql.cc2
-rw-r--r--mysql-test/r/rpl_charset.result6
-rw-r--r--mysql-test/r/rpl_rotate_logs.result2
-rw-r--r--mysql-test/r/rpl_timezone.result2
-rw-r--r--mysql-test/r/sp-security.result4
-rw-r--r--mysql-test/r/sp.result12
-rw-r--r--mysql-test/t/connect.test2
-rw-r--r--mysql-test/t/rpl_charset.test6
-rw-r--r--mysql-test/t/rpl_rotate_logs.test3
-rw-r--r--mysql-test/t/rpl_timezone.test2
-rw-r--r--mysql-test/t/sp-security.test4
-rw-r--r--mysql-test/t/sp.test17
-rw-r--r--mysys/my_error.c12
-rw-r--r--sql/filesort.cc3
-rw-r--r--sql/ha_innodb.cc18
-rw-r--r--sql/ha_innodb.h2
-rw-r--r--sql/handler.cc23
-rw-r--r--sql/item.cc44
-rw-r--r--sql/item_cmpfunc.cc41
-rw-r--r--sql/item_func.cc71
-rw-r--r--sql/item_row.cc4
-rw-r--r--sql/item_strfunc.cc17
-rw-r--r--sql/item_subselect.cc33
-rw-r--r--sql/item_subselect.h8
-rw-r--r--sql/item_sum.cc29
-rw-r--r--sql/item_timefunc.cc4
-rw-r--r--sql/item_uniq.h2
-rw-r--r--sql/lock.cc6
-rw-r--r--sql/log.cc5
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/mysql_priv.h248
-rw-r--r--sql/mysqld.cc25
-rw-r--r--sql/parse_file.cc39
-rw-r--r--sql/protocol.cc18
-rw-r--r--sql/protocol.h3
-rw-r--r--sql/protocol_cursor.cc3
-rw-r--r--sql/repl_failsafe.cc59
-rw-r--r--sql/repl_failsafe.h6
-rw-r--r--sql/set_var.cc83
-rw-r--r--sql/share/czech/errmsg.txt19
-rw-r--r--sql/share/danish/errmsg.txt19
-rw-r--r--sql/share/dutch/errmsg.txt19
-rw-r--r--sql/share/english/errmsg.txt19
-rw-r--r--sql/share/estonian/errmsg.txt19
-rw-r--r--sql/share/french/errmsg.txt19
-rw-r--r--sql/share/german/errmsg.txt19
-rw-r--r--sql/share/greek/errmsg.txt19
-rw-r--r--sql/share/hungarian/errmsg.txt19
-rw-r--r--sql/share/italian/errmsg.txt19
-rw-r--r--sql/share/japanese/errmsg.txt19
-rw-r--r--sql/share/korean/errmsg.txt19
-rw-r--r--sql/share/norwegian-ny/errmsg.txt19
-rw-r--r--sql/share/norwegian/errmsg.txt19
-rw-r--r--sql/share/polish/errmsg.txt19
-rw-r--r--sql/share/portuguese/errmsg.txt19
-rw-r--r--sql/share/romanian/errmsg.txt19
-rw-r--r--sql/share/russian/errmsg.txt19
-rw-r--r--sql/share/serbian/errmsg.txt19
-rw-r--r--sql/share/slovak/errmsg.txt19
-rw-r--r--sql/share/spanish/errmsg.txt19
-rw-r--r--sql/share/swedish/errmsg.txt19
-rw-r--r--sql/share/ukrainian/errmsg.txt19
-rw-r--r--sql/slave.cc27
-rw-r--r--sql/slave.h4
-rw-r--r--sql/sp.cc3
-rw-r--r--sql/sp_head.cc24
-rw-r--r--sql/sp_rcontext.cc15
-rw-r--r--sql/sql_acl.cc157
-rw-r--r--sql/sql_acl.h16
-rw-r--r--sql/sql_analyse.cc15
-rw-r--r--sql/sql_base.cc96
-rw-r--r--sql/sql_class.cc21
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_db.cc50
-rw-r--r--sql/sql_delete.cc101
-rw-r--r--sql/sql_do.cc6
-rw-r--r--sql/sql_error.cc14
-rw-r--r--sql/sql_handler.cc35
-rw-r--r--sql/sql_help.cc68
-rw-r--r--sql/sql_insert.cc82
-rw-r--r--sql/sql_lex.cc2
-rw-r--r--sql/sql_lex.h10
-rw-r--r--sql/sql_load.cc35
-rw-r--r--sql/sql_map.cc10
-rw-r--r--sql/sql_parse.cc682
-rw-r--r--sql/sql_prepare.cc208
-rw-r--r--sql/sql_rename.cc9
-rw-r--r--sql/sql_repl.cc104
-rw-r--r--sql/sql_repl.h10
-rw-r--r--sql/sql_select.cc69
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/sql_show.cc205
-rw-r--r--sql/sql_table.cc321
-rw-r--r--sql/sql_trigger.cc40
-rw-r--r--sql/sql_udf.cc26
-rw-r--r--sql/sql_union.cc72
-rw-r--r--sql/sql_update.cc127
-rw-r--r--sql/sql_view.cc88
-rw-r--r--sql/sql_view.h6
-rw-r--r--sql/sql_yacc.yy291
-rw-r--r--sql/table.cc22
-rw-r--r--sql/unireg.cc4
103 files changed, 2529 insertions, 1885 deletions
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 1e190496fde..f98bb4cb75c 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 59 Temple Placeo Suite 330, Boston, MA 02111-1307 USA */
/* Definefile for error messagenumbers */
@@ -387,4 +387,23 @@
#define ER_VIEW_NONUPD_CHECK 1368
#define ER_VIEW_CHECK_FAILED 1369
#define ER_SP_ACCESS_DENIED_ERROR 1370
-#define ER_ERROR_MESSAGES 371
+#define ER_RELAY_LOG_FAIL 1371
+#define ER_PASSWD_LENGTH 1372
+#define ER_UNKNOWN_TARGET_BINLOG 1373
+#define ER_IO_ERR_LOG_INDEX_READ 1374
+#define ER_BINLOG_PURGE_PROHIBITED 1375
+#define ER_FSEEK_FAIL 1376
+#define ER_BINLOG_PURGE_FATAL_ERR 1377
+#define ER_LOG_IN_USE 1378
+#define ER_LOG_PURGE_UNKNOWN_ERR 1379
+#define ER_RELAY_LOG_INIT 1380
+#define ER_NO_BINARY_LOGGING 1381
+#define ER_RESERVED_SYNTAX 1382
+#define ER_WSAS_FAILED 1383
+#define ER_DIFF_GROUPS_PROC 1384
+#define ER_NO_GROUP_FOR_PROC 1385
+#define ER_ORDER_WITH_PROC 1386
+#define ER_LOGING_PROHIBIT_CHANGING_OF 1387
+#define ER_NO_FILE_MAPPING 1388
+#define ER_WRONG_MAGIC 1389
+#define ER_ERROR_MESSAGES 390
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 9fba0327525..15f07667625 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -664,7 +664,7 @@ bool Protocol::send_fields(List<Item> *list, uint 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/mysql-test/r/rpl_charset.result b/mysql-test/r/rpl_charset.result
index 2ffdb2c720a..9a002953b45 100644
--- a/mysql-test/r/rpl_charset.result
+++ b/mysql-test/r/rpl_charset.result
@@ -162,9 +162,9 @@ master-bin.000001 # Query 1 # use `mysqltest2`; drop database mysqltest2
master-bin.000001 # Query 1 # SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
master-bin.000001 # Query 1 # drop database mysqltest3
set global character_set_server=latin2;
-ERROR HY000: Binary logging and replication forbid changing the global server character set or collation
+ERROR HY000: Binary logging and replication forbid changing the global server character set, collation
set global character_set_server=latin2;
-ERROR HY000: Binary logging and replication forbid changing the global server character set or collation
+ERROR HY000: Binary logging and replication forbid changing the global server character set, collation
set one_shot @@character_set_server=latin5;
set @@max_join_size=1000;
select @@character_set_server;
@@ -181,7 +181,7 @@ select @@character_set_server;
@@character_set_server
latin5
set one_shot max_join_size=10;
-ERROR HY000: The SET ONE_SHOT syntax is reserved for purposes internal to the MySQL server
+ERROR HY000: The 'SET ONE_SHOT' syntax is reserved for purposes internal to the MySQL server
set character_set_client=9999999;
ERROR 42000: Unknown character set: '9999999'
set collation_server=9999998;
diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result
index 85071e13555..cfd296fd44b 100644
--- a/mysql-test/r/rpl_rotate_logs.result
+++ b/mysql-test/r/rpl_rotate_logs.result
@@ -1,7 +1,7 @@
drop table if exists t1, t2, t3, t4;
drop table if exists t1, t2, t3, t4;
start slave;
-ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
+ERROR HY000: File 'TESTDIR/var/slave-data/master.info' not found (Errcode: 13)
start slave;
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result
index 6dc8f87393c..495fccd35a3 100644
--- a/mysql-test/r/rpl_timezone.result
+++ b/mysql-test/r/rpl_timezone.result
@@ -73,5 +73,5 @@ t
2001-09-09 03:46:40
1000000000
set global time_zone='MET';
-ERROR HY000: Binary logging and replication forbid changing of the global server time zone
+ERROR HY000: Binary logging and replication forbid changing the global server time zone
drop table t1, t2;
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 23804e62ef5..25582796812 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -30,7 +30,7 @@ db1_secret
select * from db1_secret.t1;
ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
create procedure db1_secret.dummy() begin end;
-ERROR 42000: Unknown database 'db1_secret'
+ERROR 42000: Access denied for user 'user1'@'localhost' to database 'db1_secret'
drop procedure db1_secret.dummy;
ERROR 42000: PROCEDURE db1_secret.dummy does not exist
call db1_secret.stamp(3);
@@ -40,7 +40,7 @@ db1_secret
select * from db1_secret.t1;
ERROR 42000: Access denied for user ''@'localhost' to database 'db1_secret'
create procedure db1_secret.dummy() begin end;
-ERROR 42000: Unknown database 'db1_secret'
+ERROR 42000: Access denied for user ''@'localhost' to database 'db1_secret'
drop procedure db1_secret.dummy;
ERROR 42000: PROCEDURE db1_secret.dummy does not exist
select * from t1;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index bcabf693e4c..8745a274851 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -1746,10 +1746,20 @@ drop table if exists t3|
create procedure bug4904()
begin
declare continue handler for sqlstate 'HY000' begin end;
-create table t2 as select * from t;
+create table t2 as select * from t3;
end|
call bug4904()|
+ERROR 42S02: Table 'test.t3' doesn't exist
drop procedure bug4904|
+create table t3 (s1 char character set latin1, s2 char character set latin2)|
+create procedure bug4904 ()
+begin
+declare continue handler for sqlstate 'HY000' begin end;
+select s1 from t3 union select s2 from t3;
+end|
+call bug4904()|
+drop procedure bug4904|
+drop table t3|
create procedure bug336(out y int)
begin
declare x int;
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index 4598ca5ea15..8e1a92a586e 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -49,7 +49,7 @@ flush privileges;
#show tables;
connect (con1,localhost,test,gambling2,mysql);
set password="";
---error 1105
+--error 1372
set password='gambling3';
set password=old_password('gambling3');
show tables;
diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test
index 839fe5d377b..1bd72d059ab 100644
--- a/mysql-test/t/rpl_charset.test
+++ b/mysql-test/t/rpl_charset.test
@@ -112,10 +112,10 @@ sync_slave_with_master;
# Check that we can't change global.collation_server
-error 1105;
+error 1387;
set global character_set_server=latin2;
connection master;
-error 1105;
+error 1387;
set global character_set_server=latin2;
# Check that SET ONE_SHOT is really one shot
@@ -129,7 +129,7 @@ select @@character_set_server;
select @@character_set_server;
# ONE_SHOT on not charset/collation stuff is not allowed
-error 1105;
+error 1382;
set one_shot max_join_size=10;
# Test of wrong character set numbers;
diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test
index c3c0ff5be10..63ddf495347 100644
--- a/mysql-test/t/rpl_rotate_logs.test
+++ b/mysql-test/t/rpl_rotate_logs.test
@@ -23,7 +23,8 @@ drop table if exists t1, t2, t3, t4;
# START SLAVE will fail because it can't read the file (mode 000)
# (system error 13)
---error 1201
+--replace_result $MYSQL_TEST_DIR TESTDIR
+--error 1105
start slave;
system chmod 600 var/slave-data/master.info;
# It will fail again because the file is empty so the slave cannot get valuable
diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test
index 8dff90a84cf..ebb58a9c880 100644
--- a/mysql-test/t/rpl_timezone.test
+++ b/mysql-test/t/rpl_timezone.test
@@ -76,7 +76,7 @@ select * from t2;
# replication
#
connection master;
---error 1105
+--error 1387
set global time_zone='MET';
# Clean up
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index 2b53bbc528a..d1119499cf1 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -58,7 +58,7 @@ select db1_secret.db();
select * from db1_secret.t1;
# ...and not this
---error 1049
+--error 1044
create procedure db1_secret.dummy() begin end;
--error 1305
drop procedure db1_secret.dummy;
@@ -78,7 +78,7 @@ select db1_secret.db();
select * from db1_secret.t1;
# ...and not this
---error 1049
+--error 1044
create procedure db1_secret.dummy() begin end;
--error 1305
drop procedure db1_secret.dummy;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 88d1b8c0356..ec1fb3e7452 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1870,13 +1870,28 @@ create procedure bug4904()
begin
declare continue handler for sqlstate 'HY000' begin end;
- create table t2 as select * from t;
+ create table t2 as select * from t3;
end|
+-- error 1146
call bug4904()|
drop procedure bug4904|
+create table t3 (s1 char character set latin1, s2 char character set latin2)|
+
+create procedure bug4904 ()
+begin
+ declare continue handler for sqlstate 'HY000' begin end;
+
+ select s1 from t3 union select s2 from t3;
+end|
+
+call bug4904()|
+
+drop procedure bug4904|
+drop table t3|
+
#
# BUG#336
#
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 8a377f63c7e..75aa84efca0 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -22,6 +22,18 @@
/* Define some external variables for error handling */
+/*
+ WARNING!
+ my_error family functions have to be used according following rules:
+ - if message have not parameters use my_message(ER_CODE, ER(ER_CODE), MYF(N))
+ - if message have only integer parameters, string constants (created
+ inside program) or string put (and cut if it is need) in some limited
+ length buffer before passing it as parameter then you can use
+ my_error(ER_CODE, MYF(N), ...). Never pass string get from user to
+ my_error.
+ - in all other cases use my_printf_error(ER_CODE, ER(ER_CODE), MYF(N), ...)
+*/
+
const char ** NEAR my_errmsg[MAXMAPS]={0,0,0,0};
char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 1f80728095d..ec16cce32bb 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -284,7 +284,8 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
}
}
if (error)
- my_error(ER_FILSORT_ABORT,MYF(ME_ERROR+ME_WAITTANG));
+ my_message(ER_FILSORT_ABORT, ER(ER_FILSORT_ABORT),
+ MYF(ME_ERROR+ME_WAITTANG));
else
statistic_add(thd->status_var.filesort_rows,
(ulong) records, &LOCK_status);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 370458c6e01..34fc4873d43 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -495,8 +495,10 @@ innobase_mysql_tmpfile(void)
if (fd2 < 0) {
DBUG_PRINT("error",("Got error %d on dup",fd2));
my_errno=errno;
- my_error(EE_OUT_OF_FILERESOURCES,
- MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
+ my_printf_error(EE_OUT_OF_FILERESOURCES,
+ ER(EE_OUT_OF_FILERESOURCES),
+ MYF(ME_BELL+ME_WAITTANG),
+ filename, my_errno);
}
my_close(fd, MYF(MY_WME));
}
@@ -5028,7 +5030,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 */
@@ -5042,7 +5044,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);
@@ -5071,7 +5073,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);
@@ -5088,7 +5090,7 @@ innodb_show_status(
my_free(str, MYF(0));
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
protocol->prepare_for_resend();
@@ -5096,10 +5098,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 7e337afed0e..d7eecea11fc 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -233,7 +233,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/handler.cc b/sql/handler.cc
index b61d28e035a..8b6458d3662 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -517,7 +517,8 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
if ((error=ndbcluster_commit(thd,trans->ndb_tid)))
{
if (error == -1)
- my_error(ER_ERROR_DURING_COMMIT, MYF(0));
+ my_message_(ER_ERROR_DURING_COMMIT, ER(ER_ERROR_DURING_COMMIT),
+ MYF(0));
error=1;
}
if (trans == &thd->transaction.all)
@@ -592,7 +593,8 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
if ((error=ndbcluster_rollback(thd, trans->ndb_tid)))
{
if (error == -1)
- my_error(ER_ERROR_DURING_ROLLBACK, MYF(0));
+ my_message(ER_ERROR_DURING_ROLLBACK, ER(ER_ERROR_DURING_ROLLBACK),
+ MYF(0));
error=1;
}
trans->ndb_tid = 0;
@@ -1198,7 +1200,8 @@ void handler::print_error(int error, myf errflag)
str.length(max_length-4);
str.append("...");
}
- my_error(ER_DUP_ENTRY,MYF(0),str.c_ptr(),key_nr+1);
+ my_printf_error(ER_DUP_ENTRY, ER(ER_DUP_ENTRY), MYF(0),
+ str.c_ptr(), key_nr+1);
DBUG_VOID_RETURN;
}
textno=ER_DUP_KEY;
@@ -1220,7 +1223,7 @@ void handler::print_error(int error, myf errflag)
textno=ER_CRASHED_ON_REPAIR;
break;
case HA_ERR_OUT_OF_MEM:
- my_error(ER_OUT_OF_RESOURCES,errflag);
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), errflag);
DBUG_VOID_RETURN;
case HA_ERR_WRONG_COMMAND:
textno=ER_ILLEGAL_HA;
@@ -1281,9 +1284,13 @@ void handler::print_error(int error, myf errflag)
{
const char* engine= table_type();
if (temporary)
- my_error(ER_GET_TEMPORARY_ERRMSG,MYF(0),error,str.ptr(),engine);
+ my_printf_error(ER_GET_TEMPORARY_ERRMSG,
+ ER(ER_GET_TEMPORARY_ERRMSG), MYF(0),
+ error, str.ptr(), engine);
else
- my_error(ER_GET_ERRMSG,MYF(0),error,str.ptr(),engine);
+ my_printf_error(ER_GET_ERRMSG,
+ ER(ER_GET_ERRMSG), MYF(0),
+ error, str.ptr(), engine);
}
else
my_error(ER_GET_ERRNO,errflag,error);
@@ -1412,7 +1419,9 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
error=table.file->create(name,&table,create_info);
VOID(closefrm(&table));
if (error)
- my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,error);
+ my_printf_error(ER_CANT_CREATE_TABLE, ER(ER_CANT_CREATE_TABLE),
+ MYF(ME_BELL+ME_WAITTANG),
+ name,error);
DBUG_RETURN(error != 0);
}
diff --git a/sql/item.cc b/sql/item.cc
index 05e5eb9076f..f37224c6bf5 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1466,7 +1466,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_real()
@@ -2907,10 +2907,11 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference)
current_sel->having_fix_field))) ||
!(*ref)->fixed)
{
- my_error(ER_ILLEGAL_REFERENCE, MYF(0), name,
- ((*ref)->with_sum_func?
- "reference to group function":
- "forward reference in item list"));
+ my_printf_error(ER_ILLEGAL_REFERENCE, ER(ER_ILLEGAL_REFERENCE), MYF(0),
+ name,
+ ((*ref)->with_sum_func?
+ "reference to group function":
+ "forward reference in item list"));
return TRUE;
}
max_length= (*ref)->max_length;
@@ -2931,6 +2932,8 @@ void Item_ref::cleanup()
DBUG_ENTER("Item_ref::cleanup");
Item_ident::cleanup();
result_field= 0;
+ if (hook_ptr)
+ *hook_ptr= orig_item;
DBUG_VOID_RETURN;
}
@@ -3026,17 +3029,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];
}
@@ -3045,15 +3048,15 @@ 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);
- return 0;
+ return FALSE;
}
void Item_default_value::print(String *str)
@@ -3081,14 +3084,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];
}
@@ -3097,7 +3100,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]);
@@ -3110,7 +3113,7 @@ bool Item_insert_value::fix_fields(THD *thd,
set_field(new Field_null(0, 0, Field::NONE, tmp_field->field_name,
tmp_field->table, &my_charset_bin));
}
- return 0;
+ return FALSE;
}
void Item_insert_value::print(String *str)
@@ -3600,11 +3603,12 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
old_derivation= collation.derivation_name();
if (item_type == STRING_RESULT && collation.aggregate(item->collation))
{
- my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0),
- old_cs, old_derivation,
- item->collation.collation->name,
- item->collation.derivation_name(),
- "UNION");
+ my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
+ ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
+ old_cs, old_derivation,
+ item->collation.collation->name,
+ item->collation.derivation_name(),
+ "UNION");
return 1;
}
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 105c5c4402e..63d20b2dab3 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -53,10 +53,11 @@ static void agg_cmp_type(Item_result *type, Item **items, uint nitems)
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname)
{
- my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
- c1.collation->name,c1.derivation_name(),
- c2.collation->name,c2.derivation_name(),
- fname);
+ my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
+ ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
+ c1.collation->name,c1.derivation_name(),
+ c2.collation->name,c2.derivation_name(),
+ fname);
}
@@ -600,17 +601,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;
@@ -619,7 +620,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;
}
@@ -1956,7 +1957,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;
@@ -1974,7 +1975,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;
@@ -1987,7 +1988,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)
@@ -2339,12 +2340,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())
@@ -2362,7 +2363,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();
@@ -2395,7 +2396,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref)
}
}
}
- return 0;
+ return FALSE;
}
#ifdef USE_REGEX
@@ -2406,13 +2407,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_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV))
- return 1;
+ return TRUE;
used_tables_cache=args[0]->used_tables() | args[1]->used_tables();
not_null_tables_cache= (args[0]->not_null_tables() |
@@ -2426,7 +2427,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(),
@@ -2437,7 +2438,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;
@@ -2445,7 +2446,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 d5b11ce78a5..65e1cceb5bb 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -45,10 +45,11 @@ bool check_reserved_words(LEX_STRING *name)
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
const char *fname)
{
- my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
- c1.collation->name,c1.derivation_name(),
- c2.collation->name,c2.derivation_name(),
- fname);
+ my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
+ ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
+ c1.collation->name, c1.derivation_name(),
+ c2.collation->name, c2.derivation_name(),
+ fname);
}
static void my_coll_agg_error(DTCollation &c1,
@@ -56,11 +57,12 @@ static void my_coll_agg_error(DTCollation &c1,
DTCollation &c3,
const char *fname)
{
- my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
- c1.collation->name,c1.derivation_name(),
- c2.collation->name,c2.derivation_name(),
- c3.collation->name,c3.derivation_name(),
- fname);
+ my_printf_error(ER_CANT_AGGREGATE_3COLLATIONS,
+ ER(ER_CANT_AGGREGATE_3COLLATIONS), MYF(0),
+ c1.collation->name, c1.derivation_name(),
+ c2.collation->name, c2.derivation_name(),
+ c3.collation->name, c3.derivation_name(),
+ fname);
}
@@ -74,7 +76,8 @@ static void my_coll_agg_error(Item** args, uint count, const char *fname)
args[2]->collation,
fname);
else
- my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname);
+ my_printf_error(ER_CANT_AGGREGATE_NCOLLATIONS,
+ ER(ER_CANT_AGGREGATE_NCOLLATIONS), MYF(0),fname);
}
@@ -281,8 +284,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
@@ -298,7 +301,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++)
@@ -310,7 +313,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;
@@ -322,10 +325,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)
@@ -1708,7 +1711,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);
@@ -1716,7 +1719,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;
@@ -1733,7 +1736,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;
@@ -1746,7 +1749,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
@@ -1779,7 +1782,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();
@@ -1838,7 +1841,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;
@@ -1850,9 +1853,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);
}
@@ -2463,7 +2466,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
@@ -2489,7 +2492,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables,
entry->collation.set(args[0]->collation);
collation.set(entry->collation);
cached_result_type= args[0]->result_type();
- return 0;
+ return FALSE;
}
@@ -2647,7 +2650,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
@@ -2677,7 +2680,7 @@ Item_func_set_user_var::check()
DBUG_ASSERT(0);
break;
}
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -3140,7 +3143,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;
@@ -3163,7 +3166,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;
@@ -3245,7 +3248,8 @@ err:
key=NO_SUCH_KEY;
return 0;
}
- my_error(ER_FT_MATCHING_KEY_NOT_FOUND,MYF(0));
+ my_message(ER_FT_MATCHING_KEY_NOT_FOUND,
+ ER(ER_FT_MATCHING_KEY_NOT_FOUND), MYF(0));
return 1;
}
@@ -3374,7 +3378,8 @@ 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_printf_error(ER_VARIABLE_IS_NOT_STRUCT, ER(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 8a020861fef..0c7eae9d920 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(THD *thd, Item **ref_pointer_array,
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 2fcb64ce9d6..b3ba0b4a4f3 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -42,10 +42,11 @@ String my_empty_string("",default_charset_info);
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
const char *fname)
{
- my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0),
- c1.collation->name,c1.derivation_name(),
- c2.collation->name,c2.derivation_name(),
- fname);
+ my_printf_error(ER_CANT_AGGREGATE_2COLLATIONS,
+ ER(ER_CANT_AGGREGATE_2COLLATIONS), MYF(0),
+ c1.collation->name, c1.derivation_name(),
+ c2.collation->name, c2.derivation_name(),
+ fname);
}
uint nr_of_decimals(const char *str)
@@ -2218,7 +2219,8 @@ void Item_func_set_collation::fix_length_and_dec()
{
if (!(set_collation= get_charset_by_name(colname,MYF(0))))
{
- my_error(ER_UNKNOWN_COLLATION, MYF(0), colname);
+ my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0),
+ colname);
return;
}
}
@@ -2226,8 +2228,9 @@ void Item_func_set_collation::fix_length_and_dec()
if (!set_collation ||
!my_charset_same(args[0]->collation.collation,set_collation))
{
- my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
- colname,args[0]->collation.collation->csname);
+ my_printf_error(ER_COLLATION_CHARSET_MISMATCH,
+ ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0),
+ colname, args[0]->collation.collation->csname);
return;
}
collation.set(set_collation, DERIVATION_EXPLICIT);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 7190fe3d625..f8c5c0aac90 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();
@@ -171,7 +171,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();
}
@@ -1504,12 +1504,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;
@@ -1526,12 +1526,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);
@@ -1549,14 +1549,15 @@ 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 2e25677d617..d0ff3654e48 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;
virtual bool no_tables()= 0;
};
@@ -315,7 +315,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);
bool no_tables();
};
@@ -336,7 +336,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);
bool no_tables();
};
@@ -366,7 +366,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);
bool no_tables();
};
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4a5278a87d4..cd98a3cc309 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -173,8 +173,9 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (!thd->allow_sum_func)
{
- my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0));
- return 1;
+ my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
+ MYF(0));
+ return TRUE;
}
thd->allow_sum_func=0; // No included group funcs
decimals=0;
@@ -182,7 +183,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;
@@ -193,7 +194,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;
}
@@ -205,8 +206,9 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
Item *item= args[0];
if (!thd->allow_sum_func)
{
- my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0));
- return 1;
+ my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
+ MYF(0));
+ return TRUE;
}
thd->allow_sum_func=0; // No included group funcs
@@ -214,7 +216,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)
@@ -245,7 +247,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;
}
@@ -2004,8 +2006,9 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (!thd->allow_sum_func)
{
- my_error(ER_INVALID_GROUP_FUNC_USE,MYF(0));
- return 1;
+ my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
+ MYF(0));
+ return TRUE;
}
thd->allow_sum_func= 0;
@@ -2019,7 +2022,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;
}
@@ -2029,12 +2032,12 @@ 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;
/* We'll convert all blobs to varchar fields in the temporary table */
tmp_table_param->convert_blob_length= group_concat_max_len;
tables_list= tables;
fixed= 1;
- return 0;
+ return FALSE;
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 394507af4f0..d1b490008df 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1669,7 +1669,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;
@@ -1679,7 +1679,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 d21e2e2a619..e74c09ca3c4 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/lock.cc b/sql/lock.cc
index 6d5ca5bf6b4..76b85946a4a 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -430,7 +430,8 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
*write_lock_used=table;
if (table->db_stat & HA_READ_ONLY)
{
- my_error(ER_OPEN_AS_READONLY,MYF(0),table->table_name);
+ my_printf_error(ER_OPEN_AS_READONLY, ER(ER_OPEN_AS_READONLY), MYF(0),
+ table->table_name);
my_free((gptr) sql_lock,MYF(0));
return 0;
}
@@ -795,7 +796,8 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
if (thd->global_read_lock) // This thread had the read locks
{
if (is_not_commit)
- my_error(ER_CANT_UPDATE_WITH_READLOCK,MYF(0));
+ my_message(ER_CANT_UPDATE_WITH_READLOCK,
+ ER(ER_CANT_UPDATE_WITH_READLOCK), MYF(0));
(void) pthread_mutex_unlock(&LOCK_open);
/*
We allow FLUSHer to COMMIT; we assume FLUSHer knows what it does.
diff --git a/sql/log.cc b/sql/log.cc
index 86b76ed883e..7f273247c6f 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1515,9 +1515,10 @@ err:
if (error)
{
if (my_errno == EFBIG)
- my_error(ER_TRANS_CACHE_FULL, MYF(0));
+ my_message(ER_TRANS_CACHE_FULL, ER(ER_TRANS_CACHE_FULL), MYF(0));
else
- my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
+ my_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0),
+ name, errno);
write_error=1;
}
if (file == &log_file)
diff --git a/sql/log_event.cc b/sql/log_event.cc
index e8dc6a8827b..ccc563d31ac 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -2598,7 +2598,7 @@ Slave: load data infile on table '%s' at log position %s in log \
my_afree(load_data_query);
if (thd->query_error)
{
- /* this err/sql_errno code is copy-paste from send_error() */
+ /* this err/sql_errno code is copy-paste from net_send_error() */
const char *err;
int sql_errno;
if ((err=thd->net.last_error)[0])
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 7d1ffe97e08..75f04ea7126 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -411,17 +411,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);
-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 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"
@@ -471,12 +471,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,
@@ -504,7 +504,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);
@@ -523,22 +523,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);
@@ -551,20 +551,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, int (*processor)(THD *thd,
LEX *lex,
TABLE_LIST *table));
@@ -578,61 +578,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);
-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_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);
+bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
+ Item **conds, uint order_num, ORDER *order);
+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);
@@ -689,46 +689,46 @@ 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);
int get_quote_char_for_identifier(THD *thd, 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);
@@ -743,13 +743,13 @@ 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, bool reopen= 0);
-int mysql_ha_close(THD *thd, TABLE_LIST *tables);
-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_open(THD *thd, TABLE_LIST *tables, bool reopen= 0);
+bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
+bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
+ List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags);
/* mysql_ha_flush mode_flags bits */
#define MYSQL_HA_CLOSE_FINAL 0x00
@@ -789,16 +789,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);
@@ -823,8 +823,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table,
bool return_if_owned_by_thd=0);
bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables);
void copy_field_from_tmp_record(Field *field,int offset);
-int fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors);
-int fill_record(Field **field,List<Item> &values, bool ignore_errors);
+bool fill_record(THD *thd, List<Item> &fields, List<Item> &values,
+ bool ignore_errors);
+bool fill_record(THD *thd, Field **field, List<Item> &values,
+ bool ignore_errors);
OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild);
inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
@@ -848,10 +850,10 @@ 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 ignore_check_option_errors);
+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,
+ bool ignore_check_option_errors);
int write_record(THD *thd, TABLE *table, COPY_INFO *info);
/* sql_manager.cc */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 675f57c4ea5..9a1044eed2e 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1172,7 +1172,8 @@ static void server_init(void)
WSADATA WsaData;
if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData))
{
- my_message(0,"WSAStartup Failed\n",MYF(0));
+ /* errors are not read yet, so we use test here */
+ my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0));
unireg_abort(1);
}
}
@@ -1334,8 +1335,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);
}
@@ -1366,7 +1368,7 @@ void close_connection(THD *thd, uint errcode, bool lock)
if ((vio=thd->net.vio) != 0)
{
if (errcode)
- send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
+ net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
vio_close(vio); /* vio is freed in delete thd */
}
if (lock)
@@ -2130,6 +2132,11 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags)
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 &&
@@ -2137,6 +2144,9 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags)
{
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))
@@ -2155,6 +2165,9 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags)
{
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);
@@ -3430,10 +3443,10 @@ 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);
+ net_printf_error(thd, ER_CANT_CREATE_THREAD, error);
(void) pthread_mutex_lock(&LOCK_thread_count);
close_connection(thd,0,0);
delete thd;
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index c3043ed2c73..91b29ce9b61 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -350,7 +350,8 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
if (stat_info.st_size > INT_MAX-1)
{
- my_error(ER_FPARSER_TOO_BIG_FILE, MYF(0), file_name->str);
+ my_printf_error(ER_FPARSER_TOO_BIG_FILE,
+ ER(ER_FPARSER_TOO_BIG_FILE), MYF(0), file_name->str);
DBUG_RETURN(0);
}
@@ -412,7 +413,8 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root,
frm_error:
if (bad_format_errors)
{
- my_error(ER_FPARSER_BAD_HEADER, MYF(0), file_name->str);
+ my_printf_error(ER_FPARSER_BAD_HEADER, ER(ER_FPARSER_BAD_HEADER), MYF(0),
+ file_name->str);
DBUG_RETURN(0);
}
else
@@ -625,7 +627,8 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
// it is comment
if (!(ptr= strchr(ptr, '\n')))
{
- my_error(ER_FPARSER_EOF_IN_COMMENT, MYF(0), line);
+ my_printf_error(ER_FPARSER_EOF_IN_COMMENT,
+ ER(ER_FPARSER_EOF_IN_COMMENT), MYF(0), line);
DBUG_RETURN(TRUE);
}
ptr++;
@@ -667,8 +670,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
(LEX_STRING *)(base +
parameter->offset))))
{
- my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
- parameter->name.str, line);
+ my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER,
+ ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0),
+ parameter->name.str, line);
DBUG_RETURN(TRUE);
}
break;
@@ -679,8 +683,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
(LEX_STRING *)
(base + parameter->offset))))
{
- my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
- parameter->name.str, line);
+ my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER,
+ ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0),
+ parameter->name.str, line);
DBUG_RETURN(TRUE);
}
break;
@@ -689,8 +694,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
case FILE_OPTIONS_REV:
if (!(eol= strchr(ptr, '\n')))
{
- my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
- parameter->name.str, line);
+ my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER,
+ ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0),
+ parameter->name.str, line);
DBUG_RETURN(TRUE);
}
{
@@ -707,8 +713,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
/* yyyy-mm-dd HH:MM:SS = 19(PARSE_FILE_TIMESTAMPLENGTH) characters */
if (ptr[PARSE_FILE_TIMESTAMPLENGTH] != '\n')
{
- my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
- parameter->name.str, line);
+ my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER,
+ ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0),
+ parameter->name.str, line);
DBUG_RETURN(TRUE);
}
memcpy(val->str, ptr, PARSE_FILE_TIMESTAMPLENGTH);
@@ -747,8 +754,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
break;
list_err_w_message:
- my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
- parameter->name.str, line);
+ my_printf_error(ER_FPARSER_ERROR_IN_PARAMETER,
+ ER(ER_FPARSER_ERROR_IN_PARAMETER), MYF(0),
+ parameter->name.str, line);
list_err:
DBUG_RETURN(TRUE);
}
@@ -761,8 +769,9 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
// skip unknown parameter
if (!(ptr= strchr(ptr, '\n')))
{
- my_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER, MYF(0),
- line);
+ my_printf_error(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER,
+ ER(ER_FPARSER_EOF_IN_UNKNOWN_PARAMETER), MYF(0),
+ line);
DBUG_RETURN(TRUE);
}
ptr++;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 2b0ae60f944..e0d256fbe87 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -53,14 +53,14 @@ bool Protocol_prep::net_store_data(const char *from, uint length)
/* Send a error string to client */
-void send_error(THD *thd, uint sql_errno, const char *err)
+void net_send_error(THD *thd, uint sql_errno, const char *err)
{
#ifndef EMBEDDED_LIBRARY
uint length;
char buff[MYSQL_ERRMSG_SIZE+2], *pos;
#endif
NET *net= &thd->net;
- DBUG_ENTER("send_error");
+ DBUG_ENTER("net_send_error");
DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno,
err ? err : net->last_error[0] ?
net->last_error : "NULL"));
@@ -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)
{
@@ -172,7 +169,7 @@ void send_warning(THD *thd, uint sql_errno, const char *err)
*/
void
-net_printf(THD *thd, uint errcode, ...)
+net_printf_error(THD *thd, uint errcode, ...)
{
va_list args;
uint length,offset;
@@ -185,7 +182,7 @@ net_printf(THD *thd, uint errcode, ...)
#endif
NET *net= &thd->net;
- DBUG_ENTER("net_printf");
+ DBUG_ENTER("net_printf_error");
DBUG_PRINT("enter",("message: %u",errcode));
if (thd->spcont && thd->spcont->find_handler(errcode,
@@ -199,8 +196,8 @@ net_printf(THD *thd, uint errcode, ...)
#endif
va_start(args,errcode);
/*
- The following is needed to make net_printf() work with 0 argument for
- errorcode and use the argument after that as the format string. This
+ The following is needed to make net_printf_error() work with 0 argument
+ for errorcode and use the argument after that as the format string. This
is useful for rare errors that are not worth the hassle to put in
errmsg.sys, but at the same time, the message is not fixed text
*/
@@ -627,7 +624,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
DBUG_RETURN(prepare_for_send(list));
err:
- send_error(thd,ER_OUT_OF_RESOURCES); /* purecov: inspected */
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES),
+ MYF(0)); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
diff --git a/sql/protocol.h b/sql/protocol.h
index d342af3ee9f..fddd3ceba94 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -173,7 +173,8 @@ public:
};
void send_warning(THD *thd, uint sql_errno, const char *err=0);
-void net_printf(THD *thd,uint sql_errno, ...);
+void net_printf_error(THD *thd, uint sql_errno, ...);
+void net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L,
const char *info=0);
void send_eof(THD *thd, bool no_flush=0);
diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc
index 104457b3bcc..a5bf94469e7 100644
--- a/sql/protocol_cursor.cc
+++ b/sql/protocol_cursor.cc
@@ -84,7 +84,8 @@ bool Protocol_cursor::send_fields(List<Item> *list, uint flags)
DBUG_RETURN(FALSE);
err:
- send_error(thd, ER_OUT_OF_RESOURCES); /* purecov: inspected */
+ my_message(ER_OUT_OF_RESOURCES, ER(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 253b2c96545..d49afb5f59d 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -194,7 +194,6 @@ err:
my_message(ER_UNKNOWN_ERROR, "Wrong parameters to function register_slave",
MYF(0));
err2:
- send_error(thd);
return 1;
}
@@ -438,7 +437,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");
@@ -450,9 +449,10 @@ int show_new_master(THD* thd)
if (translate_master(thd, lex_mi, errmsg))
{
if (errmsg[0])
- my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),
- "SHOW NEW MASTER", errmsg);
- DBUG_RETURN(-1);
+ my_printf_error(ER_ERROR_WHEN_EXECUTING_COMMAND,
+ ER(ER_ERROR_WHEN_EXECUTING_COMMAND), MYF(0),
+ "SHOW NEW MASTER", errmsg);
+ DBUG_RETURN(TRUE);
}
else
{
@@ -461,14 +461,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);
}
}
@@ -631,7 +631,7 @@ err:
}
-int show_slave_hosts(THD* thd)
+bool show_slave_hosts(THD* thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
@@ -653,7 +653,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);
@@ -674,12 +674,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);
}
@@ -760,7 +760,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;
@@ -782,16 +782,16 @@ int load_master_data(THD* thd)
(error=terminate_slave_threads(active_mi,restart_thread_mask,
1 /*skip lock*/)))
{
- send_error(thd,error);
+ my_message(error, ER(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_printf_error(error= ER_CONNECT_TO_MASTER,
+ ER(ER_CONNECT_TO_MASTER), MYF(0), mysql_error(&mysql));
goto err;
}
@@ -803,8 +803,8 @@ 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_printf_error(error = ER_QUERY_ON_MASTER,
+ ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql));
goto err;
}
@@ -817,7 +817,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_message(error = ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0));
goto err;
}
@@ -831,8 +831,8 @@ 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_printf_error(error = ER_QUERY_ON_MASTER,
+ ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql));
goto err;
}
@@ -877,7 +877,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;
}
@@ -886,8 +885,8 @@ 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_printf_error(error = ER_QUERY_ON_MASTER,
+ ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql));
cleanup_mysql_results(db_res, cur_table_res - 1, table_res);
goto err;
}
@@ -925,7 +924,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_message(ER_MASTER_INFO, ER(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);
@@ -944,8 +943,8 @@ 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_printf_error(error = ER_QUERY_ON_MASTER,
+ ER(ER_QUERY_ON_MASTER), MYF(0), mysql_error(&mysql));
goto err;
}
}
@@ -954,10 +953,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_printf_error(ER_RELAY_LOG_FAIL, ER(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 ad0219bb735..dfaacf557e8 100644
--- a/sql/repl_failsafe.h
+++ b/sql/repl_failsafe.h
@@ -38,11 +38,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 ccac3082d5b..a183f815a59 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -899,8 +899,8 @@ bool sys_var_str::check(THD *thd, set_var *var)
return 0;
if ((res=(*check_func)(thd, var)) < 0)
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name,
- var->value->str_value.ptr());
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), MYF(0),
+ name, var->value->str_value.ptr());
return res;
}
@@ -1174,7 +1174,8 @@ static int check_max_delayed_threads(THD *thd, set_var *var)
val != (longlong) global_system_variables.max_insert_delayed_threads)
{
char buf[64];
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name, llstr(val, buf));
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR),
+ MYF(0), var->var->name, llstr(val, buf));
return 1;
}
return 0;
@@ -1472,7 +1473,8 @@ bool sys_var::check_enum(THD *thd, set_var *var, TYPELIB *enum_names)
return 0;
err:
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, value);
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), MYF(0),
+ name, value);
return 1;
}
@@ -1513,7 +1515,8 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
return 0;
err:
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, buff);
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR),
+ MYF(0), name, buff);
return 1;
}
@@ -1537,8 +1540,9 @@ 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_printf_error(ER_INCORRECT_GLOBAL_LOCAL_VAR,
+ ER(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 */
@@ -1581,7 +1585,8 @@ 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_printf_error(ER_VAR_CANT_BE_READ, ER(ER_VAR_CANT_BE_READ), MYF(0),
+ name);
}
return 0;
}
@@ -1693,7 +1698,8 @@ bool sys_var_thd_date_time_format::check(THD *thd, set_var *var)
if (!(format= date_time_format_make(date_time_type,
res->ptr(), res->length())))
{
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr());
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR), MYF(0),
+ name, res->c_ptr());
return 1;
}
@@ -1791,12 +1797,14 @@ bool sys_var_collation::check(THD *thd, set_var *var)
String str(buff,sizeof(buff), system_charset_info), *res;
if (!(res=var->value->val_str(&str)))
{
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR, ER(ER_WRONG_VALUE_FOR_VAR),
+ MYF(0), name, "NULL");
return 1;
}
if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0))))
{
- my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr());
+ my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0),
+ res->c_ptr());
return 1;
}
}
@@ -1806,7 +1814,8 @@ bool sys_var_collation::check(THD *thd, set_var *var)
{
char buf[20];
int10_to_str((int) var->value->val_int(), buf, -10);
- my_error(ER_UNKNOWN_COLLATION, MYF(0), buf);
+ my_printf_error(ER_UNKNOWN_COLLATION, ER(ER_UNKNOWN_COLLATION), MYF(0),
+ buf);
return 1;
}
}
@@ -1827,7 +1836,8 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
{
if (!nullable)
{
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL");
+ my_printf_error(ER_WRONG_VALUE_FOR_VAR,
+ ER(ER_WRONG_VALUE_FOR_VAR), MYF(0), name, "NULL");
return 1;
}
tmp= NULL;
@@ -1835,7 +1845,8 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
!(tmp=get_old_charset_by_name(res->c_ptr())))
{
- my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
+ my_printf_error(ER_UNKNOWN_CHARACTER_SET, ER(ER_UNKNOWN_CHARACTER_SET),
+ MYF(0), res->c_ptr());
return 1;
}
}
@@ -1967,8 +1978,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);
@@ -2074,8 +2085,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);
@@ -2353,7 +2364,7 @@ bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
pthread_mutex_lock(&active_mi->rli.run_lock);
if (active_mi->rli.slave_running)
{
- my_error(ER_SLAVE_MUST_STOP, MYF(0));
+ my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0));
result=1;
}
pthread_mutex_unlock(&active_mi->rli.run_lock);
@@ -2424,8 +2435,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
@@ -2433,7 +2443,8 @@ bool sys_var_thd_time_zone::check(THD *thd, set_var *var)
if (!(var->save_result.time_zone=
my_tz_find(res, thd->lex->time_zone_tables_used)))
{
- my_error(ER_UNKNOWN_TIME_ZONE, MYF(0), res ? res->c_ptr() : "NULL");
+ my_printf_error(ER_UNKNOWN_TIME_ZONE, ER(ER_UNKNOWN_TIME_ZONE), MYF(0),
+ res ? res->c_ptr() : "NULL");
return 1;
}
return 0;
@@ -2703,9 +2714,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)
@@ -2718,7 +2726,8 @@ 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_printf_error(ER_UNKNOWN_SYSTEM_VARIABLE, ER(ER_UNKNOWN_SYSTEM_VARIABLE),
+ MYF(0), (char*) str);
return var;
}
@@ -2804,9 +2813,8 @@ int set_var::check(THD *thd)
{
if (var->check_type(type))
{
- my_error(type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE,
- MYF(0),
- var->name);
+ int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
+ my_printf_error(err, ER(err), MYF(0), var->name);
return -1;
}
if ((type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL)))
@@ -2816,7 +2824,7 @@ int set_var::check(THD *thd)
{
if (var->check_default(type))
{
- my_error(ER_NO_DEFAULT, MYF(0), var->name);
+ my_printf_error(ER_NO_DEFAULT, ER(ER_NO_DEFAULT), MYF(0), var->name);
return -1;
}
return 0;
@@ -2826,7 +2834,8 @@ int set_var::check(THD *thd)
return -1;
if (var->check_update_type(value->result_type()))
{
- my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name);
+ my_printf_error(ER_WRONG_TYPE_FOR_VAR, ER(ER_WRONG_TYPE_FOR_VAR), MYF(0),
+ var->name);
return -1;
}
return var->check(thd, this) ? -1 : 0;
@@ -2849,9 +2858,8 @@ int set_var::light_check(THD *thd)
{
if (var->check_type(type))
{
- my_error(type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE,
- MYF(0),
- var->name);
+ int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
+ my_printf_error(err, ER(err), MYF(0), var->name);
return -1;
}
if (type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL))
@@ -2917,7 +2925,7 @@ int set_var_user::update(THD *thd)
if (user_var_item->update())
{
/* Give an error if it's not given already */
- my_error(ER_SET_CONSTANTS_ONLY, MYF(0));
+ my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0));
return -1;
}
return 0;
@@ -2978,8 +2986,9 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var)
value= "unknown";
err:
- my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), value);
- return 1;
+ my_printf_error(ER_UNKNOWN_STORAGE_ENGINE, ER(ER_UNKNOWN_STORAGE_ENGINE),
+ MYF(0), value);
+ return 1;
}
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index e3c08eeca89..68816534d3a 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -399,3 +399,22 @@ character-set=latin2
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 78610219ade..f475c9cd371 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -390,3 +390,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 051a2a13ab8..471997e8a22 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -399,3 +399,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 bb2a9cb59ba..293227e64b9 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -387,3 +387,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 14764d764aa..59e55207946 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -392,3 +392,22 @@ character-set=latin7
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 7c3e833c903..be6c440b509 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -387,3 +387,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 7cda8bef089..3afdd3ab496 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -400,3 +400,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 7b9bf7e967e..b0b158f5851 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -387,3 +387,22 @@ character-set=greek
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 d4e5c5c744f..ba5f662a196 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -392,3 +392,22 @@ character-set=latin2
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 c697edb4cd7..d7ce95f8ed3 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -387,3 +387,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 e1a32f1894b..56df55f3db4 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -391,3 +391,22 @@ character-set=ujis
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 adb08b67474..1672dcb7dc6 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -387,3 +387,22 @@ character-set=euckr
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 057accd3c5b..187bab28cf1 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -389,3 +389,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 5506d95592a..ba1d11aa158 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -389,3 +389,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 38cefd45338..9d9940ca69d 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -392,3 +392,22 @@ character-set=latin2
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 7689db06451..214b4753f1c 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -389,3 +389,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 ad486367ec9..2019bcc98f5 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -392,3 +392,22 @@ character-set=latin2
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 d057ab53256..3354d6a7ee5 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -392,3 +392,22 @@ character-set=koi8r
"CHECK OPTION ÄÌÑ ÎÅÏÂÎÏ×ÌÑÅÍÏÇÏ VIEW '%-.64s.%-.64s'"
"ÐÒÏ×ÅÒËÁ CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÐÒÏ×ÁÌÉÌÁÓØ"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 6e38b1c3d11..385f6f2044c 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -380,3 +380,22 @@ character-set=cp1250
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 a9667b8ba62..8ee06be1128 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -395,3 +395,22 @@ character-set=latin2
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 17600f336c0..2215da6d57e 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -391,3 +391,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 8b061ac0eec..92ef9e1659b 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -387,3 +387,22 @@ character-set=latin1
"CHECK OPTION on non-updatable view '%-.64s.%-.64s'"
"CHECK OPTION failed '%-.64s.%-.64s'"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 317b2d596fa..c1f86886870 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -393,3 +393,22 @@ character-set=koi8u
"CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÝÏ ÎÅ ÍÏÖÅ ÂÕÔÉ ÏÎÏ×ÌÅÎÎÉÍ"
"ÐÅÒÅצÒËÁ CHECK OPTION ÄÌÑ VIEW '%-.64s.%-.64s' ÎÅ ÐÒÏÊÛÌÁ"
"Access denied; you are not the procedure/function definer of '%s'"
+"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 b25bdb7e926..d14e9784834 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1493,7 +1493,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_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
DBUG_RETURN(1);
}
if (net->read_pos[0] == 255) // error from master
@@ -1502,7 +1502,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_printf_error(ER_MASTER, ER(ER_MASTER), MYF(0), err_msg);
DBUG_RETURN(1);
}
thd->command = COM_TABLE_DUMP;
@@ -1511,7 +1511,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_message(ER_GET_ERRNO, "Out of memory", MYF(0));
DBUG_RETURN(1);
}
thd->query= query;
@@ -1525,7 +1525,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;
}
@@ -1552,7 +1551,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;
}
@@ -1562,7 +1560,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_message(ER_MASTER_NET_READ, ER(ER_MASTER_NET_READ), MYF(0));
sql_print_error("create_table_from_dump: failed in\
handler::net_read_dump()");
goto err;
@@ -1582,7 +1580,8 @@ 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_printf_error(ER_INDEX_REBUILD, ER(ER_INDEX_REBUILD), MYF(0),
+ tables.table->real_name);
err:
close_thread_tables(thd);
@@ -1605,12 +1604,12 @@ 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_printf_error(ER_CONNECT_TO_MASTER, ER(ER_CONNECT_TO_MASTER), MYF(0),
+ mysql_error(mysql));
mysql_close(mysql);
DBUG_RETURN(1);
}
@@ -1634,7 +1633,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
}
@@ -2271,7 +2270,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;
@@ -2335,7 +2334,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])
{
@@ -2434,10 +2433,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 b8ff86cf301..34e3e20ce06 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -490,8 +490,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 a99a3ee8a2a..bf1ad5d5fcf 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1001,7 +1001,8 @@ sp_cache_functions(THD *thd, LEX *lex)
{
delete newlex;
thd->lex= oldlex;
- net_printf(thd, ER_SP_DOES_NOT_EXIST, "FUNCTION", ls->str);
+ my_printf_error(ER_SP_DOES_NOT_EXIST, ER(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 a18bc2abe39..f07bb89e154 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_printf_error(ER_SP_WRONG_NO_OF_ARGS, ER(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,8 @@ 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_printf_error(ER_SP_LILABEL_MISMATCH, ER(ER_SP_LILABEL_MISMATCH),
+ MYF(0), "GOTO", bp->lab->name);
return -1;
}
}
@@ -1791,7 +1787,7 @@ sp_instr_error::execute(THD *thd, uint *nextp)
{
DBUG_ENTER("sp_instr_error::execute");
- my_error(m_errcode, MYF(0));
+ my_message(m_errcode, ER(m_errcode), MYF(0));
*nextp= m_ip+1;
DBUG_RETURN(-1);
}
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 51a1bb2e550..609882b84c6 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -153,7 +153,8 @@ sp_cursor::pre_open(THD *thd)
{
if (m_isopen)
{
- send_error(thd, ER_SP_CURSOR_ALREADY_OPEN);
+ my_message(ER_SP_CURSOR_ALREADY_OPEN, ER(ER_SP_CURSOR_ALREADY_OPEN),
+ MYF(0));
return NULL;
}
@@ -187,7 +188,7 @@ sp_cursor::close(THD *thd)
{
if (! m_isopen)
{
- send_error(thd, ER_SP_CURSOR_NOT_OPEN);
+ my_message(ER_SP_CURSOR_NOT_OPEN, ER(ER_SP_CURSOR_NOT_OPEN), MYF(0));
return -1;
}
destroy();
@@ -217,12 +218,12 @@ sp_cursor::fetch(THD *thd, List<struct sp_pvar> *vars)
if (! m_isopen)
{
- send_error(thd, ER_SP_CURSOR_NOT_OPEN);
+ my_message(ER_SP_CURSOR_NOT_OPEN, ER(ER_SP_CURSOR_NOT_OPEN), MYF(0));
return -1;
}
if (m_current_row == NULL)
{
- send_error(thd, ER_SP_FETCH_NO_DATA);
+ my_message(ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA), MYF(0));
return -1;
}
@@ -234,7 +235,8 @@ 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_message(ER_SP_WRONG_NO_OF_FETCH_ARGS,
+ ER(ER_SP_WRONG_NO_OF_FETCH_ARGS), MYF(0));
return -1;
}
s= row[fldcount];
@@ -260,7 +262,8 @@ 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_message(ER_SP_WRONG_NO_OF_FETCH_ARGS,
+ ER(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 9e571e4b84c..cd20888cb98 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,15 @@ 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_message(ER_PASSWORD_ANONYMOUS_USER, ER(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 +1283,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_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0));
DBUG_RETURN(1);
}
/* update loaded acl entry: */
@@ -1298,7 +1296,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 */
}
@@ -1471,7 +1468,8 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
(byte*) table->field[0]->ptr,0,
HA_READ_KEY_EXACT))
{
- my_error(ER_PASSWORD_NO_MATCH,MYF(0)); /* purecov: deadcode */
+ my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH),
+ MYF(0)); /* purecov: deadcode */
DBUG_RETURN(1); /* purecov: deadcode */
}
store_record(table,record[1]);
@@ -1554,7 +1552,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
/* what == 'N' means revoke */
if (what == 'N')
{
- my_error(ER_NONEXISTING_GRANT, MYF(0), combo.user.str, combo.host.str);
+ my_printf_error(ER_NONEXISTING_GRANT, ER(ER_NONEXISTING_GRAN), MYF(0),
+ combo.user.str, combo.host.str);
goto end;
}
/*
@@ -1571,8 +1570,9 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
else if (((thd->variables.sql_mode & MODE_NO_AUTO_CREATE_USER) &&
!password_len) || !create_user)
{
- my_error(ER_NO_PERMISSION_TO_CREATE_USER, MYF(0),
- thd->user, thd->host_or_ip);
+ my_printf_error(ER_NO_PERMISSION_TO_CREATE_USER,
+ ER(ER_NO_PERMISSION_TO_CREATE_USER), MYF(0),
+ thd->user, thd->host_or_ip);
goto end;
}
old_row_exists = 0;
@@ -1748,7 +1748,7 @@ static int replace_db_table(TABLE *table, const char *db,
/* Check if there is such a user in user table in memory? */
if (!find_acl_user(combo.host.str,combo.user.str))
{
- my_error(ER_PASSWORD_NO_MATCH,MYF(0));
+ my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), MYF(0));
DBUG_RETURN(-1);
}
@@ -1760,7 +1760,8 @@ static int replace_db_table(TABLE *table, const char *db,
{
if (what == 'N')
{ // no row, no revoke
- my_error(ER_NONEXISTING_GRANT, MYF(0), combo.user.str, combo.host.str);
+ my_printf_error(ER_NONEXISTING_GRANT, ER(ER_NONEXISTING_GRANT), MYF(0),
+ combo.user.str, combo.host.str);
goto abort;
}
old_row_exists = 0;
@@ -2067,8 +2068,10 @@ static int replace_column_table(GRANT_TABLE *g_t,
{
if (revoke_grant)
{
- my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0),
- combo.user.str, combo.host.str, table_name); /* purecov: inspected */
+ my_printf_error(ER_NONEXISTING_TABLE_GRANT,
+ ER(ER_NONEXISTING_TABLE_GRANT), MYF(0),
+ combo.user.str, combo.host.str,
+ table_name); /* purecov: inspected */
result= -1; /* purecov: inspected */
continue; /* purecov: inspected */
}
@@ -2211,7 +2214,8 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
*/
if (!find_acl_user(combo.host.str,combo.user.str))
{
- my_error(ER_PASSWORD_NO_MATCH,MYF(0)); /* purecov: deadcode */
+ my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH),
+ MYF(0)); /* purecov: deadcode */
DBUG_RETURN(-1); /* purecov: deadcode */
}
@@ -2233,9 +2237,10 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
*/
if (revoke_grant)
{ // no row, no revoke
- my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0),
- combo.user.str, combo.host.str,
- table_name); /* purecov: deadcode */
+ my_printf_error(ER_NONEXISTING_TABLE_GRANT,
+ ER(ER_NONEXISTING_TABLE_GRANT), MYF(0),
+ combo.user.str, combo.host.str,
+ table_name); /* purecov: deadcode */
DBUG_RETURN(-1); /* purecov: deadcode */
}
old_row_exists = 0;
@@ -2317,11 +2322,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)
@@ -2338,12 +2343,13 @@ 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);
+ my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE),
+ MYF(0));
+ DBUG_RETURN(TRUE);
}
if (columns.elements && !revoke_grant)
@@ -2352,8 +2358,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++))
{
@@ -2363,9 +2369,9 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
column->column.length(), 0, 0, 0, 0,
&unused_field_idx))
{
- my_error(ER_BAD_FIELD_ERROR, MYF(0),
- column->column.c_ptr(), table_list->alias);
- DBUG_RETURN(-1);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
+ column->column.c_ptr(), table_list->alias);
+ DBUG_RETURN(TRUE);
}
column_priv|= column->rights;
}
@@ -2379,8 +2385,9 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
fn_format(buf,buf,"","",4+16+32);
if (access(buf,F_OK))
{
- my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db, table_list->alias);
- DBUG_RETURN(-1);
+ my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0),
+ table_list->db, table_list->alias);
+ DBUG_RETURN(TRUE);
}
}
@@ -2413,19 +2420,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= thd->mem_root;
thd->mem_root= &memex;
@@ -2437,8 +2444,9 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
if (Str->host.length > HOSTNAME_LENGTH ||
Str->user.length > USERNAME_LENGTH)
{
- my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0));
- result= -1;
+ my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
+ MYF(0));
+ result= TRUE;
continue;
}
/* Create user if needed */
@@ -2448,7 +2456,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
}
@@ -2466,9 +2474,10 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
{
if (revoke_grant)
{
- my_error(ER_NONEXISTING_TABLE_GRANT, MYF(0),
- Str->user.str, Str->host.str, table_list->real_name);
- result= -1;
+ my_printf_error(ER_NONEXISTING_TABLE_GRANT,
+ ER(ER_NONEXISTING_TABLE_GRANT), MYF(0),
+ Str->user.str, Str->host.str, table_list->real_name);
+ result= TRUE;
continue;
}
grant_table = new GRANT_TABLE (Str->host.str, db_name,
@@ -2477,7 +2486,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);
@@ -2522,7 +2531,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
rights, column_priv, revoke_grant))
{
/* Should only happen if table is crashed */
- result= -1; /* purecov: deadcode */
+ result= TRUE; /* purecov: deadcode */
}
else if (tables[2].table)
{
@@ -2531,7 +2540,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
db_name, real_name,
rights, revoke_grant)))
{
- result= -1;
+ result= TRUE;
}
}
}
@@ -2545,8 +2554,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;
@@ -2558,7 +2567,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)
@@ -2589,14 +2598,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)
@@ -2613,7 +2622,8 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
if (Str->host.length > HOSTNAME_LENGTH ||
Str->user.length > USERNAME_LENGTH)
{
- my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0));
+ my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
+ MYF(0));
result= -1;
continue;
}
@@ -2910,11 +2920,12 @@ 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_printf_error(ER_TABLEACCESS_DENIED_ERROR,
+ ER(ER_TABLEACCESS_DENIED_ERROR), MYF(0),
+ command,
+ thd->priv_user,
+ thd->host_or_ip,
+ table ? table->real_name : "unknown");
}
DBUG_RETURN(1);
}
@@ -3176,7 +3187,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;
@@ -3191,7 +3202,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)
@@ -3202,8 +3213,9 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (lex_user->host.length > HOSTNAME_LENGTH ||
lex_user->user.length > USERNAME_LENGTH)
{
- my_error(ER_GRANT_WRONG_HOST_OR_USER,MYF(0));
- DBUG_RETURN(-1);
+ my_message(ER_GRANT_WRONG_HOST_OR_USER, ER(ER_GRANT_WRONG_HOST_OR_USER),
+ MYF(0));
+ DBUG_RETURN(TRUE);
}
for (counter=0 ; counter < acl_users.elements ; counter++)
@@ -3220,9 +3232,10 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
if (counter == acl_users.elements)
{
- my_error(ER_NONEXISTING_GRANT, MYF(0),
- lex_user->user.str, lex_user->host.str);
- DBUG_RETURN(-1);
+ my_printf_error(ER_NONEXISTING_GRANT,
+ ER(ER_NONEXISTING_GRANT), MYF(0),
+ lex_user->user.str, lex_user->host.str);
+ DBUG_RETURN(TRUE);
}
Item_string *field=new Item_string("",0,&my_charset_latin1);
@@ -3234,7 +3247,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));
@@ -3556,7 +3569,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);
}
@@ -3625,7 +3638,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;
@@ -3636,7 +3649,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));
@@ -3724,7 +3737,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);
}
@@ -3734,11 +3747,11 @@ int mysql_drop_user(THD *thd, List <LEX_USER> &list)
rw_unlock(&LOCK_grant);
close_thread_tables(thd);
if (result)
- my_error(ER_DROP_USER, MYF(0));
+ my_message(ER_DROP_USER, ER(ER_DROP_USER), MYF(0));
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, revoked;
int result;
@@ -3747,7 +3760,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));
@@ -3861,7 +3874,7 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
close_thread_tables(thd);
if (result)
- my_error(ER_REVOKE_GRANTS, MYF(0));
+ my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0));
DBUG_RETURN(result);
}
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_analyse.cc b/sql/sql_analyse.cc
index 2259d3bead8..69b7b987152 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -81,14 +81,18 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
(*param->item)->val_real() < 0)
{
delete pc;
- my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
+ my_printf_error(ER_WRONG_PARAMETERS_TO_PROCEDURE,
+ ER(ER_WRONG_PARAMETERS_TO_PROCEDURE), MYF(0),
+ proc_name);
DBUG_RETURN(0);
}
pc->max_tree_elements = (uint) (*param->item)->val_int();
param = param->next;
if (param->next) // no third parameter possible
{
- my_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, MYF(0), proc_name);
+ my_printf_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE,
+ ER(ER_WRONG_PARAMCOUNT_TO_PROCEDURE), MYF(0),
+ proc_name);
DBUG_RETURN(0);
}
// second parameter
@@ -96,7 +100,9 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
(*param->item)->val_real() < 0)
{
delete pc;
- my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
+ my_printf_error(ER_WRONG_PARAMETERS_TO_PROCEDURE,
+ ER(ER_WRONG_PARAMETERS_TO_PROCEDURE), MYF(0),
+ proc_name);
DBUG_RETURN(0);
}
pc->max_treemem = (uint) (*param->item)->val_int();
@@ -105,7 +111,8 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
(*param->item)->val_real() < 0)
{
delete pc;
- my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
+ my_printf_error(ER_WRONG_PARAMETERS_TO_PROCEDURE,
+ ER(ER_WRONG_PARAMETERS_TO_PROCEDURE), MYF(0), proc_name);
DBUG_RETURN(0);
}
// if only one parameter was given, it will be the value of max_tree_elements
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index eeb34f6b600..b32aa033209 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1262,7 +1262,8 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh)
next=table->next;
if (!tables || (!db_stat && reopen_table(table,1)))
{
- my_error(ER_CANT_REOPEN_TABLE,MYF(0),table->table_name);
+ my_printf_error(ER_CANT_REOPEN_TABLE, ER(ER_CANT_REOPEN_TABLE),
+ MYF(0),table->table_name);
VOID(hash_delete(&open_cache,(byte*) table));
error=1;
}
@@ -1547,7 +1548,8 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
{
/* Give right error message */
thd->clear_error();
- my_error(ER_NOT_KEYFILE, MYF(0), name, my_errno);
+ my_printf_error(ER_NOT_KEYFILE, ER(ER_NOT_KEYFILE), MYF(0),
+ name, my_errno);
sql_print_error("Couldn't repair table: %s.%s",db,name);
if (entry->file)
closefrm(entry);
@@ -1612,7 +1614,8 @@ err:
{
TABLE_LIST * view= table_desc->belong_to_view;
thd->clear_error();
- my_error(ER_VIEW_INVALID, MYF(0), view->view_db.str, view->view_name.str);
+ my_printf_error(ER_VIEW_INVALID, ER(ER_VIEW_INVALID), MYF(0),
+ view->view_db.str, view->view_name.str);
}
DBUG_RETURN(1);
}
@@ -1853,15 +1856,14 @@ 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;
@@ -1870,7 +1872,7 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
(thd->fill_derived_tables() &&
mysql_handle_derived(thd->lex, &mysql_derived_filling)))
- DBUG_RETURN(thd->net.report_error ? -1 : 1); /* purecov: inspected */
+ DBUG_RETURN(TRUE); /* purecov: inspected */
relink_tables_for_multidelete(thd);
DBUG_RETURN(0);
}
@@ -2692,9 +2694,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);
@@ -2712,7 +2714,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;
@@ -2820,8 +2822,9 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table,
(pos= find_type(&table->keynames, name->ptr(), name->length(), 1)) <=
0)
{
- my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), name->c_ptr(),
- table->real_name);
+ my_printf_error(ER_KEY_COLUMN_DOES_NOT_EXITS,
+ ER(ER_KEY_COLUMN_DOES_NOT_EXITS), MYF(0),
+ name->c_ptr(), table->real_name);
map->set_all();
return 1;
}
@@ -3037,9 +3040,10 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
DBUG_RETURN(0);
if (!table_name)
- my_error(ER_NO_TABLES_USED, MYF(0));
+ my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0));
else
- my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name);
+ my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
+ table_name);
err:
DBUG_RETURN(1);
@@ -3261,8 +3265,25 @@ err_no_arena:
** Returns : 1 if some field has wrong type
******************************************************************************/
-int
-fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors)
+
+/*
+ Fill fields with given items.
+
+ SYNOPSIS
+ fill_record()
+ thd thread handler
+ fields Item_fields list to be filled
+ values values to fill with
+ ignore_errors TRUE if we should ignore errors
+
+ RETURN
+ FALSE OK
+ TRUE error occured
+*/
+
+bool
+fill_record(THD * thd, List<Item> &fields, List<Item> &values,
+ bool ignore_errors)
{
List_iterator_fast<Item> f(fields),v(values);
Item *value;
@@ -3277,14 +3298,32 @@ fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors)
if (rfield == table->next_number_field)
table->auto_increment_field_not_null= TRUE;
if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
- DBUG_RETURN(1);
+ {
+ my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
+ DBUG_RETURN(TRUE);
+ }
}
- DBUG_RETURN(0);
+ DBUG_RETURN(thd->net.report_error);
}
-int
-fill_record(Field **ptr,List<Item> &values, bool ignore_errors)
+/*
+ Fill field buffer with values from Field list
+
+ SYNOPSIS
+ fill_record()
+ thd thread handler
+ ptr pointer on pointer to record
+ values list of fields
+ ignore_errors TRUE if we should ignore errors
+
+ RETURN
+ FALSE OK
+ TRUE error occured
+*/
+
+bool
+fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
{
List_iterator_fast<Item> v(values);
Item *value;
@@ -3298,9 +3337,12 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors)
if (field == table->next_number_field)
table->auto_increment_field_not_null= TRUE;
if ((value->save_in_field(field, 0) < 0) && !ignore_errors)
- DBUG_RETURN(1);
+ {
+ my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
+ DBUG_RETURN(TRUE);
+ }
}
- DBUG_RETURN(0);
+ DBUG_RETURN(thd->net.report_error);
}
@@ -3531,7 +3573,8 @@ open_new_frm(const char *path, const char *alias,
{
if (table_desc == 0 || table_desc->required_type == FRMTYPE_TABLE)
{
- my_error(ER_WRONG_OBJECT, MYF(0), db, table_name, "BASE TABLE");
+ my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0),
+ db, table_name, "BASE TABLE");
goto err;
}
if (mysql_make_view(parser, table_desc))
@@ -3540,7 +3583,8 @@ open_new_frm(const char *path, const char *alias,
else
{
/* only VIEWs are supported now */
- my_error(ER_FRM_UNKNOWN_TYPE, MYF(0), path, parser->type()->str);
+ my_printf_error(ER_FRM_UNKNOWN_TYPE, ER(ER_FRM_UNKNOWN_TYPE), MYF(0),
+ path, parser->type()->str);
goto err;
}
DBUG_RETURN(0);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 8a1b6fae6e7..6f236f42df9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -701,8 +701,8 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length)
key_length + 1);
if (!new_table)
{
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL),
- ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1);
+ my_printf_error(EE_OUTOFMEMORY, ER(EE_OUTOFMEMORY), MYF(ME_BELL),
+ ALIGN_SIZE(sizeof(TABLE_LIST)) + key_length + 1);
killed= KILL_CONNECTION;
return 0;
}
@@ -821,7 +821,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));
}
@@ -925,7 +925,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);
@@ -1018,7 +1018,8 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
if (!access(path, F_OK))
{
- my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);
+ my_printf_error(ER_FILE_EXISTS_ERROR, ER(ER_FILE_EXISTS_ERROR), MYF(0),
+ exchange->file_name);
return -1;
}
/* Create the file world readable */
@@ -1249,7 +1250,7 @@ bool select_dump::send_data(List<Item> &items)
}
if (row_count++ > 1)
{
- my_error(ER_TOO_MANY_ROWS, MYF(0));
+ my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
goto err;
}
while ((item=li++))
@@ -1262,7 +1263,8 @@ bool select_dump::send_data(List<Item> &items)
}
else if (my_b_write(&cache,(byte*) res->ptr(),res->length()))
{
- my_error(ER_ERROR_ON_WRITE,MYF(0), path, my_errno);
+ my_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0),
+ path, my_errno);
goto err;
}
}
@@ -1421,7 +1423,8 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
if (var_list.elements != list.elements)
{
- my_error(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, MYF(0));
+ my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT,
+ ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
return 1;
}
while ((item=li++))
@@ -1722,7 +1725,7 @@ bool select_dumpvar::send_data(List<Item> &items)
}
if (row_count++)
{
- my_error(ER_TOO_MANY_ROWS, MYF(0));
+ my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
DBUG_RETURN(1);
}
while ((zz=my_li++) && (item=it++))
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 85a18b10671..41a560d41cf 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -41,6 +41,7 @@ enum enum_check_fields { CHECK_FIELD_IGNORE, CHECK_FIELD_WARN,
CHECK_FIELD_ERROR_FOR_NULL };
extern char internal_table_name[2];
+extern const char **errmesg;
/* log info errors */
#define LOG_INFO_EOF -1
@@ -1157,6 +1158,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
@@ -1209,7 +1211,8 @@ public:
}
inline void send_kill_message() const
{
- my_error(killed_errno(), MYF(0));
+ int err= killed_errno();
+ my_message(err, ER(err), MYF(0));
}
/* return TRUE if we will abort query if we make a warning now */
inline bool really_abort_on_warning()
@@ -1251,8 +1254,6 @@ public:
class JOIN;
-void send_error(THD *thd, uint sql_errno=0, const char *err=0);
-
class select_result :public Sql_alloc {
protected:
THD *thd;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index ad74bb8f833..42d6549f843 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -374,13 +374,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;
@@ -408,7 +408,8 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
{
if (!(create_options & HA_LEX_CREATE_IF_NOT_EXISTS))
{
- my_error(ER_DB_CREATE_EXISTS,MYF(0),db);
+ my_printf_error(ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), MYF(0),
+ db);
error= -1;
goto exit;
}
@@ -418,12 +419,13 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
{
if (my_errno != ENOENT)
{
- my_error(EE_STAT, MYF(0),path,my_errno);
+ my_printf_error(EE_STAT, ER(EE_STAT), MYF(0), path, my_errno);
goto exit;
}
if (my_mkdir(path,0777,MYF(0)) < 0)
{
- my_error(ER_CANT_CREATE_DB,MYF(0),db,my_errno);
+ my_printf_error(ER_CANT_CREATE_DB, ER(ER_CANT_CREATE_DB),
+ MYF(0), db, my_errno);
error= -1;
goto exit;
}
@@ -484,7 +486,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;
@@ -527,7 +529,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);
}
@@ -543,11 +545,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;
@@ -577,7 +579,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if (!if_exists)
{
error= -1;
- my_error(ER_DB_DROP_EXISTS,MYF(0),db);
+ my_printf_error(ER_DB_DROP_EXISTS, ER(ER_DB_DROP_EXISTS), MYF(0), db);
goto exit;
}
else
@@ -801,7 +803,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
*/
if (found_other_files)
{
- my_error(ER_DB_DROP_RMDIR, MYF(0), org_path, EEXIST);
+ my_printf_error(ER_DB_DROP_RMDIR, ER(ER_DB_DROP_RMDIR), MYF(0),
+ org_path, EEXIST);
DBUG_RETURN(-1);
}
else
@@ -864,7 +867,8 @@ static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error)
*--pos=0;
if (rmdir(path) < 0 && send_error)
{
- my_error(ER_DB_DROP_RMDIR, MYF(0), path, errno);
+ my_printf_error(ER_DB_DROP_RMDIR, ER(ER_DB_DROP_RMDIR), MYF(0),
+ path, errno);
DBUG_RETURN(-1);
}
DBUG_RETURN(0);
@@ -985,12 +989,13 @@ 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_message(ER_NO_DB_ERROR, ER(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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), dbname);
x_free(dbname);
DBUG_RETURN(1);
}
@@ -1003,10 +1008,11 @@ 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_printf_error(ER_DBACCESS_DENIED_ERROR,
+ ER(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 +1027,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_printf_error(ER_BAD_DB_ERROR, ER(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 b8f560b3ef2..31363583806 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;
@@ -42,22 +42,23 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
SELECT_LEX *select_lex= &thd->lex->select_lex;
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_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
+ ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
+ DBUG_RETURN(TRUE);
}
if (thd->lex->duplicates == DUP_IGNORE)
@@ -86,7 +87,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;
@@ -104,8 +105,9 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
{
delete select;
free_underlaid_joins(thd, select_lex);
- send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
- DBUG_RETURN(1);
+ my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
+ ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
+ DBUG_RETURN(TRUE);
}
}
if (options & OPTION_QUICK)
@@ -136,7 +138,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
{
delete select;
free_underlaid_joins(thd, 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,
@@ -151,7 +153,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
{
delete select;
free_underlaid_joins(thd, select_lex);
- DBUG_RETURN(-1); // This will force out message
+ DBUG_RETURN(TRUE);
}
init_read_record(&info,thd,table,select,1,1);
deleted=0L;
@@ -254,15 +256,13 @@ cleanup:
thd->lock=0;
}
free_underlaid_joins(thd, 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(error >= 0 || thd->net.report_error);
}
@@ -276,11 +276,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");
@@ -288,19 +287,21 @@ 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);
+ my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE), MYF(0),
+ table_list->alias, "DELETE");
+ DBUG_RETURN(TRUE);
}
if (unique_table(table_list, table_list->next_global))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), MYF(0),
+ table_list->real_name);
+ DBUG_RETURN(TRUE);
}
select_lex->fix_prepare_information(thd, conds);
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -324,16 +325,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");
/*
@@ -343,7 +343,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;
@@ -354,9 +354,9 @@ int mysql_multi_delete_prepare(THD *thd)
if (!target_tbl->correspondent_table->updatable ||
check_key_in_view(thd, target_tbl->correspondent_table))
{
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), target_tbl->real_name,
- "DELETE");
- DBUG_RETURN(-1);
+ my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE),
+ MYF(0), target_tbl->real_name, "DELETE");
+ DBUG_RETURN(TRUE);
}
/*
Check are deleted table used somewhere inside subqueries.
@@ -372,14 +372,13 @@ int mysql_multi_delete_prepare(THD *thd)
un->check_updateable(target_tbl->correspondent_table->db,
target_tbl->correspondent_table->real_name))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0),
- target_tbl->correspondent_table->real_name);
- res= -1;
- break;
+ my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED),
+ MYF(0), target_tbl->correspondent_table->real_name);
+ DBUG_RETURN(TRUE);
}
}
}
- DBUG_RETURN(res);
+ DBUG_RETURN(FALSE);
}
@@ -525,7 +524,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)
@@ -671,9 +670,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);
@@ -698,12 +695,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));
@@ -739,9 +736,9 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
db_type table_type;
if ((table_type=get_table_type(path)) == DB_TYPE_UNKNOWN)
{
- my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db,
- table_list->real_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0),
+ table_list->db, table_list->real_name);
+ DBUG_RETURN(TRUE);
}
if (!ha_supports_generate(table_type))
{
@@ -754,11 +751,11 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
DBUG_RETURN(error);
}
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:
@@ -785,5 +782,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 3fbefdd37ef..adae481d608 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -183,14 +183,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");
@@ -201,7 +201,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;
@@ -225,10 +225,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 edb895fd24a..e1df25ae724 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -140,11 +140,11 @@ static void mysql_ha_hash_free(TABLE_LIST *tables)
error messages.
RETURN
- 0 ok
- != 0 error
+ FALSE OK
+ TRUE Error
*/
-int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
+bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
{
TABLE_LIST *hash_tables;
char *db, *name, *alias;
@@ -236,11 +236,11 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (! reopen)
send_ok(thd);
DBUG_PRINT("exit",("OK"));
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
err:
DBUG_PRINT("exit",("ERROR"));
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
@@ -327,15 +327,15 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
offset_limit
RETURN
- 0 ok
- != 0 error
+ FALSE ok
+ TRUE error
*/
-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)
{
TABLE_LIST *hash_tables;
TABLE *table;
@@ -512,10 +512,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->record[0], table->key_info + keyno, key_len);
error= table->file->index_read(table->record[0],
key,key_len,ha_rkey_mode);
@@ -523,7 +520,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
break;
}
default:
- send_error(thd,ER_ILLEGAL_HA);
+ my_message(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0));
goto err;
}
@@ -552,7 +549,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
if (item->send(thd->protocol, &buffer))
{
protocol->free(); // Free used
- my_error(ER_OUT_OF_RESOURCES,MYF(0));
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
goto err;
}
}
@@ -564,13 +561,13 @@ ok:
mysql_unlock_tables(thd,lock);
send_eof(thd);
DBUG_PRINT("exit",("OK"));
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
err:
mysql_unlock_tables(thd,lock);
err0:
DBUG_PRINT("exit",("ERROR"));
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index aed86b78e93..33bf4c481a2 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_message(ER_CORRUPT_HELP_DB, ER(ER_CORRUPT_HELP_DB), MYF(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 6e0260d1acb..f39753f0e62 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -100,7 +100,8 @@ check_insert_fields(THD *thd, TABLE_LIST *table_list, List<Item> &fields,
if (check_unique && thd->dupp_field)
{
- my_error(ER_FIELD_SPECIFIED_TWICE,MYF(0), thd->dupp_field->field_name);
+ my_printf_error(ER_FIELD_SPECIFIED_TWICE, ER(ER_FIELD_SPECIFIED_TWICE),
+ MYF(0), thd->dupp_field->field_name);
return -1;
}
if (table->timestamp_field && // Don't set timestamp if used
@@ -115,12 +116,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 +175,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 +201,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";
@@ -291,13 +292,18 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
if (fields.elements || !value_count)
{
restore_record(table,default_values); // Get empty record
- if (fill_record(fields, *values, 0)|| thd->net.report_error)
+ if (fill_record(thd, fields, *values, 0))
{
if (values_list.elements != 1 && !thd->net.report_error)
{
info.records++;
continue;
}
+ /*
+ 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.
+ */
error=1;
break;
}
@@ -308,7 +314,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
restore_record(table,default_values); // Get empty record
else
table->record[0][0]=table->default_values[0]; // Fix delete marker
- if (fill_record(table->field,*values, 0) || thd->net.report_error)
+ if (fill_record(thd, table->field, *values, 0))
{
if (values_list.elements != 1 && ! thd->net.report_error)
{
@@ -468,7 +474,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
@@ -478,7 +484,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);
}
@@ -596,7 +602,8 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
(insert_into_view &&
check_view_insertability(table_list, thd->query_id)))
{
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "INSERT");
+ my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE),
+ MYF(0), table_list->alias, "INSERT");
DBUG_RETURN(1);
}
DBUG_RETURN(0);
@@ -612,11 +619,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)
@@ -624,7 +631,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))
@@ -639,15 +646,16 @@ 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_global))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED),
+ MYF(0), table_list->real_name);
+ DBUG_RETURN(TRUE);
}
thd->lex->select_lex.first_execution= 0;
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -739,7 +747,7 @@ 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))
+ if (fill_record(thd, *info->update_fields, *info->update_values, 0))
goto err;
/* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */
@@ -1001,7 +1009,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
{
delete tmp;
thd->fatal_error();
- my_error(ER_OUT_OF_RESOURCES,MYF(0));
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
pthread_mutex_unlock(&LOCK_delayed_create);
DBUG_RETURN(0);
}
@@ -1021,7 +1029,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);
}
@@ -1317,7 +1325,8 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
if (!(di->table->file->table_flags() & HA_CAN_INSERT_DELAYED))
{
thd->fatal_error();
- my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name);
+ my_printf_error(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0),
+ di->table_list.real_name);
goto end;
}
di->table->copy_blobs=1;
@@ -1649,11 +1658,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");
@@ -1665,8 +1674,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);
}
@@ -1742,9 +1751,9 @@ bool select_insert::send_data(List<Item> &values)
DBUG_RETURN(0);
}
if (fields->elements)
- fill_record(*fields, values, 1);
+ fill_record(thd, *fields, values, 1);
else
- fill_record(table->field, values, 1);
+ fill_record(thd, table->field, values, 1);
switch (table_list->view_check_option(thd,
thd->lex->duplicates == DUP_IGNORE))
{
@@ -1769,8 +1778,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)
{
@@ -1846,8 +1854,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];
@@ -1918,7 +1924,7 @@ bool select_create::send_data(List<Item> &values)
unit->offset_limit_cnt--;
return 0;
}
- fill_record(field, values, 1);
+ fill_record(thd, field, values, 1);
if (thd->net.report_error || write_record(thd, table, &info))
return 1;
if (table->next_number_field) // Clear for next record
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 86219abc632..926d2802103 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1308,7 +1308,7 @@ bool st_select_lex::test_limit()
if (select_limit != HA_POS_ERROR)
{
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
- "LIMIT & IN/ALL/ANY/SOME subquery");
+ "LIMIT & IN/ALL/ANY/SOME subquery");
return(1);
}
// We need only 1 row to determinate existence
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index fd1c1dee0b7..7a41c42dd69 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -342,8 +342,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
@@ -403,9 +403,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();
@@ -413,7 +413,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 lex_start(THD *thd, uchar *buf, uint length);
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 9c2a025e089..4f5cf463fb6 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -80,7 +80,7 @@ static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
String &enclosed, ulong skip_lines,
bool ignore_check_option_errors);
-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,
bool ignore_check_option_errors)
@@ -116,17 +116,18 @@ 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);
if (setup_tables(thd, table_list, &unused_conds))
DBUG_RETURN(-1);
if (!table_list->updatable || check_key_in_view(thd, table_list))
{
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD");
- DBUG_RETURN(-1);
+ my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE),
+ MYF(0), table_list->alias, "LOAD");
+ DBUG_RETURN(TRUE);
}
table= table_list->table;
transactional_table= table->file->has_transactions();
@@ -145,14 +146,15 @@ 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);
+ my_printf_error(ER_FIELD_SPECIFIED_TWICE, ER(ER_FIELD_SPECIFIED_TWICE),
+ MYF(0), thd->dupp_field->field_name);
+ DBUG_RETURN(TRUE);
}
if (check_that_all_fields_are_given_values(thd, table))
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
uint tot_length=0;
@@ -178,7 +180,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 */
@@ -210,7 +212,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 &&
@@ -221,15 +223,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
((stat_info.st_mode & S_IFREG) == S_IFREG ||
(stat_info.st_mode & S_IFIFO) == S_IFIFO)))
{
- my_error(ER_TEXTFILE_NOT_READABLE,MYF(0),name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_TEXTFILE_NOT_READABLE,
+ ER(ER_TEXTFILE_NOT_READABLE), MYF(0), name);
+ 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;
@@ -244,7 +247,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..917a8f2c30f 100644
--- a/sql/sql_map.cc
+++ b/sql/sql_map.cc
@@ -47,13 +47,13 @@ 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_printf_error(ER_NO_FILE_MAPPING, ER(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_printf_error(ER_WRONG_MAGIC, ER(ER_WRONG_MAGIC), MYF(0), name);
VOID(munmap(map,size));
map=0;
}
@@ -112,8 +112,8 @@ 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_printf_error(ER_NO_FILE_MAPPING, ER(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 6d90b4eac05..652a0493f6b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -166,7 +166,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
my_malloc(sizeof(struct user_conn) + temp_len+1,
MYF(MY_WME)))))
{
- send_error(thd, 0, NullS); // Out of memory
+ net_send_error(thd, 0, NullS); // Out of memory
return_val=1;
goto end;
}
@@ -184,7 +184,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
if (my_hash_insert(&hash_user_connections, (byte*) uc))
{
my_free((char*) uc,0);
- send_error(thd, 0, NullS); // Out of memory
+ net_send_error(thd, 0, NullS); // Out of memory
return_val=1;
goto end;
}
@@ -259,7 +259,7 @@ int check_user(THD *thd, enum enum_server_command command,
*/
if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323)
{
- net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE);
+ net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
mysql_log.write(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN(-1);
}
@@ -291,8 +291,8 @@ int check_user(THD *thd, enum enum_server_command command,
NET *net= &thd->net;
if (opt_secure_auth_local)
{
- net_printf(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
- thd->user, thd->host_or_ip);
+ net_printf_error(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
+ thd->user, thd->host_or_ip);
mysql_log.write(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE),
thd->user, thd->host_or_ip);
DBUG_RETURN(-1);
@@ -331,7 +331,7 @@ int check_user(THD *thd, enum enum_server_command command,
VOID(pthread_mutex_unlock(&LOCK_thread_count));
if (!count_ok)
{ // too many connections
- send_error(thd, ER_CON_COUNT_ERROR);
+ net_send_error(thd, ER_CON_COUNT_ERROR);
DBUG_RETURN(-1);
}
}
@@ -381,14 +381,14 @@ int check_user(THD *thd, enum enum_server_command command,
}
else if (res == 2) // client gave short hash, server has long hash
{
- net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE);
+ net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN(-1);
}
- net_printf(thd, ER_ACCESS_DENIED_ERROR,
- thd->user,
- thd->host_or_ip,
- passwd_len ? ER(ER_YES) : ER(ER_NO));
+ net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
+ thd->user,
+ thd->host_or_ip,
+ passwd_len ? ER(ER_YES) : ER(ER_NO));
mysql_log.write(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
thd->user,
thd->host_or_ip,
@@ -451,16 +451,16 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
if (max_user_connections &&
max_user_connections < (uint) uc->connections)
{
- net_printf(thd,ER_TOO_MANY_USER_CONNECTIONS, uc->user);
+ net_printf_error(thd, ER_TOO_MANY_USER_CONNECTIONS, uc->user);
error=1;
goto end;
}
if (uc->user_resources.connections &&
uc->user_resources.connections <= uc->conn_per_hour)
{
- net_printf(thd, ER_USER_LIMIT_REACHED, uc->user,
- "max_connections",
- (long) uc->user_resources.connections);
+ net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user,
+ "max_connections",
+ (long) uc->user_resources.connections);
error=1;
goto end;
}
@@ -592,8 +592,8 @@ static bool check_mqh(THD *thd, uint check_command)
if (uc->user_resources.questions &&
uc->questions++ >= uc->user_resources.questions)
{
- net_printf(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions",
- (long) uc->user_resources.questions);
+ net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions",
+ (long) uc->user_resources.questions);
error=1;
goto end;
}
@@ -603,8 +603,8 @@ static bool check_mqh(THD *thd, uint check_command)
if (uc->user_resources.updates && uc_update_queries[check_command] &&
uc->updates++ >= uc->user_resources.updates)
{
- net_printf(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates",
- (long) uc->user_resources.updates);
+ net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates",
+ (long) uc->user_resources.updates);
error=1;
goto end;
}
@@ -1010,7 +1010,7 @@ pthread_handler_decl(handle_one_connection,arg)
if ((error=check_connection(thd)))
{ // Wrong permissions
if (error > 0)
- net_printf(thd,error,thd->host_or_ip);
+ net_printf_error(thd, error, thd->host_or_ip);
#ifdef __NT__
if (vio_type(net->vio) == VIO_TYPE_NAMEDPIPE)
my_sleep(1000); /* must wait after eof() */
@@ -1057,7 +1057,7 @@ pthread_handler_decl(handle_one_connection,arg)
thd->host_or_ip,
(net->last_errno ? ER(net->last_errno) :
ER(ER_UNKNOWN_ERROR)));
- send_error(thd,net->last_errno,NullS);
+ net_send_error(thd, net->last_errno, NullS);
statistic_increment(aborted_threads,&LOCK_status);
}
else if (thd->killed)
@@ -1126,8 +1126,8 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
uint length=(uint) strlen(buff);
if (buff[length-1]!='\n' && !feof(file))
{
- send_error(thd,ER_NET_PACKET_TOO_LARGE, NullS);
- thd->is_fatal_error= 1;
+ net_send_error(thd, ER_NET_PACKET_TOO_LARGE, NullS);
+ thd->fatal_error();
break;
}
while (length && (my_isspace(thd->charset(), buff[length-1]) ||
@@ -1204,7 +1204,8 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0),
+ db ? db : "NULL");
goto err;
}
if (lower_case_table_names)
@@ -1280,7 +1281,7 @@ bool do_command(THD *thd)
statistic_increment(aborted_threads,&LOCK_status);
DBUG_RETURN(TRUE); // We have to close it.
}
- send_error(thd,net->last_errno,NullS);
+ net_send_error(thd, net->last_errno, NullS);
net->error= 0;
DBUG_RETURN(FALSE);
}
@@ -1383,8 +1384,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:
@@ -1409,7 +1409,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_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
break;
}
#endif
@@ -1432,7 +1432,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_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
break;
}
@@ -1444,7 +1444,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_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
x_free(thd->user);
thd->user= save_user;
thd->priv_user= save_priv_user;
@@ -1552,7 +1552,8 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
break;
#else
{
@@ -1565,7 +1566,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_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
break;
}
pend= strend(packet);
@@ -1619,7 +1620,8 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0),
+ db ? db : "NULL");
break;
}
if (check_access(thd,CREATE_ACL,db,0,1,0))
@@ -1639,14 +1641,16 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(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_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
break;
}
mysql_log.write(thd,command,db);
@@ -1693,9 +1697,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;
}
@@ -1719,7 +1721,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));
@@ -1803,7 +1804,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
send_eof(thd);
break;
default:
- send_error(thd, ER_UNKNOWN_COM_ERROR);
+ my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
break;
}
break;
@@ -1822,7 +1823,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_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
break;
}
if (thd->lock || thd->open_tables || thd->derived_tables)
@@ -1831,8 +1832,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->net.report_error)
+ net_send_error(thd);
time_t start_of_query=thd->start_time;
thd->end_time(); // Set start time
@@ -1877,8 +1881,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)
@@ -1903,7 +1907,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;
@@ -1913,7 +1917,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;
}
/****************************************************************************
@@ -1921,10 +1925,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 SELECT_LEX (have special meaning for many of non-SELECTcommands) */
SELECT_LEX *select_lex= &lex->select_lex;
@@ -1981,7 +1985,7 @@ mysql_execute_command(THD *thd)
if (all_tables_not_ok(thd, all_tables))
{
/* we warn the slave SQL thread */
- my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
DBUG_RETURN(0);
}
#ifndef TO_BE_DELETED
@@ -2005,7 +2009,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;
@@ -2021,7 +2024,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);
}
@@ -2050,20 +2053,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);
@@ -2083,10 +2080,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)
@@ -2127,10 +2121,7 @@ mysql_execute_command(THD *thd)
*/
DBUG_ASSERT(!is_var_null);
if (!pstr)
- {
- res= -1;
- break; // EOM (error should be reported by allocator)
- }
+ goto error;
}
else
{
@@ -2148,11 +2139,8 @@ mysql_execute_command(THD *thd)
query_len= need_conversion? (pstr->length() * to_cs->mbmaxlen) :
pstr->length();
if (!(query_str= alloc_root(thd->mem_root, query_len+1)))
- {
- res= -1;
- break; // EOM (error should be reported by allocator)
- }
-
+ goto error;
+
if (need_conversion)
{
uint dummy_errors;
@@ -2174,8 +2162,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;
}
@@ -2201,22 +2189,22 @@ 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");
+ my_printf_error(ER_UNKNOWN_STMT_HANDLER, ER(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:
@@ -2266,12 +2254,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
@@ -2367,7 +2355,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;
@@ -2398,7 +2386,8 @@ 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_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
+ first_table->real_name);
break;
}
pthread_mutex_lock(&LOCK_active_mi);
@@ -2425,7 +2414,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;
@@ -2435,10 +2424,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
@@ -2469,7 +2455,8 @@ 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_printf_error(ER_UPDATE_TABLE_USED, ER(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 */
@@ -2482,7 +2469,8 @@ mysql_execute_command(THD *thd)
{
if (unique_table(tab, select_tables))
{
- net_printf(thd, ER_UPDATE_TABLE_USED, tab->real_name);
+ my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED),
+ MYF(0), tab->real_name);
goto create_error;
}
}
@@ -2529,11 +2517,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);
@@ -2541,7 +2527,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;
@@ -2570,7 +2556,8 @@ unsent_create_error:
*/
if (thd->locked_tables || thd->active_transaction())
{
- send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
+ my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION),
+ MYF(0));
goto error;
}
{
@@ -2584,16 +2571,17 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(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= 1;
- break;
+ my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
+ lex->name);
+ goto error;
}
if (!select_lex->db)
select_lex->db= first_table->db;
@@ -2624,7 +2612,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;
@@ -2669,16 +2657,15 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
goto error;
#else
{
@@ -2692,7 +2679,8 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
goto error;
#else
{
@@ -2798,8 +2786,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:
{
@@ -2824,8 +2810,6 @@ unsent_create_error:
select_lex->item_list, lex->value_list,
(lex->value_list.elements ?
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;
@@ -2878,11 +2862,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
@@ -2899,7 +2881,8 @@ unsent_create_error:
*/
if (thd->locked_tables || thd->active_transaction())
{
- send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION,NullS);
+ my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
@@ -2913,8 +2896,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:
@@ -2932,15 +2913,12 @@ 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)) ||
(res= mysql_multi_delete_prepare(thd)))
- break;
+ goto error;
if (!thd->is_fatal_error && (result= new multi_delete(thd,aux_tables,
table_count)))
@@ -2955,12 +2933,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;
}
@@ -2972,10 +2948,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
{
@@ -2999,13 +2972,14 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
goto error;
#else
if ((specialflag & SPECIAL_SKIP_SHOW_DB) &&
@@ -3051,7 +3025,8 @@ unsent_create_error:
break;
case SQLCOM_SHOW_LOGS:
#ifdef DONT_ALLOW_SHOW_COMMANDS
- send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
+ my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
goto error;
#else
{
@@ -3064,30 +3039,33 @@ unsent_create_error:
case SQLCOM_SHOW_TABLES:
/* FALL THROUGH */
#ifdef DONT_ALLOW_SHOW_COMMANDS
- send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
+ my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
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_message(ER_NO_DB_ERROR, ER(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_printf_error(ER_WRONG_DB_NAME, ER(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_printf_error(ER_DBACCESS_DENIED_ERROR,
+ ER(ER_DBACCESS_DENIED_ERROR), MYF(0),
+ thd->priv_user,
+ thd->priv_host,
+ db);
goto error;
}
/* grant is checked in mysqld_show_tables */
@@ -3113,7 +3091,8 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
goto error;
#else
{
@@ -3134,7 +3113,8 @@ 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_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND),
+ MYF(0)); /* purecov: inspected */
goto error;
#else
{
@@ -3170,7 +3150,7 @@ unsent_create_error:
if (!(thd->client_capabilities & CLIENT_LOCAL_FILES) ||
! opt_local_infile)
{
- send_error(thd,ER_NOT_ALLOWED_COMMAND);
+ my_message(ER_NOT_ALLOWED_COMMAND, ER(ER_NOT_ALLOWED_COMMAND), MYF(0));
goto error;
}
if (check_one_table_access(thd, privilege, all_tables))
@@ -3186,15 +3166,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)))
{
@@ -3205,8 +3183,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;
}
@@ -3255,7 +3231,8 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0),
+ lex->name);
break;
}
/*
@@ -3270,7 +3247,7 @@ purposes internal to the MySQL server", MYF(0));
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name)))
{
- my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
break;
}
#endif
@@ -3285,7 +3262,8 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0),
+ lex->name);
break;
}
/*
@@ -3300,7 +3278,7 @@ purposes internal to the MySQL server", MYF(0));
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name)))
{
- my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
break;
}
#endif
@@ -3308,7 +3286,8 @@ 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_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
res=mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : lex->name),
@@ -3319,7 +3298,8 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0),
+ lex->name);
break;
}
/*
@@ -3334,7 +3314,7 @@ purposes internal to the MySQL server", MYF(0));
(!db_ok(lex->name, replicate_do_db, replicate_ignore_db) ||
!db_ok_with_wild_table(lex->name)))
{
- my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0));
break;
}
#endif
@@ -3342,7 +3322,8 @@ 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_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
res=mysql_alter_db(thd,lex->name,&lex->create_info);
@@ -3352,14 +3333,16 @@ 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_printf_error(ER_WRONG_DB_NAME, ER(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_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
res=mysqld_show_create_db(thd,lex->name,&lex->create_info);
@@ -3373,13 +3356,14 @@ 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_printf_error(ER_UDF_EXISTS, ER(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;
}
@@ -3458,8 +3442,9 @@ purposes internal to the MySQL server", MYF(0));
{
if (lex->columns.elements)
{
- send_error(thd,ER_ILLEGAL_GRANT_FOR_TABLE);
- res=1;
+ my_message(ER_ILLEGAL_GRANT_FOR_TABLE, ER(ER_ILLEGAL_GRANT_FOR_TABLE),
+ MYF(0));
+ goto error;
}
else
res = mysql_grant(thd, select_lex->db, lex->users_list, lex->grant,
@@ -3499,9 +3484,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.
@@ -3524,7 +3507,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))
@@ -3568,9 +3550,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)) |
@@ -3595,7 +3575,7 @@ purposes internal to the MySQL server", MYF(0));
send_ok(thd);
}
else
- res= -1;
+ goto error;
break;
}
case SQLCOM_ROLLBACK:
@@ -3617,7 +3597,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:
@@ -3629,29 +3609,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_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
delete lex->sphead;
lex->sphead= 0;
goto error;
@@ -3665,7 +3642,7 @@ purposes internal to the MySQL server", MYF(0));
if (udf)
{
- net_printf(thd, ER_UDF_EXISTS, name);
+ my_printf_error(ER_UDF_EXISTS, ER(ER_UDF_EXISTS), MYF(0), name);
delete lex->sphead;
lex->sphead= 0;
goto error;
@@ -3675,14 +3652,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_printf_error(ER_SP_NORETURN, ER(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();
@@ -3690,19 +3667,22 @@ 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_printf_error(ER_SP_ALREADY_EXISTS, ER(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_printf_error(ER_BAD_DB_ERROR, ER(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_printf_error(ER_SP_STORE_FAILED, ER(ER_SP_STORE_FAILED), MYF(0),
+ SP_TYPE_STRING(lex), name);
lex->unit.cleanup();
delete lex->sphead;
lex->sphead= 0;
@@ -3716,8 +3696,9 @@ 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_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
+ MYF(0), "PROCEDURE",
+ lex->spname->m_qname.str);
goto error;
}
else
@@ -3731,17 +3712,11 @@ 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
- /*
- When executing substatements, they're assumed to send_error when
- it happens, but not to send_ok.
- */
my_bool nsok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
#endif
@@ -3749,7 +3724,7 @@ purposes internal to the MySQL server", MYF(0));
{
if (! (thd->client_capabilities & CLIENT_MULTI_RESULTS))
{
- send_error(thd, ER_SP_BADSELECT);
+ my_message(ER_SP_BADSELECT, ER(ER_SP_BADSELECT), MYF(0));
#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
#endif
@@ -3782,7 +3757,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
@@ -3792,6 +3767,7 @@ purposes internal to the MySQL server", MYF(0));
case SQLCOM_ALTER_PROCEDURE:
case SQLCOM_ALTER_FUNCTION:
{
+ int result;
sp_head *sp;
st_sp_chistics chistics;
@@ -3802,32 +3778,29 @@ purposes internal to the MySQL server", MYF(0));
sp= sp_find_function(thd, lex->spname);
mysql_reset_errors(thd);
if (! sp)
- res= SP_KEY_NOT_FOUND;
+ result= SP_KEY_NOT_FOUND;
else
{
if (check_sp_definer_access(thd, sp))
- {
- res= -1;
- break;
- }
+ goto error;
memcpy(&lex->sp_chistics, &chistics, sizeof(lex->sp_chistics));
if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
- res= sp_update_procedure(thd, lex->spname, &lex->sp_chistics);
+ result= sp_update_procedure(thd, lex->spname, &lex->sp_chistics);
else
- res= sp_update_function(thd, lex->spname, &lex->sp_chistics);
+ result= sp_update_function(thd, lex->spname, &lex->sp_chistics);
}
- switch (res)
+ 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),
- lex->spname->m_qname.str);
+ my_printf_error(ER_SP_DOES_NOT_EXIST, ER(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),
- lex->spname->m_qname.str);
+ my_printf_error(ER_SP_CANT_ALTER, ER(ER_SP_CANT_ALTER), MYF(0),
+ SP_COM_STRING(lex), lex->spname->m_qname.str);
goto error;
}
break;
@@ -3836,6 +3809,7 @@ purposes internal to the MySQL server", MYF(0));
case SQLCOM_DROP_FUNCTION:
{
sp_head *sp;
+ int result;
if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
sp= sp_find_procedure(thd, lex->spname);
@@ -3843,21 +3817,18 @@ purposes internal to the MySQL server", MYF(0));
sp= sp_find_function(thd, lex->spname);
mysql_reset_errors(thd);
if (! sp)
- res= SP_KEY_NOT_FOUND;
+ result= SP_KEY_NOT_FOUND;
else
{
if (check_sp_definer_access(thd, sp))
- {
- res= -1;
- break;
- }
+ goto error;
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);
@@ -3875,7 +3846,8 @@ purposes internal to the MySQL server", MYF(0));
#endif
}
}
- switch (res)
+ res= result;
+ switch (result)
{
case SP_OK:
send_ok(thd);
@@ -3886,34 +3858,32 @@ 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_printf_error(ER_SP_DOES_NOT_EXIST, ER(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_printf_error(ER_SP_DROP_FAILED, ER(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_printf_error(ER_TOO_LONG_IDENT, ER(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_printf_error(ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), MYF(0),
+ SP_COM_STRING(lex), lex->spname->m_name.str);
goto error;
}
break;
@@ -3922,18 +3892,16 @@ 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_printf_error(ER_TOO_LONG_IDENT, ER(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_printf_error(ER_SP_DOES_NOT_EXIST, ER(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:
@@ -3955,13 +3923,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;
}
@@ -4029,17 +3993,10 @@ 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);
}
@@ -4118,7 +4075,8 @@ 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_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR),
+ MYF(0)); /* purecov: tested */
DBUG_RETURN(TRUE); /* purecov: tested */
}
@@ -4145,10 +4103,13 @@ 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_printf_error(ER_ACCESS_DENIED_ERROR,
+ ER(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 */
}
@@ -4175,10 +4136,13 @@ 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_printf_error(ER_DBACCESS_DENIED_ERROR,
+ ER(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 */
}
@@ -4212,8 +4176,8 @@ 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_printf_error(ER_SPECIFIC_ACCESS_DENIED_ERROR,
+ ER(ER_SPECIFIC_ACCESS_DENIED_ERROR), MYF(0), command);
return 1;
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
}
@@ -4328,7 +4292,8 @@ 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_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR),
+ MYF(0)); /* purecov: tested */
return TRUE; /* purecov: tested */
}
}
@@ -4366,7 +4331,8 @@ check_sp_definer_access(THD *thd, sp_head *sp)
strncmp(thd->priv_host, hst->str, hst->length) == 0)
return FALSE; /* Both user and host must match */
- my_error(ER_SP_ACCESS_DENIED_ERROR, MYF(0), sp->m_qname.str);
+ my_printf_error(ER_SP_ACCESS_DENIED_ERROR, ER(ER_SP_ACCESS_DENIED_ERROR),
+ MYF(0), sp->m_qname.str);
return TRUE; /* Not definer or root */
}
@@ -4528,7 +4494,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);
@@ -4629,7 +4595,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)
@@ -4745,7 +4710,8 @@ 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_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0),
+ field_name); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
if (type_modifier & PRI_KEY_FLAG)
@@ -4776,7 +4742,8 @@ 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_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0),
+ field_name);
DBUG_RETURN(1);
}
else if (default_value->type() == Item::NULL_ITEM)
@@ -4785,20 +4752,23 @@ 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_printf_error(ER_INVALID_DEFAULT, ER(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_printf_error(ER_INVALID_DEFAULT, ER(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_printf_error(ER_INVALID_ON_UPDATE, ER(ER_INVALID_ON_UPDATE), MYF(0),
+ field_name);
DBUG_RETURN(1);
}
@@ -4924,7 +4894,9 @@ 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_printf_error(ER_BLOB_CANT_HAVE_DEFAULT,
+ ER(ER_BLOB_CANT_HAVE_DEFAULT), MYF(0),
+ field_name); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
new_field->def=0;
@@ -4944,7 +4916,8 @@ 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_printf_error(ER_WRONG_FIELD_SPEC, ER(ER_WRONG_FIELD_SPEC), MYF(0),
+ field_name);
DBUG_RETURN(1);
}
else if (tmp_length > PRECISION_FOR_FLOAT)
@@ -5041,7 +5014,8 @@ 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_printf_error(ER_TOO_BIG_SET, ER(ER_TOO_BIG_SET), MYF(0),
+ field_name); /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
new_field->pack_length=(interval->count+7)/8;
@@ -5067,7 +5041,8 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
&not_used, &not_used2, &not_used3);
if (thd->cuted_fields)
{
- net_printf(thd,ER_INVALID_DEFAULT,field_name);
+ my_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0),
+ field_name);
DBUG_RETURN(1);
}
}
@@ -5089,7 +5064,8 @@ 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_printf_error(ER_INVALID_DEFAULT, ER(ER_INVALID_DEFAULT), MYF(0),
+ field_name);
DBUG_RETURN(1);
}
}
@@ -5103,14 +5079,15 @@ 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_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(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_printf_error(ER_WRONG_FIELD_SPEC, ER(ER_WRONG_FIELD_SPEC), MYF(0),
+ field_name);
DBUG_RETURN(1);
}
if (!new_field->pack_length)
@@ -5240,7 +5217,8 @@ 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_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
+ table->table.str);
DBUG_RETURN(0);
}
@@ -5248,7 +5226,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
{
if (table->sel)
{
- net_printf(thd,ER_DERIVED_MUST_HAVE_ALIAS);
+ my_message(ER_DERIVED_MUST_HAVE_ALIAS,
+ ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0));
DBUG_RETURN(0);
}
if (!(alias_str=thd->memdup(alias_str,table->table.length+1)))
@@ -5304,7 +5283,8 @@ 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_printf_error(ER_NONUNIQ_TABLE, ER(ER_NONUNIQ_TABLE), MYF(0),
+ alias_str); /* purecov: tested */
DBUG_RETURN(0); /* purecov: tested */
}
}
@@ -5800,7 +5780,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 */
@@ -5848,7 +5828,8 @@ static bool append_file_to_dir(THD *thd, const char **filename_ptr,
if (strlen(*filename_ptr)+strlen(table_name) >= FN_REFLEN-1 ||
!test_if_hard_path(*filename_ptr))
{
- my_error(ER_WRONG_TABLE_NAME, MYF(0), *filename_ptr);
+ my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
+ *filename_ptr);
return 1;
}
/* Fix is using unix filename format on dos */
@@ -5882,7 +5863,8 @@ bool check_simple_select()
char command[80];
strmake(command, lex->yylval->symbol.str,
min(lex->yylval->symbol.length, sizeof(command)-1));
- net_printf(thd, ER_CANT_USE_OPTION_HERE, command);
+ my_printf_error(ER_CANT_USE_OPTION_HERE, ER(ER_CANT_USE_OPTION_HERE),
+ MYF(0), command);
return 1;
}
return 0;
@@ -5970,7 +5952,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;
@@ -5987,7 +5969,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;
@@ -6014,12 +5996,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;
@@ -6029,8 +6010,8 @@ 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);
+ my_printf_error(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
+ DBUG_RETURN(TRUE);
}
/*
Ensure that we have UPDATE or SELECT privilege for each table
@@ -6047,7 +6028,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;
}
@@ -6064,7 +6045,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);
}
}
}
@@ -6077,9 +6058,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);
}
/*
@@ -6092,11 +6073,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=
@@ -6111,11 +6092,12 @@ 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);
+ my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
+ ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
+ DBUG_RETURN(TRUE);
}
for (target_tbl= aux_tables; target_tbl; target_tbl= target_tbl->next_local)
{
@@ -6131,14 +6113,14 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
}
if (!walk)
{
- my_error(ER_UNKNOWN_TABLE, MYF(0), target_tbl->real_name,
- "MULTI DELETE");
- DBUG_RETURN(-1);
+ my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0),
+ target_tbl->real_name, "MULTI DELETE");
+ DBUG_RETURN(TRUE);
}
walk->lock_type= target_tbl->lock_type;
target_tbl->correspondent_table= walk; // Remember corresponding table
}
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -6151,12 +6133,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");
/*
@@ -6165,7 +6146,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));
}
@@ -6178,21 +6159,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);
+ my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
+ 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));
}
@@ -6205,19 +6185,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);
}
@@ -6230,12 +6209,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 insert_precheck(THD *thd, TABLE_LIST *tables)
{
LEX *lex= thd->lex;
DBUG_ENTER("insert_precheck");
@@ -6245,14 +6223,14 @@ int insert_precheck(THD *thd, TABLE_LIST *tables)
(lex->value_list.elements ? UPDATE_ACL : 0));
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);
+ my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
+ DBUG_RETURN(TRUE);
}
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -6266,17 +6244,17 @@ int insert_precheck(THD *thd, TABLE_LIST *tables)
create_table Table which will be created
RETURN VALUE
- 0 OK
- 1 Error (message is 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;
SELECT_LEX *select_lex= &lex->select_lex;
ulong want_priv;
- int error= 1; // Error message is given
+ bool error= TRUE; // Error message is given
DBUG_ENTER("create_table_precheck");
want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ?
@@ -6318,7 +6296,7 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables,
if (tables && check_table_access(thd, SELECT_ACL, tables,0))
goto err;
}
- error= 0;
+ error= FALSE;
err:
DBUG_RETURN(error);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 75cfac5f58a..e29f6329e58 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -123,16 +123,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);
@@ -140,8 +137,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;
@@ -181,7 +176,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;
}
@@ -882,24 +877,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;
DBUG_ENTER("mysql_test_insert");
if ((res= insert_precheck(thd, table_list)))
@@ -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,10 +1056,10 @@ 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 (!lex->result && !(lex->result= new (stmt->mem_root) select_send))
@@ -1078,19 +1069,14 @@ static int mysql_test_select(Prepared_statement *stmt,
}
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)
@@ -1120,7 +1106,7 @@ static int mysql_test_select(Prepared_statement *stmt,
goto err_prep;
}
}
- result= 0; // ok
+ result= FALSE; // ok
err_prep:
unit->cleanup();
@@ -1139,30 +1125,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);
}
@@ -1176,22 +1159,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;
@@ -1200,7 +1182,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;
}
}
@@ -1220,18 +1202,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;
@@ -1244,7 +1225,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();
@@ -1301,16 +1282,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;
/*
here we do not pass tables for opening, tables will be opened and locked
by mysql_multi_update_prepare
@@ -1513,15 +1493,13 @@ static int check_prepared_statement(Prepared_statement *stmt,
All other is not supported yet
*/
res= -1;
- my_error(ER_UNSUPPORTED_PS, MYF(0));
+ my_message(ER_UNSUPPORTED_PS, ER(ER_UNSUPPORTED_PS), MYF(0));
goto error;
}
if (res == 0)
DBUG_RETURN(text_protocol? 0 : (send_prep_stmt(stmt, 0) ||
thd->protocol->flush()));
error:
- if (res < 0)
- send_error(thd,thd->killed_errno());
DBUG_RETURN(1);
}
@@ -1551,10 +1529,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(thd, ER_OUT_OF_RESOURCES);
return 1;
- }
for (to= stmt->param_array;
to < stmt->param_array + stmt->param_count;
++to)
@@ -1578,10 +1553,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
@@ -1595,21 +1570,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)
{
@@ -1618,16 +1590,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);
@@ -1639,8 +1609,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);
@@ -1828,8 +1797,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));
@@ -1837,7 +1805,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;
}
@@ -1859,10 +1827,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
DBUG_PRINT("info",("Using READ_ONLY cursor"));
if (!stmt->cursor &&
!(stmt->cursor= new (&stmt->main_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;
}
@@ -1930,7 +1895,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;
}
@@ -1956,14 +1920,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;
}
@@ -1976,7 +1938,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;
@@ -2066,7 +2027,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;
}
@@ -2117,8 +2077,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;
@@ -2149,8 +2108,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 */
@@ -2200,8 +2158,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_rename.cc b/sql/sql_rename.cc
index 3298eb68a91..25874e1335a 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -44,7 +44,8 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
if (thd->locked_tables || thd->active_transaction())
{
- my_error(ER_LOCK_OR_ACTIVE_TRANSACTION,MYF(0));
+ my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
+ ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
DBUG_RETURN(1);
}
@@ -156,7 +157,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
unpack_filename(name, name);
if (!access(name,F_OK))
{
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_alias);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_alias);
DBUG_RETURN(ren_table); // This can't be skipped
}
sprintf(name,"%s/%s/%s%s",mysql_data_home,
@@ -165,7 +167,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
unpack_filename(name, name);
if ((table_type=get_table_type(name)) == DB_TYPE_UNKNOWN)
{
- my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
+ my_printf_error(ER_FILE_NOT_FOUND, ER(ER_FILE_NOT_FOUND), MYF(0),
+ name, my_errno);
if (!skip_error)
DBUG_RETURN(ren_table);
}
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 10f0c23f54d..3ef7e01d248 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -276,41 +276,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_message(errmsg, ER(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(thd);
- return 0;
+ return FALSE;
}
mysql_bin_log.make_log_name(search_file_name, to_log);
@@ -320,7 +318,7 @@ 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)
{
if (!mysql_bin_log.is_open())
{
@@ -756,7 +754,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;
}
@@ -872,7 +870,7 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (slave_errno)
{
if (net_report)
- send_error(thd, slave_errno);
+ my_message(slave_errno, ER(slave_errno), MYF(0));
DBUG_RETURN(1);
}
else if (net_report)
@@ -922,7 +920,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
if (slave_errno)
{
if (net_report)
- send_error(thd, slave_errno);
+ my_message(slave_errno, ER(slave_errno), MYF(0));
return 1;
}
else if (net_report)
@@ -1003,8 +1001,8 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
err:
unlock_slave_threads(mi);
- if (error)
- my_error(sql_errno, MYF(0), errmsg);
+ if (error)
+ my_printf_error(sql_errno, ER(sql_errno), MYF(0), errmsg);
DBUG_RETURN(error);
}
@@ -1057,7 +1055,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;
@@ -1068,9 +1066,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_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0));
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
thd->proc_info = "Changing master";
@@ -1078,9 +1076,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_message(ER_MASTER_INFO, ER(ER_MASTER_INFO), MYF(0));
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
/*
@@ -1197,9 +1195,10 @@ 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_printf_error(ER_RELAY_LOG_FAIL, ER(ER_RELAY_LOG_FAIL), MYF(0),
+ errmsg);
unlock_slave_threads(mi);
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
}
else
@@ -1213,9 +1212,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_printf_error(ER_RELAY_LOG_INIT, ER(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;
@@ -1257,14 +1256,15 @@ 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)
{
if (!mysql_bin_log.is_open())
{
- my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
+ my_message(ER_FLUSH_MASTER_BINLOG_CLOSED,
+ ER(ER_FLUSH_MASTER_BINLOG_CLOSED), MYF(ME_BELL+ME_WAITTANG));
return 1;
}
return mysql_bin_log.reset_logs(thd);
@@ -1288,7 +1288,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");
@@ -1302,7 +1302,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())
{
@@ -1406,20 +1406,21 @@ err:
if (errmsg)
{
- my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),
- "SHOW BINLOG EVENTS", errmsg);
- DBUG_RETURN(-1);
+ my_printf_error(ER_ERROR_WHEN_EXECUTING_COMMAND,
+ ER(ER_ERROR_WHEN_EXECUTING_COMMAND), MYF(0),
+ "SHOW BINLOG EVENTS", errmsg);
+ 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");
@@ -1432,7 +1433,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())
@@ -1445,10 +1446,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);
}
@@ -1460,11 +1461,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];
@@ -1475,15 +1476,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_message(ER_NO_BINARY_LOGGING, ER(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();
@@ -1501,11 +1501,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 66fdfb4c022..71b25548da4 100644
--- a/sql/sql_repl.h
+++ b/sql/sql_repl.h
@@ -43,17 +43,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 d07e274b0b7..f0584837028 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -205,9 +205,9 @@ static void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
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");
@@ -232,11 +232,14 @@ int handle_select(THD *thd, LEX *lex, select_result *result)
}
DBUG_PRINT("info",("res: %d report_error: %d", res,
thd->net.report_error));
- if (thd->net.report_error || res < 0)
+ res|= thd->net.report_error;
+ if (unlikely(res))
{
- 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);
}
@@ -374,7 +377,8 @@ JOIN::prepare(Item ***rref_pointer_array,
}
if (flag == 3)
{
- my_error(ER_MIX_OF_GROUP_FUNC_AND_FIELDS,MYF(0));
+ my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS,
+ ER(ER_MIX_OF_GROUP_FUNC_AND_FIELDS), MYF(0));
DBUG_RETURN(-1);
}
}
@@ -401,21 +405,22 @@ 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_message(ER_DIFF_GROUPS_PROC, ER(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_message(ER_ORDER_WITH_PROC, ER(ER_ORDER_WITH_PROC),
+ MYF(0)); /* purecov: inspected */
goto err; /* purecov: inspected */
}
}
@@ -1803,7 +1808,7 @@ Cursor::fetch(ulong num_rows)
if (thd->killed) /* Aborted by user */
{
- my_error(ER_SERVER_SHUTDOWN,MYF(0));
+ my_message(ER_SERVER_SHUTDOWN, ER(ER_SERVER_SHUTDOWN), MYF(0));
return -1;
}
@@ -1940,7 +1945,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,
@@ -1948,7 +1953,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");
@@ -1956,7 +1961,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))
{
@@ -1965,7 +1973,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
@@ -1984,7 +1992,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,
@@ -2032,10 +2040,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);
}
@@ -2192,7 +2198,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
if (s->dependent & s->table->map)
{
join->tables=0; // Don't use join->table
- my_error(ER_WRONG_OUTER_JOIN,MYF(0));
+ my_message(ER_WRONG_OUTER_JOIN, ER(ER_WRONG_OUTER_JOIN), MYF(0));
DBUG_RETURN(1);
}
s->key_dependent= s->dependent;
@@ -5614,7 +5620,8 @@ bool error_if_full_join(JOIN *join)
{
if (tab->type == JT_ALL && (!tab->select || !tab->select->quick))
{
- my_error(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,MYF(0));
+ my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE,
+ ER(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE), MYF(0));
return(1);
}
}
@@ -10717,7 +10724,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
}
if (copy_blobs(first_field))
{
- my_error(ER_OUTOFMEMORY,MYF(0));
+ my_message(ER_OUTOFMEMORY, ER(ER_OUTOFMEMORY), MYF(0));
error=0;
goto err;
}
@@ -12736,10 +12743,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;
@@ -12790,9 +12797,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);
}
@@ -13003,17 +13008,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 e1bf60f6896..7fd9bf48b0b 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -333,7 +333,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 7043379bf8f..b46834882c6 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;
@@ -846,16 +839,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;
@@ -868,18 +861,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);
+ my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0),
+ table_list->db, table_list->real_name, "VIEW");
+ DBUG_RETURN(TRUE);
}
table= table_list->table;
@@ -887,7 +878,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)
@@ -906,31 +897,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];
@@ -947,8 +938,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_printf_error(ER_WRONG_DB_NAME, ER(ER_WRONG_DB_NAME), MYF(0), dbname);
+ DBUG_RETURN(TRUE);
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -959,11 +950,12 @@ 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_printf_error(ER_DBACCESS_DENIED_ERROR,
+ ER(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
@@ -977,8 +969,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_printf_error(ER_BAD_DB_ERROR, ER(ER_BAD_DB_ERROR), MYF(0), dbname);
+ DBUG_RETURN(TRUE);
}
if (found_libchar)
path[length-1]= FN_LIBCHAR;
@@ -991,7 +983,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);
@@ -1016,12 +1008,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;
@@ -1034,19 +1026,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;
@@ -1057,8 +1049,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;
@@ -1084,7 +1075,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);
@@ -1135,11 +1126,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);
}
@@ -1157,12 +1148,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;
@@ -1828,7 +1815,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());
@@ -1836,7 +1823,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));
@@ -1847,7 +1834,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++ )
{
@@ -1868,10 +1855,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)
@@ -1884,7 +1871,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());
@@ -1901,7 +1888,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++ )
{
@@ -1914,18 +1901,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;
@@ -1937,7 +1924,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;
@@ -2229,11 +2216,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 e73bf81eb74..301130c13ca 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -63,15 +63,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 */
@@ -84,9 +84,10 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
{
if (thd->global_read_lock)
{
- my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0),
- tables->real_name);
- error= 1;
+ my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
+ ER(ER_TABLE_NOT_LOCKED_FOR_WRITE), MYF(0),
+ tables->real_name);
+ error= TRUE;
goto err;
}
while (global_read_lock && ! thd->killed)
@@ -106,9 +107,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);
}
@@ -268,9 +269,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (wrong_tables.length())
{
if (!foreign_key_error)
- my_error(ER_BAD_TABLE_ERROR,MYF(0), wrong_tables.c_ptr());
+ my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
+ wrong_tables.c_ptr());
else
- my_error(ER_ROW_IS_REFERENCED, MYF(0));
+ my_message(ER_ROW_IS_REFERENCED, ER(ER_ROW_IS_REFERENCED), MYF(0));
error= 1;
}
@@ -468,7 +470,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (check_column_name(sql_field->field_name))
{
- my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name);
+ my_printf_error(ER_WRONG_COLUMN_NAME, ER(ER_WRONG_COLUMN_NAME), MYF(0),
+ sql_field->field_name);
DBUG_RETURN(-1);
}
@@ -485,7 +488,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (field_no < select_field_pos || dup_no >= select_field_pos)
{
- my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name);
+ my_printf_error(ER_DUP_FIELDNAME, ER(ER_DUP_FIELDNAME), MYF(0),
+ sql_field->field_name);
DBUG_RETURN(-1);
}
else
@@ -626,24 +630,27 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (timestamps_with_niladic > 1)
{
- my_error(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS,MYF(0));
+ my_message(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS,
+ ER(ER_TOO_MUCH_AUTO_TIMESTAMP_COLS), MYF(0));
DBUG_RETURN(-1);
}
if (auto_increment > 1)
{
- my_error(ER_WRONG_AUTO_KEY,MYF(0));
+ my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));
DBUG_RETURN(-1);
}
if (auto_increment &&
(file->table_flags() & HA_NO_AUTO_INCREMENT))
{
- my_error(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,MYF(0));
+ my_message(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT,
+ ER(ER_TABLE_CANT_HANDLE_AUTO_INCREMENT), MYF(0));
DBUG_RETURN(-1);
}
if (blob_columns && (file->table_flags() & HA_NO_BLOBS))
{
- my_error(ER_TABLE_CANT_HANDLE_BLOB,MYF(0));
+ my_message(ER_TABLE_CANT_HANDLE_BLOB, ER(ER_TABLE_CANT_HANDLE_BLOB),
+ MYF(0));
DBUG_RETURN(-1);
}
@@ -669,9 +676,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (fk_key->ref_columns.elements &&
fk_key->ref_columns.elements != fk_key->columns.elements)
{
- my_error(ER_WRONG_FK_DEF, MYF(0), fk_key->name ? fk_key->name :
- "foreign key without name",
- ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
+ my_printf_error(ER_WRONG_FK_DEF, ER(ER_WRONG_FK_DEF), MYF(0),
+ (fk_key->name ?
+ fk_key->name :
+ "foreign key without name"),
+ ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
DBUG_RETURN(-1);
}
continue;
@@ -685,7 +694,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (key->name && strlen(key->name) > NAME_LEN)
{
- my_error(ER_TOO_LONG_IDENT, MYF(0), key->name);
+ my_printf_error(ER_TOO_LONG_IDENT, ER(ER_TOO_LONG_IDENT), MYF(0),
+ key->name);
DBUG_RETURN(-1);
}
key_iterator2.rewind ();
@@ -725,7 +735,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (key->name && !tmp_table &&
!my_strcasecmp(system_charset_info,key->name,primary_key_name))
{
- my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name);
+ my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
+ MYF(0), key->name);
DBUG_RETURN(-1);
}
}
@@ -793,7 +804,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
if (!(file->table_flags() & HA_CAN_FULLTEXT))
{
- my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0));
+ my_message(ER_TABLE_CANT_HANDLE_FT, ER(ER_TABLE_CANT_HANDLE_FT),
+ MYF(0));
DBUG_RETURN(-1);
}
}
@@ -934,7 +946,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (key->type == Key::SPATIAL)
{
- my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0));
+ my_message(ER_SPATIAL_CANT_HAVE_NULL,
+ ER(ER_SPATIAL_CANT_HAVE_NULL), MYF(0));
DBUG_RETURN(-1);
}
}
@@ -980,7 +993,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
(key_info->flags & HA_NOSAME))) &&
column->length != length)))
{
- my_error(ER_WRONG_SUB_KEY,MYF(0));
+ my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0));
DBUG_RETURN(-1);
}
else if (!(file->table_flags() & HA_NO_PREFIX_CHAR_KEYS))
@@ -1033,7 +1046,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{
if (primary_key)
{
- my_error(ER_MULTIPLE_PRI_KEY,MYF(0));
+ my_message(ER_MULTIPLE_PRI_KEY, ER(ER_MULTIPLE_PRI_KEY),
+ MYF(0));
DBUG_RETURN(-1);
}
key_name=primary_key_name;
@@ -1044,7 +1058,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
key_info_buffer,key_info);
if (check_if_keyname_exists(key_name,key_info_buffer,key_info))
{
- my_error(ER_DUP_KEYNAME,MYF(0),key_name);
+ my_printf_error(ER_DUP_KEYNAME, ER(ER_DUP_KEYNAME), MYF(0),
+ key_name);
DBUG_RETURN(-1);
}
key_info->name=(char*) key_name;
@@ -1052,7 +1067,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
if (!key_info->name || check_column_name(key_info->name))
{
- my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name);
+ my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
+ MYF(0), key_info->name);
DBUG_RETURN(-1);
}
if (!(key_info->flags & HA_NULL_PART_KEY))
@@ -1069,12 +1085,12 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
if (!unique_key && !primary_key &&
(file->table_flags() & HA_REQUIRE_PRIMARY_KEY))
{
- my_error(ER_REQUIRES_PRIMARY_KEY,MYF(0));
+ my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0));
DBUG_RETURN(-1);
}
if (auto_increment > 0)
{
- my_error(ER_WRONG_AUTO_KEY,MYF(0));
+ my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0));
DBUG_RETURN(-1);
}
/* Sort keys in optimized order */
@@ -1108,30 +1124,31 @@ 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");
/* Check for duplicate fields and check type of table to create */
if (!fields.elements)
{
- my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0));
- DBUG_RETURN(-1);
+ my_message(ER_TABLE_MUST_HAVE_COLUMNS, ER(ER_TABLE_MUST_HAVE_COLUMNS),
+ MYF(0));
+ DBUG_RETURN(TRUE);
}
if ((new_db_type= ha_checktype(create_info->db_type)) !=
create_info->db_type)
@@ -1160,8 +1177,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
(file->table_flags() & HA_NO_TEMP_TABLES))
{
- my_error(ER_ILLEGAL_HA,MYF(0),table_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0), table_name);
+ DBUG_RETURN(TRUE);
}
#endif
@@ -1186,7 +1203,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)
@@ -1209,10 +1226,11 @@ 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);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), MYF(0),
+ alias);
+ DBUG_RETURN(TRUE);
}
if (wait_if_global_read_lock(thd, 0, 1))
DBUG_RETURN(error);
@@ -1224,10 +1242,11 @@ 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);
+ my_printf_error(ER_TABLE_EXISTS_ERROR,
+ ER(ER_TABLE_EXISTS_ERROR), MYF(0), table_name);
goto end;
}
}
@@ -1253,10 +1272,11 @@ 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);
+ my_printf_error(ER_TABLE_EXISTS_ERROR,
+ ER(ER_TABLE_EXISTS_ERROR), MYF(0), table_name);
goto end;
}
}
@@ -1292,7 +1312,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);
@@ -1475,7 +1495,8 @@ mysql_rename_table(enum db_type base,
}
delete file;
if (error)
- my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error);
+ my_printf_error(ER_ERROR_ON_RENAME, ER(ER_ERROR_ON_RENAME),
+ MYF(0), from, to, error);
DBUG_RETURN(error != 0);
}
@@ -1565,7 +1586,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;
@@ -1742,20 +1763,20 @@ end:
/*
RETURN VALUES
- 0 Message sent to net (admin operation went ok)
- -1 Message should be sent by caller
- (admin operation or network communication failed)
+ FALSE Message sent to net (admin operation went ok)
+ TRUE Message should be sent by caller
+ (admin operation or network communication failed)
*/
-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;
@@ -1773,7 +1794,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_flush(thd, tables, MYSQL_HA_CLOSE_FINAL);
for (table= tables; table; table= table->next_local)
@@ -1785,9 +1806,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)
@@ -1813,7 +1831,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;
@@ -1857,9 +1875,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);
@@ -1960,16 +1976,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,
@@ -1978,7 +1994,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,
@@ -1988,7 +2004,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,
@@ -1998,7 +2014,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,
@@ -2016,11 +2032,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;
@@ -2032,8 +2048,9 @@ int mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
if (!(key_cache= get_key_cache(key_cache_name)))
{
pthread_mutex_unlock(&LOCK_global_system_variables);
- my_error(ER_UNKNOWN_KEY_CACHE, MYF(0), key_cache_name->str);
- DBUG_RETURN(-1);
+ my_printf_error(ER_UNKNOWN_KEY_CACHE, ER(ER_UNKNOWN_KEY_CACHE), MYF(0),
+ key_cache_name->str);
+ DBUG_RETURN(TRUE);
}
pthread_mutex_unlock(&LOCK_global_system_variables);
check_opt.key_cache= key_cache;
@@ -2091,11 +2108,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,
@@ -2115,13 +2132,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];
@@ -2129,7 +2146,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");
@@ -2141,8 +2159,9 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
check_table_name(src_table,table_ident->table.length)) ||
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);
+ my_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME), MYF(0),
+ src_table);
+ DBUG_RETURN(TRUE);
}
bzero((gptr)&src_tables_list, sizeof(src_tables_list));
@@ -2160,7 +2179,8 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
reg_ext, NullS);
if (access(src_path, F_OK))
{
- my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table);
+ my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
+ src_table);
goto err;
}
}
@@ -2229,7 +2249,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:
@@ -2240,10 +2260,11 @@ 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);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), MYF(0),
+ table_name);
err:
pthread_mutex_lock(&LOCK_open);
@@ -2253,7 +2274,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;
@@ -2268,7 +2289,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;
@@ -2502,7 +2523,8 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
}
if (idx>= table->keys)
{
- my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), drop_key->name);
+ my_printf_error(ER_CANT_DROP_FIELD_OR_KEY, ER(ER_CANT_DROP_FIELD_OR_KEY),
+ MYF(0), drop_key->name);
/*don't need to free((gptr) key_numbers);*/
DBUG_RETURN(-1);
}
@@ -2559,13 +2581,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=0;
int error;
@@ -2594,7 +2616,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)
@@ -2625,8 +2647,9 @@ 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);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_name_buff);
+ DBUG_RETURN(TRUE);
}
}
else
@@ -2637,8 +2660,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
F_OK))
{
/* Table will be closed in do_command() */
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0), new_alias);
- DBUG_RETURN(-1);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_alias);
+ DBUG_RETURN(TRUE);
}
}
}
@@ -2678,7 +2702,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
error=0;
if (!access(new_name_buff,F_OK))
{
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_name);
error= -1;
}
else
@@ -2822,8 +2847,9 @@ 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);
+ my_printf_error(ER_BLOB_CANT_HAVE_DEFAULT,
+ ER(ER_BLOB_CANT_HAVE_DEFAULT), MYF(0), def->change);
+ DBUG_RETURN(TRUE);
}
def->def=alter->def; // Use new default
alter_it.remove();
@@ -2836,8 +2862,9 @@ 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);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
+ def->change, table_name);
+ DBUG_RETURN(TRUE);
}
if (!def->after)
create_list.push_back(def);
@@ -2854,22 +2881,24 @@ 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);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR),
+ MYF(0), def->after, table_name);
+ DBUG_RETURN(TRUE);
}
find_it.after(def); // Put element after this
}
}
if (alter_info->alter_list.elements)
{
- my_error(ER_BAD_FIELD_ERROR,MYF(0),alter_info->alter_list.head()->name,
- table_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0),
+ alter_info->alter_list.head()->name, table_name);
+ DBUG_RETURN(TRUE);
}
if (!create_list.elements)
{
- my_error(ER_CANT_REMOVE_ALL_FIELDS,MYF(0));
- DBUG_RETURN(-1);
+ my_message(ER_CANT_REMOVE_ALL_FIELDS, ER(ER_CANT_REMOVE_ALL_FIELDS),
+ MYF(0));
+ DBUG_RETURN(TRUE);
}
/*
@@ -2957,22 +2986,25 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (key->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);
+ my_printf_error(ER_WRONG_NAME_FOR_INDEX, ER(ER_WRONG_NAME_FOR_INDEX),
+ MYF(0), key->name);
+ DBUG_RETURN(TRUE);
}
}
}
if (alter_info->drop_list.elements)
{
- my_error(ER_CANT_DROP_FIELD_OR_KEY,MYF(0),
- alter_info->drop_list.head()->name);
+ my_printf_error(ER_CANT_DROP_FIELD_OR_KEY,
+ ER(ER_CANT_DROP_FIELD_OR_KEY), MYF(0),
+ alter_info->drop_list.head()->name);
goto err;
}
if (alter_info->alter_list.elements)
{
- my_error(ER_CANT_DROP_FIELD_OR_KEY,MYF(0),
- alter_info->alter_list.head()->name);
+ my_printf_error(ER_CANT_DROP_FIELD_OR_KEY,
+ ER(ER_CANT_DROP_FIELD_OR_KEY), MYF(0),
+ alter_info->alter_list.head()->name);
goto err;
}
@@ -3175,7 +3207,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (!access(new_name_buff,F_OK))
{
error=1;
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), new_name_buff);
VOID(quick_rm_table(new_db_type,new_db,tmp_name));
VOID(pthread_mutex_unlock(&LOCK_open));
goto err;
@@ -3313,10 +3346,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);
}
@@ -3502,8 +3535,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;
@@ -3525,7 +3558,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;
@@ -3539,7 +3572,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)
{
@@ -3558,7 +3591,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
{
@@ -3620,11 +3653,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 5d175be74e1..4a99296a7a5 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;
@@ -73,20 +74,21 @@ 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);
+ my_printf_error(ER_TRG_ON_VIEW_OR_TEMP_TABLE,
+ ER(ER_TRG_ON_VIEW_OR_TEMP_TABLE), MYF(0), tables->alias);
+ DBUG_RETURN(TRUE);
}
if (!table->triggers)
{
if (!create)
{
- my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
- DBUG_RETURN(-1);
+ my_message(ER_TRG_DOES_NOT_EXIST, ER(ER_TRG_DOES_NOT_EXIST), MYF(0));
+ DBUG_RETURN(TRUE);
}
if (!(table->triggers= new (&table->mem_root) Table_triggers_list()))
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
/*
@@ -96,12 +98,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);
@@ -140,7 +142,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables)
/* We don't allow creation of several triggers of the same type yet */
if (bodies[lex->trg_chistics.event][lex->trg_chistics.action_time])
{
- my_error(ER_TRG_ALREADY_EXISTS, MYF(0));
+ my_message(ER_TRG_ALREADY_EXISTS, ER(ER_TRG_ALREADY_EXISTS), MYF(0));
return 1;
}
@@ -150,7 +152,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables)
if (my_strcasecmp(system_charset_info, lex->name_and_length.str,
name->str) == 0)
{
- my_error(ER_TRG_ALREADY_EXISTS, MYF(0));
+ my_message(ER_TRG_ALREADY_EXISTS, ER(ER_TRG_ALREADY_EXISTS), MYF(0));
return 1;
}
}
@@ -256,7 +258,7 @@ bool Table_triggers_list::drop_trigger(THD *thd, TABLE_LIST *tables)
}
}
- my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
+ my_message(ER_TRG_DOES_NOT_EXIST, ER(ER_TRG_DOES_NOT_EXIST), MYF(0));
return 1;
}
@@ -416,8 +418,8 @@ err_with_lex_cleanup:
We don't care about this error message much because .TRG files will
be merged into .FRM anyway.
*/
- my_error(ER_WRONG_OBJECT, MYF(0), table_name, triggers_file_ext,
- "TRIGGER");
+ my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0),
+ table_name, triggers_file_ext, "TRIGGER");
DBUG_RETURN(1);
}
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 0bb8ac8a28b..964021ce7fa 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -368,7 +368,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_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
DBUG_RETURN(1);
}
@@ -379,19 +379,20 @@ 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_message(ER_UDF_NO_PATHS, ER(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_printf_error(ER_TOO_LONG_IDENT, ER(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_printf_error(ER_UDF_EXISTS, ER(ER_UDF_EXISTS), MYF(0), udf->name);
goto err;
}
if (!(dl = find_udf_dl(udf->dl)))
@@ -400,7 +401,8 @@ 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_printf_error(ER_CANT_OPEN_LIBRARY, ER(ER_CANT_OPEN_LIBRARY), MYF(0),
+ udf->dl, errno, dlerror());
goto err;
}
new_dl=1;
@@ -410,16 +412,14 @@ int mysql_create_function(THD *thd,udf_func *udf)
if (udf->func == NULL)
{
- net_printf(thd, ER_CANT_FIND_DL_ENTRY, udf->name);
+ my_printf_error(ER_CANT_FIND_DL_ENTRY, ER(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;
@@ -447,7 +447,8 @@ 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_printf_error(ER_ERROR_ON_WRITE, ER(ER_ERROR_ON_WRITE), MYF(0),
+ "func@mysql", error);
del_udf(u_d);
goto err;
}
@@ -470,14 +471,15 @@ 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_message(ER_OUT_OF_RESOURCES, ER(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_printf_error(ER_FUNCTION_NOT_DEFINED, ER(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 792e2cdf775..815e04c0111 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);
}
@@ -76,7 +75,7 @@ bool select_union::send_data(List<Item> &values)
unit->offset_limit_cnt--;
return 0;
}
- fill_record(table->field, values, 1);
+ fill_record(thd, table->field, values, 1);
if (thd->net.report_error || write_record(thd, table,&info))
{
if (thd->net.last_errno == ER_RECORD_FILE_FULL)
@@ -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;
@@ -177,16 +175,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;
@@ -239,7 +237,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
sl->with_wild= 0;
last_procedure= join->procedure;
- if (res || thd_arg->is_fatal_error)
+ if ((res= (res || thd_arg->is_fatal_error)))
goto err;
if (sl == first_select)
{
@@ -269,7 +267,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);
}
}
}
@@ -325,7 +323,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
{
if (tmp_arena)
thd->restore_backup_item_arena(tmp_arena, &backup);
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
}
if (tmp_arena)
@@ -343,7 +341,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;
@@ -378,15 +376,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();
@@ -395,7 +393,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)
@@ -410,7 +408,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())
{
@@ -465,7 +463,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;
@@ -474,7 +472,7 @@ int st_select_lex_unit::exec()
{
examined_rows+= thd->examined_row_count;
thd->lex->current_select= lex_select_save;
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
}
if (res)
@@ -500,7 +498,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();
@@ -519,7 +517,7 @@ int st_select_lex_unit::exec()
fake_select_lex->options, result)))
{
fake_select_lex->table_list.empty();
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
/*
@@ -566,7 +564,7 @@ int st_select_lex_unit::exec()
}
-int st_select_lex_unit::cleanup()
+bool st_select_lex_unit::cleanup()
{
int error= 0;
JOIN *join;
@@ -574,7 +572,7 @@ int st_select_lex_unit::cleanup()
if (cleaned)
{
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
cleaned= 1;
@@ -648,19 +646,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 9d382baf155..dfc46150847 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -73,7 +73,8 @@ static bool check_fields(THD *thd, List<Item> &items)
if (!(field= item->filed_for_view_update()))
{
/* item has name, because it comes from VIEW SELECT list */
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ my_printf_error(ER_NONUPDATEABLE_COLUMN, ER(ER_NONUPDATEABLE_COLUMN),
+ MYF(0), item->name);
return TRUE;
}
/*
@@ -86,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 +118,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 +157,17 @@ int mysql_update(THD *thd,
res= setup_fields(thd, 0, table_list, fields, 1, 0, 0);
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);
+ my_printf_error(ER_NON_UPDATABLE_TABLE, ER(ER_NON_UPDATABLE_TABLE),
+ MYF(0), table_list->alias, "UPDATE");
+ DBUG_RETURN(TRUE);
}
if (table->timestamp_field)
{
@@ -184,7 +186,7 @@ int mysql_update(THD *thd,
if (setup_fields(thd, 0, table_list, values, 0, 0, 0))
{
free_underlaid_joins(thd, 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 +199,10 @@ int mysql_update(THD *thd,
free_underlaid_joins(thd, 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())
@@ -362,8 +364,9 @@ int mysql_update(THD *thd,
if (!(select && select->skip_record()))
{
store_record(table,record[1]);
- if (fill_record(fields,values, 0) || thd->net.report_error)
+ if (fill_record(thd, fields, values, 0))
break; /* purecov: inspected */
+
found++;
if (table->triggers)
@@ -457,9 +460,7 @@ int mysql_update(THD *thd,
}
free_underlaid_joins(thd, 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,
@@ -473,7 +474,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(error >= 0 || thd->net.report_error);
err:
delete select;
@@ -484,7 +485,7 @@ err:
table->file->extra(HA_EXTRA_NO_KEYREAD);
}
thd->abort_on_warning= 0;
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
/*
@@ -499,11 +500,10 @@ err:
order - ORDER BY clause 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 mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
+bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
Item **conds, uint order_num, ORDER *order)
{
TABLE *table= table_list->table;
@@ -527,16 +527,17 @@ int mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
setup_order(thd, select_lex->ref_pointer_array,
table_list, all_fields, all_fields, order) ||
setup_ftfuncs(select_lex))
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
/* Check that we are not using table that we are updating in a sub select */
if (unique_table(table_list, table_list->next_global))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_UPDATE_TABLE_USED, ER(ER_UPDATE_TABLE_USED), MYF(0),
+ table_list->real_name);
+ DBUG_RETURN(TRUE);
}
select_lex->fix_prepare_information(thd, conds);
- DBUG_RETURN(0);
+ DBUG_RETURN(FALSE);
}
@@ -569,11 +570,11 @@ static table_map get_table_map(List<Item> *items)
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;
ulong opened_tables;
@@ -619,7 +620,7 @@ int mysql_multi_update_prepare(THD *thd)
res= setup_fields(thd, 0, table_list, *fields, 1, 0, 0),
lex->select_lex.no_wrap_view_item= 0,
res))
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
for (tl= table_list; tl ; tl= tl->next_local)
{
@@ -632,7 +633,7 @@ int mysql_multi_update_prepare(THD *thd)
if (update_view && check_fields(thd, *fields))
{
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
tables_for_update= get_table_map(fields);
@@ -657,8 +658,10 @@ int mysql_multi_update_prepare(THD *thd)
{
if (!tl->updatable || check_key_in_view(thd, tl))
{
- my_error(ER_NON_UPDATABLE_TABLE, MYF(0), tl->alias, "UPDATE");
- DBUG_RETURN(-1);
+ my_printf_error(ER_NON_UPDATABLE_TABLE,
+ ER(ER_NON_UPDATABLE_TABLE), MYF(0),
+ tl->alias, "UPDATE");
+ DBUG_RETURN(TRUE);
}
/*
@@ -668,8 +671,9 @@ int mysql_multi_update_prepare(THD *thd)
if (lex->select_lex.check_updateable_in_subqueries(tl->db,
tl->real_name))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), tl->real_name);
- DBUG_RETURN(-1);
+ my_printf_error(ER_UPDATE_TABLE_USED,
+ ER(ER_UPDATE_TABLE_USED), MYF(0), tl->real_name);
+ DBUG_RETURN(TRUE);
}
DBUG_PRINT("info",("setting table `%s` for update", tl->alias));
tl->lock_type= lex->multi_lock_option;
@@ -688,7 +692,7 @@ int mysql_multi_update_prepare(THD *thd)
opened_tables= thd->status_var.opened_tables;
/* now lock and fill tables */
if (lock_tables(thd, table_list, table_count))
- DBUG_RETURN(thd->net.report_error ? -1 : 1);
+ DBUG_RETURN(TRUE);
/*
we have to re-call fixfields for fixed items, because lock maybe
@@ -719,12 +723,12 @@ int mysql_multi_update_prepare(THD *thd)
res= setup_fields(thd, 0, table_list, *fields, 1, 0, 0),
lex->select_lex.no_wrap_view_item= 0,
res))
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
if (thd->fill_derived_tables() &&
mysql_handle_derived(lex, &mysql_derived_filling))
DBUG_RETURN(thd->net.report_error ? -1 : 1);
- DBUG_RETURN (0);
+ DBUG_RETURN (FALSE);
}
@@ -732,16 +736,16 @@ int mysql_multi_update_prepare(THD *thd)
Setup multi-update handling and call SELECT to do the join
*/
-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");
@@ -750,7 +754,7 @@ int mysql_multi_update(THD *thd,
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 &
@@ -767,7 +771,7 @@ int mysql_multi_update(THD *thd,
result, unit, select_lex);
delete result;
thd->abort_on_warning= 0;
- DBUG_RETURN(res);
+ DBUG_RETURN(TRUE);
}
@@ -805,7 +809,7 @@ int multi_update::prepare(List<Item> &not_used_values,
if (!tables_to_update)
{
- my_error(ER_NO_TABLES_USED, MYF(0));
+ my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0));
DBUG_RETURN(1);
}
@@ -1091,8 +1095,10 @@ bool multi_update::send_data(List<Item> &not_used_values)
{
table->status|= STATUS_UPDATED;
store_record(table,record[1]);
- if (fill_record(*fields_for_table[offset], *values_for_table[offset], 0))
+ if (fill_record(thd, *fields_for_table[offset],
+ *values_for_table[offset], 0))
DBUG_RETURN(1);
+
found++;
if (compare_record(table, thd->query_id))
{
@@ -1135,7 +1141,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
{
int error;
TABLE *tmp_table= tmp_tables[offset];
- fill_record(tmp_table->field+1, *values_for_table[offset], 1);
+ fill_record(thd, tmp_table->field+1, *values_for_table[offset], 1);
found++;
/* Store pointer to row */
memcpy((char*) tmp_table->field[0]->ptr,
@@ -1161,7 +1167,7 @@ bool multi_update::send_data(List<Item> &not_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)
@@ -1354,7 +1360,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 760ada9cdbd..cd739071d7b 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -42,13 +42,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;
@@ -58,7 +57,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 ||
@@ -67,16 +66,17 @@ 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 ||
lex->variables_used || lex->param_list.elements)
{
- my_error((lex->derived_tables ?
+ int err= (lex->derived_tables ?
ER_VIEW_SELECT_DERIVED :
- ER_VIEW_SELECT_VARIABLE), MYF(0));
- res= -1;
+ ER_VIEW_SELECT_VARIABLE);
+ my_message(err, ER(err), MYF(0));
+ res= TRUE;
goto err;
}
@@ -102,7 +102,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)
@@ -120,7 +120,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
@@ -156,7 +156,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;
}
}
@@ -178,8 +178,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,8 +190,9 @@ int mysql_create_view(THD *thd,
/* is this table temporary and is not view? */
if (tbl->table->tmp_table != NO_TMP_TABLE && !tbl->view)
{
- my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias);
- res= -1;
+ my_printf_error(ER_VIEW_SELECT_TMPTABLE,
+ ER(ER_VIEW_SELECT_TMPTABLE), MYF(0), tbl->alias);
+ res= TRUE;
goto err;
}
@@ -200,8 +201,9 @@ int mysql_create_view(THD *thd,
strcmp(tbl->view_db.str, view->db) == 0 &&
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;
+ my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0),
+ tbl->view_db.str, tbl->view_name.str);
+ res= TRUE;
goto err;
}
@@ -221,7 +223,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,8 +257,9 @@ 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);
+ my_printf_error(ER_DUP_FIELDNAME, ER(ER_DUP_FIELDNAME),
+ MYF(0), item->name);
+ DBUG_RETURN(TRUE);
}
}
}
@@ -295,7 +298,7 @@ int mysql_create_view(THD *thd,
thd->host_or_ip,
item->name,
view->real_name);
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
}
}
@@ -304,7 +307,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));
@@ -322,9 +325,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);
}
@@ -431,7 +432,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
{
if (mode == VIEW_CREATE_NEW)
{
- my_error(ER_TABLE_EXISTS_ERROR, MYF(0), view->alias);
+ my_printf_error(ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
+ MYF(0), view->alias);
DBUG_RETURN(-1);
}
@@ -441,8 +443,9 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
if (!parser->ok() ||
strncmp("VIEW", parser->type()->str, parser->type()->length))
{
- my_error(ER_WRONG_OBJECT, MYF(0), (view->db ? view->db : thd->db),
- view->real_name, "VIEW");
+ my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0),
+ (view->db ? view->db : thd->db),
+ view->real_name, "VIEW");
DBUG_RETURN(-1);
}
@@ -462,7 +465,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
{
if (mode == VIEW_ALTER)
{
- my_error(ER_NO_SUCH_TABLE, MYF(0), view->db, view->alias);
+ my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0),
+ view->db, view->alias);
DBUG_RETURN(-1);
}
}
@@ -525,7 +529,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
if (view->with_check != VIEW_CHECK_NONE &&
!view->updatable_view)
{
- my_error(ER_VIEW_NONUPD_CHECK, MYF(0), view->db, view->real_name);
+ my_printf_error(ER_VIEW_NONUPD_CHECK, ER(ER_VIEW_NONUPD_CHECK), MYF(0),
+ view->db, view->real_name);
DBUG_RETURN(-1);
}
@@ -696,7 +701,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
if (check_table_access(thd, SELECT_ACL, view_tables, 1) &&
check_table_access(thd, SHOW_VIEW_ACL, table, 1))
{
- my_error(ER_VIEW_NO_EXPLAIN, MYF(0));
+ my_message(ER_VIEW_NO_EXPLAIN, ER(ER_VIEW_NO_EXPLAIN), MYF(0));
goto err;
}
}
@@ -845,12 +850,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];
@@ -876,9 +880,11 @@ int mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
continue;
}
if (type)
- my_error(ER_WRONG_OBJECT, MYF(0), view->db, view->real_name, "VIEW");
+ my_printf_error(ER_WRONG_OBJECT, ER(ER_WRONG_OBJECT), MYF(0),
+ view->db, view->real_name, "VIEW");
else
- my_error(ER_BAD_TABLE_ERROR, MYF(0), name);
+ my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
+ name);
goto err;
}
if (my_delete(path, MYF(MY_WME)))
@@ -886,11 +892,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 fe5ce7640ea..9974c7934dd 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -817,7 +817,7 @@ query:
if (!thd->bootstrap &&
(!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT)))
{
- send_error(thd,ER_EMPTY_QUERY);
+ my_message(ER_EMPTY_QUERY, ER(ER_EMPTY_QUERY), MYF(0));
YYABORT;
}
else
@@ -1153,7 +1153,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 */
@@ -1226,7 +1226,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;
}
@@ -1307,7 +1307,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 */
@@ -1467,7 +1467,8 @@ sp_fdparam:
if (spc->find_pvar(&$1, TRUE))
{
- net_printf(YYTHD, ER_SP_DUP_PARAM, $1.str);
+ my_printf_error(ER_SP_DUP_PARAM, ER(ER_SP_DUP_PARAM), MYF(0),
+ $1.str);
YYABORT;
}
spc->push_pvar(&$1, (enum enum_field_types)$2, sp_param_in);
@@ -1493,7 +1494,8 @@ sp_pdparam:
if (spc->find_pvar(&$2, TRUE))
{
- net_printf(YYTHD, ER_SP_DUP_PARAM, $2.str);
+ my_printf_error(ER_SP_DUP_PARAM, ER(ER_SP_DUP_PARAM), MYF(0),
+ $2.str);
YYABORT;
}
spc->push_pvar(&$2, (enum enum_field_types)$3,
@@ -1531,12 +1533,14 @@ 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_message(ER_SP_VARCOND_AFTER_CURSHNDLR,
+ ER(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_message(ER_SP_CURSOR_AFTER_HANDLER,
+ ER(ER_SP_CURSOR_AFTER_HANDLER), MYF(0));
YYABORT;
}
$$.vars= $1.vars + $2.vars;
@@ -1584,7 +1588,8 @@ sp_decl:
if (spc->find_cond(&$2, TRUE))
{
- net_printf(YYTHD, ER_SP_DUP_COND, $2.str);
+ my_printf_error(ER_SP_DUP_COND, ER(ER_SP_DUP_COND), MYF(0),
+ $2.str);
YYABORT;
}
YYTHD->lex->spcont->push_cond(&$2, $5);
@@ -1641,7 +1646,8 @@ sp_decl:
if (ctx->find_cursor(&$2, &offp, TRUE))
{
- net_printf(YYTHD, ER_SP_DUP_CURS, $2.str);
+ my_printf_error(ER_SP_DUP_CURS, ER(ER_SP_DUP_CURS), MYF(0),
+ $2.str);
delete $5;
YYABORT;
}
@@ -1668,12 +1674,14 @@ sp_cursor_stmt:
if (lex->sql_command != SQLCOM_SELECT)
{
- send_error(YYTHD, ER_SP_BAD_CURSOR_QUERY);
+ my_message(ER_SP_BAD_CURSOR_QUERY, ER(ER_SP_BAD_CURSOR_QUERY),
+ MYF(0));
YYABORT;
}
if (lex->result)
{
- send_error(YYTHD, ER_SP_BAD_CURSOR_SELECT);
+ my_message(ER_SP_BAD_CURSOR_SELECT, ER(ER_SP_BAD_CURSOR_SELECT),
+ MYF(0));
YYABORT;
}
lex->sp_lex_in_use= TRUE;
@@ -1743,7 +1751,8 @@ sp_hcond:
$$= Lex->spcont->find_cond(&$1);
if ($$ == NULL)
{
- net_printf(YYTHD, ER_SP_COND_MISMATCH, $1.str);
+ my_printf_error(ER_SP_COND_MISMATCH, ER(ER_SP_COND_MISMATCH),
+ MYF(0), $1.str);
YYABORT;
}
}
@@ -1772,7 +1781,8 @@ sp_decl_idents:
if (spc->find_pvar(&$1, TRUE))
{
- net_printf(YYTHD, ER_SP_DUP_VAR, $1.str);
+ my_printf_error(ER_SP_DUP_VAR, ER(ER_SP_DUP_VAR), MYF(0),
+ $1.str);
YYABORT;
}
spc->push_pvar(&$1, (enum_field_types)0, sp_param_in);
@@ -1785,7 +1795,8 @@ sp_decl_idents:
if (spc->find_pvar(&$3, TRUE))
{
- net_printf(YYTHD, ER_SP_DUP_VAR, $3.str);
+ my_printf_error(ER_SP_DUP_VAR, ER(ER_SP_DUP_VAR), MYF(0),
+ $3.str);
YYABORT;
}
spc->push_pvar(&$3, (enum_field_types)0, sp_param_in);
@@ -1818,7 +1829,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_message(ER_SP_NO_USE, ER(ER_SP_NO_USE), MYF(0));
YYABORT;
}
/* Don't add an instruction for empty SET statements.
@@ -1837,7 +1848,7 @@ sp_proc_stmt:
*/
if (sp->m_type != TYPE_ENUM_PROCEDURE)
{
- send_error(YYTHD, ER_SP_BADSTATEMENT);
+ my_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0));
YYABORT;
}
else
@@ -1867,7 +1878,7 @@ sp_proc_stmt:
if (lex->sphead->m_type == TYPE_ENUM_PROCEDURE)
{
- send_error(YYTHD, ER_SP_BADRETURN);
+ my_message(ER_SP_BADRETURN, ER(ER_SP_BADRETURN), MYF(0));
YYABORT;
}
else
@@ -1876,7 +1887,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_message(ER_SP_BADSTATEMENT, ER(ER_SP_BADSTATEMENT), MYF(0));
YYABORT;
}
i= new sp_instr_freturn(lex->sphead->instructions(),
@@ -1939,7 +1950,9 @@ sp_proc_stmt:
if (! lab)
{
- net_printf(YYTHD, ER_SP_LILABEL_MISMATCH, "LEAVE", $2.str);
+ my_printf_error(ER_SP_LILABEL_MISMATCH,
+ ER(ER_SP_LILABEL_MISMATCH), MYF(0),
+ "LEAVE", $2.str);
YYABORT;
}
else
@@ -1969,7 +1982,9 @@ sp_proc_stmt:
if (! lab || lab->type != SP_LAB_ITER)
{
- net_printf(YYTHD, ER_SP_LILABEL_MISMATCH, "ITERATE", $2.str);
+ my_printf_error(ER_SP_LILABEL_MISMATCH,
+ ER(ER_SP_LILABEL_MISMATCH), MYF(0),
+ "ITERATE", $2.str);
YYABORT;
}
else
@@ -1997,7 +2012,8 @@ sp_proc_stmt:
if (lab)
{
- net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $2.str);
+ my_printf_error(ER_SP_LABEL_REDEFINE,
+ ER(ER_SP_LABEL_REDEFINE), MYF(0), $2.str);
YYABORT;
}
else
@@ -2021,7 +2037,7 @@ sp_proc_stmt:
if (sp->m_in_handler)
{
- send_error(lex->thd, ER_SP_GOTO_IN_HNDLR);
+ my_message(ER_SP_GOTO_IN_HNDLR, ER(ER_SP_GOTO_IN_HNDLR), MYF(0));
YYABORT;
}
lab= ctx->find_label($2.str);
@@ -2072,7 +2088,8 @@ sp_proc_stmt:
if (! lex->spcont->find_cursor(&$2, &offset))
{
- net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
+ my_printf_error(ER_SP_CURSOR_MISMATCH,
+ ER(ER_SP_CURSOR_MISMATCH), MYF(0), $2.str);
YYABORT;
}
i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
@@ -2087,7 +2104,8 @@ sp_proc_stmt:
if (! lex->spcont->find_cursor(&$3, &offset))
{
- net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $3.str);
+ my_printf_error(ER_SP_CURSOR_MISMATCH,
+ ER(ER_SP_CURSOR_MISMATCH), MYF(0), $3.str);
YYABORT;
}
i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
@@ -2104,7 +2122,8 @@ sp_proc_stmt:
if (! lex->spcont->find_cursor(&$2, &offset))
{
- net_printf(YYTHD, ER_SP_CURSOR_MISMATCH, $2.str);
+ my_printf_error(ER_SP_CURSOR_MISMATCH,
+ ER(ER_SP_CURSOR_MISMATCH), MYF(0), $2.str);
YYABORT;
}
i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset);
@@ -2128,7 +2147,8 @@ sp_fetch_list:
if (!spc || !(spv = spc->find_pvar(&$1)))
{
- net_printf(YYTHD, ER_SP_UNDECLARED_VAR, $1.str);
+ my_printf_error(ER_SP_UNDECLARED_VAR,
+ ER(ER_SP_UNDECLARED_VAR), MYF(0), $1.str);
YYABORT;
}
else
@@ -2150,7 +2170,8 @@ sp_fetch_list:
if (!spc || !(spv = spc->find_pvar(&$3)))
{
- net_printf(YYTHD, ER_SP_UNDECLARED_VAR, $3.str);
+ my_printf_error(ER_SP_UNDECLARED_VAR,
+ ER(ER_SP_UNDECLARED_VAR), MYF(0), $3.str);
YYABORT;
}
else
@@ -2274,7 +2295,8 @@ sp_labeled_control:
if (lab)
{
- net_printf(YYTHD, ER_SP_LABEL_REDEFINE, $1.str);
+ my_printf_error(ER_SP_LABEL_REDEFINE,
+ ER(ER_SP_LABEL_REDEFINE), MYF(0), $1.str);
YYABORT;
}
else
@@ -2295,7 +2317,8 @@ 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_printf_error(ER_SP_LABEL_MISMATCH,
+ ER(ER_SP_LABEL_MISMATCH), MYF(0), $5.str);
YYABORT;
}
}
@@ -2553,9 +2576,11 @@ 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_printf_error(ER_CONFLICTING_DECLARATIONS,
+ ER(ER_CONFLICTING_DECLARATIONS), MYF(0),
+ "CHARACTER SET ",
+ cinfo->default_table_charset->csname,
+ "CHARACTER SET ", $4->csname);
YYABORT;
}
Lex->create_info.default_table_charset= $4;
@@ -2570,8 +2595,9 @@ 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_printf_error(ER_COLLATION_CHARSET_MISMATCH,
+ ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0),
+ $4->name, cinfo->default_table_charset->csname);
YYABORT;
}
Lex->create_info.default_table_charset= $4;
@@ -2583,7 +2609,8 @@ storage_engines:
{
$$ = ha_resolve_by_name($1.str,$1.length);
if ($$ == DB_TYPE_UNKNOWN) {
- net_printf(YYTHD, ER_UNKNOWN_STORAGE_ENGINE, $1.str);
+ my_printf_error(ER_UNKNOWN_STORAGE_ENGINE,
+ ER(ER_UNKNOWN_STORAGE_ENGINE), MYF(0), $1.str);
YYABORT;
}
};
@@ -2773,18 +2800,20 @@ 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_printf_error(ER_FEATURE_DISABLED,
+ ER(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;
@@ -2948,8 +2977,9 @@ attribute:
{
if (Lex->charset && !my_charset_same(Lex->charset,$2))
{
- net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
- $2->name,Lex->charset->csname);
+ my_printf_error(ER_COLLATION_CHARSET_MISMATCH,
+ ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0),
+ $2->name,Lex->charset->csname);
YYABORT;
}
else
@@ -2974,7 +3004,8 @@ charset_name:
{
if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))))
{
- net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,$1.str);
+ my_printf_error(ER_UNKNOWN_CHARACTER_SET,
+ ER(ER_UNKNOWN_CHARACTER_SET), MYF(0), $1.str);
YYABORT;
}
}
@@ -2992,7 +3023,8 @@ 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_printf_error(ER_UNKNOWN_CHARACTER_SET,
+ ER(ER_UNKNOWN_CHARACTER_SET), MYF(0), $1.str);
YYABORT;
}
}
@@ -3008,7 +3040,8 @@ collation_name:
{
if (!($$=get_charset_by_name($1.str,MYF(0))))
{
- net_printf(YYTHD,ER_UNKNOWN_COLLATION,$1.str);
+ my_printf_error(ER_UNKNOWN_COLLATION,
+ ER(ER_UNKNOWN_COLLATION), MYF(0), $1.str);
YYABORT;
}
};
@@ -3032,9 +3065,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;
}
}
@@ -3096,8 +3130,9 @@ 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_printf_error(ER_FEATURE_DISABLED,
+ ER(ER_FEATURE_DISABLED), MYF(0),
+ sym_group_geom.name, sym_group_geom.needed_define);
YYABORT;
#endif
};
@@ -3129,8 +3164,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_message(ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), MYF(0),
+ sym_group_geom.name, sym_group_geom.needed_define);
YYABORT;
#endif
}
@@ -3371,7 +3406,8 @@ 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_printf_error(ER_WRONG_TABLE_NAME, ER(ER_WRONG_TABLE_NAME),
+ MYF(0), $3->table.str);
YYABORT;
}
lex->alter_info.flags|= ALTER_RENAME;
@@ -3386,8 +3422,9 @@ 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_printf_error(ER_COLLATION_CHARSET_MISMATCH,
+ ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0),
+ $5->name, $4->csname);
YYABORT;
}
LEX *lex= Lex;
@@ -3518,7 +3555,8 @@ 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_message(ER_BAD_SLAVE_UNTIL_COND,
+ ER(ER_BAD_SLAVE_UNTIL_COND), MYF(0));
YYABORT;
}
@@ -4231,9 +4269,10 @@ simple_expr:
{
if (!$1.symbol->create_func)
{
- net_printf(Lex->thd, ER_FEATURE_DISABLED,
- $1.symbol->group->name,
- $1.symbol->group->needed_define);
+ my_printf_error(ER_FEATURE_DISABLED,
+ ER(ER_FEATURE_DISABLED), MYF(0),
+ $1.symbol->group->name,
+ $1.symbol->group->needed_define);
YYABORT;
}
$$= ((Item*(*)(void))($1.symbol->create_func))();
@@ -4242,9 +4281,10 @@ simple_expr:
{
if (!$1.symbol->create_func)
{
- net_printf(Lex->thd, ER_FEATURE_DISABLED,
- $1.symbol->group->name,
- $1.symbol->group->needed_define);
+ my_printf_error(ER_FEATURE_DISABLED,
+ ER(ER_FEATURE_DISABLED), MYF(0),
+ $1.symbol->group->name,
+ $1.symbol->group->needed_define);
YYABORT;
}
$$= ((Item*(*)(Item*))($1.symbol->create_func))($3);
@@ -4253,9 +4293,10 @@ simple_expr:
{
if (!$1.symbol->create_func)
{
- net_printf(Lex->thd, ER_FEATURE_DISABLED,
- $1.symbol->group->name,
- $1.symbol->group->needed_define);
+ my_printf_error(ER_FEATURE_DISABLED,
+ ER(ER_FEATURE_DISABLED), MYF(0),
+ $1.symbol->group->name,
+ $1.symbol->group->needed_define);
YYABORT;
}
$$= ((Item*(*)(Item*,Item*))($1.symbol->create_func))($3,$5);
@@ -4264,9 +4305,10 @@ simple_expr:
{
if (!$1.symbol->create_func)
{
- net_printf(Lex->thd, ER_FEATURE_DISABLED,
- $1.symbol->group->name,
- $1.symbol->group->needed_define);
+ my_printf_error(ER_FEATURE_DISABLED,
+ ER(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);
@@ -4369,8 +4411,9 @@ simple_expr:
#ifdef HAVE_SPATIAL
$$= $1;
#else
- net_printf(Lex->thd, ER_FEATURE_DISABLED,
- sym_group_geom.name, sym_group_geom.needed_define);
+ my_printf_error(ER_FEATURE_DISABLED,
+ ER(ER_FEATURE_DISABLED), MYF(0),
+ sym_group_geom.name, sym_group_geom.needed_define);
YYABORT;
#endif
}
@@ -5226,12 +5269,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
@@ -5239,7 +5282,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;
}
@@ -5263,9 +5306,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;
@@ -5363,9 +5405,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;
@@ -5429,7 +5469,8 @@ select_var_ident:
if (!lex->spcont || !(t=lex->spcont->find_pvar(&$1)))
{
- net_printf(YYTHD, ER_SP_UNDECLARED_VAR, $1.str);
+ my_printf_error(ER_SP_UNDECLARED_VAR,
+ ER(ER_SP_UNDECLARED_VAR), MYF(0), $1.str);
YYABORT;
}
if (! lex->result)
@@ -5520,7 +5561,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;
@@ -5532,7 +5573,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;
@@ -5785,8 +5826,9 @@ 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_printf_error(ER_NON_UPDATABLE_TABLE,
+ ER(ER_NON_UPDATABLE_TABLE), MYF(0),
+ lex->select_lex.get_table_list()->alias, "UPDATE");
YYABORT;
}
else
@@ -6111,7 +6153,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;
}
}
@@ -6122,7 +6164,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;
}
};
@@ -6274,7 +6316,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);
@@ -6296,7 +6338,8 @@ 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_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY),
+ MYF(0));
YYABORT;
}
lex->sql_command=SQLCOM_KILL;
@@ -6467,7 +6510,7 @@ param_marker:
(uchar *) thd->query));
if (!($$= item) || lex->param_list.push_back(item))
{
- send_error(thd, ER_OUT_OF_RESOURCES);
+ my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
YYABORT;
}
}
@@ -6523,7 +6566,6 @@ NUM_literal:
$$= new Item_real($1.str, $1.length);
if (YYTHD->net.report_error)
{
- send_error(YYTHD, 0, NullS);
YYABORT;
}
}
@@ -6532,7 +6574,6 @@ NUM_literal:
$$ = new Item_float($1.str, $1.length);
if (YYTHD->net.report_error)
{
- send_error(YYTHD, 0, NullS);
YYABORT;
}
}
@@ -6621,16 +6662,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;
}
@@ -6647,8 +6686,9 @@ 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_printf_error(ER_BAD_FIELD_ERROR,
+ ER(ER_BAD_FIELD_ERROR), MYF(0),
+ $3.str, new_row ? "NEW": "OLD");
YYABORT;
}
@@ -6735,8 +6775,9 @@ IDENT_sys:
$1.length);
if (wlen < $1.length)
{
- net_printf(YYTHD, ER_INVALID_CHARACTER_STRING, cs->csname,
- $1.str + wlen);
+ my_printf_error(ER_INVALID_CHARACTER_STRING,
+ ER(ER_INVALID_CHARACTER_STRING), MYF(0),
+ cs->csname, $1.str + wlen);
YYABORT;
}
$$= $1;
@@ -7119,7 +7160,8 @@ option_value:
*/
if (lex->query_tables)
{
- send_error(YYTHD, ER_SP_SUBSELECT_NYI);
+ my_message(ER_SP_SUBSELECT_NYI, ER(ER_SP_SUBSELECT_NYI),
+ MYF(0));
YYABORT;
}
sp_instr_set_user_var *i=
@@ -7142,7 +7184,8 @@ option_value:
sp_instr_set_trigger_field *i;
if (lex->query_tables)
{
- send_error(YYTHD, ER_SP_SUBSELECT_NYI);
+ my_message(ER_SP_SUBSELECT_NYI, ER(ER_SP_SUBSELECT_NYI),
+ MYF(0));
YYABORT;
}
if ($3)
@@ -7171,7 +7214,8 @@ option_value:
Error message also should be improved.
*/
- net_printf(YYTHD, ER_BAD_FIELD_ERROR, $1.base_name, "NEW");
+ my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR),
+ MYF(0), $1.base_name, "NEW");
YYABORT;
}
lex->sphead->add_instr(i);
@@ -7237,7 +7281,9 @@ option_value:
$3= $3 ? $3 : $2;
if (!my_charset_same($2,$3))
{
- net_printf(thd,ER_COLLATION_CHARSET_MISMATCH,$3->name,$2->csname);
+ my_printf_error(ER_COLLATION_CHARSET_MISMATCH,
+ ER(ER_COLLATION_CHARSET_MISMATCH), MYF(0),
+ $3->name, $2->csname);
YYABORT;
}
lex->var_list.push_back(new set_var_collation_client($3,$3,$3));
@@ -7303,18 +7349,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 */
@@ -7327,7 +7373,8 @@ internal_variable_name:
if (!tmp)
YYABORT;
if (!tmp->is_struct())
- net_printf(YYTHD, ER_VARIABLE_IS_NOT_STRUCT, $3.str);
+ my_printf_error(ER_VARIABLE_IS_NOT_STRUCT,
+ ER(ER_VARIABLE_IS_NOT_STRUCT), MYF(0), $3.str);
$$.var= tmp;
$$.base_name= $1;
}
@@ -7338,7 +7385,8 @@ internal_variable_name:
if (!tmp)
YYABORT;
if (!tmp->is_struct())
- net_printf(YYTHD, ER_VARIABLE_IS_NOT_STRUCT, $3.str);
+ my_printf_error(ER_VARIABLE_IS_NOT_STRUCT,
+ ER(ER_VARIABLE_IS_NOT_STRUCT), MYF(0), $3.str);
$$.var= tmp;
$$.base_name.str= (char*) "default";
$$.base_name.length= 7;
@@ -7587,7 +7635,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;
@@ -7597,7 +7645,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;
@@ -7607,7 +7655,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;
@@ -7623,7 +7671,8 @@ opt_table:
lex->grant = DB_ACLS & ~GRANT_ACL;
else if (lex->columns.elements)
{
- send_error(lex->thd,ER_ILLEGAL_GRANT_FOR_TABLE);
+ my_message(ER_ILLEGAL_GRANT_FOR_TABLE,
+ ER(ER_ILLEGAL_GRANT_FOR_TABLE), MYF(0));
YYABORT;
}
}
@@ -7635,7 +7684,8 @@ opt_table:
lex->grant = DB_ACLS & ~GRANT_ACL;
else if (lex->columns.elements)
{
- send_error(lex->thd,ER_ILLEGAL_GRANT_FOR_TABLE);
+ my_message(ER_ILLEGAL_GRANT_FOR_TABLE,
+ ER(ER_ILLEGAL_GRANT_FOR_TABLE), MYF(0));
YYABORT;
}
}
@@ -7647,7 +7697,8 @@ opt_table:
lex->grant= GLOBAL_ACLS & ~GRANT_ACL;
else if (lex->columns.elements)
{
- send_error(lex->thd,ER_ILLEGAL_GRANT_FOR_TABLE);
+ my_message(ER_ILLEGAL_GRANT_FOR_TABLE,
+ ER(ER_ILLEGAL_GRANT_FOR_TABLE), MYF(0));
YYABORT;
}
}
@@ -7832,7 +7883,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)
diff --git a/sql/table.cc b/sql/table.cc
index 0e8045abacf..095c3f037d5 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -984,11 +984,12 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype)
uint length=dirname_part(buff,name);
buff[length-1]=0;
db=buff+dirname_length(buff);
- my_error(ER_NO_SUCH_TABLE,MYF(0),db,form->real_name);
+ my_printf_error(ER_NO_SUCH_TABLE, ER(ER_NO_SUCH_TABLE), MYF(0),
+ db, form->real_name);
}
else
- my_error(ER_FILE_NOT_FOUND,errortype,
- fn_format(buff,name,form_dev,reg_ext,0),my_errno);
+ my_printf_error(ER_FILE_NOT_FOUND, ER(ER_FILE_NOT_FOUND), errortype,
+ fn_format(buff, name, form_dev, reg_ext, 0), my_errno);
break;
case 2:
{
@@ -996,14 +997,15 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype)
datext= datext==NullS ? "" : datext;
err_no= (my_errno == ENOENT) ? ER_FILE_NOT_FOUND : (my_errno == EAGAIN) ?
ER_FILE_USED : ER_CANT_OPEN_FILE;
- my_error(err_no,errortype,
- fn_format(buff,form->real_name,form_dev,datext,2),my_errno);
+ my_printf_error(err_no, ER(err_no), errortype,
+ fn_format(buff, form->real_name, form_dev, datext, 2),
+ my_errno);
break;
}
default: /* Better wrong error than none */
case 4:
- my_error(ER_NOT_FORM_FILE,errortype,
- fn_format(buff,name,form_dev,reg_ext,0));
+ my_printf_error(ER_NOT_FORM_FILE, ER(ER_NOT_FORM_FILE), errortype,
+ fn_format(buff, name, form_dev, reg_ext, 0));
break;
}
DBUG_VOID_RETURN;
@@ -1726,7 +1728,8 @@ err:
if (thd->net.last_errno == ER_BAD_FIELD_ERROR)
{
thd->clear_error();
- my_error(ER_VIEW_INVALID, MYF(0), view_db.str, view_name.str);
+ my_printf_error(ER_VIEW_INVALID, ER(ER_VIEW_INVALID), MYF(0),
+ view_db.str, view_name.str);
}
thd->lex->select_lex.no_wrap_view_item= save_wrapper;
thd->lex->current_select= current_select_save;
@@ -1780,7 +1783,8 @@ int st_table_list::view_check_option(THD *thd, bool ignore_failure)
}
else
{
- my_error(ER_VIEW_CHECK_FAILED, MYF(0), view_db.str, view_name.str);
+ my_printf_error(ER_VIEW_CHECK_FAILED, ER(ER_VIEW_CHECK_FAILED), MYF(0),
+ view_db.str, view_name.str);
return(VIEW_CHECK_ERROR);
}
}
diff --git a/sql/unireg.cc b/sql/unireg.cc
index decac2a0549..636156940a4 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -383,7 +383,7 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
if (create_fields.elements > MAX_FIELDS)
{
- my_error(ER_TOO_MANY_FIELDS,MYF(0));
+ my_message(ER_TOO_MANY_FIELDS, ER(ER_TOO_MANY_FIELDS), MYF(0));
DBUG_RETURN(1);
}
@@ -448,7 +448,7 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
if (info_length+(ulong) create_fields.elements*FCOMP+288+
n_length+int_length+com_length > 65535L || int_count > 255)
{
- my_error(ER_TOO_MANY_FIELDS,MYF(0));
+ my_message(ER_TOO_MANY_FIELDS, ER(ER_TOO_MANY_FIELDS), MYF(0));
DBUG_RETURN(1);
}