Bugs in MySQL 4.1 with derived table

Bugs in MySQL 4.1 with derived table

am 28.10.2002 12:57:15 von Jocelyn Fournier

Hi,

How-to-repeat :

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

Why should a database be selected ?

mysql> SELECT a FROM (SELECT a);
ERROR 2013: Lost connection to MySQL server during query

Stack trace :

0x80a1d31 handle_segfault(int) + 481
0x8285168 pthread_sighandler + 176
0x80cb2d4 create_tmp_field(THD*, st_table*, Item*, Item::Type,
Item_result_field***, Field**, bool, bool) + 1108
0x80cc5f3 create_tmp_table(THD*, TMP_TABLE_PARAM*, List&, st_order*,
bool, bool, bool, unsigned long, st_select_lex_unit*) + 4115
0x8137b06 mysql_derived(THD*, st_lex*, st_select_lex_unit*, st_table_list*,
bool) + 838
0x80b0314 mysql_execute_command(THD*) + 17860
0x80b0dc9 mysql_parse(THD*, char*, unsigned) + 153
0x80aaed7 dispatch_command(enum_server_command, THD*, char*, unsigned) + 855
0x80aab6f do_command(THD*) + 111
0x80aa44f handle_one_connection(void*) + 895
0x82829fa pthread_start_thread + 218
0x82b6eaa thread_start + 4

mysql> SELECT dates FROM (SELECT 1 as dates FROM whateveryouwant);

This query freezes MySQL monitor

(pls note I do not apply yet all the patches you submitted to me. Sorry if
they already solve the problems :))

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-thread12869@lists.mysql.com
To unsubscribe, e-mail

Re: Bugs in MySQL 4.1 with derived table

am 28.10.2002 22:00:51 von Sinisa Milivojevic

Jocelyn Fournier writes:
> Hi,
>
> How-to-repeat :
>
> mysql> SELECT 1 FROM (SELECT 1);
> ERROR 1046: No Database Selected
>
> Why should a database be selected ?
>
> mysql> SELECT a FROM (SELECT a);
> ERROR 2013: Lost connection to MySQL server during query
>
> Stack trace :
>
> 0x80a1d31 handle_segfault(int) + 481
> 0x8285168 pthread_sighandler + 176
> 0x80cb2d4 create_tmp_field(THD*, st_table*, Item*, Item::Type,
> Item_result_field***, Field**, bool, bool) + 1108
> 0x80cc5f3 create_tmp_table(THD*, TMP_TABLE_PARAM*, List&, st_order*,
> bool, bool, bool, unsigned long, st_select_lex_unit*) + 4115
> 0x8137b06 mysql_derived(THD*, st_lex*, st_select_lex_unit*, st_table_list*,
> bool) + 838
> 0x80b0314 mysql_execute_command(THD*) + 17860
> 0x80b0dc9 mysql_parse(THD*, char*, unsigned) + 153
> 0x80aaed7 dispatch_command(enum_server_command, THD*, char*, unsigned) + 855
> 0x80aab6f do_command(THD*) + 111
> 0x80aa44f handle_one_connection(void*) + 895
> 0x82829fa pthread_start_thread + 218
> 0x82b6eaa thread_start + 4
>
> mysql> SELECT dates FROM (SELECT 1 as dates FROM whateveryouwant);
>
> This query freezes MySQL monitor
>
> (pls note I do not apply yet all the patches you submitted to me. Sorry if
> they already solve the problems :))
>
> Regards,
> Jocelyn
>

Thank you for your bug report, which enabled me to fix all above bugs.

This is a patch:

===== /mnt/work/mysql-4.1/sql/sql_parse.cc 1.252 vs edited =====
*** /tmp/sql_parse.cc-1.252-17356 Fri Oct 25 01:48:33 2002
--- edited//mnt/work/mysql-4.1/sql/sql_parse.cc Mon Oct 28 22:47:07 2002
***************
*** 1388,1397 ****
for (TABLE_LIST *cursor= tables;
cursor;
cursor= cursor->next)
! if (cursor->derived && mysql_derived(thd, lex,
(SELECT_LEX_UNIT *)cursor->derived,
! cursor, 0))
DBUG_VOID_RETURN;
}
if ((lex->select_lex.next_select_in_list() &&
lex->unit.create_total_list(thd, lex, &tables)) ||
--- 1388,1401 ----
for (TABLE_LIST *cursor= tables;
cursor;
cursor= cursor->next)
! if (cursor->derived && (res=mysql_derived(thd, lex,
(SELECT_LEX_UNIT *)cursor->derived,
! cursor, 0)))
! {
! if (res < 0)
! send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
DBUG_VOID_RETURN;
+ }
}
if ((lex->select_lex.next_select_in_list() &&
lex->unit.create_total_list(thd, lex, &tables)) ||
***************
*** 2777,2783 ****
found=1;
}
}
! else if (check_access(thd,want_access,tables->db,&tables->grant.priv ilege,
0, no_errors))
return TRUE;
}
--- 2781,2787 ----
found=1;
}
}
! else if (tables->db && check_access(thd,want_access,tables->db,&tables->grant.privi lege,
0, no_errors))
return TRUE;
}
===== /mnt/work/mysql-4.1/sql/sql_derived.cc 1.8 vs edited =====
*** /tmp/sql_derived.cc-1.8-17403 Fri Oct 4 11:29:22 2002
--- edited//mnt/work/mysql-4.1/sql/sql_derived.cc Mon Oct 28 22:23:55 2002
***************
*** 70,76 ****

if (tables_is_opened || !(res=open_and_lock_tables(thd,tables)))
{
! if (tables && setup_fields(thd,tables,item_list,0,0,1))
{
res=-1;
goto exit;
--- 70,76 ----

if (tables_is_opened || !(res=open_and_lock_tables(thd,tables)))
{
! if (setup_fields(thd,tables,item_list,0,0,1))
{
res=-1;
goto exit;
***************
*** 113,118 ****
--- 113,119 ----
t->table=table;
table->derived_select_number= sl->select_number;
sl->exclude();
+ t->db= (tables && tables->db && tables->db[0]) ? t->db : thd->db;
t->derived=(SELECT_LEX *)0; // just in case ...
}
}



--
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-thread12870@lists.mysql.com
To unsubscribe, e-mail