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
433206c1
Commit
433206c1
authored
Aug 20, 2004
by
igor@rurik.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge rurik.mysql.com:/home/igor/mysql-4.1
into rurik.mysql.com:/home/igor/dev/mysql-4.1-0
parents
7a27f2ce
f2b9c5f4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
0 deletions
+78
-0
mysql-test/r/olap.result
mysql-test/r/olap.result
+36
-0
mysql-test/t/olap.test
mysql-test/t/olap.test
+37
-0
sql/item_sum.cc
sql/item_sum.cc
+3
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-0
No files found.
mysql-test/r/olap.result
View file @
433206c1
...
...
@@ -271,3 +271,39 @@ i i COUNT(*)
100 NULL 2
NULL NULL 2
drop table t1,t2;
CREATE TABLE user_day(
user_id INT NOT NULL,
date DATE NOT NULL,
UNIQUE INDEX user_date (user_id, date)
);
INSERT INTO user_day VALUES
(1, '2004-06-06' ),
(1, '2004-06-07' ),
(2, '2004-06-06' );
SELECT
d.date AS day,
COUNT(d.user_id) as sample,
COUNT(next_day.user_id) AS not_cancelled
FROM user_day d
LEFT JOIN user_day next_day
ON next_day.user_id=d.user_id AND
next_day.date= DATE_ADD( d.date, interval 1 day )
GROUP BY day;
day sample not_cancelled
2004-06-06 2 1
2004-06-07 1 0
SELECT
d.date AS day,
COUNT(d.user_id) as sample,
COUNT(next_day.user_id) AS not_cancelled
FROM user_day d
LEFT JOIN user_day next_day
ON next_day.user_id=d.user_id AND
next_day.date= DATE_ADD( d.date, interval 1 day )
GROUP BY day
WITH ROLLUP;
day sample not_cancelled
2004-06-06 2 1
2004-06-07 1 0
NULL 3 1
DROP TABLE user_day;
mysql-test/t/olap.test
View file @
433206c1
...
...
@@ -88,3 +88,40 @@ INSERT INTO t2 VALUES (100),(200);
SELECT
i
,
COUNT
(
*
)
FROM
t1
GROUP
BY
i
WITH
ROLLUP
;
SELECT
t1
.
i
,
t2
.
i
,
COUNT
(
*
)
FROM
t1
,
t2
GROUP
BY
t1
.
i
,
t2
.
i
WITH
ROLLUP
;
drop
table
t1
,
t2
;
#bug #4767: ROLLUP with LEFT JOIN
CREATE
TABLE
user_day
(
user_id
INT
NOT
NULL
,
date
DATE
NOT
NULL
,
UNIQUE
INDEX
user_date
(
user_id
,
date
)
);
INSERT
INTO
user_day
VALUES
(
1
,
'2004-06-06'
),
(
1
,
'2004-06-07'
),
(
2
,
'2004-06-06'
);
SELECT
d
.
date
AS
day
,
COUNT
(
d
.
user_id
)
as
sample
,
COUNT
(
next_day
.
user_id
)
AS
not_cancelled
FROM
user_day
d
LEFT
JOIN
user_day
next_day
ON
next_day
.
user_id
=
d
.
user_id
AND
next_day
.
date
=
DATE_ADD
(
d
.
date
,
interval
1
day
)
GROUP
BY
day
;
SELECT
d
.
date
AS
day
,
COUNT
(
d
.
user_id
)
as
sample
,
COUNT
(
next_day
.
user_id
)
AS
not_cancelled
FROM
user_day
d
LEFT
JOIN
user_day
next_day
ON
next_day
.
user_id
=
d
.
user_id
AND
next_day
.
date
=
DATE_ADD
(
d
.
date
,
interval
1
day
)
GROUP
BY
day
WITH
ROLLUP
;
DROP
TABLE
user_day
;
sql/item_sum.cc
View file @
433206c1
...
...
@@ -159,7 +159,10 @@ Item *Item_sum::get_tmp_table_item(THD *thd)
if
(
!
arg
->
const_item
())
{
if
(
arg
->
type
()
==
Item
::
FIELD_ITEM
)
{
arg
->
maybe_null
=
result_field_tmp
->
maybe_null
();
((
Item_field
*
)
arg
)
->
field
=
result_field_tmp
++
;
}
else
sum_item
->
args
[
i
]
=
new
Item_field
(
result_field_tmp
++
);
}
...
...
sql/sql_select.cc
View file @
433206c1
...
...
@@ -4997,6 +4997,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
blob_count
++
;
}
((
Item_sum
*
)
item
)
->
args
[
i
]
=
new
Item_field
(
new_field
);
if
(((
Item_sum
*
)
item
)
->
arg_count
==
1
)
((
Item_sum
*
)
item
)
->
result_field
=
new_field
;
}
}
}
...
...
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