[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    mysql: DATE_SUB crashes mysqld
From:       Michael Widenius <monty () monty ! pp ! sci ! fi>
Date:       1999-01-30 23:08:32
[Download RAW message or body]

>>>>> "Software" == Software Development <junkyard@primate.wisc.edu> writes:

>> Description:
Software> The following script illustrates the problem:

Software> 	use test;

Software> 	drop table if exists dtest;
Software> 	create table dtest (d date);
Software> 	insert into dtest values("1999-01-01");
Software> 	select date_sub("1999-01-01",interval 155 day) from dtest;
Software> 	select date_sub(d,interval 155 day) from dtest;

Software> The first date_sub() runs fine.  The second date_sub() crashes the
Software> server (script output below), even though the date value is the same.
Software> Seems to be a problem of accessing a date field from a table, not
Software> of accessing a date value per se.

Hi!

Thanks for the clear bug report.

This was a new bug in 3.22.15; Sorry about that.  It seams that we have 
to do a 3.22.16 shortly :(

*** /my/monty/master/mysql-3.22.15-gamma/sql/item_timefunc.cc	Thu Jan 21 03:07:58 1999
--- ./item_timefunc.cc	Sun Jan 31 00:03:36 1999
***************
*** 990,1002 ****
    if (res == str)
      str= &str_value;				// Don't change argument
    if (type == TIMESTAMP_DATE && !datetime_type)
      sprintf((char*) str->ptr(),"%04d-%02d-%02d",
  	    ltime.year,ltime.month,ltime.day);
    else
      sprintf((char*) str->ptr(),"%04d-%02d-%02d %02d:%02d:%02d",
  	    ltime.year,ltime.month,ltime.day,
  	    ltime.hour,ltime.minute,ltime.second);
!   str->length(strlen(str->ptr()));
    return str;
  
   null_date:
--- 990,1011 ----
    if (res == str)
      str= &str_value;				// Don't change argument
    if (type == TIMESTAMP_DATE && !datetime_type)
+   {
+     if (str->alloc(11))
+       goto null_date;
      sprintf((char*) str->ptr(),"%04d-%02d-%02d",
  	    ltime.year,ltime.month,ltime.day);
+     str->length(10);
+   }
    else
+   {
+     if (str->alloc(20))
+       goto null_date;
      sprintf((char*) str->ptr(),"%04d-%02d-%02d %02d:%02d:%02d",
  	    ltime.year,ltime.month,ltime.day,
  	    ltime.hour,ltime.minute,ltime.second);
!     str->length(19);
!   }
    return str;
  
   null_date:

Regards,
Monty
-----------------------------------------------------------
Send a mail to mdomo@tcx.se with
unsubscribe mysql your@subscription.address
in the body of the message to unsubscribe from this list.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic