Skip to content

Commit 631c82d

Browse files
author
msvensson@shellback.(none)
committed
Bug#18888 Trying to overwrite sql/lex_hash.h during build
- As a sideeffect of the patch to generate lex_hash.h only once on the machine where the source dist was produced, a problem was found when compiling a mysqld without partition support - it would crash when looking up the lex symbols due to mismatch between lex.h and the generated lex_hash.h - Remove the ifdef for partition in lex.h - Fix minor problem with"EXPLAIN PARTITION" when not compiled with partition(existed also without the above patch) - Add test case that will be run when we don't have partition support compiled into mysqld - Return error ER_FEATURE_DISABLED if user tries to use PARTITION when there is no support for it.
1 parent 8f75d09 commit 631c82d

File tree

7 files changed

+124
-5
lines changed

7 files changed

+124
-5
lines changed

mysql-test/r/not_partition.require

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Variable_name Value
2+
have_partitioning NO

mysql-test/r/not_partition.result

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
CREATE TABLE t1 (
2+
firstname VARCHAR(25) NOT NULL,
3+
lastname VARCHAR(25) NOT NULL,
4+
username VARCHAR(16) NOT NULL,
5+
email VARCHAR(35),
6+
joined DATE NOT NULL
7+
)
8+
PARTITION BY KEY(joined)
9+
PARTITIONS 6;
10+
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
11+
ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2;
12+
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
13+
drop table t1;
14+
ERROR 42S02: Unknown table 't1'
15+
CREATE TABLE t1 (
16+
firstname VARCHAR(25) NOT NULL,
17+
lastname VARCHAR(25) NOT NULL,
18+
username VARCHAR(16) NOT NULL,
19+
email VARCHAR(35),
20+
joined DATE NOT NULL
21+
)
22+
PARTITION BY RANGE( YEAR(joined) ) (
23+
PARTITION p0 VALUES LESS THAN (1960),
24+
PARTITION p1 VALUES LESS THAN (1970),
25+
PARTITION p2 VALUES LESS THAN (1980),
26+
PARTITION p3 VALUES LESS THAN (1990),
27+
PARTITION p4 VALUES LESS THAN MAXVALUE
28+
);
29+
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
30+
drop table t1;
31+
ERROR 42S02: Unknown table 't1'
32+
CREATE TABLE t1 (id INT, purchased DATE)
33+
PARTITION BY RANGE( YEAR(purchased) )
34+
SUBPARTITION BY HASH( TO_DAYS(purchased) )
35+
SUBPARTITIONS 2 (
36+
PARTITION p0 VALUES LESS THAN (1990),
37+
PARTITION p1 VALUES LESS THAN (2000),
38+
PARTITION p2 VALUES LESS THAN MAXVALUE
39+
);
40+
ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-partition' to have it working
41+
drop table t1;
42+
ERROR 42S02: Unknown table 't1'
43+
create table t1 (a varchar(10) charset latin1 collate latin1_bin);
44+
insert into t1 values (''),(' '),('a'),('a '),('a ');
45+
explain partitions select * from t1 where a='a ' OR a='a';
46+
id select_type table partitions type possible_keys key key_len ref rows Extra
47+
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 Using where
48+
drop table t1;

mysql-test/t/not_partition.test

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--disable_abort_on_error
2+
# Run this tets only when mysqld don't has partitioning
3+
# the statements are not expected to work, just check that we
4+
# can't crash the server
5+
-- require r/not_partition.require
6+
disable_query_log;
7+
show variables like "have_partitioning";
8+
enable_query_log;
9+
10+
11+
--error ER_FEATURE_DISABLED
12+
CREATE TABLE t1 (
13+
firstname VARCHAR(25) NOT NULL,
14+
lastname VARCHAR(25) NOT NULL,
15+
username VARCHAR(16) NOT NULL,
16+
email VARCHAR(35),
17+
joined DATE NOT NULL
18+
)
19+
PARTITION BY KEY(joined)
20+
PARTITIONS 6;
21+
22+
--error ER_FEATURE_DISABLED
23+
ALTER TABLE t1 PARTITION BY KEY(joined) PARTITIONS 2;
24+
25+
--error ER_BAD_TABLE_ERROR
26+
drop table t1;
27+
28+
--error ER_FEATURE_DISABLED
29+
CREATE TABLE t1 (
30+
firstname VARCHAR(25) NOT NULL,
31+
lastname VARCHAR(25) NOT NULL,
32+
username VARCHAR(16) NOT NULL,
33+
email VARCHAR(35),
34+
joined DATE NOT NULL
35+
)
36+
PARTITION BY RANGE( YEAR(joined) ) (
37+
PARTITION p0 VALUES LESS THAN (1960),
38+
PARTITION p1 VALUES LESS THAN (1970),
39+
PARTITION p2 VALUES LESS THAN (1980),
40+
PARTITION p3 VALUES LESS THAN (1990),
41+
PARTITION p4 VALUES LESS THAN MAXVALUE
42+
);
43+
--error ER_BAD_TABLE_ERROR
44+
drop table t1;
45+
46+
--error ER_FEATURE_DISABLED
47+
CREATE TABLE t1 (id INT, purchased DATE)
48+
PARTITION BY RANGE( YEAR(purchased) )
49+
SUBPARTITION BY HASH( TO_DAYS(purchased) )
50+
SUBPARTITIONS 2 (
51+
PARTITION p0 VALUES LESS THAN (1990),
52+
PARTITION p1 VALUES LESS THAN (2000),
53+
PARTITION p2 VALUES LESS THAN MAXVALUE
54+
);
55+
--error ER_BAD_TABLE_ERROR
56+
drop table t1;
57+
58+
# Create a table without partitions to test "EXPLAIN PARTITIONS"
59+
create table t1 (a varchar(10) charset latin1 collate latin1_bin);
60+
insert into t1 values (''),(' '),('a'),('a '),('a ');
61+
explain partitions select * from t1 where a='a ' OR a='a';
62+
drop table t1;

