mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
SQL: MAX microseconds for current system rows [fixes #245]
This commit is contained in:
@@ -194,29 +194,29 @@ drop table t2;
|
|||||||
end~~
|
end~~
|
||||||
call test_01('timestamp(6)', 'myisam', 'sys_end');
|
call test_01('timestamp(6)', 'myisam', 'sys_end');
|
||||||
x y sys_end
|
x y sys_end
|
||||||
3 4 2038-01-19 03:14:07.000000
|
3 4 2038-01-19 03:14:07.999999
|
||||||
2 3 2038-01-19 03:14:07.000000
|
2 3 2038-01-19 03:14:07.999999
|
||||||
40 33 2038-01-19 03:14:07.000000
|
40 33 2038-01-19 03:14:07.999999
|
||||||
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
|
call test_01('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
|
||||||
x y vtq_commit_ts(sys_end)
|
x y vtq_commit_ts(sys_end)
|
||||||
3 4 2038-01-19 03:14:07.000000
|
3 4 2038-01-19 03:14:07.999999
|
||||||
2 3 2038-01-19 03:14:07.000000
|
2 3 2038-01-19 03:14:07.999999
|
||||||
40 33 2038-01-19 03:14:07.000000
|
40 33 2038-01-19 03:14:07.999999
|
||||||
call test_02('timestamp(6)', 'myisam', 'sys_end');
|
call test_02('timestamp(6)', 'myisam', 'sys_end');
|
||||||
id x y sys_end
|
id x y sys_end
|
||||||
1 33 44 2038-01-19 03:14:07.000000
|
1 33 44 2038-01-19 03:14:07.999999
|
||||||
20 33 44 2038-01-19 03:14:07.000000
|
20 33 44 2038-01-19 03:14:07.999999
|
||||||
40 33 44 2038-01-19 03:14:07.000000
|
40 33 44 2038-01-19 03:14:07.999999
|
||||||
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
|
call test_02('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
|
||||||
id x y vtq_commit_ts(sys_end)
|
id x y vtq_commit_ts(sys_end)
|
||||||
1 33 44 2038-01-19 03:14:07.000000
|
1 33 44 2038-01-19 03:14:07.999999
|
||||||
20 33 44 2038-01-19 03:14:07.000000
|
20 33 44 2038-01-19 03:14:07.999999
|
||||||
40 33 44 2038-01-19 03:14:07.000000
|
40 33 44 2038-01-19 03:14:07.999999
|
||||||
call test_03('timestamp(6)', 'myisam', 'sys_end');
|
call test_03('timestamp(6)', 'myisam', 'sys_end');
|
||||||
x y sys_end
|
x y sys_end
|
||||||
8001 9001 2038-01-19 03:14:07.000000
|
8001 9001 2038-01-19 03:14:07.999999
|
||||||
1001 2001 2038-01-19 03:14:07.000000
|
1001 2001 2038-01-19 03:14:07.999999
|
||||||
1002 2002 2038-01-19 03:14:07.000000
|
1002 2002 2038-01-19 03:14:07.999999
|
||||||
x y
|
x y
|
||||||
8001 9001
|
8001 9001
|
||||||
1001 2001
|
1001 2001
|
||||||
@@ -225,9 +225,9 @@ drop table t1;
|
|||||||
drop view vt1_1;
|
drop view vt1_1;
|
||||||
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
|
call test_03('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
|
||||||
x y vtq_commit_ts(sys_end)
|
x y vtq_commit_ts(sys_end)
|
||||||
8001 9001 2038-01-19 03:14:07.000000
|
8001 9001 2038-01-19 03:14:07.999999
|
||||||
1001 2001 2038-01-19 03:14:07.000000
|
1001 2001 2038-01-19 03:14:07.999999
|
||||||
1002 2002 2038-01-19 03:14:07.000000
|
1002 2002 2038-01-19 03:14:07.999999
|
||||||
x y
|
x y
|
||||||
8001 9001
|
8001 9001
|
||||||
1001 2001
|
1001 2001
|
||||||
|
@@ -168,7 +168,7 @@ set @ts_start= sys_commit_ts('sys_trx_start');
|
|||||||
set @ts_end= sys_commit_ts('sys_trx_end');
|
set @ts_end= sys_commit_ts('sys_trx_end');
|
||||||
set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all');
|
set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all');
|
||||||
prepare select_p0 from @str;
|
prepare select_p0 from @str;
|
||||||
set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07\' as D from t1 partition (pn) for system_time all');
|
set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn) for system_time all');
|
||||||
prepare select_pn from @str;
|
prepare select_pn from @str;
|
||||||
execute select_p0;
|
execute select_p0;
|
||||||
x A B
|
x A B
|
||||||
|
@@ -85,7 +85,7 @@ x
|
|||||||
create or replace view vt1 as select * from t1;
|
create or replace view vt1 as select * from t1;
|
||||||
show create view vt1;
|
show create view vt1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `x`,`t1`.`sys_trx_start` AS `sys_trx_start`,`t1`.`sys_trx_end` AS `sys_trx_end` from `t1` FOR SYSTEM_TIME ALL where `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' latin1 latin1_swedish_ci
|
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`x` AS `x`,`t1`.`sys_trx_start` AS `sys_trx_start`,`t1`.`sys_trx_end` AS `sys_trx_end` from `t1` FOR SYSTEM_TIME ALL where `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' latin1 latin1_swedish_ci
|
||||||
drop view vt1;
|
drop view vt1;
|
||||||
drop view vt2;
|
drop view vt2;
|
||||||
create view vt1 as select * from t1 for system_time all;
|
create view vt1 as select * from t1 for system_time all;
|
||||||
@@ -178,15 +178,15 @@ create or replace table t3 (x int);
|
|||||||
create or replace view vt1 as select * from t1, t2, t3;
|
create or replace view vt1 as select * from t1, t2, t3;
|
||||||
show create view vt1;
|
show create view vt1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,`t3`.`x` AS `x`,`t1`.`sys_trx_start` AS `sys_trx_start`,`t1`.`sys_trx_end` AS `sys_trx_end` from ((`t1` FOR SYSTEM_TIME ALL join `t2` FOR SYSTEM_TIME ALL) join `t3`) where `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' and `t2`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' latin1 latin1_swedish_ci
|
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`b` AS `b`,`t3`.`x` AS `x`,`t1`.`sys_trx_start` AS `sys_trx_start`,`t1`.`sys_trx_end` AS `sys_trx_end` from ((`t1` FOR SYSTEM_TIME ALL join `t2` FOR SYSTEM_TIME ALL) join `t3`) where `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' and `t2`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' latin1 latin1_swedish_ci
|
||||||
create or replace view vt1 as select * from t3, t2, t1;
|
create or replace view vt1 as select * from t3, t2, t1;
|
||||||
show create view vt1;
|
show create view vt1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t3`.`x` AS `x`,`t2`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`sys_trx_start` AS `sys_trx_start`,`t2`.`sys_trx_end` AS `sys_trx_end` from ((`t3` join `t2` FOR SYSTEM_TIME ALL) join `t1` FOR SYSTEM_TIME ALL) where `t2`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' and `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' latin1 latin1_swedish_ci
|
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t3`.`x` AS `x`,`t2`.`b` AS `b`,`t1`.`a` AS `a`,`t2`.`sys_trx_start` AS `sys_trx_start`,`t2`.`sys_trx_end` AS `sys_trx_end` from ((`t3` join `t2` FOR SYSTEM_TIME ALL) join `t1` FOR SYSTEM_TIME ALL) where `t2`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' and `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' latin1 latin1_swedish_ci
|
||||||
create or replace view vt1 as select a, t2.sys_trx_end as endo from t3, t1, t2;
|
create or replace view vt1 as select a, t2.sys_trx_end as endo from t3, t1, t2;
|
||||||
show create view vt1;
|
show create view vt1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`sys_trx_end` AS `endo`,`t2`.`sys_trx_start` AS `sys_trx_start` from ((`t3` join `t1` FOR SYSTEM_TIME ALL) join `t2` FOR SYSTEM_TIME ALL) where `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' and `t2`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07' latin1 latin1_swedish_ci
|
vt1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vt1` AS select `t1`.`a` AS `a`,`t2`.`sys_trx_end` AS `endo`,`t2`.`sys_trx_start` AS `sys_trx_start` from ((`t3` join `t1` FOR SYSTEM_TIME ALL) join `t2` FOR SYSTEM_TIME ALL) where `t1`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' and `t2`.`sys_trx_end` = TIMESTAMP'2038-01-19 03:14:07.999999' latin1 latin1_swedish_ci
|
||||||
create or replace view vvt1 as select * from t1, t2, vt1;
|
create or replace view vvt1 as select * from t1, t2, vt1;
|
||||||
ERROR HY000: Creating VIEW `vvt1` is prohibited: versioned VIEW `vt1` in query!
|
ERROR HY000: Creating VIEW `vvt1` is prohibited: versioned VIEW `vt1` in query!
|
||||||
drop view vt1, vt12;
|
drop view vt1, vt12;
|
||||||
|
@@ -102,7 +102,7 @@ set @ts_start= sys_commit_ts('sys_trx_start');
|
|||||||
set @ts_end= sys_commit_ts('sys_trx_end');
|
set @ts_end= sys_commit_ts('sys_trx_end');
|
||||||
set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all');
|
set @str= concat('select x, ', @ts_start, ' < @now as A, ', @ts_end, ' > @now as B from t1 partition (p0) for system_time all');
|
||||||
prepare select_p0 from @str;
|
prepare select_p0 from @str;
|
||||||
set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07\' as D from t1 partition (pn) for system_time all');
|
set @str= concat('select x, ', @ts_start, ' > @now as C, ', @ts_end, ' = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn) for system_time all');
|
||||||
prepare select_pn from @str;
|
prepare select_pn from @str;
|
||||||
|
|
||||||
execute select_p0;
|
execute select_p0;
|
||||||
|
@@ -137,7 +137,7 @@ insert into t1 values (1);
|
|||||||
create trigger read_end after update on t1
|
create trigger read_end after update on t1
|
||||||
for each row set @end = old.sys_trx_end;
|
for each row set @end = old.sys_trx_end;
|
||||||
update t1 set a=2;
|
update t1 set a=2;
|
||||||
--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.000000" MAX_RESULT
|
--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.999999" MAX_RESULT
|
||||||
select @end;
|
select @end;
|
||||||
|
|
||||||
create or replace table t1 (a int) with system versioning;
|
create or replace table t1 (a int) with system versioning;
|
||||||
|
@@ -150,7 +150,7 @@ insert into t1 values (1);
|
|||||||
create trigger read_end after update on t1
|
create trigger read_end after update on t1
|
||||||
for each row set @end = old.sys_trx_end;
|
for each row set @end = old.sys_trx_end;
|
||||||
update t1 set a=2;
|
update t1 set a=2;
|
||||||
--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.000000" MAX_RESULT
|
--replace_result 18446744073709551615 MAX_RESULT "2038-01-19 03:14:07.999999" MAX_RESULT
|
||||||
select @end;
|
select @end;
|
||||||
|
|
||||||
create or replace table t1 (a int) with system versioning;
|
create or replace table t1 (a int) with system versioning;
|
||||||
|
@@ -2012,6 +2012,7 @@ bool Field_vers_system::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate, ulonglo
|
|||||||
if (trx_id == ULONGLONG_MAX)
|
if (trx_id == ULONGLONG_MAX)
|
||||||
{
|
{
|
||||||
get_thd()->variables.time_zone->gmt_sec_to_TIME(ltime, TIMESTAMP_MAX_VALUE);
|
get_thd()->variables.time_zone->gmt_sec_to_TIME(ltime, TIMESTAMP_MAX_VALUE);
|
||||||
|
ltime->second_part= TIME_MAX_SECOND_PART;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cached == trx_id)
|
if (cached == trx_id)
|
||||||
@@ -5481,10 +5482,11 @@ void Field_timestampf::set_max()
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("Field_timestampf::set_max");
|
DBUG_ENTER("Field_timestampf::set_max");
|
||||||
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED;
|
||||||
|
DBUG_ASSERT(dec == TIME_SECOND_PART_DIGITS);
|
||||||
|
|
||||||
set_notnull();
|
set_notnull();
|
||||||
mi_int4store(ptr, TIMESTAMP_MAX_VALUE);
|
mi_int4store(ptr, TIMESTAMP_MAX_VALUE);
|
||||||
memset(ptr + 4, 0x0, value_length() - 4);
|
mi_int3store(ptr + 4, TIME_MAX_SECOND_PART);
|
||||||
|
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
@@ -5494,7 +5496,8 @@ bool Field_timestampf::is_max()
|
|||||||
DBUG_ENTER("Field_timestampf::is_max");
|
DBUG_ENTER("Field_timestampf::is_max");
|
||||||
ASSERT_COLUMN_MARKED_FOR_READ;
|
ASSERT_COLUMN_MARKED_FOR_READ;
|
||||||
|
|
||||||
DBUG_RETURN(mi_sint4korr(ptr) == 0x7fffffff);
|
DBUG_RETURN(mi_sint4korr(ptr) == TIMESTAMP_MAX_VALUE &&
|
||||||
|
mi_sint3korr(ptr + 4) == TIME_MAX_SECOND_PART);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_time_t Field_timestampf::get_timestamp(const uchar *pos,
|
my_time_t Field_timestampf::get_timestamp(const uchar *pos,
|
||||||
|
@@ -67,6 +67,7 @@ Item_func_vtq_ts::get_date(MYSQL_TIME *res, ulonglong fuzzy_date)
|
|||||||
{
|
{
|
||||||
null_value= false;
|
null_value= false;
|
||||||
thd->variables.time_zone->gmt_sec_to_TIME(res, TIMESTAMP_MAX_VALUE);
|
thd->variables.time_zone->gmt_sec_to_TIME(res, TIMESTAMP_MAX_VALUE);
|
||||||
|
res->second_part= TIME_MAX_SECOND_PART;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -676,7 +676,8 @@ bool vers_select_conds_t::init_from_sysvar(THD *thd)
|
|||||||
if (type != FOR_SYSTEM_TIME_UNSPECIFIED && type != FOR_SYSTEM_TIME_ALL)
|
if (type != FOR_SYSTEM_TIME_UNSPECIFIED && type != FOR_SYSTEM_TIME_ALL)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(type == FOR_SYSTEM_TIME_AS_OF);
|
DBUG_ASSERT(type == FOR_SYSTEM_TIME_AS_OF);
|
||||||
start= new (thd->mem_root) Item_datetime_literal(thd, &in.ltime, 6);
|
start= new (thd->mem_root)
|
||||||
|
Item_datetime_literal(thd, &in.ltime, TIME_SECOND_PART_DIGITS);
|
||||||
if (!start)
|
if (!start)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -921,7 +922,9 @@ int vers_setup_select(THD *thd, TABLE_LIST *tables, COND **where_expr,
|
|||||||
{
|
{
|
||||||
MYSQL_TIME max_time;
|
MYSQL_TIME max_time;
|
||||||
thd->variables.time_zone->gmt_sec_to_TIME(&max_time, TIMESTAMP_MAX_VALUE);
|
thd->variables.time_zone->gmt_sec_to_TIME(&max_time, TIMESTAMP_MAX_VALUE);
|
||||||
curr= newx Item_datetime_literal(thd, &max_time);
|
max_time.second_part= TIME_MAX_SECOND_PART;
|
||||||
|
curr= newx Item_datetime_literal(thd, &max_time,
|
||||||
|
TIME_SECOND_PART_DIGITS);
|
||||||
cond1= newx Item_func_eq(thd, row_end, curr);
|
cond1= newx Item_func_eq(thd, row_end, curr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -10017,8 +10017,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
// 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(&query_start);
|
to_sys_trx_start->store_time(&query_start);
|
||||||
|
|
||||||
static const timeval max_tv= {0x7fffffff, 0};
|
static const timeval max_tv= {TIMESTAMP_MAX_VALUE, TIME_MAX_SECOND_PART};
|
||||||
static const uint dec= 6;
|
static const uint dec= TIME_SECOND_PART_DIGITS;
|
||||||
to_sys_trx_end->set_notnull(to_sys_trx_end->null_offset());
|
to_sys_trx_end->set_notnull(to_sys_trx_end->null_offset());
|
||||||
my_timestamp_to_binary(&max_tv, to_sys_trx_end->ptr, dec);
|
my_timestamp_to_binary(&max_tv, to_sys_trx_end->ptr, dec);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user