Commit 7548f142 authored by Mikael Ronstrom's avatar Mikael Ronstrom

BUG#49591, Fixed version string in SHOW CREATE TABLE to accomodate for column...

BUG#49591, Fixed version string in SHOW CREATE TABLE to accomodate for column list partitioning and new function to_seconds
parent ed02cca1
...@@ -69,7 +69,7 @@ Table Create Table ...@@ -69,7 +69,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(5) DEFAULT NULL `a` varchar(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a) /*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN ('''') ENGINE = MyISAM, (PARTITION p0 VALUES IN ('''') ENGINE = MyISAM,
PARTITION p1 VALUES IN ('\\') ENGINE = MyISAM, PARTITION p1 VALUES IN ('\\') ENGINE = MyISAM,
PARTITION p2 VALUES IN ('\0') ENGINE = MyISAM) */ PARTITION p2 VALUES IN ('\0') ENGINE = MyISAM) */
...@@ -128,7 +128,7 @@ t1 CREATE TABLE `t1` ( ...@@ -128,7 +128,7 @@ t1 CREATE TABLE `t1` (
`c` varchar(25) DEFAULT NULL, `c` varchar(25) DEFAULT NULL,
`d` datetime DEFAULT NULL `d` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE COLUMNS(a,b,c,d) /*!50500 PARTITION BY RANGE COLUMNS(a,b,c,d)
SUBPARTITION BY HASH (to_seconds(d)) SUBPARTITION BY HASH (to_seconds(d))
SUBPARTITIONS 4 SUBPARTITIONS 4
(PARTITION p0 VALUES LESS THAN (1,'0',MAXVALUE,'1900-01-01') ENGINE = MyISAM, (PARTITION p0 VALUES LESS THAN (1,'0',MAXVALUE,'1900-01-01') ENGINE = MyISAM,
...@@ -211,7 +211,7 @@ t1 CREATE TABLE `t1` ( ...@@ -211,7 +211,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL `b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a,b) /*!50500 PARTITION BY LIST COLUMNS(a,b)
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM, (PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM, PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */ PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
...@@ -245,7 +245,7 @@ t1 CREATE TABLE `t1` ( ...@@ -245,7 +245,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL, `a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL `b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a,b) /*!50500 PARTITION BY LIST COLUMNS(a,b)
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM, (PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM, PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */ PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
...@@ -299,7 +299,7 @@ Table Create Table ...@@ -299,7 +299,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a) /*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM, (PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */ PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
insert into t1 values (1); insert into t1 values (1);
...@@ -314,7 +314,7 @@ Table Create Table ...@@ -314,7 +314,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a) /*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM, (PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */ PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
drop table t1; drop table t1;
...@@ -349,7 +349,7 @@ t1 CREATE TABLE `t1` ( ...@@ -349,7 +349,7 @@ t1 CREATE TABLE `t1` (
`c` varchar(5) DEFAULT NULL, `c` varchar(5) DEFAULT NULL,
`d` int(11) DEFAULT NULL `d` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE COLUMNS(a,b,c) /*!50500 PARTITION BY RANGE COLUMNS(a,b,c)
SUBPARTITION BY KEY (c,d) SUBPARTITION BY KEY (c,d)
SUBPARTITIONS 3 SUBPARTITIONS 3
(PARTITION p0 VALUES LESS THAN (1,'abc','abc') ENGINE = MyISAM, (PARTITION p0 VALUES LESS THAN (1,'abc','abc') ENGINE = MyISAM,
...@@ -382,7 +382,7 @@ t1 CREATE TABLE `t1` ( ...@@ -382,7 +382,7 @@ t1 CREATE TABLE `t1` (
`b` varchar(2) DEFAULT NULL, `b` varchar(2) DEFAULT NULL,
`c` int(11) DEFAULT NULL `c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE COLUMNS(a,b,c) /*!50500 PARTITION BY RANGE COLUMNS(a,b,c)
(PARTITION p0 VALUES LESS THAN (1,'A',1) ENGINE = MyISAM, (PARTITION p0 VALUES LESS THAN (1,'A',1) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (1,'B',1) ENGINE = MyISAM) */ PARTITION p1 VALUES LESS THAN (1,'B',1) ENGINE = MyISAM) */
insert into t1 values (1, 'A', 1); insert into t1 values (1, 'A', 1);
......
drop table if exists t1, t2; drop table if exists t1, t2;
create table t1 (a int) create table t1 (a int)
partition by range (a) partition by range (a)
subpartition by hash(to_seconds(a))
(partition p0 values less than (1));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE (a)
SUBPARTITION BY HASH (to_seconds(a))
(PARTITION p0 VALUES LESS THAN (1) ENGINE = MyISAM) */
drop table t1;
create table t1 (a int)
partition by range (a)
( partition p0 values less than (NULL), ( partition p0 values less than (NULL),
partition p1 values less than (MAXVALUE)); partition p1 values less than (MAXVALUE));
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
...@@ -30,6 +43,14 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -30,6 +43,14 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t1 where a < '2007-03-07 23:59:59'; explain partitions select * from t1 where a < '2007-03-07 23:59:59';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where 1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE (TO_SECONDS(a))
(PARTITION p0 VALUES LESS THAN (63340531200) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (63342604800) ENGINE = MyISAM) */
drop table t1; drop table t1;
create table t1 (a date) create table t1 (a date)
partition by range(to_seconds(a)) partition by range(to_seconds(a))
...@@ -53,6 +74,14 @@ select * from t1 where a <= '2005-01-01'; ...@@ -53,6 +74,14 @@ select * from t1 where a <= '2005-01-01';
a a
2003-12-30 2003-12-30
2004-12-31 2004-12-31
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE (to_seconds(a))
(PARTITION p0 VALUES LESS THAN (63240134400) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (63271756800) ENGINE = MyISAM) */
drop table t1; drop table t1;
create table t1 (a datetime) create table t1 (a datetime)
partition by range(to_seconds(a)) partition by range(to_seconds(a))
...@@ -75,6 +104,14 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -75,6 +104,14 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
select * from t1 where a <= '2005-01-01'; select * from t1 where a <= '2005-01-01';
a a
2004-01-01 11:59:29 2004-01-01 11:59:29
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50500 PARTITION BY RANGE (to_seconds(a))
(PARTITION p0 VALUES LESS THAN (63240177600) ENGINE = MyISAM,
PARTITION p1 VALUES LESS THAN (63271800000) ENGINE = MyISAM) */
drop table t1; drop table t1;
create table t1 (a int, b char(20)) create table t1 (a int, b char(20))
partition by range columns(a,b) partition by range columns(a,b)
......
...@@ -7,7 +7,7 @@ Table Create Table ...@@ -7,7 +7,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(2) CHARACTER SET cp1250 DEFAULT NULL `a` varchar(2) CHARACTER SET cp1250 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a) /*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN (_cp1250 0x81) ENGINE = MyISAM) */ (PARTITION p0 VALUES IN (_cp1250 0x81) ENGINE = MyISAM) */
drop table t1; drop table t1;
create table t1 (a varchar(2) character set cp1250) create table t1 (a varchar(2) character set cp1250)
...@@ -18,7 +18,7 @@ Table Create Table ...@@ -18,7 +18,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(2) CHARACTER SET cp1250 DEFAULT NULL `a` varchar(2) CHARACTER SET cp1250 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a) /*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN ('€') ENGINE = MyISAM) */ (PARTITION p0 VALUES IN ('€') ENGINE = MyISAM) */
drop table t1; drop table t1;
create table t1 (a varchar(1500), b varchar(1570)) create table t1 (a varchar(1500), b varchar(1570))
...@@ -45,7 +45,7 @@ Table Create Table ...@@ -45,7 +45,7 @@ Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(2) CHARACTER SET ucs2 DEFAULT NULL `a` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMNS(a) /*!50500 PARTITION BY LIST COLUMNS(a)
(PARTITION p0 VALUES IN ('†') ENGINE = MyISAM, (PARTITION p0 VALUES IN ('†') ENGINE = MyISAM,
PARTITION p1 VALUES IN ('') ENGINE = MyISAM) */ PARTITION p1 VALUES IN ('') ENGINE = MyISAM) */
insert into t1 values (''); insert into t1 values ('');
......
...@@ -9,6 +9,16 @@ ...@@ -9,6 +9,16 @@
drop table if exists t1, t2; drop table if exists t1, t2;
--enable_warnings --enable_warnings
#
#BUG#49591, Add proper version number to SHOW CREATE TABLE
#
create table t1 (a int)
partition by range (a)
subpartition by hash(to_seconds(a))
(partition p0 values less than (1));
show create table t1;
drop table t1;
--error ER_NULL_IN_VALUES_LESS_THAN --error ER_NULL_IN_VALUES_LESS_THAN
create table t1 (a int) create table t1 (a int)
partition by range (a) partition by range (a)
...@@ -30,6 +40,7 @@ explain partitions select * from t1 where a < '2007-03-08 00:00:01'; ...@@ -30,6 +40,7 @@ explain partitions select * from t1 where a < '2007-03-08 00:00:01';
explain partitions select * from t1 where a <= '2007-03-08 00:00:00'; explain partitions select * from t1 where a <= '2007-03-08 00:00:00';
explain partitions select * from t1 where a <= '2007-03-07 23:59:59'; explain partitions select * from t1 where a <= '2007-03-07 23:59:59';
explain partitions select * from t1 where a < '2007-03-07 23:59:59'; explain partitions select * from t1 where a < '2007-03-07 23:59:59';
show create table t1;
drop table t1; drop table t1;
# #
# New test cases for new function to_seconds # New test cases for new function to_seconds
...@@ -44,6 +55,7 @@ explain partitions select * from t1 where a <= '2003-12-31'; ...@@ -44,6 +55,7 @@ explain partitions select * from t1 where a <= '2003-12-31';
select * from t1 where a <= '2003-12-31'; select * from t1 where a <= '2003-12-31';
explain partitions select * from t1 where a <= '2005-01-01'; explain partitions select * from t1 where a <= '2005-01-01';
select * from t1 where a <= '2005-01-01'; select * from t1 where a <= '2005-01-01';
show create table t1;
drop table t1; drop table t1;
create table t1 (a datetime) create table t1 (a datetime)
...@@ -56,6 +68,7 @@ explain partitions select * from t1 where a <= '2004-01-01 11:59.59'; ...@@ -56,6 +68,7 @@ explain partitions select * from t1 where a <= '2004-01-01 11:59.59';
select * from t1 where a <= '2004-01-01 11:59:59'; select * from t1 where a <= '2004-01-01 11:59:59';
explain partitions select * from t1 where a <= '2005-01-01'; explain partitions select * from t1 where a <= '2005-01-01';
select * from t1 where a <= '2005-01-01'; select * from t1 where a <= '2005-01-01';
show create table t1;
drop table t1; drop table t1;
# #
......
...@@ -894,6 +894,15 @@ class Item { ...@@ -894,6 +894,15 @@ class Item {
(*traverser)(this, arg); (*traverser)(this, arg);
} }
/*
This is used to get the most recent version of any function in
an item tree. The version is the version where a MySQL function
was introduced in. So any function which is added should use
this function and set the int_arg to maximum of the input data
and their own version info.
*/
virtual bool intro_version(uchar *int_arg) { return 0; }
virtual bool remove_dependence_processor(uchar * arg) { return 0; } virtual bool remove_dependence_processor(uchar * arg) { return 0; }
virtual bool remove_fixed(uchar * arg) { fixed= 0; return 0; } virtual bool remove_fixed(uchar * arg) { fixed= 0; return 0; }
virtual bool cleanup_processor(uchar *arg); virtual bool cleanup_processor(uchar *arg);
......
...@@ -91,6 +91,15 @@ class Item_func_to_seconds :public Item_int_func ...@@ -91,6 +91,15 @@ class Item_func_to_seconds :public Item_int_func
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp); longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;} bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
bool intro_version(uchar *int_arg)
{
int *input_version= (int*)int_arg;
/* This function was introduced in 5.5 */
int output_version= (*input_version, 50500);
*input_version= output_version;
return 0;
}
}; };
......
...@@ -115,6 +115,42 @@ char *partition_info::create_default_partition_names(uint part_no, ...@@ -115,6 +115,42 @@ char *partition_info::create_default_partition_names(uint part_no,
} }
/*
Generate a version string for partition expression
This function must be updated every time there is a possibility for
a new function of a higher version number than 5.5.0.
SYNOPSIS
set_show_version_string()
RETURN VALUES
None
*/
void partition_info::set_show_version_string(String *packet)
{
int version= 0;
if (column_list)
packet->append(STRING_WITH_LEN("\n/*!50500"));
else
{
if (part_expr)
part_expr->walk(&Item::intro_version, 0, (uchar*)&version);
if (subpart_expr)
subpart_expr->walk(&Item::intro_version, 0, (uchar*)&version);
if (version == 0)
{
/* No new functions in partition function */
packet->append(STRING_WITH_LEN("\n/*!50100"));
}
else
{
char buf[65];
char *buf_ptr= longlong10_to_str((longlong)version, buf, 10);
packet->append(STRING_WITH_LEN("\n/*!"));
packet->append(buf, (size_t)(buf_ptr - buf));
}
}
}
/* /*
Create a unique name for the subpartition as part_name'sp''subpart_no' Create a unique name for the subpartition as part_name'sp''subpart_no'
SYNOPSIS SYNOPSIS
......
...@@ -302,6 +302,7 @@ class partition_info : public Sql_alloc ...@@ -302,6 +302,7 @@ class partition_info : public Sql_alloc
bool check_partition_field_length(); bool check_partition_field_length();
bool init_column_part(); bool init_column_part();
bool add_column_list_value(THD *thd, Item *item); bool add_column_list_value(THD *thd, Item *item);
void set_show_version_string(String *packet);
private: private:
static int list_part_cmp(const void* a, const void* b); static int list_part_cmp(const void* a, const void* b);
bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info, bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info,
......
...@@ -1497,7 +1497,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, ...@@ -1497,7 +1497,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
show_table_options, show_table_options,
NULL, NULL)))) NULL, NULL))))
{ {
packet->append(STRING_WITH_LEN("\n/*!50100")); table->part_info->set_show_version_string(packet);
packet->append(part_syntax, part_syntax_len); packet->append(part_syntax, part_syntax_len);
packet->append(STRING_WITH_LEN(" */")); packet->append(STRING_WITH_LEN(" */"));
my_free(part_syntax, MYF(0)); my_free(part_syntax, MYF(0));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment