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
d028fb9f
Commit
d028fb9f
authored
Dec 28, 2020
by
Vicențiu Ciorbaru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: reduce indentation of end_send
Reorder end_send to exit via return instead of large if-else block.
parent
d624464b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
89 deletions
+86
-89
sql/sql_select.cc
sql/sql_select.cc
+86
-89
No files found.
sql/sql_select.cc
View file @
d028fb9f
...
...
@@ -21943,8 +21943,7 @@ join_read_next_same_or_null(READ_RECORD *info)
/* ARGSUSED */
static
enum_nested_loop_state
end_send
(
JOIN
*
join
,
JOIN_TAB
*
join_tab
__attribute__
((
unused
)),
bool
end_of_records
)
end_send
(
JOIN
*
join
,
JOIN_TAB
*
join_tab
,
bool
end_of_records
)
{
DBUG_ENTER
(
"end_send"
);
/*
...
...
@@ -21956,104 +21955,103 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
//TODO pass fields via argument
List
<
Item
>
*
fields
=
join_tab
?
(
join_tab
-
1
)
->
fields
:
join
->
fields
;
if
(
!
end_of_records
)
if
(
end_of_records
)
{
if
(
join
->
table_count
&&
join
->
join_tab
->
is_using_loose_index_scan
())
{
/* Copy non-aggregated fields when loose index scan is used. */
copy_fields
(
&
join
->
tmp_table_param
);
}
if
(
join
->
having
&&
join
->
having
->
val_int
()
==
0
)
DBUG_RETURN
(
NESTED_LOOP_OK
);
// Didn't match having
if
(
join
->
procedure
)
if
(
join
->
procedure
&&
join
->
procedure
->
end_of_records
())
DBUG_RETURN
(
NESTED_LOOP_ERROR
);
DBUG_RETURN
(
NESTED_LOOP_OK
);
}
if
(
join
->
table_count
&&
join
->
join_tab
->
is_using_loose_index_scan
())
{
/* Copy non-aggregated fields when loose index scan is used. */
copy_fields
(
&
join
->
tmp_table_param
);
}
if
(
join
->
having
&&
join
->
having
->
val_int
()
==
0
)
DBUG_RETURN
(
NESTED_LOOP_OK
);
// Didn't match having
if
(
join
->
procedure
)
{
if
(
join
->
procedure
->
send_row
(
join
->
procedure_fields_list
))
DBUG_RETURN
(
NESTED_LOOP_ERROR
);
DBUG_RETURN
(
NESTED_LOOP_OK
);
}
if
(
join
->
do_send_rows
)
{
int
error
;
/* result < 0 if row was not accepted and should not be counted */
if
(
unlikely
((
error
=
join
->
result
->
send_data_with_check
(
*
fields
,
join
->
unit
,
join
->
send_records
))))
{
if
(
join
->
procedure
->
send_row
(
join
->
procedure_fields_list
)
)
if
(
error
>
0
)
DBUG_RETURN
(
NESTED_LOOP_ERROR
);
DBUG_RETURN
(
NESTED_LOOP_OK
);
}
if
(
join
->
do_send_rows
)
{
int
error
;
/* result < 0 if row was not accepted and should not be counted */
if
(
unlikely
((
error
=
join
->
result
->
send_data_with_check
(
*
fields
,
join
->
unit
,
join
->
send_records
))))
{
if
(
error
>
0
)
DBUG_RETURN
(
NESTED_LOOP_ERROR
);
// error < 0 => duplicate row
join
->
duplicate_rows
++
;
}
// error < 0 => duplicate row
join
->
duplicate_rows
++
;
}
}
++
join
->
send_records
;
if
(
join
->
send_records
>=
join
->
unit
->
lim
.
get_select_limit
()
&&
!
join
->
do_send_rows
)
++
join
->
send_records
;
if
(
join
->
send_records
>=
join
->
unit
->
lim
.
get_select_limit
()
&&
!
join
->
do_send_rows
)
{
/*
If we have used Priority Queue for optimizing order by with limit,
then stop here, there are no more records to consume.
When this optimization is used, end_send is called on the next
join_tab.
*/
if
(
join
->
order
&&
join
->
select_options
&
OPTION_FOUND_ROWS
&&
join_tab
>
join
->
join_tab
&&
(
join_tab
-
1
)
->
filesort
&&
(
join_tab
-
1
)
->
filesort
->
using_pq
)
{
/*
If we have used Priority Queue for optimizing order by with limit,
then stop here, there are no more records to consume.
When this optimization is used, end_send is called on the next
join_tab.
*/
if
(
join
->
order
&&
join
->
select_options
&
OPTION_FOUND_ROWS
&&
join_tab
>
join
->
join_tab
&&
(
join_tab
-
1
)
->
filesort
&&
(
join_tab
-
1
)
->
filesort
->
using_pq
)
{
DBUG_PRINT
(
"info"
,
(
"filesort NESTED_LOOP_QUERY_LIMIT"
));
DBUG_RETURN
(
NESTED_LOOP_QUERY_LIMIT
);
}
DBUG_PRINT
(
"info"
,
(
"filesort NESTED_LOOP_QUERY_LIMIT"
));
DBUG_RETURN
(
NESTED_LOOP_QUERY_LIMIT
);
}
if
(
join
->
send_records
>=
join
->
unit
->
lim
.
get_select_limit
()
&&
join
->
do_send_rows
)
}
if
(
join
->
send_records
>=
join
->
unit
->
lim
.
get_select_limit
()
&&
join
->
do_send_rows
)
{
if
(
join
->
select_options
&
OPTION_FOUND_ROWS
)
{
if
(
join
->
select_options
&
OPTION_FOUND_ROWS
)
JOIN_TAB
*
jt
=
join
->
join_tab
;
if
((
join
->
table_count
==
1
)
&&
!
join
->
sort_and_group
&&
!
join
->
send_group_parts
&&
!
join
->
having
&&
!
jt
->
select_cond
&&
!
(
jt
->
select
&&
jt
->
select
->
quick
)
&&
(
jt
->
table
->
file
->
ha_table_flags
()
&
HA_STATS_RECORDS_IS_EXACT
)
&&
(
jt
->
ref
.
key
<
0
))
{
JOIN_TAB
*
jt
=
join
->
join_tab
;
if
((
join
->
table_count
==
1
)
&&
!
join
->
sort_and_group
&&
!
join
->
send_group_parts
&&
!
join
->
having
&&
!
jt
->
select_cond
&&
!
(
jt
->
select
&&
jt
->
select
->
quick
)
&&
(
jt
->
table
->
file
->
ha_table_flags
()
&
HA_STATS_RECORDS_IS_EXACT
)
&&
(
jt
->
ref
.
key
<
0
))
{
/* Join over all rows in table; Return number of found rows */
TABLE
*
table
=
jt
->
table
;
/* Join over all rows in table; Return number of found rows */
TABLE
*
table
=
jt
->
table
;
if
(
jt
->
filesort_result
)
// If filesort was used
{
join
->
send_records
=
jt
->
filesort_result
->
found_rows
;
}
else
{
table
->
file
->
info
(
HA_STATUS_VARIABLE
);
join
->
send_records
=
table
->
file
->
stats
.
records
;
}
}
else
{
join
->
do_send_rows
=
0
;
if
(
join
->
unit
->
fake_select_lex
)
join
->
unit
->
fake_select_lex
->
limit_params
.
select_limit
=
0
;
DBUG_RETURN
(
NESTED_LOOP_OK
);
}
if
(
jt
->
filesort_result
)
// If filesort was used
{
join
->
send_records
=
jt
->
filesort_result
->
found_rows
;
}
else
{
table
->
file
->
info
(
HA_STATUS_VARIABLE
);
join
->
send_records
=
table
->
file
->
stats
.
records
;
}
}
else
{
join
->
do_send_rows
=
0
;
if
(
join
->
unit
->
fake_select_lex
)
join
->
unit
->
fake_select_lex
->
limit_params
.
select_limit
=
0
;
DBUG_RETURN
(
NESTED_LOOP_OK
);
}
DBUG_RETURN
(
NESTED_LOOP_QUERY_LIMIT
);
// Abort nicely
}
else
if
(
join
->
send_records
>=
join
->
fetch_limit
)
{
/*
There is a server side cursor and all rows for
this fetch request are sent.
*/
DBUG_RETURN
(
NESTED_LOOP_CURSOR_LIMIT
);
}
DBUG_RETURN
(
NESTED_LOOP_QUERY_LIMIT
);
// Abort nicely
}
else
else
if
(
join
->
send_records
>=
join
->
fetch_limit
)
{
if
(
join
->
procedure
&&
join
->
procedure
->
end_of_records
())
DBUG_RETURN
(
NESTED_LOOP_ERROR
);
/*
There is a server side cursor and all rows for
this fetch request are sent.
*/
DBUG_RETURN
(
NESTED_LOOP_CURSOR_LIMIT
);
}
DBUG_RETURN
(
NESTED_LOOP_OK
);
}
...
...
@@ -22069,8 +22067,7 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
*/
enum_nested_loop_state
end_send_group
(
JOIN
*
join
,
JOIN_TAB
*
join_tab
__attribute__
((
unused
)),
bool
end_of_records
)
end_send_group
(
JOIN
*
join
,
JOIN_TAB
*
join_tab
,
bool
end_of_records
)
{
int
idx
=
-
1
;
enum_nested_loop_state
ok_code
=
NESTED_LOOP_OK
;
...
...
@@ -22099,7 +22096,7 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{
if
(
join
->
having
&&
join
->
having
->
val_int
()
==
0
)
error
=
-
1
;
// Didn't satisfy having
else
else
{
if
(
join
->
do_send_rows
)
error
=
join
->
procedure
->
send_row
(
*
fields
)
?
1
:
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