Bug #3372 Using literals in WHERE clause of UPDATE joining tables causes crash
Submitted: 2 Apr 2004 10:41 Modified: 2 Apr 2004 10:48
Reporter: Nathan Tanner Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.14-standard-log OS:Linux (RedHat 9.0)
Assigned to: Dean Ellis CPU Architecture:Any

[2 Apr 2004 10:41] Nathan Tanner
Description:
If you use a literal comparison in the WHERE clause of an UPDATE statement that uses two or more tables, it causes a server crash:

UPDATE [table1], [table2] SET [somefield]=[somevalue] WHERE 'n'='y' [...rest of where clause]

Looking at the MySQL .err log, we see this (which doesn't help):

mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=402653184
read_buffer_size=2093056
max_used_connections=11
max_connections=1000
threads_connected=10
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 290904 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=0x58e5cc08
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xbfd5ec58, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x807474f
0x82a0ad8
0x80ad014
0x80ad399
0x809e79f
0x8098f95
0x80ac58d
0x8080a9f
0x8082f6b
0x807e5b3
0x80844ee
0x807d79f
0x829e28c
0x82d199a
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://www.mysql.com/doc/en/Using_stack_trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do 
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8851968 = update test1, test2 set field1=field2 where 'n'='y'
thd->thread_id=10
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.
040402 11:19:41  InnoDB: Database was not shut down normally.
InnoDB: Starting recovery from log files...
InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 43932
InnoDB: Doing recovery: scanned up to log sequence number 0 43932
040402 11:19:41  InnoDB: Flushing modified pages from the buffer pool...
040402 11:19:41  InnoDB: Started
/usr/sbin/mysqld: ready for connections.
Version: '4.0.14-standard-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306

How to repeat:
mysql> create table test1(field1 char(10));
mysql> create table test2(field2 char(10));
mysql> insert into test1 values ("test1");
mysql> insert into test2 values ("test2");
mysql> update test1, test2 set field1=field2 where 'n'='y';
ERROR 2013: Lost connection to MySQL server during query

Suggested fix:
Fix the bug.
[2 Apr 2004 10:48] Dean Ellis
I cannot repeat this with 4.0.19.  Try a current release and update if you still see the problem.
[2 Apr 2004 11:44] Nathan Tanner
Looks like it must have been fixed in 4.0.17. 4.0.16 still gives the error, but 4.0.17 does not. As a side note, windows versions of MySQL version <= 4.0.16 crash completely when queries outlined in this report are run... MySQL has to be restarted.