mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-37164 Assertion `vers_conditions.delete_history' failed upon PREPARE
Wrong assertion was added by f1f9284181
(MDEV-34046) because PS
parameter is applicable not only to DELETE HISTORY.
Keeping value of select_lex->where for DELETE HISTORY was remade via
prep_where which is read by reinit_stmt_before_use(). For SELECT
prep_where is set in JOIN::optimize_inner() and that is not called for
DELETE.
This commit is contained in:
@@ -277,6 +277,40 @@ a row_start row_end
|
||||
2 2000-01-01 00:00:01.000000 2000-01-01 00:00:02.000000
|
||||
3 2000-01-01 00:00:02.000000 2038-01-19 03:14:07.999999
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
select *, row_start, row_end from t for system_time as of @ts1;
|
||||
a row_start row_end
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
2 2000-01-01 00:00:01.000000 2000-01-01 00:00:02.000000
|
||||
execute immediate "select *, row_start, row_end from t for system_time as of ?" using @ts1;
|
||||
a row_start row_end
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
2 2000-01-01 00:00:01.000000 2000-01-01 00:00:02.000000
|
||||
prepare stmt from 'select *, row_start, row_end from t for system_time as of ?';
|
||||
execute stmt using @ts1;
|
||||
a row_start row_end
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
2 2000-01-01 00:00:01.000000 2000-01-01 00:00:02.000000
|
||||
Execute stmt using @ts1;
|
||||
a row_start row_end
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
2 2000-01-01 00:00:01.000000 2000-01-01 00:00:02.000000
|
||||
select *, row_start, row_end from t for system_time as of @ts2;
|
||||
a row_start row_end
|
||||
3 2000-01-01 00:00:02.000000 2038-01-19 03:14:07.999999
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
execute immediate "select *, row_start, row_end from t for system_time as of ?" using @ts2;
|
||||
a row_start row_end
|
||||
3 2000-01-01 00:00:02.000000 2038-01-19 03:14:07.999999
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
execute stmt using @ts2;
|
||||
a row_start row_end
|
||||
3 2000-01-01 00:00:02.000000 2038-01-19 03:14:07.999999
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
Execute stmt using @ts2;
|
||||
a row_start row_end
|
||||
3 2000-01-01 00:00:02.000000 2038-01-19 03:14:07.999999
|
||||
100 2000-01-01 00:00:00.000000 2038-01-19 03:14:07.999999
|
||||
drop prepare stmt;
|
||||
execute immediate "delete history from t before system_time @ts1";
|
||||
select *, row_start, row_end from t for system_time all order by a;
|
||||
a row_start row_end
|
||||
@@ -463,4 +497,11 @@ a row_start row_end
|
||||
drop prepare stmt;
|
||||
drop table t;
|
||||
set timestamp= default;
|
||||
#
|
||||
# MDEV-37164 Assertion `vers_conditions.delete_history' failed upon PREPARE
|
||||
#
|
||||
create table t (a int) with system versioning;
|
||||
insert into t values (1),(2);
|
||||
prepare stmt from 'select * from t for system_time as of timestamp ?';
|
||||
drop table t;
|
||||
# End of 10.11 tests
|
||||
|
@@ -276,6 +276,17 @@ set @ts2= '2000-01-01 00:00:02'; set timestamp= unix_timestamp(@ts2);
|
||||
update t set a= a + 1 where a < 100;
|
||||
set @ts3= '2000-01-01 00:00:03'; set timestamp= unix_timestamp(@ts3);
|
||||
select *, row_start, row_end from t for system_time all order by a;
|
||||
select *, row_start, row_end from t for system_time as of @ts1;
|
||||
execute immediate "select *, row_start, row_end from t for system_time as of ?" using @ts1;
|
||||
prepare stmt from 'select *, row_start, row_end from t for system_time as of ?';
|
||||
execute stmt using @ts1;
|
||||
Execute stmt using @ts1;
|
||||
select *, row_start, row_end from t for system_time as of @ts2;
|
||||
execute immediate "select *, row_start, row_end from t for system_time as of ?" using @ts2;
|
||||
execute stmt using @ts2;
|
||||
Execute stmt using @ts2;
|
||||
drop prepare stmt;
|
||||
|
||||
execute immediate "delete history from t before system_time @ts1";
|
||||
select *, row_start, row_end from t for system_time all order by a;
|
||||
execute immediate "delete history from t before system_time @ts2";
|
||||
@@ -352,6 +363,14 @@ drop prepare stmt;
|
||||
drop table t;
|
||||
set timestamp= default;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-37164 Assertion `vers_conditions.delete_history' failed upon PREPARE
|
||||
--echo #
|
||||
create table t (a int) with system versioning;
|
||||
insert into t values (1),(2);
|
||||
prepare stmt from 'select * from t for system_time as of timestamp ?';
|
||||
drop table t;
|
||||
|
||||
--echo # End of 10.11 tests
|
||||
|
||||
--source suite/versioning/common_finish.inc
|
||||
|
@@ -1279,21 +1279,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
}
|
||||
|
||||
if (vers_conditions.type == SYSTEM_TIME_ALL)
|
||||
{
|
||||
if (vers_conditions.has_param)
|
||||
{
|
||||
/*
|
||||
Parameter substitution (set_params_from_actual_params()) works
|
||||
on existing items so we don't have to reevaluate table->where
|
||||
(in update_this below), we just update SELECT_LEX WHERE expression
|
||||
from existing table conditions.
|
||||
*/
|
||||
DBUG_ASSERT(vers_conditions.delete_history);
|
||||
DBUG_ASSERT(thd->stmt_arena->is_stmt_execute());
|
||||
where= and_items(thd, where, table->where);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
bool timestamps_only= table->table->versioned(VERS_TIMESTAMP);
|
||||
@@ -1322,7 +1308,6 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
the loop, but at execution enter update_this. The second execution
|
||||
is skipped on vers_conditions.type == SYSTEM_TIME_ALL condition.
|
||||
*/
|
||||
DBUG_ASSERT(vers_conditions.delete_history);
|
||||
if (thd->stmt_arena->is_stmt_prepare())
|
||||
continue;
|
||||
DBUG_ASSERT(thd->stmt_arena->is_stmt_execute());
|
||||
@@ -1347,6 +1332,8 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
else
|
||||
where= and_items(thd, where, cond);
|
||||
table->where= and_items(thd, table->where, cond);
|
||||
if (where && vers_conditions.has_param && vers_conditions.delete_history)
|
||||
prep_where= where->copy_andor_structure(thd);
|
||||
}
|
||||
|
||||
table->vers_conditions.set_all();
|
||||
|
Reference in New Issue
Block a user