Bug #4681 | mysql-test-run fails 'union' test on Solaris x86 with Forte compiler | ||
---|---|---|---|
Submitted: | 21 Jul 2004 18:32 | Modified: | 30 Aug 2004 10:34 |
Reporter: | Alan Burlison | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Installing | Severity: | S2 (Serious) |
Version: | 4.0.20 | OS: | Solaris (Solaris 10) |
Assigned to: | Sergei Golubchik | CPU Architecture: | Any |
[21 Jul 2004 18:32]
Alan Burlison
[22 Jul 2004 21:54]
Alan Burlison
Please close this bug as 'not a bug'. This problem was in fact caused by a bug a bug in the x86 Forte optimizer rather than anything in MySQL. Using any optimization level higher than '-xO1' triggers the problem. The affected statement is at line 211 of sql_union.cc: add_rows+= (ulonglong) (thd->limit_found_rows - (table->file->records - records_at_start)); The bug causes the high-order 32 bits of add_rows to be set to 'FFFFFFFF' instead of '00000000'. I've logged a bug against the compiler, the Sun bugid is 5077233. Note that this bug only appears in the x86 compiler, the sparc one gives the correct result. There are three possible workarounds, any of them will avoid the problem: 1. Don't use the optimizer - you need to modify OPTIMIZE_CFLAGS, OPTIMIZE_CXXFLAGS. MAX_C_OPTIMIZE and MAX_CXX_OPTIMIZE in configure to do this - by default the optimizer is on ('-O') on Solaris. 2. Compile MySQL with '-DBIG_TABLES' in CFLAGS and CXXFLAGS 3. Apply the following patch to the MySQL source: *** sql/sql_union.cc.orig Thu Jul 22 18:46:17 2004 --- sql/sql_union.cc Thu Jul 22 18:46:57 2004 *************** *** 32,38 **** List<Item> item_list; TABLE *table; int res; ! ulonglong add_rows= 0; ulong found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; ulong describe= lex->select_lex.options & SELECT_DESCRIBE; TABLE_LIST result_table_list; --- 32,38 ---- List<Item> item_list; TABLE *table; int res; ! ha_rows add_rows= 0; ulong found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; ulong describe= lex->select_lex.options & SELECT_DESCRIBE; TABLE_LIST result_table_list;
[23 Jul 2004 18:45]
Sergei Golubchik
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html Additional info: Thank you for the great report! I think for now we will go with the -DBIG_TABLES solution. About your third workaround, as in the add_rows+= (ulonglong) (thd->limit_found_rows - (table->file->records - records_at_start)); thd->limit_found_rows is also ulonglong, then I think this cast may (or may not :) help add_rows+= thd->limit_found_rows - (ulonglong)(table->file->records - records_at_start); I'm afraid we don't have Sun FORTE compiler on our Solarix/x86 box, so I cannot test whether it helps :(
[23 Jul 2004 19:18]
Alan Burlison
Unfortunately the additonal cast doesn't help - the result of (table->file->records - records_at_start) is ulong, so the compiler is already going to have to promote it to ulonglong to subtract it from thd->limit_found_rows which is a ulonglong - the additional cast just tells the compiler to do the conversion it already know it has to do - the problem is it does it incorrectly. Nice try though ;-)
[30 Aug 2004 10:34]
Sergei Golubchik
fixed in 4.0.21
[22 Oct 2005 1:02]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/31299