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
c0b5bf5e
Commit
c0b5bf5e
authored
Feb 21, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some UNION bug fixes..
parent
66d4f05c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
131 deletions
+174
-131
sql/sql_select.cc
sql/sql_select.cc
+168
-131
sql/sql_union.cc
sql/sql_union.cc
+6
-0
No files found.
sql/sql_select.cc
View file @
c0b5bf5e
...
@@ -144,7 +144,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab);
...
@@ -144,7 +144,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab);
static
void
init_sum_functions
(
Item_sum
**
func
);
static
void
init_sum_functions
(
Item_sum
**
func
);
static
bool
update_sum_func
(
Item_sum
**
func
);
static
bool
update_sum_func
(
Item_sum
**
func
);
static
void
select_describe
(
JOIN
*
join
,
bool
need_tmp_table
,
bool
need_order
,
static
void
select_describe
(
JOIN
*
join
,
bool
need_tmp_table
,
bool
need_order
,
bool
distinct
);
bool
distinct
,
const
char
*
message
=
NullS
);
static
void
describe_info
(
THD
*
thd
,
const
char
*
info
);
static
void
describe_info
(
THD
*
thd
,
const
char
*
info
);
/*
/*
...
@@ -195,6 +195,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -195,6 +195,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
Procedure
*
procedure
;
Procedure
*
procedure
;
List
<
Item
>
all_fields
(
fields
);
List
<
Item
>
all_fields
(
fields
);
bool
select_distinct
;
bool
select_distinct
;
SELECT_LEX
*
select_lex
=
&
(
thd
->
lex
.
select_lex
);
DBUG_ENTER
(
"mysql_select"
);
DBUG_ENTER
(
"mysql_select"
);
/* Check that all tables, fields, conds and order are ok */
/* Check that all tables, fields, conds and order are ok */
...
@@ -350,6 +351,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -350,6 +351,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
}
}
if
(
cond_value
==
Item
::
COND_FALSE
||
!
thd
->
select_limit
)
if
(
cond_value
==
Item
::
COND_FALSE
||
!
thd
->
select_limit
)
{
/* Impossible cond */
{
/* Impossible cond */
if
(
select_options
&
SELECT_DESCRIBE
&&
select_lex
->
next
)
select_describe
(
&
join
,
false
,
false
,
false
,
"Impossible WHERE"
);
else
error
=
return_zero_rows
(
result
,
tables
,
fields
,
error
=
return_zero_rows
(
result
,
tables
,
fields
,
join
.
tmp_table_param
.
sum_func_count
!=
0
&&
!
group
,
join
.
tmp_table_param
.
sum_func_count
!=
0
&&
!
group
,
select_options
,
"Impossible WHERE"
,
having
,
select_options
,
"Impossible WHERE"
,
having
,
...
@@ -366,6 +370,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -366,6 +370,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
{
{
if
(
res
<
0
)
if
(
res
<
0
)
{
{
if
(
select_options
&
SELECT_DESCRIBE
&&
select_lex
->
next
)
select_describe
(
&
join
,
false
,
false
,
false
,
"No matching min/max row"
);
else
error
=
return_zero_rows
(
result
,
tables
,
fields
,
!
group
,
error
=
return_zero_rows
(
result
,
tables
,
fields
,
!
group
,
select_options
,
"No matching min/max row"
,
select_options
,
"No matching min/max row"
,
having
,
procedure
);
having
,
procedure
);
...
@@ -374,9 +381,12 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -374,9 +381,12 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
}
}
if
(
select_options
&
SELECT_DESCRIBE
)
if
(
select_options
&
SELECT_DESCRIBE
)
{
{
if
(
select_lex
->
next
)
select_describe
(
&
join
,
false
,
false
,
false
,
"Select tables optimized away"
);
else
describe_info
(
thd
,
"Select tables optimized away"
);
describe_info
(
thd
,
"Select tables optimized away"
);
delete
procedure
;
delete
procedure
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
error
);
}
}
tables
=
0
;
// All tables resolved
tables
=
0
;
// All tables resolved
}
}
...
@@ -385,7 +395,12 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -385,7 +395,12 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
{
// Only test of functions
{
// Only test of functions
error
=
0
;
error
=
0
;
if
(
select_options
&
SELECT_DESCRIBE
)
if
(
select_options
&
SELECT_DESCRIBE
)
{
if
(
select_lex
->
next
)
select_describe
(
&
join
,
false
,
false
,
false
,
"No tables used"
);
else
describe_info
(
thd
,
"No tables used"
);
describe_info
(
thd
,
"No tables used"
);
}
else
else
{
{
result
->
send_fields
(
fields
,
1
);
result
->
send_fields
(
fields
,
1
);
...
@@ -463,6 +478,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -463,6 +478,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
}
}
if
(
make_join_select
(
&
join
,
select
,
conds
))
if
(
make_join_select
(
&
join
,
select
,
conds
))
{
{
if
(
select_options
&
SELECT_DESCRIBE
&&
select_lex
->
next
)
select_describe
(
&
join
,
false
,
false
,
false
,
"Impossible WHERE noticed after reading const tables"
);
else
error
=
return_zero_rows
(
result
,
tables
,
fields
,
error
=
return_zero_rows
(
result
,
tables
,
fields
,
join
.
tmp_table_param
.
sum_func_count
!=
0
&&
!
group
,
join
.
tmp_table_param
.
sum_func_count
!=
0
&&
!
group
,
select_options
,
select_options
,
...
@@ -535,7 +553,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -535,7 +553,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
make_join_readinfo
(
&
join
,
make_join_readinfo
(
&
join
,
(
select_options
&
(
SELECT_DESCRIBE
|
(
select_options
&
(
SELECT_DESCRIBE
|
SELECT_NO_JOIN_CACHE
))
|
SELECT_NO_JOIN_CACHE
))
|
(
thd
->
lex
.
select_lex
.
ftfunc_list
.
elements
?
SELECT_NO_JOIN_CACHE
:
0
));
(
select_lex
->
ftfunc_list
.
elements
?
SELECT_NO_JOIN_CACHE
:
0
));
/* Need to tell Innobase that to play it safe, it should fetch all
/* Need to tell Innobase that to play it safe, it should fetch all
columns of the tables: this is because MySQL
columns of the tables: this is because MySQL
...
@@ -2516,6 +2534,7 @@ static void
...
@@ -2516,6 +2534,7 @@ static void
make_join_readinfo
(
JOIN
*
join
,
uint
options
)
make_join_readinfo
(
JOIN
*
join
,
uint
options
)
{
{
uint
i
;
uint
i
;
SELECT_LEX
*
select_lex
=
&
(
join
->
thd
->
lex
.
select_lex
);
DBUG_ENTER
(
"make_join_readinfo"
);
DBUG_ENTER
(
"make_join_readinfo"
);
for
(
i
=
join
->
const_tables
;
i
<
join
->
tables
;
i
++
)
for
(
i
=
join
->
const_tables
;
i
<
join
->
tables
;
i
++
)
...
@@ -2598,7 +2617,7 @@ make_join_readinfo(JOIN *join,uint options)
...
@@ -2598,7 +2617,7 @@ make_join_readinfo(JOIN *join,uint options)
/* These init changes read_record */
/* These init changes read_record */
if
(
tab
->
use_quick
==
2
)
if
(
tab
->
use_quick
==
2
)
{
{
join
->
thd
->
lex
.
select_lex
.
options
|=
QUERY_NO_GOOD_INDEX_USED
;
select_lex
->
options
|=
QUERY_NO_GOOD_INDEX_USED
;
tab
->
read_first_record
=
join_init_quick_read_record
;
tab
->
read_first_record
=
join_init_quick_read_record
;
statistic_increment
(
select_range_check_count
,
&
LOCK_status
);
statistic_increment
(
select_range_check_count
,
&
LOCK_status
);
}
}
...
@@ -2613,7 +2632,7 @@ make_join_readinfo(JOIN *join,uint options)
...
@@ -2613,7 +2632,7 @@ make_join_readinfo(JOIN *join,uint options)
}
}
else
else
{
{
join
->
thd
->
lex
.
select_lex
.
options
|=
QUERY_NO_INDEX_USED
;
select_lex
->
options
|=
QUERY_NO_INDEX_USED
;
statistic_increment
(
select_scan_count
,
&
LOCK_status
);
statistic_increment
(
select_scan_count
,
&
LOCK_status
);
}
}
}
}
...
@@ -2625,7 +2644,7 @@ make_join_readinfo(JOIN *join,uint options)
...
@@ -2625,7 +2644,7 @@ make_join_readinfo(JOIN *join,uint options)
}
}
else
else
{
{
join
->
thd
->
lex
.
select_lex
.
options
|=
QUERY_NO_INDEX_USED
;
select_lex
->
options
|=
QUERY_NO_INDEX_USED
;
statistic_increment
(
select_full_join_count
,
&
LOCK_status
);
statistic_increment
(
select_full_join_count
,
&
LOCK_status
);
}
}
}
}
...
@@ -6940,16 +6959,17 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
...
@@ -6940,16 +6959,17 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab)
****************************************************************************/
****************************************************************************/
static
void
select_describe
(
JOIN
*
join
,
bool
need_tmp_table
,
bool
need_order
,
static
void
select_describe
(
JOIN
*
join
,
bool
need_tmp_table
,
bool
need_order
,
bool
distinct
)
bool
distinct
,
const
char
*
message
)
{
{
List
<
Item
>
field_list
;
List
<
Item
>
field_list
;
Item
*
item
;
Item
*
item
;
THD
*
thd
=
join
->
thd
;
THD
*
thd
=
join
->
thd
;
SELECT_LEX
*
select_lex
=
&
(
join
->
thd
->
lex
.
select_lex
);
DBUG_ENTER
(
"select_describe"
);
DBUG_ENTER
(
"select_describe"
);
/* Don't log this into the slow query log */
/* Don't log this into the slow query log */
join
->
thd
->
lex
.
select_lex
.
options
&=
~
(
QUERY_NO_INDEX_USED
|
QUERY_NO_GOOD_INDEX_USED
);
select_lex
->
options
&=
~
(
QUERY_NO_INDEX_USED
|
QUERY_NO_GOOD_INDEX_USED
);
if
(
join
->
thd
->
lex
.
select
==
&
join
->
thd
->
lex
.
select_lex
)
if
(
join
->
thd
->
lex
.
select
==
select_lex
)
{
{
field_list
.
push_back
(
new
Item_empty_string
(
"table"
,
NAME_LEN
));
field_list
.
push_back
(
new
Item_empty_string
(
"table"
,
NAME_LEN
));
field_list
.
push_back
(
new
Item_empty_string
(
"type"
,
10
));
field_list
.
push_back
(
new
Item_empty_string
(
"type"
,
10
));
...
@@ -6970,6 +6990,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
...
@@ -6970,6 +6990,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
}
char
buff
[
512
],
*
buff_ptr
;
char
buff
[
512
],
*
buff_ptr
;
String
tmp
(
buff
,
sizeof
(
buff
)),
*
packet
=
&
thd
->
packet
;
String
tmp
(
buff
,
sizeof
(
buff
)),
*
packet
=
&
thd
->
packet
;
if
(
message
)
{
packet
->
length
(
0
);
net_store_null
(
packet
);
net_store_null
(
packet
);
net_store_null
(
packet
);
net_store_null
(
packet
);
net_store_null
(
packet
);
net_store_null
(
packet
);
net_store_null
(
packet
);
net_store_data
(
packet
,
message
,
strlen
(
message
));
if
(
my_net_write
(
&
thd
->
net
,(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_VOID_RETURN
;
}
else
{
table_map
used_tables
=
0
;
table_map
used_tables
=
0
;
for
(
uint
i
=
0
;
i
<
join
->
tables
;
i
++
)
for
(
uint
i
=
0
;
i
<
join
->
tables
;
i
++
)
{
{
...
@@ -7093,11 +7129,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
...
@@ -7093,11 +7129,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
}
}
net_store_data
(
packet
,
buff
,(
uint
)
(
buff_ptr
-
buff
));
net_store_data
(
packet
,
buff
,(
uint
)
(
buff_ptr
-
buff
));
if
(
my_net_write
(
&
thd
->
net
,(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
if
(
my_net_write
(
&
thd
->
net
,(
char
*
)
packet
->
ptr
(),
packet
->
length
()))
DBUG_VOID_RETURN
;
/* purecov: i
nspected */
DBUG_VOID_RETURN
;
/* Purecov: I
nspected */
// For next iteration
// For next iteration
used_tables
|=
table
->
map
;
used_tables
|=
table
->
map
;
}
}
}
if
(
!
join
->
thd
->
lex
.
select
->
next
)
if
(
!
join
->
thd
->
lex
.
select
->
next
)
send_eof
(
&
thd
->
net
);
send_eof
(
&
thd
->
net
);
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
...
sql/sql_union.cc
View file @
c0b5bf5e
...
@@ -76,6 +76,12 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
...
@@ -76,6 +76,12 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
for
(
sl
=
&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
)
for
(
sl
=
&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
)
{
{
lex
->
select
=
sl
;
lex
->
select
=
sl
;
thd
->
offset_limit
=
sl
->
offset_limit
;
thd
->
select_limit
=
sl
->
select_limit
+
sl
->
offset_limit
;
if
(
thd
->
select_limit
<
sl
->
select_limit
)
thd
->
select_limit
=
HA_POS_ERROR
;
// no limit
if
(
thd
->
select_limit
==
HA_POS_ERROR
)
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
res
=
mysql_select
(
thd
,
(
TABLE_LIST
*
)
sl
->
table_list
.
first
,
res
=
mysql_select
(
thd
,
(
TABLE_LIST
*
)
sl
->
table_list
.
first
,
sl
->
item_list
,
sl
->
item_list
,
sl
->
where
,
sl
->
where
,
...
...
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