Bug in mysql-4.1 with UNION and derived table

Bug in mysql-4.1 with UNION and derived table

am 09.11.2002 18:37:00 von Jocelyn Fournier

Hi,

How-to-repeat :

mysql> SELECT 1 UNION SELECT 1 FROM (SELECT 1);
ERROR 1046: No Database Selected

However :

mysql> SELECT 1 FROM (SELECT 1) UNION SELECT 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

If I select a database :

use Hardwarefr

mysql> SELECT 1 UNION SELECT 1 FROM (SELECT 1);
ERROR 1146: Table 'Hardwarefr.' doesn't exist

Regards,
Jocelyn

------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread12921@lists.mysql.com
To unsubscribe, e-mail

Re: Bug in mysql-4.1 with UNION and derived table

am 09.11.2002 19:55:21 von Sinisa Milivojevic

Jocelyn Fournier writes:
> Hi,
>
> How-to-repeat :
>
> mysql> SELECT 1 UNION SELECT 1 FROM (SELECT 1);
> ERROR 1046: No Database Selected
>
> However :
>
> mysql> SELECT 1 FROM (SELECT 1) UNION SELECT 1;
> +---+
> | 1 |
> +---+
> | 1 |
> +---+
> 1 row in set (0.00 sec)
>
> If I select a database :
>
> use Hardwarefr
>
> mysql> SELECT 1 UNION SELECT 1 FROM (SELECT 1);
> ERROR 1146: Table 'Hardwarefr.' doesn't exist
>
> Regards,
> Jocelyn

Hi!

Thanks for your bug report.

This is fixed and should appear in 4.1 BK tree soon.

This is a patch:


===== sql/sql_parse.cc 1.260 vs edited =====
*** /tmp/sql_parse.cc-1.260-22011 Sat Nov 9 15:40:41 2002
--- edited/sql/sql_parse.cc Sat Nov 9 20:49:54 2002
***************
*** 1332,1344 ****
TODO: make derived tables processing 'inside' SELECT processing.
TODO: solve problem with depended derived tables in subselects
*/
! if (lex->derived_tables)
{
for (TABLE_LIST *cursor= tables;
cursor;
cursor= cursor->next)
if (cursor->derived && (res=mysql_derived(thd, lex,
! (SELECT_LEX_UNIT *)cursor->derived,
cursor)))
{
if (res < 0)
--- 1332,1349 ----
TODO: make derived tables processing 'inside' SELECT processing.
TODO: solve problem with depended derived tables in subselects
*/
! if ((lex->select_lex.next_select_in_list() &&
! lex->unit.create_total_list(thd, lex, &tables)) ||
! (table_rules_on && tables && thd->slave_thread &&
! !tables_ok(thd,tables)))
! DBUG_VOID_RETURN;
! if (lex->derived_tables)
{
for (TABLE_LIST *cursor= tables;
cursor;
cursor= cursor->next)
if (cursor->derived && (res=mysql_derived(thd, lex,
! (SELECT_LEX_UNIT *)cursor->derived,
cursor)))
{
if (res < 0)
***************
*** 1346,1356 ****
DBUG_VOID_RETURN;
}
}
- if ((lex->select_lex.next_select_in_list() &&
- lex->unit.create_total_list(thd, lex, &tables)) ||
- (table_rules_on && tables && thd->slave_thread &&
- !tables_ok(thd,tables)))
- DBUG_VOID_RETURN;

thread_safe_increment(com_stat[lex->sql_command],&LOCK_statu s);
switch (lex->sql_command) {
--- 1351,1356 ----

--
Regards,
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread12925@lists.mysql.com
To unsubscribe, e-mail