mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
Merge
This commit is contained in:
commit
540015aac8
7 changed files with 168 additions and 11 deletions
|
@ -47,6 +47,12 @@ partition by list column_list(a,b)
|
|||
( partition p0 values in ((1, NULL), (2, NULL), (NULL, NULL)),
|
||||
partition p1 values in ((1,1), (2,2)),
|
||||
partition p2 values in ((3, NULL), (NULL, 1)));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
LIST COLUMN_LIST a,b (1,NULL),(2,NULL),(NULL,NULL)
|
||||
LIST COLUMN_LIST a,b (1,1),(2,2)
|
||||
LIST COLUMN_LIST a,b (3,NULL),(NULL,1)
|
||||
insert into t1 values (3, NULL);
|
||||
insert into t1 values (NULL, 1);
|
||||
insert into t1 values (NULL, NULL);
|
||||
|
@ -91,6 +97,11 @@ create table t1 (a int)
|
|||
partition by list (a)
|
||||
( partition p0 values in (2, 1),
|
||||
partition p1 values in (4, NULL, 3));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
LIST a 2,1
|
||||
LIST a NULL,4,3
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (2);
|
||||
insert into t1 values (3);
|
||||
|
@ -108,6 +119,11 @@ create table t1 (a int)
|
|||
partition by list column_list(a)
|
||||
( partition p0 values in (2, 1),
|
||||
partition p1 values in (4, NULL, 3));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
LIST COLUMN_LIST a 2,1
|
||||
LIST COLUMN_LIST a 4,NULL,3
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (2);
|
||||
insert into t1 values (3);
|
||||
|
@ -132,6 +148,25 @@ subpartitions 4
|
|||
partition p1 values less than (1, 'a', MAXVALUE, TO_DAYS('1999-01-01')),
|
||||
partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
|
||||
partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
|
||||
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
|
||||
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
|
||||
RANGE COLUMN_LIST a,b,c,d 1,NULL,MAXVALUE,NULL
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,730120
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,'a',MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
||||
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
|
||||
drop table t1;
|
||||
create table t1 (a int, b char(10), c varchar(5), d int)
|
||||
partition by range column_list(a,b,c)
|
||||
|
@ -141,6 +176,21 @@ subpartitions 3
|
|||
partition p1 values less than (2,'abc','abc'),
|
||||
partition p2 values less than (3,'abc','abc'),
|
||||
partition p3 values less than (4,'abc','abc'));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
RANGE COLUMN_LIST a,b,c 1,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 1,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 1,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 2,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 2,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 2,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 3,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 3,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 3,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 4,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 4,'abc','abc'
|
||||
RANGE COLUMN_LIST a,b,c 4,'abc','abc'
|
||||
insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3);
|
||||
insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3);
|
||||
insert into t1 values (1,'c','d',1),(2,'c','d',2),(3,'c','d',3);
|
||||
|
@ -155,6 +205,11 @@ create table t1 (a int, b varchar(2), c int)
|
|||
partition by range column_list (a, b, c)
|
||||
(partition p0 values less than (1, 'A', 1),
|
||||
partition p1 values less than (1, 'B', 1));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
RANGE COLUMN_LIST a,b,c 1,'A',1
|
||||
RANGE COLUMN_LIST a,b,c 1,'B',1
|
||||
insert into t1 values (1, 'A', 1);
|
||||
explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1;
|
||||
id select_type table partitions type possible_keys key key_len ref rows Extra
|
||||
|
|
|
@ -54,6 +54,17 @@ subpartitions 2
|
|||
partition p1 values in (1),
|
||||
partition pnull values in (null, 2),
|
||||
partition p3 values in (3));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
LIST a 0
|
||||
LIST a 0
|
||||
LIST a 1
|
||||
LIST a 1
|
||||
LIST a NULL,2
|
||||
LIST a NULL,2
|
||||
LIST a 3
|
||||
LIST a 3
|
||||
insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
|
||||
insert into t1 values (2,0),(2,1),(3,0),(3,1);
|
||||
explain partitions select * from t1 where a is null;
|
||||
|
|
|
@ -8,6 +8,11 @@ create table t1 (a datetime not null)
|
|||
partition by range (TO_SECONDS(a))
|
||||
( partition p0 VALUES LESS THAN (TO_SECONDS('2007-03-08 00:00:00')),
|
||||
partition p1 VALUES LESS THAN (TO_SECONDS('2007-04-01 00:00:00')));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
partition_method partition_expression partition_description
|
||||
RANGE TO_SECONDS(a) 63340531200
|
||||
RANGE TO_SECONDS(a) 63342604800
|
||||
INSERT INTO t1 VALUES ('2007-03-01 12:00:00'), ('2007-03-07 12:00:00');
|
||||
INSERT INTO t1 VALUES ('2007-03-08 12:00:00'), ('2007-03-15 12:00:00');
|
||||
explain partitions select * from t1 where a < '2007-03-08 00:00:00';
|
||||
|
|
|
@ -49,6 +49,8 @@ partition by list column_list(a,b)
|
|||
( partition p0 values in ((1, NULL), (2, NULL), (NULL, NULL)),
|
||||
partition p1 values in ((1,1), (2,2)),
|
||||
partition p2 values in ((3, NULL), (NULL, 1)));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
#
|
||||
# BUG#47754 Crash when selecting using NOT BETWEEN for column list partitioning
|
||||
#
|
||||
|
@ -76,6 +78,8 @@ create table t1 (a int)
|
|||
partition by list (a)
|
||||
( partition p0 values in (2, 1),
|
||||
partition p1 values in (4, NULL, 3));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (2);
|
||||
insert into t1 values (3);
|
||||
|
@ -95,6 +99,8 @@ create table t1 (a int)
|
|||
partition by list column_list(a)
|
||||
( partition p0 values in (2, 1),
|
||||
partition p1 values in (4, NULL, 3));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
insert into t1 values (1);
|
||||
insert into t1 values (2);
|
||||
insert into t1 values (3);
|
||||
|
@ -113,6 +119,8 @@ subpartitions 4
|
|||
partition p1 values less than (1, 'a', MAXVALUE, TO_DAYS('1999-01-01')),
|
||||
partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
|
||||
partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b char(10), c varchar(5), d int)
|
||||
|
@ -123,6 +131,8 @@ subpartitions 3
|
|||
partition p1 values less than (2,'abc','abc'),
|
||||
partition p2 values less than (3,'abc','abc'),
|
||||
partition p3 values less than (4,'abc','abc'));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
|
||||
insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3);
|
||||
insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3);
|
||||
|
@ -136,6 +146,8 @@ create table t1 (a int, b varchar(2), c int)
|
|||
partition by range column_list (a, b, c)
|
||||
(partition p0 values less than (1, 'A', 1),
|
||||
partition p1 values less than (1, 'B', 1));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
insert into t1 values (1, 'A', 1);
|
||||
explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1;
|
||||
select * from t1 where a = 1 AND b <= 'A' and c = 1;
|
||||
|
|
|
@ -40,6 +40,8 @@ subpartitions 2
|
|||
partition p1 values in (1),
|
||||
partition pnull values in (null, 2),
|
||||
partition p3 values in (3));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
|
||||
insert into t1 values (2,0),(2,1),(3,0),(3,1);
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ create table t1 (a datetime not null)
|
|||
partition by range (TO_SECONDS(a))
|
||||
( partition p0 VALUES LESS THAN (TO_SECONDS('2007-03-08 00:00:00')),
|
||||
partition p1 VALUES LESS THAN (TO_SECONDS('2007-04-01 00:00:00')));
|
||||
select partition_method, partition_expression, partition_description
|
||||
from information_schema.partitions where table_name = "t1";
|
||||
INSERT INTO t1 VALUES ('2007-03-01 12:00:00'), ('2007-03-07 12:00:00');
|
||||
INSERT INTO t1 VALUES ('2007-03-08 12:00:00'), ('2007-03-15 12:00:00');
|
||||
explain partitions select * from t1 where a < '2007-03-08 00:00:00';
|
||||
|
|
|
@ -4827,6 +4827,43 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
|
|||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
get_partition_column_description(partition_info *part_info,
|
||||
part_elem_value *list_value,
|
||||
String &tmp_str)
|
||||
{
|
||||
uint num_elements= part_info->part_field_list.elements;
|
||||
uint i;
|
||||
DBUG_ENTER("get_partition_column_description");
|
||||
|
||||
for (i= 0; i < num_elements; i++)
|
||||
{
|
||||
part_column_list_val *col_val= &list_value->col_val_array[i];
|
||||
if (col_val->max_value)
|
||||
tmp_str.append(partition_keywords[PKW_MAXVALUE].str);
|
||||
else if (col_val->null_value)
|
||||
tmp_str.append("NULL");
|
||||
else
|
||||
{
|
||||
char buffer[MAX_STR_SIZE_PF];
|
||||
String str(buffer, sizeof(buffer), &my_charset_bin);
|
||||
String *res= col_val->item_expression->val_str(&str);
|
||||
if (!res)
|
||||
{
|
||||
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (col_val->item_expression->result_type() == STRING_RESULT)
|
||||
tmp_str.append("'");
|
||||
tmp_str.append(*res);
|
||||
if (col_val->item_expression->result_type() == STRING_RESULT)
|
||||
tmp_str.append("'");
|
||||
}
|
||||
if (i != num_elements - 1)
|
||||
tmp_str.append(",");
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
|
||||
TABLE *table, bool res,
|
||||
|
@ -4837,6 +4874,7 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
|
|||
char buff[61];
|
||||
String tmp_res(buff, sizeof(buff), cs);
|
||||
String tmp_str;
|
||||
uint num_elements;
|
||||
TABLE *show_table= tables->table;
|
||||
handler *file;
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
|
@ -4958,36 +4996,68 @@ static int get_schema_partitions_record(THD *thd, TABLE_LIST *tables,
|
|||
/* Partition description */
|
||||
if (part_info->part_type == RANGE_PARTITION)
|
||||
{
|
||||
if (part_elem->range_value != LONGLONG_MAX)
|
||||
table->field[11]->store((longlong) part_elem->range_value, FALSE);
|
||||
if (part_info->column_list)
|
||||
{
|
||||
List_iterator<part_elem_value> list_val_it(part_elem->list_val_list);
|
||||
part_elem_value *list_value= list_val_it++;
|
||||
tmp_str.length(0);
|
||||
if (get_partition_column_description(part_info,
|
||||
list_value,
|
||||
tmp_str))
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
|
||||
}
|
||||
else
|
||||
table->field[11]->store(partition_keywords[PKW_MAXVALUE].str,
|
||||
{
|
||||
if (part_elem->range_value != LONGLONG_MAX)
|
||||
table->field[11]->store((longlong) part_elem->range_value, FALSE);
|
||||
else
|
||||
table->field[11]->store(partition_keywords[PKW_MAXVALUE].str,
|
||||
partition_keywords[PKW_MAXVALUE].length, cs);
|
||||
}
|
||||
table->field[11]->set_notnull();
|
||||
}
|
||||
else if (part_info->part_type == LIST_PARTITION)
|
||||
{
|
||||
List_iterator<part_elem_value> list_val_it(part_elem->list_val_list);
|
||||
part_elem_value *list_value;
|
||||
uint no_items= part_elem->list_val_list.elements;
|
||||
uint num_items= part_elem->list_val_list.elements;
|
||||
tmp_str.length(0);
|
||||
tmp_res.length(0);
|
||||
if (part_elem->has_null_value)
|
||||
{
|
||||
tmp_str.append("NULL");
|
||||
if (no_items > 0)
|
||||
if (num_items > 0)
|
||||
tmp_str.append(",");
|
||||
}
|
||||
while ((list_value= list_val_it++))
|
||||
{
|
||||
if (!list_value->unsigned_flag)
|
||||
tmp_res.set(list_value->value, cs);
|
||||
if (part_info->column_list)
|
||||
{
|
||||
if (part_info->part_field_list.elements > 1U)
|
||||
tmp_str.append("(");
|
||||
if (get_partition_column_description(part_info,
|
||||
list_value,
|
||||
tmp_str))
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (part_info->part_field_list.elements > 1U)
|
||||
tmp_str.append(")");
|
||||
}
|
||||
else
|
||||
tmp_res.set((ulonglong)list_value->value, cs);
|
||||
tmp_str.append(tmp_res);
|
||||
if (--no_items != 0)
|
||||
{
|
||||
if (!list_value->unsigned_flag)
|
||||
tmp_res.set(list_value->value, cs);
|
||||
else
|
||||
tmp_res.set((ulonglong)list_value->value, cs);
|
||||
tmp_str.append(tmp_res);
|
||||
}
|
||||
if (--num_items != 0)
|
||||
tmp_str.append(",");
|
||||
};
|
||||
}
|
||||
table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
|
||||
table->field[11]->set_notnull();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue