mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge branch '11.3' into 11.4
This commit is contained in:
@@ -729,7 +729,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
|
||||
wsrep_wfc()
|
||||
#endif /*WITH_WSREP */
|
||||
{
|
||||
ulong tmp;
|
||||
bzero(&variables, sizeof(variables));
|
||||
|
||||
/*
|
||||
@@ -880,14 +879,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
|
||||
|
||||
tablespace_op=FALSE;
|
||||
|
||||
/*
|
||||
Initialize the random generator. We call my_rnd() without a lock as
|
||||
it's not really critical if two threads modifies the structure at the
|
||||
same time. We ensure that we have an unique number foreach thread
|
||||
by adding the address of the stack.
|
||||
*/
|
||||
tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff);
|
||||
my_rnd_init(&rand, tmp + (ulong)((size_t) &rand), tmp + (ulong) ::global_query_id);
|
||||
substitute_null_with_insert_id = FALSE;
|
||||
lock_info.mysql_thd= (void *)this;
|
||||
|
||||
@@ -1206,6 +1197,63 @@ void thd_gmt_sec_to_TIME(MYSQL_THD thd, MYSQL_TIME *ltime, my_time_t t)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@brief
|
||||
Convert a non-zero DATETIME to its safe timeval based representation,
|
||||
which guarantees a safe roundtrip DATETIME->timeval->DATETIME,
|
||||
e.g. to optimize:
|
||||
|
||||
WHERE timestamp_arg0 = datetime_arg1
|
||||
|
||||
in the way that we replace "datetime_arg1" to its TIMESTAMP equivalent
|
||||
"timestamp_arg1" and switch from DATETIME comparison to TIMESTAMP comparison:
|
||||
|
||||
WHERE timestamp_arg0 = timestamp_arg1
|
||||
|
||||
This helps to avoid slow TIMESTAMP->DATETIME data type conversion
|
||||
for timestamp_arg0 per row.
|
||||
|
||||
@detail
|
||||
Round trip is possible if the input "YYYY-MM-DD hh:mm:ss" value
|
||||
satisfies the following conditions:
|
||||
|
||||
1. TIME_to_gmt_sec() returns no errors or warnings,
|
||||
which means the input value
|
||||
a. has no zeros in YYYYMMDD
|
||||
b. fits into the TIMESTAMP range
|
||||
c. does not fall into the spring forward gap
|
||||
(because values inside gaps get adjusted to the beginning of the gap)
|
||||
|
||||
2. The my_time_t value returned by TIME_to_gmt_sec() must not be
|
||||
near a DST change or near a leap second, to avoid anomalies:
|
||||
- "YYYY-MM-DD hh:mm:ss" has more than one matching my_time_t values
|
||||
- "YYYY-MM-DD hh:mm:ss" has no matching my_time_t values
|
||||
(e.g. fall into the spring forward gap)
|
||||
|
||||
@param dt The DATETIME value to convert.
|
||||
Must not be zero '0000-00-00 00:00:00.000000'.
|
||||
(The zero value must be handled by the caller).
|
||||
|
||||
@return The conversion result
|
||||
@retval If succeeded, non-NULL Timeval value.
|
||||
@retval Timeval_null value representing SQL NULL if the argument
|
||||
does not have a safe replacement.
|
||||
*/
|
||||
Timeval_null
|
||||
THD::safe_timeval_replacement_for_nonzero_datetime(const Datetime &dt)
|
||||
{
|
||||
used|= THD::TIME_ZONE_USED;
|
||||
DBUG_ASSERT(non_zero_date(dt.get_mysql_time()));
|
||||
uint error= 0;
|
||||
const MYSQL_TIME *ltime= dt.get_mysql_time();
|
||||
my_time_t sec= variables.time_zone->TIME_to_gmt_sec(ltime, &error);
|
||||
if (error /* (1) */ ||
|
||||
!variables.time_zone->is_monotone_continuous_around(sec) /* (2) */)
|
||||
return Timeval_null();
|
||||
return Timeval_null(sec, ltime->second_part);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
extern "C" my_thread_id next_thread_id_noinline()
|
||||
{
|
||||
@@ -1311,6 +1359,17 @@ void THD::init()
|
||||
/* Set to handle counting of aborted connections */
|
||||
userstat_running= opt_userstat_running;
|
||||
last_global_update_time= current_connect_time= time(NULL);
|
||||
|
||||
/*
|
||||
Initialize the random generator. We call my_rnd() without a lock as
|
||||
it's not really critical if two threads modify the structure at the
|
||||
same time. We ensure that we have a unique number for each thread
|
||||
by adding the address of this THD.
|
||||
*/
|
||||
ulong tmp= (ulong) (my_rnd(&sql_rand) * 0xffffffff);
|
||||
my_rnd_init(&rand, tmp + (ulong)(intptr) this,
|
||||
(ulong)(my_timer_cycles() + global_query_id));
|
||||
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
session_tracker.enable(this);
|
||||
#endif //EMBEDDED_LIBRARY
|
||||
@@ -1856,14 +1915,6 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
|
||||
*/
|
||||
}
|
||||
|
||||
#define SECONDS_TO_WAIT_FOR_KILL 2
|
||||
#if !defined(_WIN32) && defined(HAVE_SELECT)
|
||||
/* my_sleep() can wait for sub second times */
|
||||
#define WAIT_FOR_KILL_TRY_TIMES 20
|
||||
#else
|
||||
#define WAIT_FOR_KILL_TRY_TIMES 2
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Awake a thread.
|
||||
|
Reference in New Issue
Block a user