Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9b53e541
Commit
9b53e541
authored
Nov 20, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-13788 Server crash when issuing bad SQL partition syntax
parent
c44ece73
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
165 additions
and
20 deletions
+165
-20
mysql-test/suite/parts/inc/part_alter_values.inc
mysql-test/suite/parts/inc/part_alter_values.inc
+24
-0
mysql-test/suite/parts/r/partition_alter_innodb.result
mysql-test/suite/parts/r/partition_alter_innodb.result
+35
-0
mysql-test/suite/parts/r/partition_alter_maria.result
mysql-test/suite/parts/r/partition_alter_maria.result
+35
-0
mysql-test/suite/parts/r/partition_alter_myisam.result
mysql-test/suite/parts/r/partition_alter_myisam.result
+35
-0
mysql-test/suite/parts/t/partition_alter_innodb.test
mysql-test/suite/parts/t/partition_alter_innodb.test
+4
-0
mysql-test/suite/parts/t/partition_alter_maria.test
mysql-test/suite/parts/t/partition_alter_maria.test
+3
-0
mysql-test/suite/parts/t/partition_alter_myisam.test
mysql-test/suite/parts/t/partition_alter_myisam.test
+3
-0
sql/partition_info.cc
sql/partition_info.cc
+20
-0
sql/partition_info.h
sql/partition_info.h
+1
-0
sql/sql_partition.cc
sql/sql_partition.cc
+3
-8
sql/sql_yacc.yy
sql/sql_yacc.yy
+2
-12
No files found.
mysql-test/suite/parts/inc/part_alter_values.inc
0 → 100644
View file @
9b53e541
--
echo
#
--
echo
# MDEV-13788 Server crash when issuing bad SQL partition syntax
--
echo
#
--
eval
CREATE
TABLE
t1
(
id
int
,
d
date
)
ENGINE
=
$engine
PARTITION
BY
RANGE
COLUMNS
(
d
)
(
PARTITION
p1
VALUES
LESS
THAN
(
MAXVALUE
))
SHOW
CREATE
TABLE
t1
;
--
error
ER_PARTITION_REQUIRES_VALUES_ERROR
ALTER
TABLE
t1
REORGANIZE
PARTITION
p1
INTO
(
PARTITION
p2
,
/* Notice no values */
PARTITION
p3
VALUES
LESS
THAN
(
MAXVALUE
)
);
DROP
TABLE
t1
;
--
eval
CREATE
TABLE
t1
(
id
int
,
d
date
)
ENGINE
=
$engine
PARTITION
BY
LIST
(
id
)
(
PARTITION
p1
VALUES
IN
(
1
,
2
,
3
))
SHOW
CREATE
TABLE
t1
;
--
error
ER_PARTITION_REQUIRES_VALUES_ERROR
ALTER
TABLE
t1
REORGANIZE
PARTITION
p1
INTO
(
PARTITION
p2
,
/* Notice no values */
PARTITION
p3
VALUES
IN
(
4
,
5
,
6
)
);
DROP
TABLE
t1
;
mysql-test/suite/parts/r/partition_alter_innodb.result
0 → 100644
View file @
9b53e541
#
# MDEV-13788 Server crash when issuing bad SQL partition syntax
#
CREATE TABLE t1 (id int, d date) ENGINE=InnoDB PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`d` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE COLUMNS(d)
(PARTITION p1 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB) */
ALTER TABLE t1 REORGANIZE PARTITION p1 INTO
(
PARTITION p2, /* Notice no values */
PARTITION p3 VALUES LESS THAN (MAXVALUE)
);
ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition
DROP TABLE t1;
CREATE TABLE t1 (id int, d date) ENGINE=InnoDB PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`d` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (id)
(PARTITION p1 VALUES IN (1,2,3) ENGINE = InnoDB) */
ALTER TABLE t1 REORGANIZE PARTITION p1 INTO
(
PARTITION p2, /* Notice no values */
PARTITION p3 VALUES IN (4,5,6)
);
ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1;
mysql-test/suite/parts/r/partition_alter_maria.result
View file @
9b53e541
...
...
@@ -16,3 +16,38 @@ select * from t1;
pk dt
1 2017-09-28 15:12:00
drop table t1;
#
# MDEV-13788 Server crash when issuing bad SQL partition syntax
#
CREATE TABLE t1 (id int, d date) ENGINE=Aria PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`d` date DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE COLUMNS(d)
(PARTITION p1 VALUES LESS THAN (MAXVALUE) ENGINE = Aria) */
ALTER TABLE t1 REORGANIZE PARTITION p1 INTO
(
PARTITION p2, /* Notice no values */
PARTITION p3 VALUES LESS THAN (MAXVALUE)
);
ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition
DROP TABLE t1;
CREATE TABLE t1 (id int, d date) ENGINE=Aria PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`d` date DEFAULT NULL
) ENGINE=Aria DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (id)
(PARTITION p1 VALUES IN (1,2,3) ENGINE = Aria) */
ALTER TABLE t1 REORGANIZE PARTITION p1 INTO
(
PARTITION p2, /* Notice no values */
PARTITION p3 VALUES IN (4,5,6)
);
ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1;
mysql-test/suite/parts/r/partition_alter_myisam.result
0 → 100644
View file @
9b53e541
#
# MDEV-13788 Server crash when issuing bad SQL partition syntax
#
CREATE TABLE t1 (id int, d date) ENGINE=MyISAM PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`d` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE COLUMNS(d)
(PARTITION p1 VALUES LESS THAN (MAXVALUE) ENGINE = MyISAM) */
ALTER TABLE t1 REORGANIZE PARTITION p1 INTO
(
PARTITION p2, /* Notice no values */
PARTITION p3 VALUES LESS THAN (MAXVALUE)
);
ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition
DROP TABLE t1;
CREATE TABLE t1 (id int, d date) ENGINE=MyISAM PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL,
`d` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST (id)
(PARTITION p1 VALUES IN (1,2,3) ENGINE = MyISAM) */
ALTER TABLE t1 REORGANIZE PARTITION p1 INTO
(
PARTITION p2, /* Notice no values */
PARTITION p3 VALUES IN (4,5,6)
);
ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1;
mysql-test/suite/parts/t/partition_alter_innodb.test
0 → 100644
View file @
9b53e541
--
source
include
/
have_innodb
.
inc
--
source
include
/
have_partition
.
inc
--
let
$engine
=
InnoDB
--
source
inc
/
part_alter_values
.
inc
mysql-test/suite/parts/t/partition_alter_maria.test
View file @
9b53e541
...
...
@@ -16,3 +16,6 @@ select * from t1;
alter
table
t1
drop
partition
p20181231
;
select
*
from
t1
;
drop
table
t1
;
--
let
$engine
=
Aria
--
source
inc
/
part_alter_values
.
inc
mysql-test/suite/parts/t/partition_alter_myisam.test
0 → 100644
View file @
9b53e541
--
source
include
/
have_partition
.
inc
--
let
$engine
=
MyISAM
--
source
inc
/
part_alter_values
.
inc
sql/partition_info.cc
View file @
9b53e541
...
...
@@ -2132,6 +2132,24 @@ bool partition_info::fix_column_value_functions(THD *thd,
DBUG_RETURN
(
result
);
}
bool
partition_info
::
error_if_requires_values
()
const
{
switch
(
part_type
)
{
case
NOT_A_PARTITION
:
case
HASH_PARTITION
:
break
;
case
RANGE_PARTITION
:
my_error
(
ER_PARTITION_REQUIRES_VALUES_ERROR
,
MYF
(
0
),
"RANGE"
,
"LESS THAN"
);
return
true
;
case
LIST_PARTITION
:
my_error
(
ER_PARTITION_REQUIRES_VALUES_ERROR
,
MYF
(
0
),
"LIST"
,
"IN"
);
return
true
;
}
return
false
;
}
/*
The parser generates generic data structures, we need to set them up
as the rest of the code expects to find them. This is in reality part
...
...
@@ -2221,6 +2239,8 @@ int partition_info::fix_parser_data(THD *thd)
part_elem
=
it
++
;
List_iterator
<
part_elem_value
>
list_val_it
(
part_elem
->
list_val_list
);
num_elements
=
part_elem
->
list_val_list
.
elements
;
if
(
!
num_elements
&&
error_if_requires_values
())
DBUG_RETURN
(
true
);
DBUG_ASSERT
(
part_type
==
RANGE_PARTITION
?
num_elements
==
1U
:
TRUE
);
for
(
j
=
0
;
j
<
num_elements
;
j
++
)
...
...
sql/partition_info.h
View file @
9b53e541
...
...
@@ -313,6 +313,7 @@ class partition_info : public Sql_alloc
void
set_show_version_string
(
String
*
packet
);
void
report_part_expr_error
(
bool
use_subpart_expr
);
bool
has_same_partitioning
(
partition_info
*
new_part_info
);
bool
error_if_requires_values
()
const
;
private:
static
int
list_part_cmp
(
const
void
*
a
,
const
void
*
b
);
bool
set_up_default_partitions
(
handler
*
file
,
HA_CREATE_INFO
*
info
,
...
...
sql/sql_partition.cc
View file @
9b53e541
...
...
@@ -4770,16 +4770,11 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
my_error
(
ER_PARTITION_WRONG_VALUES_ERROR
,
MYF
(
0
),
"LIST"
,
"IN"
);
}
else
if
(
tab_part_info
->
part_type
==
RANGE_PARTITION
)
{
my_error
(
ER_PARTITION_REQUIRES_VALUES_ERROR
,
MYF
(
0
),
"RANGE"
,
"LESS THAN"
);
}
else
{
DBUG_ASSERT
(
tab_part_info
->
part_type
==
LIST_PARTITION
);
my_error
(
ER_PARTITION_REQUIRES_VALUES_ERROR
,
MYF
(
0
),
"LIST"
,
"IN"
);
DBUG_ASSERT
(
tab_part_info
->
part_type
==
RANGE_PARTITION
||
tab_part_info
->
part_type
==
LIST_PARTITION
);
(
void
)
tab_part_info
->
error_if_requires_values
(
);
}
goto
err
;
}
...
...
sql/sql_yacc.yy
View file @
9b53e541
...
...
@@ -4679,18 +4679,8 @@ opt_part_values:
partition_info *part_info= lex->part_info;
if (! lex->is_partition_management())
{
if (part_info->part_type == RANGE_PARTITION)
{
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN");
MYSQL_YYABORT;
}
if (part_info->part_type == LIST_PARTITION)
{
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"LIST", "IN");
MYSQL_YYABORT;
}
if (part_info->error_if_requires_values())
MYSQL_YYABORT;
}
else
part_info->part_type= HASH_PARTITION;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment