List:Bugs« Previous MessageNext Message »
From:Michael Widenius Date:April 8 2000 1:28am
Subject:Re: Bug with concatenated "trim" and "concat"?
View as plain text  
Hi!

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

Thimble> Hi, Ernesto.  I don't see anything wrong with what you're doing.
Thimble> This e-mail would be a good candidate for the bugs@stripped
Thimble> list (it should have used 'mysqlbug', but we'll let it slide).

Thimble> If this is indeed a bug, we will fix it as soon as possible and
Thimble> as long as it doesn't involve an extensive change in 3.22, a fix
Thimble> will be made for that branch as well as 3.23.

Thimble> Tim

Thimble> On Fri, Apr 07, 2000 at 08:31:29PM +0200, Ernesto Baschny wrote:
>> Hi!
>> 
>> I need a query that uses some string functions, but it doesn't seem
>> to work, and I guess it is a bug. Its a rather complex query, but I
>> managed to single out the piece of code that is causing the trouble.
>> Here's how you can try it on your own:
>> 
mysql> create table test ( domain char(50) );
mysql> insert into test VALUES ("hello.de" );
mysql> insert into test VALUES ("test.de" );
>> 
>> The first query, works as intended:
>> 
mysql> select domain from test
-> where concat('@', trim(leading '.' from concat('.', domain))) =
-> '@hello.de';
>> +----------+
>> | domain   |
>> +----------+
>> | hello.de |
>> +----------+
>> 1 row in set (0.00 sec)
>> 
>> 
>> Now here comes a second, almost identical query, but querying for 
>> another row:
>> 
mysql> select domain from test
-> where concat('@', trim(leading '.' from concat('.', domain)))
-> = '@test.de';
>> Empty set (0.00 sec)

<cut>

This was a bug in how concat() uses buffers in very complicated cases.
.
Here is a patch for this to 3.23;  I have added a similar patch in the
3.22 source tree.

diff -r1.2 item_strfunc.cc
153,154c153,154
< 	if (tmp_value.copy(*res) ||		// Move res to start of tmp
< 	    tmp_value.replace(0,0,*res))
---
> 	if (tmp_value.replace(0,(uint32) (res2->ptr() >= tmp_value.ptr()),
> 			      *res))

Regards,
Monty
Thread
Re: Bug with concatenated "trim" and "concat"?Thimble Smith8 Apr
  • Re: Bug with concatenated "trim" and "concat"?Michael Widenius8 Apr