1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-16937 Strict SQL with system versioned tables causes issues

Respect system fields in NO_ZERO_DATE mode.

This is the subject for refactoring in MDEV-19597
This commit is contained in:
Aleksey Midenkov
2020-05-28 22:22:20 +03:00
parent dd9773b723
commit 19da9a51ae
18 changed files with 66 additions and 30 deletions

View File

@ -50,6 +50,10 @@ if ($MTR_COMBINATION_MYISAM)
{
--let $MTR_COMBINATION_TIMESTAMP= 1
}
if ($MTR_COMBINATION_TRADITIONAL)
{
--let $MTR_COMBINATION_TIMESTAMP= 1
}
if ($MTR_COMBINATION_HEAP)
{
--let $MTR_COMBINATION_TIMESTAMP= 1

View File

@ -7,5 +7,10 @@ default-storage-engine=innodb
[myisam]
default-storage-engine=myisam
[traditional]
default-storage-engine=myisam
sql-mode=traditional
[heap]
default-storage-engine=memory

View File

@ -43,7 +43,7 @@ ASOF_x y
7 107
8 108
9 109
select x as FROMTO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as FROMTO_x, y from t1 for system_time from timestamp '1970-01-01 00:00:00' to timestamp @t1;
FROMTO_x y
0 100
1 101
@ -55,7 +55,7 @@ FROMTO_x y
7 107
8 108
9 109
select x as BETWAND_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between timestamp '1970-01-01 00:00:00' and timestamp @t1;
BETWAND_x y
0 100
1 101
@ -247,7 +247,7 @@ a b
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
a b
1 2
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
select * from (select * from t1 cross join t2 for system_time as of timestamp ('1970-01-01 00:00:00')) as tmp;
a b
create or replace table t1(a1 int) with system versioning;
create or replace table t2(a2 int) with system versioning;

View File

@ -22,7 +22,7 @@
7 107
8 108
9 109
-select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
-select x as FROMTO2_x, y from t1 for system_time from '1970-01-01 00:00' to @t1;
+select x as FROMTO2_x, y from t1 for system_time from @x0 to @x1;
FROMTO2_x y
0 100
@ -31,7 +31,7 @@
7 107
8 108
9 109
-select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
-select x as BETWAND2_x, y from t1 for system_time between timestamp '1970-01-01 00:00' and timestamp @t1;
+select x as BETWAND2_x, y from t1 for system_time between transaction @x0 and transaction @x1;
BETWAND2_x y
0 100

View File

@ -44,7 +44,7 @@ ASOF_x y
7 107
8 108
9 109
select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1;
select x as FROMTO_x, y from t1 for system_time from '1970-01-01 00:00' to timestamp @t1;
FROMTO_x y
0 100
1 101
@ -56,7 +56,7 @@ FROMTO_x y
7 107
8 108
9 109
select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between '1970-01-01 00:00' and timestamp @t1;
BETWAND_x y
0 100
1 101
@ -94,7 +94,7 @@ ASOF2_x y
7 107
8 108
9 109
select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
select x as FROMTO2_x, y from t1 for system_time from '1970-01-01 00:00' to @t1;
FROMTO2_x y
0 100
1 101
@ -106,7 +106,7 @@ FROMTO2_x y
7 107
8 108
9 109
select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '1970-01-01 00:00' and timestamp @t1;
BETWAND2_x y
0 100
1 101
@ -270,7 +270,7 @@ a b
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
a b
1 2
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
select * from (select * from t1 cross join t2 for system_time as of timestamp ('1970-01-01 00:00')) as tmp;
a b
create or replace table t1(a1 int) with system versioning;
create or replace table t2(a2 int) with system versioning;

View File

@ -134,11 +134,11 @@ select * from t for system_time all;
a
2
1
select * from t for system_time from '0-0-0' to current_timestamp(6);
select * from t for system_time from '1970-01-01 00:00' to current_timestamp(6);
a
2
1
select * from t for system_time between '0-0-0' and current_timestamp(6);
select * from t for system_time between '1970-01-01 00:00' and current_timestamp(6);
a
2
1

View File

@ -79,7 +79,7 @@ create or replace view vt12 as select * from t1 cross join t2;
select * from vt12;
a b
1 2
create or replace view vt12 as select * from t1 for system_time as of timestamp ('0-0-0') cross join t2;
create or replace view vt12 as select * from t1 for system_time as of timestamp ('1970-01-01 00:00') cross join t2;
select * from vt12;
a b
# VIEW improvements [tempesta-tech/mariadb#183]

View File

@ -48,8 +48,8 @@ if ($MTR_COMBINATION_TRX_ID)
select x, y from t1;
select x as ASOF_x, y from t1 for system_time as of timestamp @t0;
select x as FROMTO_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO_x, y from t1 for system_time from timestamp '1970-01-01 00:00:00' to timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between timestamp '1970-01-01 00:00:00' and timestamp @t1;
select x as ALL_x, y from t1 for system_time all;
--disable_query_log
@ -62,8 +62,8 @@ if ($MTR_COMBINATION_TRX_ID)
if ($MTR_COMBINATION_TIMESTAMP)
{
select x as ASOF2_x, y from t1 for system_time as of @t0;
select x as FROMTO2_x, y from t1 for system_time from timestamp '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO2_x, y from t1 for system_time from timestamp '1970-01-01 00:00:00' to timestamp @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '1970-01-01 00:00:00' and timestamp @t1;
}
--enable_query_log
@ -161,7 +161,7 @@ insert into t1 values (1);
insert into t2 values (2);
select * from (select * from t1 cross join t2) as tmp;
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
select * from (select * from t1 cross join t2 for system_time as of timestamp ('1970-01-01 00:00:00')) as tmp;
create or replace table t1(a1 int) with system versioning;
create or replace table t2(a2 int) with system versioning;

View File

@ -36,8 +36,8 @@ if($MTR_COMBINATION_TRX_ID) {
select x, y from t1;
select x as ASOF_x, y from t1 for system_time as of timestamp @t0;
select x as FROMTO_x, y from t1 for system_time from '0-0-0 0:0:0' to timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO_x, y from t1 for system_time from '1970-01-01 00:00' to timestamp @t1;
select x as BETWAND_x, y from t1 for system_time between '1970-01-01 00:00' and timestamp @t1;
select x as ALL_x, y from t1 for system_time all;
if($MTR_COMBINATION_TRX_ID) {
@ -47,8 +47,8 @@ if($MTR_COMBINATION_TRX_ID) {
}
if(!$MTR_COMBINATION_TRX_ID) {
select x as ASOF2_x, y from t1 for system_time as of @t0;
select x as FROMTO2_x, y from t1 for system_time from '0-0-0 0:0:0' to @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp @t1;
select x as FROMTO2_x, y from t1 for system_time from '1970-01-01 00:00' to @t1;
select x as BETWAND2_x, y from t1 for system_time between timestamp '1970-01-01 00:00' and timestamp @t1;
}
drop table t1;
@ -166,7 +166,7 @@ insert into t1 values (1);
insert into t2 values (2);
select * from (select * from t1 cross join t2) as tmp;
select * from (select * from (select * from t1 cross join t2) as tmp1) as tmp2;
select * from (select * from t1 cross join t2 for system_time as of timestamp ('0-0-0')) as tmp;
select * from (select * from t1 cross join t2 for system_time as of timestamp ('1970-01-01 00:00')) as tmp;
create or replace table t1(a1 int) with system versioning;
create or replace table t2(a2 int) with system versioning;

View File

@ -97,8 +97,8 @@ select * from t for system_time all;
select * from t;
select * from t for system_time as of timestamp current_timestamp(6);
select * from t for system_time all;
select * from t for system_time from '0-0-0' to current_timestamp(6);
select * from t for system_time between '0-0-0' and current_timestamp(6);
select * from t for system_time from '1970-01-01 00:00' to current_timestamp(6);
select * from t for system_time between '1970-01-01 00:00' and current_timestamp(6);
show status like "Feature_system_versioning";

View File

@ -65,7 +65,7 @@ insert into t1 values (1);
insert into t2 values (2);
create or replace view vt12 as select * from t1 cross join t2;
select * from vt12;
create or replace view vt12 as select * from t1 for system_time as of timestamp ('0-0-0') cross join t2;
create or replace view vt12 as select * from t1 for system_time as of timestamp ('1970-01-01 00:00') cross join t2;
select * from vt12;
--echo # VIEW improvements [tempesta-tech/mariadb#183]