Hi!
>>>>> "Matt" == Matt Wagner <[EMAIL PROTECTED]> writes:
Matt> Paul Wisén writes:
>> This works:
>>
mysql> select trim('foo' FROM 'foobaar');
>> +----------------------------+
>> | trim('foo' FROM 'foobaar') |
>> +----------------------------+
>> | baar |
>> +----------------------------+
>> 1 row in set (0.00 sec)
>>
>> This does not work: !
>>
mysql> select trim('foo' FROM 'foo');
>> +------------------------+
>> | trim('foo' FROM 'foo') |
>> +------------------------+
>> | foo |
>> +------------------------+
>> 1 row in set (0.00 sec)
>>
>> I was expecting a null string from this one.. But nope ??
>>
>> Why ? Is it a bug?
Matt> Hi!
Matt> Since 'foo' in your latter case is neither strictly a prefix or suffix (as
defined
Matt> by the TRIM() documentation); I'm not sure if this a bug in the code
Matt> or something that needs to be clarified in the documentation.
Matt> Monty?
This is a bug. Here is a patch:
===== sql/item_strfunc.cc 1.19 vs edited =====
*** sql/item_strfunc.cc-1.19 Wed Dec 20 16:15:49 2000
--- edited/sql/item_strfunc.cc Thu Jan 18 23:44:12 2001
***************
*** 930,936 ****
char *ptr=(char*) res->ptr();
char *end=ptr+res->length();
const char *r_ptr=remove_str->ptr();
! while (ptr+remove_length < end && !memcmp(ptr,r_ptr,remove_length))
ptr+=remove_length;
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
--- 930,936 ----
char *ptr=(char*) res->ptr();
char *end=ptr+res->length();
const char *r_ptr=remove_str->ptr();
! while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length))
ptr+=remove_length;
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
***************
*** 954,960 ****
else
#endif /* USE_MB */
{
! while (ptr + remove_length < end &&
!memcmp(end-remove_length,r_ptr,remove_length))
end-=remove_length;
}
--- 954,960 ----
else
#endif /* USE_MB */
{
! while (ptr + remove_length <= end &&
!memcmp(end-remove_length,r_ptr,remove_length))
end-=remove_length;
}
Regards,
Monty
---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php