I think it would have to be considered a simple bug. If you're not
convinced by the 'both' example he gave, here's one that's even more
obviously a bug:
mysql> select trim(leading 'foo' from 'foo');
+--------------------------------+
| trim(leading 'foo' from 'foo') |
+--------------------------------+
| foo |
+--------------------------------+
If the standard forbids such functions from creating the empty string,
then of course that's how they have to (brokenly) work. But here's
possibly even a more egregious example:
mysql> select concat('[',trim(' '),']');
+-----------------------------+
| concat('[',trim(' '),']') |
+-----------------------------+
| [ ] |
+-----------------------------+
Removing all leading and trailing space from a string consisting of
spaces should return the empty string. And in fact, ltrim and rtrim
do not have this problem:
mysql> select concat('[',ltrim(' '),']');
+------------------------------+
| concat('[',ltrim(' '),']') |
+------------------------------+
| [] |
+------------------------------+
--Pete
> 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?
>
> Hi!
>
> Since 'foo' in your latter case is neither strictly a prefix or suffix (as defined
> by the TRIM() documentation); I'm not sure if this a bug in the code
> or something that needs to be clarified in the documentation.
>
> Monty?
>
>
> Matt
>
> --
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Matt Wagner <[EMAIL PROTECTED]>
> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, http://www.mysql.com/
> /_/ /_/\_, /___/\___\_\___/ River Falls, Wisconsin, USA
> <___/ Developer
>
>
> ---------------------------------------------------------------------
> 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
>
---------------------------------------------------------------------
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