Skip to content

Commit c86773f

Browse files
midenokabarkov
authored andcommitted
MDEV-18136 Server crashes in Item_func_dyncol_create::prepare_arguments
[Closes tempesta-tech#572]
1 parent 6473641 commit c86773f

File tree

5 files changed

+47
-14
lines changed

5 files changed

+47
-14
lines changed

mysql-test/suite/versioning/r/partition.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,25 @@ set timestamp=1523466002.799571;
522522
insert into t1 values (11),(12);
523523
set timestamp=1523466004.169435;
524524
delete from t1 where pk in (11, 12);
525+
#
526+
# MDEV-18136 Server crashes in Item_func_dyncol_create::prepare_arguments
527+
#
528+
create or replace table t1 (pk int) with system versioning
529+
partition by system_time interval 7 second (
530+
partition ver_p1 history,
531+
partition ver_pn current);
532+
alter table t1
533+
partition by system_time interval column_get(column_create(7,7), 7 as int) second (
534+
partition ver_p1 history,
535+
partition ver_pn current);
536+
show create table t1;
537+
Table Create Table
538+
t1 CREATE TABLE `t1` (
539+
`pk` int(11) DEFAULT NULL
540+
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
541+
PARTITION BY SYSTEM_TIME INTERVAL 7 SECOND
542+
(PARTITION `ver_p1` HISTORY ENGINE = DEFAULT_ENGINE,
543+
PARTITION `ver_pn` CURRENT ENGINE = DEFAULT_ENGINE)
525544
# Test cleanup
526545
drop database test;
527546
create database test;

mysql-test/suite/versioning/t/partition.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,20 @@ insert into t1 values (11),(12);
475475
set timestamp=1523466004.169435;
476476
delete from t1 where pk in (11, 12);
477477

478+
--echo #
479+
--echo # MDEV-18136 Server crashes in Item_func_dyncol_create::prepare_arguments
480+
--echo #
481+
create or replace table t1 (pk int) with system versioning
482+
partition by system_time interval 7 second (
483+
partition ver_p1 history,
484+
partition ver_pn current);
485+
alter table t1
486+
partition by system_time interval column_get(column_create(7,7), 7 as int) second (
487+
partition ver_p1 history,
488+
partition ver_pn current);
489+
--replace_result $default_engine DEFAULT_ENGINE
490+
show create table t1;
491+
478492
--echo # Test cleanup
479493
drop database test;
480494
create database test;

sql/partition_info.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,26 @@ class partition_info : public Sql_alloc
395395
bool field_in_partition_expr(Field *field) const;
396396

397397
bool vers_init_info(THD *thd);
398-
bool vers_set_interval(Item *item, interval_type int_type, my_time_t start)
398+
bool vers_set_interval(THD *thd, Item *item,
399+
interval_type int_type, my_time_t start)
399400
{
400401
DBUG_ASSERT(part_type == VERSIONING_PARTITION);
401402
vers_info->interval.type= int_type;
402403
vers_info->interval.start= start;
403-
return get_interval_value(item, int_type, &vers_info->interval.step) ||
404+
if (item->fix_fields_if_needed_for_scalar(thd, &item))
405+
return true;
406+
bool error= get_interval_value(item, int_type, &vers_info->interval.step) ||
404407
vers_info->interval.step.neg || vers_info->interval.step.second_part ||
405408
!(vers_info->interval.step.year || vers_info->interval.step.month ||
406409
vers_info->interval.step.day || vers_info->interval.step.hour ||
407410
vers_info->interval.step.minute || vers_info->interval.step.second);
411+
if (error)
412+
{
413+
my_error(ER_PART_WRONG_VALUE, MYF(0),
414+
thd->lex->create_last_non_select_table->table_name.str,
415+
"INTERVAL");
416+
}
417+
return error;
408418
}
409419
bool vers_set_limit(ulonglong limit)
410420
{

sql/sql_yacc.yy

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6064,13 +6064,8 @@ opt_versioning_rotation:
60646064
| INTERVAL_SYM expr interval opt_versioning_interval_start
60656065
{
60666066
partition_info *part_info= Lex->part_info;
6067-
if (unlikely(part_info->vers_set_interval($2, $3, $4)))
6068-
{
6069-
my_error(ER_PART_WRONG_VALUE, MYF(0),
6070-
Lex->create_last_non_select_table->table_name.str,
6071-
"INTERVAL");
6067+
if (unlikely(part_info->vers_set_interval(thd, $2, $3, $4)))
60726068
MYSQL_YYABORT;
6073-
}
60746069
}
60756070
| LIMIT ulonglong_num
60766071
{

sql/sql_yacc_ora.yy

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5910,13 +5910,8 @@ opt_versioning_rotation:
59105910
| INTERVAL_SYM expr interval opt_versioning_interval_start
59115911
{
59125912
partition_info *part_info= Lex->part_info;
5913-
if (unlikely(part_info->vers_set_interval($2, $3, $4)))
5914-
{
5915-
my_error(ER_PART_WRONG_VALUE, MYF(0),
5916-
Lex->create_last_non_select_table->table_name.str,
5917-
"INTERVAL");
5913+
if (unlikely(part_info->vers_set_interval(thd, $2, $3, $4)))
59185914
MYSQL_YYABORT;
5919-
}
59205915
}
59215916
| LIMIT ulonglong_num
59225917
{

0 commit comments

Comments
 (0)