Bug #8801 "view" test fails in --ps-protocol mode (server crash)
Submitted: 25 Feb 2005 8:28 Modified: 1 Mar 2005 12:01
Reporter: Lenz Grimmer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.3-pre OS:Linux (Linux/PPC)
Assigned to: Konstantin Osipov CPU Architecture:Any

[25 Feb 2005 8:28] Lenz Grimmer
Description:
A recent 5.0 build, based on this last ChangeSet:

ChangeSet@1.1847, 2005-02-24 20:55:20+04:00, ramil@mysql.com
  fixed compilation failure affects build without InnoDB

was compiled on Linux/PPC (Debian 3.1) with BUILD/compile-ppc-debug fails when running the "view" test in PS-protocol mode with the following output:

lenz@pegasos:~/my/mysql-5.0-build/mysql-test$ ./mysql-test-run --ps-protocol view
Installing Test Databases
Removing Stale Files
Installing Master Databases
running  ../sql/mysqld --no-defaults --bootstrap --skip-grant-tables     --basedir=. --datadir=./var/master-data --skip-innodb --skip-ndbcluster --skip-bdb     --language=../sql/share/english/ --character-sets-dir=../sql/share/charsets/
Installing Slave Databases
running  ../sql/mysqld --no-defaults --bootstrap --skip-grant-tables     --basedir=. --datadir=./var/slave-data --skip-innodb --skip-ndbcluster --skip-bdb     --language=../sql/share/english/ --character-sets-dir=../sql/share/charsets/
Manager disabled, skipping manager start.
Loading Standard Test Databases
Starting Tests

TEST                            RESULT
-------------------------------------------------------
view                           [ fail ]

Errors are (from /home/lenz/my/mysql-5.0-build/mysql-test/var/log/mysqltest-time) :
/home/lenz/my/mysql-5.0-build/client/.libs/mysqltest: At line 1716: unable to execute statement 'select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = aa)': Lost connection to MySQL server during query (mysql_stmt_errno=2013 returned=1)
(the last lines may be the most important ones)

Aborting: view failed in ps-protocol mode. To continue, re-run with '--force'.

Ending Tests
Shutting-down MySQL daemon

master not cooperating with mysqladmin, will try manual kill
./mysql-test-run: line 1440: kill: (638) - No such process
master refused to die. Sending SIGKILL
./mysql-test-run: line 1444: kill: (638) - No such process
Master shutdown finished
Slave shutdown finished

GDB shows the following backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 163851 (LWP 925)]
0x100bcd5c in Item_ref::fix_fields (this=0x10cfcdb0, thd=0x10cb1038, 
    tables=0x10cfcc48, reference=0x10cfcef4) at item.cc:3707
3707      if (((*ref)->with_sum_func && name &&
(gdb) where
#0  0x100bcd5c in Item_ref::fix_fields (this=0x10cfcdb0, thd=0x10cb1038, 
    tables=0x10cfcc48, reference=0x10cfcef4) at item.cc:3707
#1  0x100d7c08 in Item_func::fix_fields (this=0x10cfcea8, thd=0x10cb1038, 
    tables=0x10cfcc48, ref=0x10cfcef4) at item_func.cc:316
#2  0x101b3244 in JOIN::prepare (this=0x10cd3fe8, 
    rref_pointer_array=0x10cfc93c, tables_init=0x10cb1038, wild_num=282053704, 
    conds_init=0x0, og_num=1, order_init=0x0, group_init=0x10cfcc48, 
    having_init=0x1, proc_param_init=0x1, select_lex_arg=0x0, 
    unit_arg=0x10cfc970) at sql_select.cc:341
#3  0x101322c4 in subselect_single_select_engine::prepare (this=0x10cfd000)
    at item_subselect.cc:1264
#4  0x1012e074 in Item_subselect::fix_fields (this=0x10cfcf70, 
    thd_param=0x10cb1038, tables=0x10cfc688, ref=0x10cd3f18)
    at item_subselect.cc:144
#5  0x100d7c08 in Item_func::fix_fields (this=0x10cfd020, thd=0x10cb1038, 
    tables=0x10cfc688, ref=0x10cfcef4) at item_func.cc:316
#6  0x101abf94 in setup_conds (thd=0x10cb1038, tables=0x10cfc688, 
    leaves=0x10cfc688, conds=0x10cd3f18) at sql_base.cc:3276
#7  0x101b313c in JOIN::prepare (this=0x10cd31a0, 
    rref_pointer_array=0x10cfbe94, tables_init=0x10cb1038, wild_num=282052232, 
    conds_init=0x10cd3eb0, og_num=1, order_init=0x10cd3f18, 
    group_init=0x10cfc688, having_init=0x1, proc_param_init=0x1, 
    select_lex_arg=0x0, unit_arg=0x10cfbbc0) at sql_select.cc:272
#8  0x101b705c in mysql_select (thd=0x10cb1038, rref_pointer_array=0x10cfbe94, 
    tables=0x10cfc688, wild_num=0, fields=@0x10cfbdfc, conds=0x10cfd020, 
    og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, 
    select_options=2458143232, result=0x10cfd0e8, unit=0x10cfbbc0, 
    select_lex=0x10cfbd90) at sql_select.cc:2027
#9  0x101b2e70 in handle_select (thd=0x10cb1038, lex=0x10cfbbb0, 
    result=0x10cfd0e8, setup_tables_done_option=0) at sql_select.cc:227
#10 0x10185178 in mysql_execute_command (thd=0x10cb1038) at sql_parse.cc:2496
#11 0x101dcc20 in mysql_stmt_execute (thd=0x10cb1038, packet=0x10ccb142 "", 
    packet_length=282053704) at sql_prepare.cc:2019
#12 0x1018378c in dispatch_command (command=COM_EXECUTE, thd=0x10cb1038, 
    packet=0x10ccb139 "z\001", packet_length=10) at sql_parse.cc:1712
#13 0x10182fec in do_command (thd=0x10cb1038) at sql_parse.cc:1454
#14 0x10182318 in handle_one_connection (arg=0x10cfcdb0) at sql_parse.cc:1110
#15 0x0ff0ce40 in pthread_start_thread () from /lib/libpthread.so.0
#16 0x0ff0ceb8 in pthread_start_thread_event () from /lib/libpthread.so.0
#17 0x0fd6f3b4 in clone () from /lib/libc.so.6
#18 0x0fd6f3b4 in clone () from /lib/libc.so.6
Previous frame identical to this frame (corrupt stack?)
(gdb) 

How to repeat:
Compile on Linux/PPC, notice the test failure as described above.
[25 Feb 2005 8:37] Lenz Grimmer
A master.trace file of this test run can be obtained from here (the attachment would be too big):

ftp://ftp.mysql.com/pub/mysql/upload/bug-8801.trace.bz2
[28 Feb 2005 21:23] Konstantin Osipov
bk commit - 5.0 tree (konstantin:1.1772) BUG#8801

ChangeSet
  1.1772 05/03/01 00:18:58 konstantin@mysql.com +1 -0
  Proposed fix for Bug#8801: the bug was in co-operation of Item_ref
  with view-merge algorithm and prepared statements: in case when some
  Item_ref pointing to a view column was substituted with a reference
  pointing to the view expression for that column
  Item_ref::ref member of the original Item_ref was left pointing to
  not_found_item (0x1).
  As we currently perform expression substition part of the view-merge
  algorithm per each execution of a prepared statement or stored procedure,
  we need to preserve original Item_ref objects usable.
[1 Mar 2005 12:01] Konstantin Osipov
Fixed in 5.0 currently marked 5.0.3