mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
SQL: default engine fix in create from versioned [fixes #206]
This commit is contained in:
committed by
Aleksey Midenkov
parent
faab918ecd
commit
46d572dde4
@ -61,6 +61,15 @@ drop table tmp;
|
|||||||
end if;
|
end if;
|
||||||
end~~
|
end~~
|
||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
|
create function if not exists non_default_engine()
|
||||||
|
returns varchar(255)
|
||||||
|
deterministic
|
||||||
|
begin
|
||||||
|
if default_engine() = 'innodb' then
|
||||||
|
return 'myisam';
|
||||||
|
end if;
|
||||||
|
return 'innodb';
|
||||||
|
end~~
|
||||||
create table t1 (
|
create table t1 (
|
||||||
x1 int unsigned,
|
x1 int unsigned,
|
||||||
Sys_start SYS_TRX_TYPE generated always as row start comment 'start',
|
Sys_start SYS_TRX_TYPE generated always as row start comment 'start',
|
||||||
@ -328,9 +337,18 @@ select st, en from t2 for system_time all where y = 2 into @st, @en;
|
|||||||
select y from t2 for system_time all where st = @st and en = @en;
|
select y from t2 for system_time all where st = @st and en = @en;
|
||||||
y
|
y
|
||||||
2
|
2
|
||||||
|
create or replace table t1 (a int) with system versioning engine INNODB_OR_MYISAM;
|
||||||
|
create or replace table t2 as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||||
|
create or replace table t2 engine INNODB_OR_MYISAM as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||||
|
ERROR HY000: `sys_trx_start` must be of type `SYS_TRX_TYPE` for versioned table `t2`
|
||||||
|
create or replace table t1 (a int, id int) with system versioning engine INNODB_OR_MYISAM;
|
||||||
|
create or replace table t2 (b int, id int);
|
||||||
|
create or replace table t3 as
|
||||||
|
select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
drop function non_default_engine;
|
||||||
drop procedure verify_vtq;
|
drop procedure verify_vtq;
|
||||||
drop procedure innodb_verify_vtq;
|
drop procedure innodb_verify_vtq;
|
||||||
drop function default_engine;
|
drop function default_engine;
|
||||||
|
@ -4,7 +4,21 @@
|
|||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
|
||||||
|
delimiter ~~;
|
||||||
|
create function if not exists non_default_engine()
|
||||||
|
returns varchar(255)
|
||||||
|
deterministic
|
||||||
|
begin
|
||||||
|
if default_engine() = 'innodb' then
|
||||||
|
return 'myisam';
|
||||||
|
end if;
|
||||||
|
return 'innodb';
|
||||||
|
end~~
|
||||||
|
delimiter ;~~
|
||||||
|
|
||||||
--let $sys_datatype= `select sys_datatype()`
|
--let $sys_datatype= `select sys_datatype()`
|
||||||
|
--let $default_engine= `select default_engine()`
|
||||||
|
--let $non_default_engine= `select non_default_engine()`
|
||||||
|
|
||||||
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
--replace_result "bigint unsigned" SYS_TRX_TYPE timestamp(6) SYS_TRX_TYPE
|
||||||
eval create table t1 (
|
eval create table t1 (
|
||||||
@ -257,8 +271,23 @@ select y from t2 for system_time all where st = @st and en = @en;
|
|||||||
select st, en from t2 for system_time all where y = 2 into @st, @en;
|
select st, en from t2 for system_time all where y = 2 into @st, @en;
|
||||||
select y from t2 for system_time all where st = @st and en = @en;
|
select y from t2 for system_time all where st = @st and en = @en;
|
||||||
|
|
||||||
|
--replace_result innodb INNODB_OR_MYISAM myisam INNODB_OR_MYISAM
|
||||||
|
eval create or replace table t1 (a int) with system versioning engine $non_default_engine;
|
||||||
|
create or replace table t2 as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||||
|
--replace_result innodb INNODB_OR_MYISAM myisam INNODB_OR_MYISAM "BIGINT(20) UNSIGNED" SYS_TRX_TYPE "TIMESTAMP(6)" SYS_TRX_TYPE
|
||||||
|
--error ER_VERS_FIELD_WRONG_TYPE
|
||||||
|
eval create or replace table t2 engine $default_engine as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
|
||||||
|
|
||||||
|
--replace_result innodb INNODB_OR_MYISAM myisam INNODB_OR_MYISAM
|
||||||
|
eval create or replace table t1 (a int, id int) with system versioning engine $non_default_engine;
|
||||||
|
create or replace table t2 (b int, id int);
|
||||||
|
create or replace table t3 as
|
||||||
|
select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
drop table t2;
|
drop table t2;
|
||||||
drop table t3;
|
drop table t3;
|
||||||
|
|
||||||
|
drop function non_default_engine;
|
||||||
|
|
||||||
-- source suite/versioning/common_finish.inc
|
-- source suite/versioning/common_finish.inc
|
||||||
|
@ -6663,9 +6663,6 @@ bool Vers_parse_info::check_and_fix_implicit(
|
|||||||
HA_CREATE_INFO *create_info,
|
HA_CREATE_INFO *create_info,
|
||||||
const char* table_name)
|
const char* table_name)
|
||||||
{
|
{
|
||||||
bool integer_fields=
|
|
||||||
create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING;
|
|
||||||
|
|
||||||
SELECT_LEX &slex= thd->lex->select_lex;
|
SELECT_LEX &slex= thd->lex->select_lex;
|
||||||
int vers_tables= 0;
|
int vers_tables= 0;
|
||||||
bool from_select= slex.item_list.elements ? true : false;
|
bool from_select= slex.item_list.elements ? true : false;
|
||||||
@ -6677,6 +6674,21 @@ bool Vers_parse_info::check_and_fix_implicit(
|
|||||||
if (table->table && table->table->versioned())
|
if (table->table && table->table->versioned())
|
||||||
vers_tables++;
|
vers_tables++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Possibly override default storage engine to match
|
||||||
|
// one used in source table.
|
||||||
|
if (!(create_info->used_fields & HA_CREATE_USED_ENGINE))
|
||||||
|
{
|
||||||
|
List_iterator_fast<Create_field> it(alter_info->create_list);
|
||||||
|
while (Create_field *f= it++)
|
||||||
|
{
|
||||||
|
if (is_trx_start(*f) || is_trx_end(*f))
|
||||||
|
{
|
||||||
|
create_info->db_type= f->field->orig_table->file->ht;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CREATE ... SELECT: if at least one table in SELECT is versioned,
|
// CREATE ... SELECT: if at least one table in SELECT is versioned,
|
||||||
@ -6750,6 +6762,8 @@ bool Vers_parse_info::check_and_fix_implicit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool integer_fields= create_info->db_type->flags & HTON_NATIVE_SYS_VERSIONING;
|
||||||
|
|
||||||
if (vers_tables > 0)
|
if (vers_tables > 0)
|
||||||
{
|
{
|
||||||
if (!generated_as_row.start && !generated_as_row.end)
|
if (!generated_as_row.start && !generated_as_row.end)
|
||||||
|
Reference in New Issue
Block a user