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
2adf3ee7
Commit
2adf3ee7
authored
Aug 25, 2007
by
gshchepa/uchum@gleb.loc
Browse files
Options
Browse Files
Download
Plain Diff
Merge gleb.loc:/home/uchum/work/bk/5.1
into gleb.loc:/home/uchum/work/bk/5.1-opt
parents
b30fbfd3
ced93cb3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
9 deletions
+81
-9
mysql-test/r/type_bit.result
mysql-test/r/type_bit.result
+15
-0
mysql-test/t/type_bit.test
mysql-test/t/type_bit.test
+13
-0
sql/sql_select.cc
sql/sql_select.cc
+53
-9
No files found.
mysql-test/r/type_bit.result
View file @
2adf3ee7
...
@@ -642,6 +642,21 @@ b+0 COUNT(DISTINCT a)
...
@@ -642,6 +642,21 @@ b+0 COUNT(DISTINCT a)
1 1
1 1
3 2
3 2
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (b BIT);
INSERT INTO t1 (b) VALUES (1), (0);
SELECT DISTINCT b FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 b b 16 1 1 Y 32 0 63
b
#
#
SELECT b FROM t1 GROUP BY b;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 b b 16 1 1 Y 32 0 63
b
#
#
DROP TABLE t1;
End of 5.0 tests
End of 5.0 tests
create table t1(a bit(7));
create table t1(a bit(7));
insert into t1 values(0x40);
insert into t1 values(0x40);
...
...
mysql-test/t/type_bit.test
View file @
2adf3ee7
...
@@ -291,6 +291,19 @@ INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
...
@@ -291,6 +291,19 @@ INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
SELECT
b
+
0
,
COUNT
(
DISTINCT
a
)
FROM
t1
GROUP
BY
b
;
SELECT
b
+
0
,
COUNT
(
DISTINCT
a
)
FROM
t1
GROUP
BY
b
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug#30245: A wrong type of a BIT field is reported when grouped by it.
#
CREATE
TABLE
t1
(
b
BIT
);
INSERT
INTO
t1
(
b
)
VALUES
(
1
),
(
0
);
--
enable_metadata
--
replace_column
1
#
SELECT
DISTINCT
b
FROM
t1
;
--
replace_column
1
#
SELECT
b
FROM
t1
GROUP
BY
b
;
--
disable_metadata
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
#
#
...
...
sql/sql_select.cc
View file @
2adf3ee7
...
@@ -195,6 +195,7 @@ static bool setup_new_fields(THD *thd, List<Item> &fields,
...
@@ -195,6 +195,7 @@ static bool setup_new_fields(THD *thd, List<Item> &fields,
List
<
Item
>
&
all_fields
,
ORDER
*
new_order
);
List
<
Item
>
&
all_fields
,
ORDER
*
new_order
);
static
ORDER
*
create_distinct_group
(
THD
*
thd
,
Item
**
ref_pointer_array
,
static
ORDER
*
create_distinct_group
(
THD
*
thd
,
Item
**
ref_pointer_array
,
ORDER
*
order
,
List
<
Item
>
&
fields
,
ORDER
*
order
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
,
bool
*
all_order_by_fields_used
);
bool
*
all_order_by_fields_used
);
static
bool
test_if_subpart
(
ORDER
*
a
,
ORDER
*
b
);
static
bool
test_if_subpart
(
ORDER
*
a
,
ORDER
*
b
);
static
TABLE
*
get_sort_by_table
(
ORDER
*
a
,
ORDER
*
b
,
TABLE_LIST
*
tables
);
static
TABLE
*
get_sort_by_table
(
ORDER
*
a
,
ORDER
*
b
,
TABLE_LIST
*
tables
);
...
@@ -543,6 +544,28 @@ JOIN::prepare(Item ***rref_pointer_array,
...
@@ -543,6 +544,28 @@ JOIN::prepare(Item ***rref_pointer_array,
fix_inner_refs
(
thd
,
all_fields
,
select_lex
,
ref_pointer_array
))
fix_inner_refs
(
thd
,
all_fields
,
select_lex
,
ref_pointer_array
))
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
if
(
group_list
)
{
/*
Because HEAP tables can't index BIT fields we need to use an
additional hidden field for grouping because later it will be
converted to a LONG field. Original field will remain of the
BIT type and will be returned to a client.
*/
for
(
ORDER
*
ord
=
group_list
;
ord
;
ord
=
ord
->
next
)
{
if
((
*
ord
->
item
)
->
type
()
==
Item
::
FIELD_ITEM
&&
(
*
ord
->
item
)
->
field_type
()
==
MYSQL_TYPE_BIT
)
{
Item_field
*
field
=
new
Item_field
(
thd
,
*
(
Item_field
**
)
ord
->
item
);
int
el
=
all_fields
.
elements
;
ref_pointer_array
[
el
]
=
field
;
all_fields
.
push_front
(
field
);
ord
->
item
=
ref_pointer_array
+
el
;
}
}
}
if
(
setup_ftfuncs
(
select_lex
))
/* should be after having->fix_fields */
if
(
setup_ftfuncs
(
select_lex
))
/* should be after having->fix_fields */
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
...
@@ -1085,12 +1108,13 @@ JOIN::optimize()
...
@@ -1085,12 +1108,13 @@ JOIN::optimize()
skip_sort_order
=
test_if_skip_sort_order
(
tab
,
order
,
select_limit
,
1
,
skip_sort_order
=
test_if_skip_sort_order
(
tab
,
order
,
select_limit
,
1
,
&
tab
->
table
->
keys_in_use_for_order_by
);
&
tab
->
table
->
keys_in_use_for_order_by
);
if
((
group_list
=
create_distinct_group
(
thd
,
select_lex
->
ref_pointer_array
,
if
((
group_list
=
create_distinct_group
(
thd
,
select_lex
->
ref_pointer_array
,
order
,
fields_list
,
order
,
fields_list
,
all_fields
,
&
all_order_fields_used
)))
&
all_order_fields_used
)))
{
{
bool
skip_group
=
(
skip_sort_order
&&
bool
skip_group
=
(
skip_sort_order
&&
test_if_skip_sort_order
(
tab
,
group_list
,
select_limit
,
1
,
test_if_skip_sort_order
(
tab
,
group_list
,
select_limit
,
1
,
&
tab
->
table
->
keys_in_use_for_group_by
)
!=
0
);
&
tab
->
table
->
keys_in_use_for_group_by
)
!=
0
);
count_field_types
(
select_lex
,
&
tmp_table_param
,
all_fields
,
0
);
if
((
skip_group
&&
all_order_fields_used
)
||
if
((
skip_group
&&
all_order_fields_used
)
||
select_limit
==
HA_POS_ERROR
||
select_limit
==
HA_POS_ERROR
||
(
order
&&
!
skip_sort_order
))
(
order
&&
!
skip_sort_order
))
...
@@ -14092,11 +14116,12 @@ setup_new_fields(THD *thd, List<Item> &fields,
...
@@ -14092,11 +14116,12 @@ setup_new_fields(THD *thd, List<Item> &fields,
static
ORDER
*
static
ORDER
*
create_distinct_group
(
THD
*
thd
,
Item
**
ref_pointer_array
,
create_distinct_group
(
THD
*
thd
,
Item
**
ref_pointer_array
,
ORDER
*
order_list
,
List
<
Item
>
&
fields
,
ORDER
*
order_list
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
,
bool
*
all_order_by_fields_used
)
bool
*
all_order_by_fields_used
)
{
{
List_iterator
<
Item
>
li
(
fields
);
List_iterator
<
Item
>
li
(
fields
);
Item
*
item
;
Item
*
item
,
**
orig_ref_pointer_array
=
ref_pointer_array
;
ORDER
*
order
,
*
group
,
**
prev
;
ORDER
*
order
,
*
group
,
**
prev
;
*
all_order_by_fields_used
=
1
;
*
all_order_by_fields_used
=
1
;
...
@@ -14136,12 +14161,31 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
...
@@ -14136,12 +14161,31 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
ORDER
*
ord
=
(
ORDER
*
)
thd
->
calloc
(
sizeof
(
ORDER
));
ORDER
*
ord
=
(
ORDER
*
)
thd
->
calloc
(
sizeof
(
ORDER
));
if
(
!
ord
)
if
(
!
ord
)
return
0
;
return
0
;
/*
We have here only field_list (not all_field_list), so we can use
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
&&
simple indexing of ref_pointer_array (order in the array and in the
item
->
field_type
()
==
MYSQL_TYPE_BIT
)
list are same)
{
*/
/*
ord
->
item
=
ref_pointer_array
;
Because HEAP tables can't index BIT fields we need to use an
additional hidden field for grouping because later it will be
converted to a LONG field. Original field will remain of the
BIT type and will be returned to a client.
*/
Item_field
*
new_item
=
new
Item_field
(
thd
,
(
Item_field
*
)
item
);
int
el
=
all_fields
.
elements
;
orig_ref_pointer_array
[
el
]
=
new_item
;
all_fields
.
push_front
(
new_item
);
ord
->
item
=
orig_ref_pointer_array
+
el
;
}
else
{
/*
We have here only field_list (not all_field_list), so we can use
simple indexing of ref_pointer_array (order in the array and in the
list are same)
*/
ord
->
item
=
ref_pointer_array
;
}
ord
->
asc
=
1
;
ord
->
asc
=
1
;
*
prev
=
ord
;
*
prev
=
ord
;
prev
=
&
ord
->
next
;
prev
=
&
ord
->
next
;
...
...
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