sql/lex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
4545
Symbols are broken into separated arrays to allow field names with
4646
same name as functions.
4747
These are kept sorted for human lookup (the symbols are hashed).
48+
49+
NOTE! The symbol tables should be the same regardless of what features
50+
are compiled into the server. Don't add ifdef'ed symbols to the
51+
lists
4852
*/
4953

5054
static SYMBOL symbols[] = {
@@ -383,11 +387,9 @@ static SYMBOL symbols[] = {
383387
{ "PACK_KEYS", SYM(PACK_KEYS_SYM)},
384388
{ "PARSER", SYM(PARSER_SYM)},
385389
{ "PARTIAL", SYM(PARTIAL)},
386-
#ifdef WITH_PARTITION_STORAGE_ENGINE
387390
{ "PARTITION", SYM(PARTITION_SYM)},
388391
{ "PARTITIONING", SYM(PARTITIONING_SYM)},
389392
{ "PARTITIONS", SYM(PARTITIONS_SYM)},
390-
#endif
391393
{ "PASSWORD", SYM(PASSWORD)},
392394
{ "PHASE", SYM(PHASE_SYM)},
393395
{ "PLUGIN", SYM(PLUGIN_SYM)},

sql/sql_class.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ int THD::send_explain_fields(select_result *result)
859859
field_list.push_back(new Item_empty_string("select_type", 19, cs));
860860
field_list.push_back(item= new Item_empty_string("table", NAME_LEN, cs));
861861
item->maybe_null= 1;
862-
#ifdef WITH_PARTITION_STORAGE_ENGINE
863862
if (lex->describe & DESCRIBE_PARTITIONS)
864863
{
865864
/* Maximum length of string that make_used_partitions_str() can produce */
@@ -868,7 +867,6 @@ int THD::send_explain_fields(select_result *result)
868867
field_list.push_back(item);
869868
item->maybe_null= 1;
870869
}
871-
#endif
872870
field_list.push_back(item= new Item_empty_string("type", 10, cs));
873871
item->maybe_null= 1;
874872
field_list.push_back(item=new Item_empty_string("possible_keys",

sql/sql_select.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds,
22002200
continue;
22012201
}
22022202
#ifdef WITH_PARTITION_STORAGE_ENGINE
2203-
bool no_partitions_used= table->no_partitions_used;
2203+
const bool no_partitions_used= table->no_partitions_used;
22042204
#else
22052205
const bool no_partitions_used= FALSE;
22062206
#endif

sql/sql_yacc.yy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,6 +3225,7 @@ opt_partitioning:
32253225
partitioning:
32263226
PARTITION_SYM
32273227
{
3228+
#ifdef WITH_PARTITION_STORAGE_ENGINE
32283229
LEX *lex= Lex;
32293230
lex->part_info= new partition_info();
32303231
if (!lex->part_info)
@@ -3236,6 +3237,12 @@ partitioning:
32363237
{
32373238
lex->alter_info.flags|= ALTER_PARTITION;
32383239
}
3240+
#else
3241+
my_error(ER_FEATURE_DISABLED, MYF(0),
3242+
"partitioning", "--with-partition");
3243+
YYABORT;
3244+
#endif
3245+
32393246
}
32403247
partition
32413248
;

0 commit comments

Comments
 (0)