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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
ab2f3651
Commit
ab2f3651
authored
Nov 27, 2010
by
Michael Widenius
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge with 5.3 (support of BIT keys in heap)
parents
52090a44
ea94906c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
177 additions
and
4 deletions
+177
-4
mysql-test/r/heap_btree.result
mysql-test/r/heap_btree.result
+35
-0
mysql-test/r/heap_hash.result
mysql-test/r/heap_hash.result
+35
-0
mysql-test/t/heap_btree.test
mysql-test/t/heap_btree.test
+16
-0
mysql-test/t/heap_hash.test
mysql-test/t/heap_hash.test
+17
-0
storage/heap/ha_heap.cc
storage/heap/ha_heap.cc
+11
-1
storage/heap/hp_create.c
storage/heap/hp_create.c
+8
-0
storage/heap/hp_hash.c
storage/heap/hp_hash.c
+55
-3
No files found.
mysql-test/r/heap_btree.result
View file @
ab2f3651
...
...
@@ -344,3 +344,38 @@ INSERT INTO t1 VALUES(1),(1);
DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a;
DROP TABLE t1;
End of 5.0 tests
# bit index in heap tables
create table t1 (a bit(63) not null) engine=heap;
insert into t1 values (869751),(736494),(226312),(802616),(728912);
alter table t1 add unique uniq_id using BTREE (a);
select 0+a from t1 where a > 736494;
0+a
802616
869751
explain select 0+a from t1 where a > 736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 3 Using where
select 0+a from t1 where a = 736494;
0+a
736494
explain select 0+a from t1 where a = 736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const uniq_id uniq_id 8 const 1
select 0+a from t1 where a=869751 or a=736494;
0+a
736494
869751
explain select 0+a from t1 where a=869751 or a=736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
select 0+a from t1 where a in (869751,736494,226312,802616);
0+a
226312
736494
802616
869751
explain select 0+a from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 4 Using where
drop table t1;
End of 5.3 tests
mysql-test/r/heap_hash.result
View file @
ab2f3651
...
...
@@ -382,3 +382,38 @@ INSERT INTO t1 VALUES('A ', 'A ');
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
DROP TABLE t1;
End of 5.0 tests
# bit index in heap tables
create table t1 (a bit(63) not null) engine=heap;
insert into t1 values (869751),(736494),(226312),(802616),(728912);
alter table t1 add unique uniq_id using HASH (a);
select 0+a from t1 where a > 736494;
0+a
869751
802616
explain select 0+a from t1 where a > 736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
select 0+a from t1 where a = 736494;
0+a
736494
explain select 0+a from t1 where a = 736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const uniq_id uniq_id 8 const 1
select 0+a from t1 where a=869751 or a=736494;
0+a
736494
869751
explain select 0+a from t1 where a=869751 or a=736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
select 0+a from t1 where a in (869751,736494,226312,802616);
0+a
226312
736494
802616
869751
explain select 0+a from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 4 Using where
drop table t1;
End of 5.3 tests
mysql-test/t/heap_btree.test
View file @
ab2f3651
...
...
@@ -263,3 +263,19 @@ DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
--
echo
# bit index in heap tables
create
table
t1
(
a
bit
(
63
)
not
null
)
engine
=
heap
;
insert
into
t1
values
(
869751
),(
736494
),(
226312
),(
802616
),(
728912
);
alter
table
t1
add
unique
uniq_id
using
BTREE
(
a
);
select
0
+
a
from
t1
where
a
>
736494
;
explain
select
0
+
a
from
t1
where
a
>
736494
;
select
0
+
a
from
t1
where
a
=
736494
;
explain
select
0
+
a
from
t1
where
a
=
736494
;
select
0
+
a
from
t1
where
a
=
869751
or
a
=
736494
;
explain
select
0
+
a
from
t1
where
a
=
869751
or
a
=
736494
;
select
0
+
a
from
t1
where
a
in
(
869751
,
736494
,
226312
,
802616
);
explain
select
0
+
a
from
t1
where
a
in
(
869751
,
736494
,
226312
,
802616
);
drop
table
t1
;
--
echo
End
of
5.3
tests
mysql-test/t/heap_hash.test
View file @
ab2f3651
...
...
@@ -284,3 +284,20 @@ INSERT INTO t1 VALUES('A ', 'A ');
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
--
echo
# bit index in heap tables
create
table
t1
(
a
bit
(
63
)
not
null
)
engine
=
heap
;
insert
into
t1
values
(
869751
),(
736494
),(
226312
),(
802616
),(
728912
);
alter
table
t1
add
unique
uniq_id
using
HASH
(
a
);
select
0
+
a
from
t1
where
a
>
736494
;
explain
select
0
+
a
from
t1
where
a
>
736494
;
select
0
+
a
from
t1
where
a
=
736494
;
explain
select
0
+
a
from
t1
where
a
=
736494
;
select
0
+
a
from
t1
where
a
=
869751
or
a
=
736494
;
explain
select
0
+
a
from
t1
where
a
=
869751
or
a
=
736494
;
select
0
+
a
from
t1
where
a
in
(
869751
,
736494
,
226312
,
802616
);
explain
select
0
+
a
from
t1
where
a
in
(
869751
,
736494
,
226312
,
802616
);
drop
table
t1
;
--
echo
End
of
5.3
tests
storage/heap/ha_heap.cc
View file @
ab2f3651
...
...
@@ -654,7 +654,8 @@ int ha_heap::create(const char *name, TABLE *table_arg,
seg
->
type
!=
HA_KEYTYPE_VARTEXT1
&&
seg
->
type
!=
HA_KEYTYPE_VARTEXT2
&&
seg
->
type
!=
HA_KEYTYPE_VARBINARY1
&&
seg
->
type
!=
HA_KEYTYPE_VARBINARY2
)
seg
->
type
!=
HA_KEYTYPE_VARBINARY2
&&
seg
->
type
!=
HA_KEYTYPE_BIT
)
seg
->
type
=
HA_KEYTYPE_BINARY
;
}
seg
->
start
=
(
uint
)
key_part
->
offset
;
...
...
@@ -686,6 +687,15 @@ int ha_heap::create(const char *name, TABLE *table_arg,
auto_key
=
key
+
1
;
auto_key_type
=
field
->
key_type
();
}
if
(
seg
->
type
==
HA_KEYTYPE_BIT
)
{
seg
->
bit_length
=
((
Field_bit
*
)
field
)
->
bit_len
;
seg
->
bit_start
=
((
Field_bit
*
)
field
)
->
bit_ofs
;
seg
->
bit_pos
=
(
uint
)
(((
Field_bit
*
)
field
)
->
bit_ptr
-
(
uchar
*
)
table_arg
->
record
[
0
]);
}
else
seg
->
bit_length
=
seg
->
bit_start
=
seg
->
bit_pos
=
0
;
}
}
mem_per_row
+=
MY_ALIGN
(
share
->
reclength
+
1
,
sizeof
(
char
*
));
...
...
storage/heap/hp_create.c
View file @
ab2f3651
...
...
@@ -104,6 +104,14 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
*/
keyinfo
->
seg
[
j
].
type
=
HA_KEYTYPE_VARTEXT1
;
break
;
case
HA_KEYTYPE_BIT
:
/*
The odd bits which stored separately (if they are present
(bit_pos, bit_length)) are already present in seg[j].length as
additional byte.
See field.h, function key_length()
*/
break
;
default:
break
;
}
...
...
storage/heap/hp_hash.c
View file @
ab2f3651
...
...
@@ -349,6 +349,15 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
}
else
{
if
(
seg
->
type
==
HA_KEYTYPE_BIT
&&
seg
->
bit_length
)
{
uchar
bits
=
get_rec_bits
(
rec
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
nr
^=
(
ulong
)
((((
uint
)
nr
&
63
)
+
nr2
)
*
((
uint
)
bits
))
+
(
nr
<<
8
);
nr2
+=
3
;
end
--
;
}
for
(;
pos
<
end
;
pos
++
)
{
nr
^=
(
ulong
)
((((
uint
)
nr
&
63
)
+
nr2
)
*
((
uint
)
*
pos
))
+
(
nr
<<
8
);
...
...
@@ -465,6 +474,14 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
else
{
uchar
*
end
=
pos
+
seg
->
length
;
if
(
seg
->
type
==
HA_KEYTYPE_BIT
&&
seg
->
bit_length
)
{
uchar
bits
=
get_rec_bits
(
rec
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
nr
*=
16777619
;
nr
^=
(
uint
)
bits
;
end
--
;
}
for
(
;
pos
<
end
;
pos
++
)
{
nr
*=
16777619
;
...
...
@@ -577,7 +594,18 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2,
}
else
{
if
(
bcmp
(
rec1
+
seg
->
start
,
rec2
+
seg
->
start
,
seg
->
length
))
uint
dec
=
0
;
if
(
seg
->
type
==
HA_KEYTYPE_BIT
&&
seg
->
bit_length
)
{
uchar
bits1
=
get_rec_bits
(
rec1
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
uchar
bits2
=
get_rec_bits
(
rec2
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
if
(
bits1
!=
bits2
)
return
1
;
dec
=
1
;
}
if
(
bcmp
(
rec1
+
seg
->
start
,
rec2
+
seg
->
start
,
seg
->
length
-
dec
))
return
1
;
}
}
...
...
@@ -660,7 +688,18 @@ int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key)
}
else
{
if
(
bcmp
(
rec
+
seg
->
start
,
key
,
seg
->
length
))
uint
dec
=
0
;
if
(
seg
->
type
==
HA_KEYTYPE_BIT
&&
seg
->
bit_length
)
{
uchar
bits
=
get_rec_bits
(
rec
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
if
(
bits
!=
(
*
key
))
return
1
;
dec
=
1
;
key
++
;
}
if
(
bcmp
(
rec
+
seg
->
start
,
key
,
seg
->
length
-
dec
))
return
1
;
}
}
...
...
@@ -689,6 +728,12 @@ void hp_make_key(HP_KEYDEF *keydef, uchar *key, const uchar *rec)
}
if
(
seg
->
type
==
HA_KEYTYPE_VARTEXT1
)
char_length
+=
seg
->
bit_start
;
/* Copy also length */
else
if
(
seg
->
type
==
HA_KEYTYPE_BIT
&&
seg
->
bit_length
)
{
*
key
++=
get_rec_bits
(
rec
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
char_length
--
;
}
memcpy
(
key
,
rec
+
seg
->
start
,(
size_t
)
char_length
);
key
+=
char_length
;
}
...
...
@@ -720,7 +765,8 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
{
uint
length
=
seg
->
length
;
uchar
*
pos
=
(
uchar
*
)
rec
+
seg
->
start
;
DBUG_ASSERT
(
seg
->
type
!=
HA_KEYTYPE_BIT
);
#ifdef HAVE_ISNAN
if
(
seg
->
type
==
HA_KEYTYPE_FLOAT
)
{
...
...
@@ -784,6 +830,12 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key,
seg
->
charset
->
cset
->
fill
(
seg
->
charset
,
(
char
*
)
key
+
char_length
,
seg
->
length
-
char_length
,
' '
);
}
if
(
seg
->
type
==
HA_KEYTYPE_BIT
&&
seg
->
bit_length
)
{
*
key
++=
get_rec_bits
(
rec
+
seg
->
bit_pos
,
seg
->
bit_start
,
seg
->
bit_length
);
char_length
--
;
}
memcpy
(
key
,
rec
+
seg
->
start
,
(
size_t
)
char_length
);
key
+=
seg
->
length
;
}
...
...
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