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
566ebb63
Commit
566ebb63
authored
Aug 27, 2003
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Plain Diff
merge fixes
parents
8b8b984d
58c659a3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
46 deletions
+55
-46
mysql-test/r/symlink.result
mysql-test/r/symlink.result
+0
-2
mysql-test/r/union.result
mysql-test/r/union.result
+1
-1
sql/sql_lex.h
sql/sql_lex.h
+2
-2
sql/sql_select.cc
sql/sql_select.cc
+3
-2
sql/sql_union.cc
sql/sql_union.cc
+49
-39
No files found.
mysql-test/r/symlink.result
View file @
566ebb63
...
@@ -46,8 +46,6 @@ alter table t8 rename t7;
...
@@ -46,8 +46,6 @@ alter table t8 rename t7;
rename table t7 to t9;
rename table t7 to t9;
drop table t1;
drop table t1;
Got one of the listed errors
Got one of the listed errors
Warnings:
Note 1008 Can't drop database 'test_mysqltest'; database doesn't exist
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
Got one of the listed errors
...
...
mysql-test/r/union.result
View file @
566ebb63
...
@@ -103,7 +103,7 @@ a b
...
@@ -103,7 +103,7 @@ a b
2 b
2 b
select found_rows();
select found_rows();
found_rows()
found_rows()
6
8
explain select a,b from t1 union all select a,b from t2;
explain select a,b from t1 union all select a,b from t2;
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
...
...
sql/sql_lex.h
View file @
566ebb63
...
@@ -272,8 +272,8 @@ protected:
...
@@ -272,8 +272,8 @@ protected:
select_result
*
result
;
select_result
*
result
;
int
res
;
int
res
;
bool
describe
,
found_rows_for_union
,
ulong
describe
,
found_rows_for_union
;
prepared
,
// prepare phase already performed for UNION (unit)
bool
prepared
,
// prepare phase already performed for UNION (unit)
optimized
,
// optimize phase already performed for UNION (unit)
optimized
,
// optimize phase already performed for UNION (unit)
executed
,
// already executed
executed
,
// already executed
t_and_f
;
// used for transferring tables_and_fields_initied UNIT:: methods
t_and_f
;
// used for transferring tables_and_fields_initied UNIT:: methods
...
...
sql/sql_select.cc
View file @
566ebb63
...
@@ -1043,6 +1043,7 @@ JOIN::exec()
...
@@ -1043,6 +1043,7 @@ JOIN::exec()
DBUG_ENTER
(
"JOIN::exec"
);
DBUG_ENTER
(
"JOIN::exec"
);
error
=
0
;
error
=
0
;
thd
->
limit_found_rows
=
thd
->
examined_row_count
=
0
;
if
(
procedure
)
if
(
procedure
)
{
{
if
(
procedure
->
change_columns
(
fields_list
)
||
if
(
procedure
->
change_columns
(
fields_list
)
||
...
@@ -1425,6 +1426,8 @@ JOIN::exec()
...
@@ -1425,6 +1426,8 @@ JOIN::exec()
thd
->
proc_info
=
"Sending data"
;
thd
->
proc_info
=
"Sending data"
;
error
=
thd
->
net
.
report_error
||
error
=
thd
->
net
.
report_error
||
do_select
(
curr_join
,
curr_fields_list
,
NULL
,
procedure
);
do_select
(
curr_join
,
curr_fields_list
,
NULL
,
procedure
);
thd
->
limit_found_rows
=
curr_join
->
send_records
;
thd
->
examined_row_count
=
curr_join
->
examined_rows
;
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
}
}
...
@@ -1547,8 +1550,6 @@ err:
...
@@ -1547,8 +1550,6 @@ err:
(
join
->
tmp_join
->
error
=
join
->
error
,
join
->
tmp_join
)
:
(
join
->
tmp_join
->
error
=
join
->
error
,
join
->
tmp_join
)
:
join
);
join
);
thd
->
limit_found_rows
=
curr_join
->
send_records
;
thd
->
examined_row_count
=
curr_join
->
examined_rows
;
thd
->
proc_info
=
"end"
;
thd
->
proc_info
=
"end"
;
err
=
join
->
cleanup
();
err
=
join
->
cleanup
();
if
(
thd
->
net
.
report_error
)
if
(
thd
->
net
.
report_error
)
...
...
sql/sql_union.cc
View file @
566ebb63
...
@@ -187,31 +187,34 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
...
@@ -187,31 +187,34 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
for
(
SELECT_LEX
*
sl
=
select_cursor
;
sl
;
sl
=
sl
->
next_select
())
for
(
SELECT_LEX
*
sl
=
select_cursor
;
sl
;
sl
=
sl
->
next_select
())
{
{
JOIN
*
join
=
new
JOIN
(
thd
,
sl
->
item_list
,
for
(
SELECT_LEX
*
sl
=
select_cursor
;
sl
;
sl
=
sl
->
next_select
())
sl
->
options
|
thd
->
options
|
SELECT_NO_UNLOCK
,
{
union_result
);
JOIN
*
join
=
new
JOIN
(
thd
,
sl
->
item_list
,
thd
->
lex
.
current_select
=
sl
;
sl
->
options
|
thd
->
options
|
SELECT_NO_UNLOCK
,
offset_limit_cnt
=
sl
->
offset_limit
;
union_result
);
select_limit_cnt
=
sl
->
select_limit
+
sl
->
offset_limit
;
thd
->
lex
.
current_select
=
sl
;
if
(
select_limit_cnt
<
sl
->
select_limit
)
offset_limit_cnt
=
sl
->
offset_limit
;
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
select_limit_cnt
=
sl
->
select_limit
+
sl
->
offset_limit
;
if
(
select_limit_cnt
==
HA_POS_ERROR
&&
!
sl
->
braces
)
if
(
select_limit_cnt
<
sl
->
select_limit
)
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
select_limit_cnt
==
HA_POS_ERROR
||
sl
->
braces
)
res
=
join
->
prepare
(
&
sl
->
ref_pointer_array
,
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
(
TABLE_LIST
*
)
sl
->
table_list
.
first
,
sl
->
with_wild
,
sl
->
where
,
res
=
join
->
prepare
(
&
sl
->
ref_pointer_array
,
((
sl
->
braces
)
?
sl
->
order_list
.
elements
:
0
)
+
(
TABLE_LIST
*
)
sl
->
table_list
.
first
,
sl
->
with_wild
,
sl
->
group_list
.
elements
,
sl
->
where
,
(
sl
->
braces
)
?
((
sl
->
braces
)
?
sl
->
order_list
.
elements
:
0
)
+
(
ORDER
*
)
sl
->
order_list
.
first
:
(
ORDER
*
)
0
,
sl
->
group_list
.
elements
,
(
ORDER
*
)
sl
->
group_list
.
first
,
(
sl
->
braces
)
?
sl
->
having
,
(
ORDER
*
)
sl
->
order_list
.
first
:
(
ORDER
*
)
0
,
(
ORDER
*
)
NULL
,
(
ORDER
*
)
sl
->
group_list
.
first
,
sl
,
this
,
t_and_f
);
sl
->
having
,
t_and_f
=
0
;
(
ORDER
*
)
NULL
,
if
(
res
||
thd
->
is_fatal_error
)
sl
,
this
,
t_and_f
);
goto
err
;
t_and_f
=
0
;
if
(
res
||
thd
->
is_fatal_error
)
goto
err
;
}
}
}
item_list
.
empty
();
item_list
.
empty
();
...
@@ -267,12 +270,15 @@ int st_select_lex_unit::exec()
...
@@ -267,12 +270,15 @@ int st_select_lex_unit::exec()
select_limit_cnt
=
sl
->
select_limit
+
sl
->
offset_limit
;
select_limit_cnt
=
sl
->
select_limit
+
sl
->
offset_limit
;
if
(
select_limit_cnt
<
sl
->
select_limit
)
if
(
select_limit_cnt
<
sl
->
select_limit
)
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
select_limit_cnt
==
HA_POS_ERROR
)
if
(
select_limit_cnt
==
HA_POS_ERROR
||
sl
->
braces
)
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
else
if
(
found_rows_for_union
)
else
{
{
rows
=
sl
->
select_limit
;
/*
sl
->
options
|=
OPTION_FOUND_ROWS
;
We are doing an union without braces. In this case
SQL_CALC_FOUND_ROWS should be done on all sub parts
*/
sl
->
options
|=
found_rows_for_union
;
}
}
/*
/*
...
@@ -301,6 +307,7 @@ int st_select_lex_unit::exec()
...
@@ -301,6 +307,7 @@ int st_select_lex_unit::exec()
}
}
if
(
!
res
)
if
(
!
res
)
{
{
records_at_start
=
table
->
file
->
records
;
sl
->
join
->
exec
();
sl
->
join
->
exec
();
res
=
sl
->
join
->
error
;
res
=
sl
->
join
->
error
;
if
(
!
res
&&
union_result
->
flush
())
if
(
!
res
&&
union_result
->
flush
())
...
@@ -314,10 +321,17 @@ int st_select_lex_unit::exec()
...
@@ -314,10 +321,17 @@ int st_select_lex_unit::exec()
thd
->
lex
.
current_select
=
lex_select_save
;
thd
->
lex
.
current_select
=
lex_select_save
;
DBUG_RETURN
(
res
);
DBUG_RETURN
(
res
);
}
}
if
(
found_rows_for_union
&&
!
sl
->
braces
&&
if
(
found_rows_for_union
&
sl
->
options
)
(
sl
->
options
&
OPTION_FOUND_ROWS
))
{
add_rows
+=
(
sl
->
join
->
send_records
>
rows
)
?
/*
sl
->
join
->
send_records
-
rows
:
0
;
This is a union without braces. Remember the number of rows that could
also have been part of the result set.
We get this from the difference of between total number of possible
rows and actual rows added to the temporary table.
*/
add_rows
+=
(
ulonglong
)
(
thd
->
limit_found_rows
-
(
table
->
file
->
records
-
records_at_start
));
}
}
}
}
}
optimized
=
1
;
optimized
=
1
;
...
@@ -382,12 +396,8 @@ int st_select_lex_unit::exec()
...
@@ -382,12 +396,8 @@ int st_select_lex_unit::exec()
(
ORDER
*
)
NULL
,
NULL
,
(
ORDER
*
)
NULL
,
(
ORDER
*
)
NULL
,
NULL
,
(
ORDER
*
)
NULL
,
options
|
SELECT_NO_UNLOCK
,
options
|
SELECT_NO_UNLOCK
,
result
,
this
,
fake_select_lex
,
0
);
result
,
this
,
fake_select_lex
,
0
);
if
(
found_rows_for_union
&&
!
res
)
if
(
!
res
)
{
thd
->
limit_found_rows
=
(
ulonglong
)
table
->
file
->
records
+
add_rows
;
thd
->
limit_found_rows
=
table
->
file
->
records
;
if
(
!
select_cursor
->
braces
)
thd
->
limit_found_rows
+=
add_rows
;
}
/*
/*
Mark for slow query log if any of the union parts didn't use
Mark for slow query log if any of the union parts didn't use
indexes efficiently
indexes efficiently
...
...
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