1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

SQL: renamed vers_thd_get_now() to THD::query_start_TIME()

This commit is contained in:
Aleksey Midenkov
2017-06-02 16:53:24 +03:00
parent 397a891538
commit f915fe8eae
3 changed files with 19 additions and 22 deletions

View File

@ -6859,6 +6859,15 @@ static bool protect_against_unsafe_warning_flood(int unsafe_type)
DBUG_RETURN(unsafe_warning_suppression_active[unsafe_type]); DBUG_RETURN(unsafe_warning_suppression_active[unsafe_type]);
} }
MYSQL_TIME THD::query_start_TIME()
{
MYSQL_TIME res;
variables.time_zone->gmt_sec_to_TIME(&res, query_start());
res.second_part= query_start_sec_part();
time_zone_used= 1;
return res;
}
/** /**
Auxiliary method used by @c binlog_query() to raise warnings. Auxiliary method used by @c binlog_query() to raise warnings.

View File

@ -3244,6 +3244,7 @@ public:
inline my_time_t query_start() { query_start_used=1; return start_time; } inline my_time_t query_start() { query_start_used=1; return start_time; }
inline ulong query_start_sec_part() inline ulong query_start_sec_part()
{ query_start_sec_part_used=1; return start_time_sec_part; } { query_start_sec_part_used=1; return start_time_sec_part; }
MYSQL_TIME query_start_TIME();
inline void set_current_time() inline void set_current_time()
{ {
my_hrtime_t hrtime= my_hrtime(); my_hrtime_t hrtime= my_hrtime();

View File

@ -5155,20 +5155,10 @@ static void make_unique_constraint_name(THD *thd, LEX_STRING *name,
** Alter a table definition ** Alter a table definition
****************************************************************************/ ****************************************************************************/
// Works as NOW(6)
static MYSQL_TIME vers_thd_get_now(THD *thd)
{
MYSQL_TIME now;
thd->variables.time_zone->gmt_sec_to_TIME(&now, thd->query_start());
now.second_part= thd->query_start_sec_part();
thd->time_zone_used= 1;
return now;
}
static void vers_table_name_date(THD *thd, const char *table_name, static void vers_table_name_date(THD *thd, const char *table_name,
char *new_name, size_t new_name_size) char *new_name, size_t new_name_size)
{ {
const MYSQL_TIME now= vers_thd_get_now(thd); const MYSQL_TIME now= thd->query_start_TIME();
my_snprintf(new_name, new_name_size, "%s_%04d%02d%02d_%02d%02d%02d_%06d", my_snprintf(new_name, new_name_size, "%s_%04d%02d%02d_%02d%02d%02d_%06d",
table_name, now.year, now.month, now.day, now.hour, now.minute, table_name, now.year, now.month, now.day, now.hour, now.minute,
now.second, now.second_part); now.second, now.second_part);
@ -5185,7 +5175,7 @@ bool operator!=(const MYSQL_TIME &lhs, const MYSQL_TIME &rhs)
// Sets sys_trx_end=MAX for rows with sys_trx_end=now(6) // Sets sys_trx_end=MAX for rows with sys_trx_end=now(6)
static bool vers_reset_alter_copy(THD *thd, TABLE *table) static bool vers_reset_alter_copy(THD *thd, TABLE *table)
{ {
const MYSQL_TIME now= vers_thd_get_now(thd); const MYSQL_TIME query_start= thd->query_start_TIME();
READ_RECORD info; READ_RECORD info;
int error= 0; int error= 0;
@ -5201,7 +5191,7 @@ static bool vers_reset_alter_copy(THD *thd, TABLE *table)
MYSQL_TIME current; MYSQL_TIME current;
if (table->vers_end_field()->get_date(&current, 0)) if (table->vers_end_field()->get_date(&current, 0))
goto err_read_record; goto err_read_record;
if (current != now) if (current != query_start)
{ {
continue; continue;
} }
@ -9793,7 +9783,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
bool make_unversioned= from->versioned() && !to->versioned(); bool make_unversioned= from->versioned() && !to->versioned();
bool keep_versioned= from->versioned() && to->versioned(); bool keep_versioned= from->versioned() && to->versioned();
Field *to_sys_trx_start= NULL, *to_sys_trx_end= NULL, *from_sys_trx_end= NULL; Field *to_sys_trx_start= NULL, *to_sys_trx_end= NULL, *from_sys_trx_end= NULL;
MYSQL_TIME now; MYSQL_TIME query_start;
DBUG_ENTER("copy_data_between_tables"); DBUG_ENTER("copy_data_between_tables");
/* Two or 3 stages; Sorting, copying data and update indexes */ /* Two or 3 stages; Sorting, copying data and update indexes */
@ -9895,7 +9885,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
if (make_versioned) if (make_versioned)
{ {
now= vers_thd_get_now(thd); query_start= thd->query_start_TIME();
to_sys_trx_start= to->vers_start_field(); to_sys_trx_start= to->vers_start_field();
to_sys_trx_end= to->vers_end_field(); to_sys_trx_end= to->vers_end_field();
} }
@ -9908,10 +9898,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
to->file->vers_auto_decrement= 0xffffffffffffffff; to->file->vers_auto_decrement= 0xffffffffffffffff;
if (thd->variables.vers_ddl_survival) if (thd->variables.vers_ddl_survival)
{ {
thd->variables.time_zone->gmt_sec_to_TIME(&now, thd->query_start()); query_start= thd->query_start_TIME();
now.second_part= thd->query_start_sec_part();
thd->time_zone_used= 1;
from_sys_trx_end= from->vers_end_field(); from_sys_trx_end= from->vers_end_field();
to_sys_trx_start= to->vers_start_field(); to_sys_trx_start= to->vers_start_field();
} }
@ -9975,7 +9962,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
{ {
to_sys_trx_start->set_notnull(to_sys_trx_start->null_offset()); to_sys_trx_start->set_notnull(to_sys_trx_start->null_offset());
// TODO: write directly to record bypassing the same checks on every call // TODO: write directly to record bypassing the same checks on every call
to_sys_trx_start->store_time(&now); to_sys_trx_start->store_time(&query_start);
static const timeval max_tv= {0x7fffffff, 0}; static const timeval max_tv= {0x7fffffff, 0};
static const uint dec= 6; static const uint dec= 6;
@ -9993,9 +9980,9 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
continue; // Do not copy history rows. continue; // Do not copy history rows.
store_record(from, record[1]); store_record(from, record[1]);
from->vers_end_field()->store_time(&now); from->vers_end_field()->store_time(&query_start);
from->file->ha_update_row(from->record[1], from->record[0]); from->file->ha_update_row(from->record[1], from->record[0]);
to_sys_trx_start->store_time(&now); to_sys_trx_start->store_time(&query_start);
} }
prev_insert_id= to->file->next_insert_id; prev_insert_id= to->file->next_insert_id;