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
8ec7190d
Commit
8ec7190d
authored
Apr 06, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/psergey/mysql-5.0-bug18237-review
parents
b3dad934
3daaa8d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
20 deletions
+7
-20
sql/opt_sum.cc
sql/opt_sum.cc
+7
-20
No files found.
sql/opt_sum.cc
View file @
8ec7190d
...
...
@@ -123,8 +123,11 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
If the storage manager of 'tl' gives exact row count, compute the total
number of rows. If there are no outer table dependencies, this count
may be used as the real count.
Schema tables are filled after this function is invoked, so we can't
get row count
*/
if
(
tl
->
table
->
file
->
table_flags
()
&
HA_NOT_EXACT_COUNT
)
if
((
tl
->
table
->
file
->
table_flags
()
&
HA_NOT_EXACT_COUNT
)
||
tl
->
schema_table
)
{
is_exact_count
=
FALSE
;
count
=
1
;
// ensure count != 0
...
...
@@ -149,31 +152,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
switch
(
item_sum
->
sum_func
())
{
case
Item_sum
:
:
COUNT_FUNC
:
/*
If the expr in
count
(expr) can never be null we can change this
If the expr in
COUNT
(expr) can never be null we can change this
to the number of rows in the tables if this number is exact and
there are no outer joins.
*/
if
(
!
conds
&&
!
((
Item_sum_count
*
)
item
)
->
args
[
0
]
->
maybe_null
&&
!
outer_tables
&&
is_exact_count
)
{
longlong
count
=
1
;
TABLE_LIST
*
table
;
for
(
table
=
tables
;
table
;
table
=
table
->
next_leaf
)
{
if
(
outer_tables
||
(
table
->
table
->
file
->
table_flags
()
&
HA_NOT_EXACT_COUNT
)
||
table
->
schema_table
)
{
const_result
=
0
;
// Can't optimize left join
break
;
}
tables
->
table
->
file
->
info
(
HA_STATUS_VARIABLE
|
HA_STATUS_NO_LOCK
);
count
*=
table
->
table
->
file
->
records
;
}
if
(
!
table
)
{
((
Item_sum_count
*
)
item
)
->
make_const
(
count
);
recalc_const_item
=
1
;
}
((
Item_sum_count
*
)
item
)
->
make_const
(
count
);
recalc_const_item
=
1
;
}
else
const_result
=
0
;
...
...
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