Bug with UNION in MySQL 4.0.11-gamma-standard

Bug with UNION in MySQL 4.0.11-gamma-standard

am 29.03.2003 05:20:52 von peter.ritt

Hi,

found a bug with union-select
in MySQL 4.0.11-gamma-standard
(php-4.3.0 as module, apache-2.0.44, Linux 2.4.19-4GB)

this query (reduced to the max):
(
select 'short' as `tab`
) union (
select 'longlong' as `tab`
);
delivers
| tab |
| short |
| longl | <- error

but this query
(
select 'longlong' as `tab`
) union (
select 'short' as `tab`
);
works fine:
| tab |
| longlong |
| short |

sorry - no great! if already known or fixed...

Peter Ritt
peter.ritt@gmx.net

--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: Bug with UNION in MySQL 4.0.11-gamma-standard

am 29.03.2003 09:01:58 von indrek siitan

Hi,

> found a bug with union-select
> in MySQL 4.0.11-gamma-standard
> (php-4.3.0 as module, apache-2.0.44, Linux 2.4.19-4GB)
>=20
> this query (reduced to the max):
> (
> select 'short' as `tab`
> ) union (
> select 'longlong' as `tab`
> );
> delivers
> | tab |
> | short |
> | longl | <- error
>=20
> but this query
> (
> select 'longlong' as `tab`
> ) union (
> select 'short' as `tab`
> );
> works fine:
> | tab |
> | longlong |
> | short |
>=20
> sorry - no great! if already known or fixed...

This is not a bug, but the way the SQL standard tells us to behave. When
performing a UNION query, the field types are based on the first query. So
if you use a constant called 'short' in the first query, the 'tab' field is
defined as VARCHAR(5) and the 'longlong' from the next query will be
truncated to fit into the VARCHAR(5) field.


Rgds,
Indrek

--=20
MySQL Users Conference and Expo: http://www.mysql.com/events/uc2003/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Indrek Siitan
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, The Support Guy
/_/ /_/\_, /___/\___\_\___/ Uuem=F5isa, Haapsalu, Estonia
<___/ www.mysql.com



--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=3Dgcdmb-bugs@m.gmane.org