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
99e2ba48
Commit
99e2ba48
authored
May 02, 2012
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
5.2 merge
parents
1a463305
167ad4c4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
7 deletions
+98
-7
client/Makefile.am
client/Makefile.am
+0
-1
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+47
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+39
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+1
-0
sql/sql_select.cc
sql/sql_select.cc
+11
-6
No files found.
client/Makefile.am
View file @
99e2ba48
...
...
@@ -93,7 +93,6 @@ mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
$(top_builddir)
/mysys/libmysys.a
\
$(LIBMYSQLCLIENT_LA)
\
$(top_builddir)
/regex/libregex.la
$(CLIENT_THREAD_LIBS)
mysql_upgrade_SOURCES
=
mysql_upgrade.c
\
$(top_srcdir)
/mysys/my_getpagesize.c
...
...
mysql-test/r/group_by.result
View file @
99e2ba48
...
...
@@ -1968,6 +1968,53 @@ field1 field2
2009-02-19 02:05:00 5
SET SESSION SQL_MODE=default;
drop table t1;
#
# LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
#
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('x');
CREATE TABLE t2 ( b INT, c VARCHAR(1), KEY (c, b) ) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(4, 'd'),(8, 'g'),(3, 'x'),(3, 'f'),
(0, 'p'),(3, 'j'),(8, 'c');
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
rand() + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
t2_1.b + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
#TODO: in merge with 5.3 add original test suite
drop table t1, t2;
# End of 5.2 tests
#
# BUG#872702: Crash in add_ref_to_table_cond() when grouping by a PK
...
...
mysql-test/t/group_by.test
View file @
99e2ba48
...
...
@@ -1342,6 +1342,45 @@ SELECT alias2.f3 AS field1 , alias2.f1 AS field2 FROM t1 AS alias1 JOIN t1 AS al
SET
SESSION
SQL_MODE
=
default
;
drop
table
t1
;
--
echo
#
--
echo
# LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
--
echo
#
CREATE
TABLE
t1
(
a
VARCHAR
(
1
)
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
'x'
);
CREATE
TABLE
t2
(
b
INT
,
c
VARCHAR
(
1
),
KEY
(
c
,
b
)
)
ENGINE
=
MyISAM
;
INSERT
INTO
t2
VALUES
(
4
,
'd'
),(
8
,
'g'
),(
3
,
'x'
),(
3
,
'f'
),
(
0
,
'p'
),(
3
,
'j'
),(
8
,
'c'
);
SELECT
t2_1
.
b
as
zzz
FROM
t1
JOIN
t2
AS
t2_1
JOIN
t2
AS
t2_2
ON
(
t2_2
.
b
=
t2_1
.
b
)
AND
(
t2_2
.
c
=
t2_1
.
c
)
WHERE
rand
()
+
1
>
0
OR
a
=
t2_1
.
c
GROUP
BY
zzz
;
SELECT
t2_1
.
b
as
zzz
FROM
t1
JOIN
t2
AS
t2_1
JOIN
t2
AS
t2_2
ON
(
t2_2
.
b
=
t2_1
.
b
)
AND
(
t2_2
.
c
=
t2_1
.
c
)
WHERE
1
>
0
OR
a
=
t2_1
.
c
GROUP
BY
zzz
;
SELECT
t2_1
.
b
as
zzz
FROM
t1
JOIN
t2
AS
t2_1
JOIN
t2
AS
t2_2
ON
(
t2_2
.
b
=
t2_1
.
b
)
AND
(
t2_2
.
c
=
t2_1
.
c
)
WHERE
t2_1
.
b
+
1
>
0
OR
a
=
t2_1
.
c
GROUP
BY
zzz
;
--
echo
#TODO: in merge with 5.3 add original test suite
drop
table
t1
,
t2
;
--
echo
# End of 5.2 tests
--
echo
#
...
...
sql/item_cmpfunc.h
View file @
99e2ba48
...
...
@@ -1567,6 +1567,7 @@ class Item_cond :public Item_bool_func
friend
int
setup_conds
(
THD
*
thd
,
TABLE_LIST
*
tables
,
TABLE_LIST
*
leaves
,
COND
**
conds
);
void
top_level_item
()
{
abort_on_null
=
1
;
}
bool
top_level
()
{
return
abort_on_null
;
}
void
copy_andor_arguments
(
THD
*
thd
,
Item_cond
*
item
);
bool
walk
(
Item_processor
processor
,
bool
walk_subquery
,
uchar
*
arg
);
Item
*
transform
(
Item_transformer
transformer
,
uchar
*
arg
);
...
...
sql/sql_select.cc
View file @
99e2ba48
...
...
@@ -11996,9 +11996,10 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab,
@param cond condition whose multiple equalities are to be checked
@param table constant table that has been read
@param const_key mark key parts as constant
*/
static
void
update_const_equal_items
(
COND
*
cond
,
JOIN_TAB
*
tab
)
static
void
update_const_equal_items
(
COND
*
cond
,
JOIN_TAB
*
tab
,
bool
const_key
)
{
if
(
!
(
cond
->
used_tables
()
&
tab
->
table
->
map
))
return
;
...
...
@@ -12009,7 +12010,10 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
List_iterator_fast
<
Item
>
li
(
*
cond_list
);
Item
*
item
;
while
((
item
=
li
++
))
update_const_equal_items
(
item
,
tab
);
update_const_equal_items
(
item
,
tab
,
(((
Item_cond
*
)
cond
)
->
top_level
()
&&
((
Item_cond
*
)
cond
)
->
functype
()
==
Item_func
::
COND_AND_FUNC
));
}
else
if
(
cond
->
type
()
==
Item
::
FUNC_ITEM
&&
((
Item_cond
*
)
cond
)
->
functype
()
==
Item_func
::
MULT_EQUAL_FUNC
)
...
...
@@ -12039,7 +12043,8 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
TABLE
*
tab
=
field
->
table
;
KEYUSE
*
use
;
for
(
use
=
stat
->
keyuse
;
use
&&
use
->
table
==
tab
;
use
++
)
if
(
!
use
->
is_for_hash_join
()
&&
possible_keys
.
is_set
(
use
->
key
)
&&
if
(
const_key
&&
!
use
->
is_for_hash_join
()
&&
possible_keys
.
is_set
(
use
->
key
)
&&
tab
->
key_info
[
use
->
key
].
key_part
[
use
->
keypart
].
field
==
field
)
tab
->
const_key_parts
[
use
->
key
]
|=
use
->
keypart_map
;
...
...
@@ -16099,7 +16104,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
List_iterator
<
TABLE_LIST
>
ti
(
join
->
select_lex
->
leaf_tables
);
/* Check appearance of new constant items in Item_equal objects */
if
(
join
->
conds
)
update_const_equal_items
(
join
->
conds
,
tab
);
update_const_equal_items
(
join
->
conds
,
tab
,
TRUE
);
while
((
tbl
=
ti
++
))
{
TABLE_LIST
*
embedded
;
...
...
@@ -16108,7 +16113,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
{
embedded
=
embedding
;
if
(
embedded
->
on_expr
)
update_const_equal_items
(
embedded
->
on_expr
,
tab
);
update_const_equal_items
(
embedded
->
on_expr
,
tab
,
TRUE
);
embedding
=
embedded
->
embedding
;
}
while
(
embedding
&&
...
...
@@ -17946,7 +17951,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit_arg,
int
ref_key
;
uint
ref_key_parts
;
int
order_direction
=
0
;
uint
used_key_parts
;
uint
used_key_parts
=
0
;
TABLE
*
table
=
tab
->
table
;
SQL_SELECT
*
select
=
tab
->
select
;
key_map
usable_keys
;
...
...
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