summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-10-01 13:15:29 +0200
committerSergei Golubchik <sergii@pisem.net>2012-10-01 13:15:29 +0200
commit416d0aebbfaaa00802d00105a0bd2faedb8b8f04 (patch)
tree5244b83a9f22d4d5899154c9a64a316111bbe6b6 /sql
parentadf6e145f77d2f7b049b977ee55ed12d05b96eac (diff)
downloadmariadb-git-416d0aebbfaaa00802d00105a0bd2faedb8b8f04.tar.gz
more fixes for test cases
mysql-test/suite/innodb/include/restart_and_reinit.inc: drop and recreate mysql.innodb* tables when deleting innodb table spaces mysql-test/t/ssl_8k_key-master.opt: with loose- prefix ssl errors are ignored sql-common/client.c: compiler warnings sql/field.cc: use the new function sql/item.cc: don't convert time to double or decimal via longlong, this loses sub-second part. Use dedicated functions. sql/item.h: incorrect cast_to_int type for params sql/item_strfunc.cc: use the new function sql/lex.h: unused sql/my_decimal.h: helper macro sql/sql_plugin.cc: workaround for a compiler warning sql/sql_yacc.yy: unused sql/transaction.cc: fix the merge for SERVER_STATUS_IN_TRANS_READONLY protocol flag storage/sphinx/CMakeLists.txt: compiler warnings
Diffstat (limited to 'sql')
-rw-r--r--sql/event_data_objects.cc6
-rw-r--r--sql/event_scheduler.cc2
-rw-r--r--sql/events.cc6
-rw-r--r--sql/field.cc6
-rw-r--r--sql/item.cc6
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_strfunc.cc5
-rw-r--r--sql/lex.h1
-rw-r--r--sql/my_decimal.h4
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_parse.cc8
-rw-r--r--sql/sql_plugin.cc2
-rw-r--r--sql/sql_yacc.yy4
-rw-r--r--sql/transaction.cc43
14 files changed, 54 insertions, 44 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index fd9568acf00..7c7ab4df9ad 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -1455,7 +1455,6 @@ end:
else
{
ulong saved_master_access;
- bool save_tx_read_only;
thd->set_query(sp_sql.c_ptr_safe(), sp_sql.length());
@@ -1463,11 +1462,14 @@ end:
NOTE: even if we run in read-only mode, we should be able to lock
the mysql.event table for writing. In order to achieve this, we
should call mysql_lock_tables() under the super-user.
+
+ Same goes for transaction access mode.
+ Temporarily reset it to read-write.
*/
saved_master_access= thd->security_ctx->master_access;
thd->security_ctx->master_access |= SUPER_ACL;
- save_tx_read_only= thd->tx_read_only;
+ bool save_tx_read_only= thd->tx_read_only;
thd->tx_read_only= false;
ret= Events::drop_event(thd, dbname, name, FALSE);
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 58aedcc45e2..bef422e9734 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -411,6 +411,8 @@ Event_scheduler::start()
We should run the event scheduler thread under the super-user privileges.
In particular, this is needed to be able to lock the mysql.event table
for writing when the server is running in the read-only mode.
+
+ Same goes for transaction access mode. Set it to read-write for this thd.
*/
new_thd->security_ctx->master_access |= SUPER_ACL;
new_thd->variables.tx_read_only= false;
diff --git a/sql/events.cc b/sql/events.cc
index 0a14038bc27..54ad76e40d4 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1069,7 +1069,6 @@ Events::load_events_from_db(THD *thd)
bool ret= TRUE;
uint count= 0;
ulong saved_master_access;
- bool save_tx_read_only;
DBUG_ENTER("Events::load_events_from_db");
DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
@@ -1078,11 +1077,14 @@ Events::load_events_from_db(THD *thd)
NOTE: even if we run in read-only mode, we should be able to lock the
mysql.event table for writing. In order to achieve this, we should call
mysql_lock_tables() under the super user.
+
+ Same goes for transaction access mode.
+ Temporarily reset it to read-write.
*/
saved_master_access= thd->security_ctx->master_access;
thd->security_ctx->master_access |= SUPER_ACL;
- save_tx_read_only= thd->tx_read_only;
+ bool save_tx_read_only= thd->tx_read_only;
thd->tx_read_only= false;
ret= db_repository->open_event_table(thd, TL_WRITE, &table);
diff --git a/sql/field.cc b/sql/field.cc
index 2084c661602..13bdec3a881 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4845,8 +4845,7 @@ my_decimal *Field_timestamp_hires::val_decimal(my_decimal *d)
{
MYSQL_TIME ltime;
get_date(&ltime, 0);
- longlong intg= TIME_to_ulonglong(&ltime);
- return seconds2my_decimal(ltime.neg, intg, ltime.second_part, d);
+ return TIME_to_my_decimal(&ltime, d);
}
int Field_timestamp_hires::store_decimal(const my_decimal *d)
@@ -5066,8 +5065,7 @@ my_decimal *Field_temporal::val_decimal(my_decimal *d)
bzero(&ltime, sizeof(ltime));
ltime.time_type= mysql_type_to_time_type(type());
}
- longlong intg= TIME_to_ulonglong(&ltime);
- return seconds2my_decimal(ltime.neg, intg, ltime.second_part, d);
+ return TIME_to_my_decimal(&ltime, d);
}
/****************************************************************************
diff --git a/sql/item.cc b/sql/item.cc
index 3031e90c9b2..367e603c6e7 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3459,7 +3459,7 @@ double Item_param::val_real()
This works for example when user says SELECT ?+0.0 and supplies
time value for the placeholder.
*/
- return ulonglong2double(TIME_to_ulonglong(&value.time));
+ return TIME_to_double(&value.time);
case NULL_VALUE:
return 0.0;
default:
@@ -3517,9 +3517,7 @@ my_decimal *Item_param::val_decimal(my_decimal *dec)
return dec;
case TIME_VALUE:
{
- longlong i= (longlong) TIME_to_ulonglong(&value.time);
- int2my_decimal(E_DEC_FATAL_ERROR, i, 0, dec);
- return dec;
+ return TIME_to_my_decimal(&value.time, dec);
}
case NULL_VALUE:
return 0;
diff --git a/sql/item.h b/sql/item.h
index f7f3edda384..1f79f833f97 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2231,7 +2231,6 @@ public:
Item_param(uint pos_in_query_arg);
enum Item_result result_type () const { return item_result_type; }
- enum Item_result cast_to_int_type() const { return item_result_type; }
enum Type type() const { return item_type; }
enum_field_types field_type() const { return param_type; }
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 48d0b32d51c..cb7b2841cfb 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -4399,10 +4399,7 @@ my_decimal *Item_dyncol_get::val_decimal(my_decimal *decimal_value)
case DYN_COL_DATETIME:
case DYN_COL_DATE:
case DYN_COL_TIME:
- decimal_value= seconds2my_decimal(val.x.time_value.neg,
- TIME_to_ulonglong(&val.x.time_value),
- val.x.time_value.second_part,
- decimal_value);
+ decimal_value= TIME_to_my_decimal(&val.x.time_value, decimal_value);
break;
}
return decimal_value;
diff --git a/sql/lex.h b/sql/lex.h
index 6587f5b8a9c..9756d5bc7cc 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -400,7 +400,6 @@ static SYMBOL symbols[] = {
{ "OLD_PASSWORD", SYM(OLD_PASSWORD)},
{ "ON", SYM(ON)},
{ "ONE", SYM(ONE_SYM)},
- { "ONE_SHOT", SYM(ONE_SHOT_SYM)},
{ "ONLINE", SYM(ONLINE_SYM)},
{ "ONLY", SYM(ONLY_SYM)},
{ "OPEN", SYM(OPEN_SYM)},
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index bd03782cb18..3b104bbdee6 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -343,6 +343,10 @@ bool my_decimal2seconds(const my_decimal *d, ulonglong *sec, ulong *microsec);
my_decimal *seconds2my_decimal(bool sign, ulonglong sec, ulong microsec,
my_decimal *d);
+#define TIME_to_my_decimal(TIME, DECIMAL) \
+ seconds2my_decimal((TIME)->neg, TIME_to_ulonglong(TIME), \
+ (TIME)->second_part, (DECIMAL))
+
int my_decimal2int(uint mask, const decimal_t *d, bool unsigned_flag,
longlong *l);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 9c3e0f8f9dd..a96fe63e3c9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4366,9 +4366,9 @@ void THD::set_status_no_good_index_used()
#endif
}
-void THD::set_command(enum enum_server_command command_arg)
+void THD::set_command(enum enum_server_command command)
{
- m_command= command_arg;
+ m_command= command;
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_CALL(set_thread_command)(m_command);
#endif
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 18fa3203c64..551e1ee1924 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3966,7 +3966,7 @@ end_with_restore_list:
}
else
{
- /* Reset the isolation level if no chaining transaction. */
+ /* Reset the isolation level and access mode if no chaining transaction.*/
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
thd->tx_read_only= thd->variables.tx_read_only;
}
@@ -4000,7 +4000,7 @@ end_with_restore_list:
}
else
{
- /* Reset the isolation level if no chaining transaction. */
+ /* Reset the isolation level and access mode if no chaining transaction.*/
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
thd->tx_read_only= thd->variables.tx_read_only;
}
@@ -4520,7 +4520,7 @@ create_sp_error:
thd->mdl_context.release_transactional_locks();
/*
We've just done a commit, reset transaction
- isolation level to the session default.
+ isolation level and access mode to the session default.
*/
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
thd->tx_read_only= thd->variables.tx_read_only;
@@ -4532,7 +4532,7 @@ create_sp_error:
thd->mdl_context.release_transactional_locks();
/*
We've just done a rollback, reset transaction
- isolation level to the session default.
+ isolation level and access mode to the session default.
*/
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
thd->tx_read_only= thd->variables.tx_read_only;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 1059103086a..5cb46d0f7ef 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1531,7 +1531,7 @@ int plugin_init(int *argc, char **argv, int flags)
/* prepare debug_sync service */
DBUG_ASSERT(strcmp(list_of_services[5].name, "debug_sync_service") == 0);
- list_of_services[5].service= *(void**)&debug_sync_C_callback_ptr;
+ list_of_services[5].service= reinterpret_cast<void*>(debug_sync_C_callback_ptr);
mysql_mutex_lock(&LOCK_plugin);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7b7f766bbd1..bb74640d9da 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1280,7 +1280,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token OFFSET_SYM
%token OLD_PASSWORD
%token ON /* SQL-2003-R */
-%token ONE_SHOT_SYM
%token ONE_SYM
%token ONLY_SYM /* SQL-2003-R */
%token ONLINE_SYM
@@ -13299,7 +13298,6 @@ keyword_sp:
| NVARCHAR_SYM {}
| OFFSET_SYM {}
| OLD_PASSWORD {}
- | ONE_SHOT_SYM {}
| ONE_SYM {}
| ONLINE_SYM {}
| ONLY_SYM {}
@@ -13424,8 +13422,6 @@ keyword_sp:
| VIA_SYM {}
;
-/* Option functions */
-
/*
SQLCOM_SET_OPTION statement.
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 277a95b90a9..7d8fc89ec8c 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -135,7 +135,9 @@ bool trans_begin(THD *thd, uint flags)
(thd->variables.option_bits & OPTION_TABLE_LOCK))
{
thd->variables.option_bits&= ~OPTION_TABLE_LOCK;
- thd->server_status&= ~SERVER_STATUS_IN_TRANS;
+ thd->server_status&=
+ ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
+ DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= test(ha_commit_trans(thd, TRUE));
}
@@ -178,6 +180,7 @@ bool trans_begin(THD *thd, uint flags)
thd->server_status|= SERVER_STATUS_IN_TRANS;
if (thd->tx_read_only)
thd->server_status|= SERVER_STATUS_IN_TRANS_READONLY;
+ DBUG_PRINT("info", ("setting SERVER_STATUS_IN_TRANS"));
/* ha_start_consistent_snapshot() relies on OPTION_BEGIN flag set. */
if (flags & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT)
@@ -204,16 +207,18 @@ bool trans_commit(THD *thd)
if (trans_check(thd))
DBUG_RETURN(TRUE);
- thd->server_status&= ~SERVER_STATUS_IN_TRANS;
+ thd->server_status&=
+ ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
+ DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= ha_commit_trans(thd, TRUE);
- if (res)
/*
if res is non-zero, then ha_commit_trans has rolled back the
transaction, so the hooks for rollback will be called.
*/
- RUN_HOOK(transaction, after_rollback, (thd, FALSE));
+ if (res)
+ (void) RUN_HOOK(transaction, after_rollback, (thd, FALSE));
else
- RUN_HOOK(transaction, after_commit, (thd, FALSE));
+ (void) RUN_HOOK(transaction, after_commit, (thd, FALSE));
thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
thd->transaction.all.modified_non_trans_table= FALSE;
thd->lex->start_transaction_opt= 0;
@@ -247,7 +252,9 @@ bool trans_commit_implicit(THD *thd)
/* Safety if one did "drop table" on locked tables */
if (!thd->locked_tables_mode)
thd->variables.option_bits&= ~OPTION_TABLE_LOCK;
- thd->server_status&= ~SERVER_STATUS_IN_TRANS;
+ thd->server_status&=
+ ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
+ DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= test(ha_commit_trans(thd, TRUE));
}
@@ -256,7 +263,7 @@ bool trans_commit_implicit(THD *thd)
/*
Upon implicit commit, reset the current transaction
- isolation level. We do not care about
+ isolation level and access mode. We do not care about
@@session.completion_type since it's documented
to not have any effect on implicit commit.
*/
@@ -284,9 +291,11 @@ bool trans_rollback(THD *thd)
if (trans_check(thd))
DBUG_RETURN(TRUE);
- thd->server_status&= ~SERVER_STATUS_IN_TRANS;
+ thd->server_status&=
+ ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
+ DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= ha_rollback_trans(thd, TRUE);
- RUN_HOOK(transaction, after_rollback, (thd, FALSE));
+ (void) RUN_HOOK(transaction, after_rollback, (thd, FALSE));
thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
thd->transaction.all.modified_non_trans_table= FALSE;
thd->lex->start_transaction_opt= 0;
@@ -332,14 +341,14 @@ bool trans_commit_stmt(THD *thd)
}
}
- if (res)
/*
if res is non-zero, then ha_commit_trans has rolled back the
transaction, so the hooks for rollback will be called.
*/
- RUN_HOOK(transaction, after_rollback, (thd, FALSE));
+ if (res)
+ (void) RUN_HOOK(transaction, after_rollback, (thd, FALSE));
else
- RUN_HOOK(transaction, after_commit, (thd, FALSE));
+ (void) RUN_HOOK(transaction, after_commit, (thd, FALSE));
thd->transaction.stmt.reset();
@@ -379,7 +388,7 @@ bool trans_rollback_stmt(THD *thd)
}
}
- RUN_HOOK(transaction, after_rollback, (thd, FALSE));
+ (void) RUN_HOOK(transaction, after_rollback, (thd, FALSE));
thd->transaction.stmt.reset();
@@ -756,7 +765,9 @@ bool trans_xa_commit(THD *thd)
thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
thd->transaction.all.modified_non_trans_table= FALSE;
- thd->server_status&= ~SERVER_STATUS_IN_TRANS;
+ thd->server_status&=
+ ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
+ DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
xid_cache_delete(&thd->transaction.xid_state);
thd->transaction.xid_state.xa_state= XA_NOTR;
@@ -803,7 +814,9 @@ bool trans_xa_rollback(THD *thd)
thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
thd->transaction.all.modified_non_trans_table= FALSE;
- thd->server_status&= ~SERVER_STATUS_IN_TRANS;
+ thd->server_status&=
+ ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
+ DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
xid_cache_delete(&thd->transaction.xid_state);
thd->transaction.xid_state.xa_state= XA_NOTR;