>Description: Certain queries on merge tables reliably fail or crash the server as the script below demonstrates.
>How-To-Repeat: Run this script: #! /bin/bash # This script demonstrates a bug in the way MySQL handles merge tables. The bug depends on # the index; it doesn't manifest if there is no index or if the fields are indexed separately. mysql -vv << EOF USE test; DROP TABLE IF EXISTS a; DROP TABLE IF EXISTS b; DROP TABLE IF EXISTS c; # Create two tables with the same definition. CREATE TABLE a ( ID INT NOT NULL, Date DATE NOT NULL, KEY (ID, Date) ); CREATE TABLE b ( ID INT NOT NULL, Date DATE NOT NULL, KEY (ID, Date) ); # Populate the tables. INSERT INTO a (ID, Date) VALUES (1, '2002-01-01'), (1, '2002-01-02'), (1, '2002-01-03'); INSERT INTO b (ID, Date) VALUES (1, '2002-02-01'), (1, '2002-02-02'), (1, '2002-02-03'); # Create a merge table combining the previous two. CREATE TABLE c ( ID INT NOT NULL, Date DATE NOT NULL, KEY (ID, Date) ) TYPE=MERGE UNION=(a, b); # This works. SELECT MIN(Date) FROM c WHERE ID = 1; # This fails by returning NULL. SELECT MAX(Date) FROM c WHERE ID = 1; # Going straight to the component tables works though. SELECT MAX(Date) FROM a WHERE ID = 1; SELECT MAX(Date) FROM b WHERE ID = 1; # The different results from these might be a clue. EXPLAIN SELECT MIN(Date) FROM c WHERE ID = 1; EXPLAIN SELECT MAX(Date) FROM c WHERE ID = 1; # This crashes the server. SELECT MIN(Date), MAX(Date) FROM c WHERE ID = 1; EOF >Fix: >Submitter-Id: <submitter ID> >Originator: Rob Steele >Organization: FatKat, Inc. >MySQL support: none >Synopsis: Selecting from merge table crashes server >Severity: serious >Priority: high >Category: mysql >Class: sw-bug >Release: mysql-3.23.54 (Official MySQL RPM) >Server: /usr/bin/mysqladmin Ver 8.23 Distrib 3.23.54, for pc-linux on i686 Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL license Server version 3.23.54-Max Protocol version 10 Connection Localhost via UNIX socket UNIX socket /tmp/mysql.sock Uptime: 7 min 44 sec Threads: 1 Questions: 1 Slow queries: 0 Opens: 6 Flush tables: 1 Open tables: 0 Queries per second avg: 0.002 >Environment: System: Linux warren.fatkat.com 2.4.18-19.8.0 #1 Thu Dec 12 05:39:29 EST 2002 i686 i686 i386 GNU/Linux 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/i386-redhat-linux/3.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) Compilation info: CC='gcc' CFLAGS='-O6 -fno-omit-frame-pointer -mpentium' CXX='gcc' CXXFLAGS='-O6 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mpentium' LDFLAGS='' LIBC: lrwxrwxrwx 1 root root 14 Oct 2 19:15 /lib/libc.so.6 -> libc-2.2.93.so -rwxr-xr-x 1 root root 1235468 Sep 5 19:12 /lib/libc-2.2.93.so -rw-r--r-- 1 root root 2233342 Sep 5 18:59 /usr/lib/libc.a -rw-r--r-- 1 root root 178 Sep 5 18:50 /usr/lib/libc.so lrwxrwxrwx 1 root root 10 Oct 2 19:53 /usr/lib/libc-client.a -> c-client.a Configure command: ./configure '--disable-shared' '--with-mysqld-ldflags=-all-static' '--with-client-ldflags=-all-static' '--without-berkeley-db' '--without-innodb' '--enable-assembler' '--enable-local-infile' '--with-mysqld-user=mysql' '--with-unix-socket-path=/var/lib/mysql/mysql.sock' '--prefix=/' '--with-extra-charsets=complex' '--exec-prefix=/usr' '--libexecdir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--localstatedir=/var/lib/mysql' '--infodir=/usr/share/info' '--includedir=/usr/include' '--mandir=/usr/share/man' '--with-comment=Official MySQL RPM' 'CC=gcc' 'CFLAGS=-O6 -fno-omit-frame-pointer -mpentium' 'CXXFLAGS=-O6 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mpentium' 'CXX=gcc' --------------------------------------------------------------------- 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