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
27000fb5
Commit
27000fb5
authored
Mar 28, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into mysql.com:/home/gluh/MySQL/Merge/5.1-new
parents
c5515cc6
44517ca0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
4 deletions
+198
-4
mysql-test/r/partition.result
mysql-test/r/partition.result
+101
-0
mysql-test/t/partition.test
mysql-test/t/partition.test
+75
-0
sql/opt_range.cc
sql/opt_range.cc
+1
-0
sql/sql_partition.cc
sql/sql_partition.cc
+20
-3
sql/sql_partition.h
sql/sql_partition.h
+1
-1
No files found.
mysql-test/r/partition.result
View file @
27000fb5
...
...
@@ -718,4 +718,105 @@ CALL test.p1(13);
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
drop table t1;
create table t1 (f1 integer) partition by range(f1)
(partition p1 values less than (0), partition p2 values less than (10));
insert into t1 set f1 = null;
select * from t1 where f1 is null;
f1
NULL
explain partitions select * from t1 where f1 is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 system NULL NULL NULL NULL 1
drop table t1;
create table t1 (f1 integer) partition by list(f1)
(partition p1 values in (1), partition p2 values in (null));
insert into t1 set f1 = null;
insert into t1 set f1 = 1;
select * from t1 where f1 is null or f1 = 1;
f1
1
NULL
drop table t1;
create table t1 (f1 smallint)
partition by list (f1) (partition p0 values in (null));
insert into t1 values (null);
select * from t1 where f1 is null;
f1
NULL
drop table t1;
create table t1 (f1 smallint)
partition by range (f1) (partition p0 values less than (0));
insert into t1 values (null);
select * from t1 where f1 is null;
f1
NULL
drop table t1;
create table t1 (f1 integer) partition by list(f1)
(
partition p1 values in (1),
partition p2 values in (NULL),
partition p3 values in (2),
partition p4 values in (3),
partition p5 values in (4)
);
insert into t1 values (1),(2),(3),(4),(null);
select * from t1 where f1 < 3;
f1
1
2
explain partitions select * from t1 where f1 < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p3 ALL NULL NULL NULL NULL 2 Using where
select * from t1 where f1 is null;
f1
NULL
explain partitions select * from t1 where f1 is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 system NULL NULL NULL NULL 1
drop table t1;
create table t1 (f1 int) partition by list(f1 div 2)
(
partition p1 values in (1),
partition p2 values in (NULL),
partition p3 values in (2),
partition p4 values in (3),
partition p5 values in (4)
);
insert into t1 values (2),(4),(6),(8),(null);
select * from t1 where f1 < 3;
f1
2
explain partitions select * from t1 where f1 < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2,p3,p4,p5 ALL NULL NULL NULL NULL 5 Using where
select * from t1 where f1 is null;
f1
NULL
explain partitions select * from t1 where f1 is null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 system NULL NULL NULL NULL 1
drop table t1;
create table t1 (a int) partition by LIST(a) (
partition pn values in (NULL),
partition p0 values in (0),
partition p1 values in (1),
partition p2 values in (2)
);
insert into t1 values (NULL),(0),(1),(2);
select * from t1 where a is null or a < 2;
a
NULL
0
1
explain partitions select * from t1 where a is null or a < 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn,p0,p1 ALL NULL NULL NULL NULL 3 Using where
select * from t1 where a is null or a < 0 or a > 1;
a
NULL
2
explain partitions select * from t1 where a is null or a < 0 or a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pn,p2 ALL NULL NULL NULL NULL 2 Using where
drop table t1;
End of 5.1 tests
mysql-test/t/partition.test
View file @
27000fb5
...
...
@@ -849,4 +849,79 @@ CALL test.p1(12);
CALL
test
.
p1
(
13
);
drop
table
t1
;
#
# Bug#18053 Partitions: crash if null
# Bug#18070 Partitions: wrong result on WHERE ... IS NULL
#
create
table
t1
(
f1
integer
)
partition
by
range
(
f1
)
(
partition
p1
values
less
than
(
0
),
partition
p2
values
less
than
(
10
));
insert
into
t1
set
f1
=
null
;
select
*
from
t1
where
f1
is
null
;
explain
partitions
select
*
from
t1
where
f1
is
null
;
drop
table
t1
;
create
table
t1
(
f1
integer
)
partition
by
list
(
f1
)
(
partition
p1
values
in
(
1
),
partition
p2
values
in
(
null
));
insert
into
t1
set
f1
=
null
;
insert
into
t1
set
f1
=
1
;
select
*
from
t1
where
f1
is
null
or
f1
=
1
;
drop
table
t1
;
create
table
t1
(
f1
smallint
)
partition
by
list
(
f1
)
(
partition
p0
values
in
(
null
));
insert
into
t1
values
(
null
);
select
*
from
t1
where
f1
is
null
;
drop
table
t1
;
create
table
t1
(
f1
smallint
)
partition
by
range
(
f1
)
(
partition
p0
values
less
than
(
0
));
insert
into
t1
values
(
null
);
select
*
from
t1
where
f1
is
null
;
drop
table
t1
;
create
table
t1
(
f1
integer
)
partition
by
list
(
f1
)
(
partition
p1
values
in
(
1
),
partition
p2
values
in
(
NULL
),
partition
p3
values
in
(
2
),
partition
p4
values
in
(
3
),
partition
p5
values
in
(
4
)
);
insert
into
t1
values
(
1
),(
2
),(
3
),(
4
),(
null
);
select
*
from
t1
where
f1
<
3
;
explain
partitions
select
*
from
t1
where
f1
<
3
;
select
*
from
t1
where
f1
is
null
;
explain
partitions
select
*
from
t1
where
f1
is
null
;
drop
table
t1
;
create
table
t1
(
f1
int
)
partition
by
list
(
f1
div
2
)
(
partition
p1
values
in
(
1
),
partition
p2
values
in
(
NULL
),
partition
p3
values
in
(
2
),
partition
p4
values
in
(
3
),
partition
p5
values
in
(
4
)
);
insert
into
t1
values
(
2
),(
4
),(
6
),(
8
),(
null
);
select
*
from
t1
where
f1
<
3
;
explain
partitions
select
*
from
t1
where
f1
<
3
;
select
*
from
t1
where
f1
is
null
;
explain
partitions
select
*
from
t1
where
f1
is
null
;
drop
table
t1
;
create
table
t1
(
a
int
)
partition
by
LIST
(
a
)
(
partition
pn
values
in
(
NULL
),
partition
p0
values
in
(
0
),
partition
p1
values
in
(
1
),
partition
p2
values
in
(
2
)
);
insert
into
t1
values
(
NULL
),(
0
),(
1
),(
2
);
select
*
from
t1
where
a
is
null
or
a
<
2
;
explain
partitions
select
*
from
t1
where
a
is
null
or
a
<
2
;
select
*
from
t1
where
a
is
null
or
a
<
0
or
a
>
1
;
explain
partitions
select
*
from
t1
where
a
is
null
or
a
<
0
or
a
>
1
;
drop
table
t1
;
--
echo
End
of
5.1
tests
sql/opt_range.cc
View file @
27000fb5
...
...
@@ -2296,6 +2296,7 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond)
RANGE_OPT_PARAM
*
range_par
=
&
prune_param
.
range_param
;
prune_param
.
part_info
=
part_info
;
prune_param
.
part_iter
.
has_null_value
=
FALSE
;
init_sql_alloc
(
&
alloc
,
thd
->
variables
.
range_alloc_block_size
,
0
);
range_par
->
mem_root
=
&
alloc
;
...
...
sql/sql_partition.cc
View file @
27000fb5
...
...
@@ -2868,9 +2868,6 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
/* Get the partitioning function value for the endpoint */
longlong
part_func_value
=
part_val_int
(
part_info
->
part_expr
);
if
(
part_info
->
part_expr
->
null_value
)
DBUG_RETURN
(
0
);
while
(
max_part_id
>
min_part_id
)
{
loc_part_id
=
(
max_part_id
+
min_part_id
+
1
)
>>
1
;
...
...
@@ -5745,6 +5742,19 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info,
else
DBUG_ASSERT
(
0
);
if
(
field
->
real_maybe_null
()
&&
part_info
->
has_null_value
)
{
if
(
*
min_value
)
{
if
(
*
max_value
&&
!
(
flags
&
(
NO_MIN_RANGE
|
NO_MAX_RANGE
)))
{
init_single_partition_iterator
(
part_info
->
has_null_part_id
,
part_iter
);
return
1
;
}
if
(
!
(
flags
&
NEAR_MIN
))
part_iter
->
has_null_value
=
TRUE
;
}
}
/* Find minimum */
if
(
flags
&
NO_MIN_RANGE
)
part_iter
->
part_nums
.
start
=
0
;
...
...
@@ -5956,7 +5966,14 @@ uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter)
uint32
get_next_partition_id_list
(
PARTITION_ITERATOR
*
part_iter
)
{
if
(
part_iter
->
part_nums
.
start
==
part_iter
->
part_nums
.
end
)
{
if
(
part_iter
->
has_null_value
)
{
part_iter
->
has_null_value
=
FALSE
;
return
part_iter
->
part_info
->
has_null_part_id
;
}
return
NOT_A_PARTITION_ID
;
}
else
return
part_iter
->
part_info
->
list_array
[
part_iter
->
part_nums
.
start
++
].
partition_id
;
...
...
sql/sql_partition.h
View file @
27000fb5
...
...
@@ -124,7 +124,7 @@ typedef uint32 (*partition_iter_func)(st_partition_iter* part_iter);
typedef
struct
st_partition_iter
{
partition_iter_func
get_next
;
bool
has_null_value
;
struct
st_part_num_range
{
uint32
start
;
...
...
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