Bug in JOINed UNION
am 20.02.2003 12:51:24 von lrueegghi
if the second SELECT part of a UNION-query contains a JOIN from a table
having NULL values and mysql tries to write these NULL values into the
result table which does not allow NULL values for this field, all
subsequent fields will contain the values of the preceding row.
How-To-Repeat:
table definitions and data:
===========================
CREATE TABLE tabMaster (
id int(3) unsigned default '0'
) TYPE=MyISAM;
INSERT INTO tabMaster (id) VALUES("1");
CREATE TABLE tabChild (
id int(3) unsigned default '0',
id_master int(5) default '0',
text1 varchar(5) default NULL,
text2 varchar(5) default NULL
) TYPE=MyISAM;
INSERT INTO tabChild (id, id_master, text1, text2) VALUES("1", "1",
"foo1", "bar1");
INSERT INTO tabChild (id, id_master, text1, text2) VALUES("2", "1",
"foo2", "bar2");
INSERT INTO tabChild (id, id_master, text1, text2) VALUES("3", "1", NULL,
"bar3");
INSERT INTO tabChild (id, id_master, text1, text2) VALUES("4", "1",
"foo4", "bar4");
===========================
if using the following query, the results will be correct (because of a
table definition which allows NULL values in column 'text1'):
SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2
UNION
SELECT id_master, tabChild.id, text1, text2 FROM tabMaster LEFT JOIN
tabChild ON tabMaster.id = tabChild.id_master
while the following query will generate wrong results in column 'text2',
row 4:
SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2
UNION
SELECT id_master, tabChild.id, text1, text2 FROM tabMaster LEFT JOIN
tabChild ON tabMaster.id = tabChild.id_master
we think, you should be able to reproduce the error with this example. if
not, please don't hesitate to ask us again.
thanks to Wendy Reets for giving us the critical hint!
here some informational stuff about our machine and mysql-release:
>Release: mysql-4.0.10-gamma-standard (Official MySQL-standard
binary)
>C compiler: 2.95.3
>C++ compiler: 2.95.3
>Environment:
System: Linux paprika 2.4.18-4GB #1 Wed Mar 27 13:57:05 UTC 2002 i686
unknown
Architecture: i686
Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc
/usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs
gcc version 2.95.3 20010315 (SuSE)
Compilation info: CC='gcc' CFLAGS='-O2 -mcpu=pentiumpro' CXX='gcc'
CXXFLAGS='-O2 -mcpu=pentiumpro
-felide-constructors' LDFLAGS='' ASFLAGS=''
LIBC:
-rwxr-xr-x 1 root root 1394302 Oct 2 10:06 /lib/libc.so.6
-rw-r--r-- 1 root root 25361748 Oct 2 09:36 /usr/lib/libc.a
-rw-r--r-- 1 root root 178 Mar 23 2002 /usr/lib/libc.so
Configure command: ./configure '--prefix=/usr/local/mysql'
'--with-comment=Official MySQL-standard b
inary' '--with-extra-charsets=complex' '--with-server-suffix=-standard'
'--enable-thread-safe-client
' '--enable-local-infile' '--enable-assembler' '--disable-shared'
'--with-client-ldflags=-all-static
' '--with-mysqld-ldflags=-all-static' '--with-innodb' 'CFLAGS=-O2
-mcpu=pentiumpro' 'CXXFLAGS=-O2 -m
cpu=pentiumpro -felide-constructors' 'CXX=gcc'
regards
martin rueegg
lukas.rueegg
--
_
_ __ (_)_ ____ _____ _ ____ __
| '_ \| \ \/ /\ \ /\ / / _ \| '__\ \/ /
| |_) | |> < \ V V / (_) | | > <
| .__/|_/_/\_\ \_/\_/ \___/|_| /_/\_\
|_| m u l t i m e d i a
lukas rueegg
ch-8005 zurich
lru_mysql@pixworx.ch
[ There are 3 kinds of people in this world: those who can count and those
who can't. ]
------------------------------------------------------------ ---------
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 bugs-thread13811@lists.mysql.com
To unsubscribe, e-mail