List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:April 2 1999 11:05am
Subject:sql_select.cc divide by zero (patch incl.)
View as plain text  
Hi!

>>>>> "Thimble" == Thimble Smith <tim@stripped> writes:

>> Description:
Thimble> SELECT
Thimble> r.resource_id, person_id
Thimble> FROM
Thimble> resources r
Thimble> LEFT JOIN
Thimble> resource_persons USING (resource_id)
Thimble> WHERE
Thimble> r.resource_id IN (1)

Thimble> This query will crash if table resources has more than one
Thimble> row and table resource_persons has zero rows.

Thimble> gdb backtrace, mysql.trace, etc. are available at:
Thimble> http://tim.desert.net/~tim/sql_select-bug.txt

>> How-To-Repeat:

Thanks for the clear bug report!

Your patch should work, but I prefered the following:

(/my/monty/sql-3.22) diff -c /my/monty/master/mysql-3.22.20/sql/sql_select.cc .
*** /my/monty/master/mysql-3.22.20/sql/sql_select.cc    Tue Mar  9 05:36:16 1999
--- ./sql_select.cc     Fri Apr  2 14:01:32 1999
***************
*** 1438,1444 ****
                  !(rec_per_key=(double) table->keyfile_info.rec_per_key[key]))
                rec_per_key=(double) s->records/rec+1;

!             if (rec_per_key/(double) s->records >= 0.01)
                tmp=rec_per_key;
              else
              {
--- 1438,1446 ----
                  !(rec_per_key=(double) table->keyfile_info.rec_per_key[key]))
                rec_per_key=(double) s->records/rec+1;

!             if (!s->records)
!               tmp=0;
!             else if (rec_per_key/(double) s->records >= 0.01)
                tmp=rec_per_key;
              else
              {

Regards,
Monty
Thread
sql_select.cc divide by zero (patch incl.)Thimble Smith2 Apr
  • sql_select.cc divide by zero (patch incl.)Michael Widenius2 Apr
  • Re: connection problem with mySQL from servletMichael Yuan13 Jun
  • Re: connection problem with mySQL from servletBrevsville Administrator13 Jun
  • Re: connection problem with mySQL from servletCLAUDE LEBLANC13 Jun