The cause for this bug is that MariaDB 5.3 still processes derived tables
(subqueries in the FROM clause) by fully executing them during the parse
phase. This will be remedied by MWL#106 once merged into the main 5.3.
The assert statement is triggered when MATERIALIZATION is ON for EXPLAIN
EXTENDED for derived tables with an IN subquery as follows:
- mysql_parse calls JOIN::exec for the derived table as if it is regular
execution (not explain).
- When materialization is ON, this call goes all the way to
subselect_hash_sj_engine::exec, which creates a partial match engine
because of NULL presence.
- In order to proceed with normal execution, the hash_sj engine substitutes
itself with the created partial match engine.
- After the parse phase it turns out that this execution was part of
EXPLAIN EXTENDED, which in turn calls
Item_cond::print -> ... -> Item_subselect::print,
which calls engine->print().
Since subselect_hash_sj_engine::exec substituted the current
Item_subselect engine with a partial match engine, eventually we call
its ::print() method. However the partial match engines are designed only
for execution, hence there is no implementation of this print() method.
The fix temporarily removes the assert, until this code is merged with
MWL#106.
The bug was a result of missing logic to handle the case
when there are 'expensive' predicates that are not evaluated
during constant table optimization. Such is the case for
the IN predicate, which is considered expensive if it is
computed via materialization. In general this bug can be
triggered with any expensive predicate instead of IN.
When FALSE constant predicates are not evaluated during constant
optimization, the execution path changes so that instead of
setting JOIN::zero_result_cause after make_join_select, and
exiting JOIN::exec via the call to return_zero_rows(), execution
ends in JOIN::exec in the branch:
if (join->tables == join->const_tables)
{
...
else if (join->send_row_on_empty_set())
...
rc= join->result->send_data(*columns_list);
}
Unlike return_zero_rows(), this branch didn't evaluate the
having clause of the query.
The patch adds a call to evaluate the HAVING clause of a query even
when all tables are constant, because even for an empty result set
some aggregate functions may produce a NULL value.
- When building multiple-equalities for HAVING, don't set JOIN::cond_equal, set
join_having_equal instead. Setting JOIN::cond_equal based on HAVING makes
equality propagation data self-inconsistent
Fixed overflow when using long --debug=xxxxxx line.
Fixed that "mysqld --disable-debug --debug" works.
Ensure that MariaDB doesn't start if the Aria engine didn't start and we are using Aria for temporary tables.
More DBUG_ASSERT() and more info in debug log.
dbug/dbug.c:
Fixed crash in mysqld caused by an overflow when using long --debug=xxxxxx line
sql/mysqld.cc:
Fixed that "mysqld --disable-debug --debug" works.
Documented myisam-recover=OFF option
storage/maria/ha_maria.cc:
Ensure that MariaDB doesn't start if the Aria engine didn't start and we are using Aria for temporary tables.
storage/maria/ma_delete.c:
Added missing write of changed key on node page.
This could fix LP#608369 "Page: 1 Found wrong page type 0' on CHECK TABLE EXTENDED"
Changed so that we log page numbers (not positions)
Added KEY_OP_DEBUG_2 log entry to get more debug information into the log
storage/maria/ma_key_recover.c:
Changed so that we log page numbers (not positions)
In case of wrong page information after index_redo, dump pages to debug log
storage/maria/ma_loghandler.h:
Added KEY_OP_DEBUG_2
storage/maria/ma_search.c:
Changed so that we log page numbers (not positions)
storage/maria/ma_write.c:
Changed so that we log page numbers (not positions)
sql/sql_parse.cc:
Make some not commonly used functions with big local variables to separate functions to make default stack usage smaller.
Decrease size of db_buff[] (Was bigger than needed)
Allocate current_global_status_var with malloc().
storage/maria/ha_maria.cc:
Don't allocate HA_CHECK on stack (it's > 100K)
storage/maria/ma_check.c:
Removed duplicated code
The condition over the outer tables now are extracted from
the on condition of any outer join. This condition is
saved in a special field of the JOIN_TAB structure for
the first inner table of the outer join. The condition
is checked before the first inner table is accessed. If
it turns out to be false the table is not accessed at all
and a null complemented row is generated immediately.
Fix some bugs where we stored values other than 0 or 1 in my_bool
Fixed some compiler warnings
client/mysql.cc:
Changed interrupted_query from my_bool to int, as we stored 2 in it.
client/mysqladmin.cc:
Changed return variable type to same type as function value type
client/mysqltest.cc:
Changed 'found' to int as we store other values than 0 or 1 into it
Changed type for parameter of set_reconnect() to match usage.
extra/libevent/evbuffer.c:
Added __attribute__((unused))
extra/libevent/event.c:
Added __attribute__((unused))
extra/libevent/signal.c:
Added __attribute__((unused))
sql/event_data_objects.h:
my_bool -> bool
sql/event_db_repository.cc:
my_bool -> bool
sql/event_db_repository.h:
my_bool -> bool
sql/event_parse_data.h:
my_bool -> bool
sql/events.cc:
my_bool -> bool
sql/events.h:
my_bool -> bool
sql/field.cc:
my_bool -> bool
sql/field.h:
my_bool -> bool
sql/hash_filo.h:
my_bool -> bool
sql/item.cc:
my_bool -> bool
sql/item.h:
my_bool -> bool
sql/item_cmpfunc.h:
my_bool -> bool
Changed result_for_null_param from my_bool to int as we stored -1 in it.
sql/item_func.cc:
my_bool -> bool
Modified udf wrapper functions so that the UDF functions would continue to use my_bool. (To keep compatibility with UDF:s)
sql/item_func.h:
my_bool -> bool
sql/item_subselect.h:
my_bool -> bool
sql/item_sum.cc:
Modified udf wrapper functions so that the UDF functions would continue to use my_bool. (To keep compatibility with UDF:s)
sql/parse_file.h:
my_bool -> bool
sql/rpl_mi.h:
my_bool -> bool
sql/sp_rcontext.h:
my_bool -> bool
sql/sql_analyse.h:
my_bool -> bool
sql/sql_base.cc:
Change some assignments so that we don't initialize bool variables with int's.
sql/sql_bitmap.h:
my_bool -> bool
sql/sql_cache.cc:
my_bool -> bool
sql/sql_cache.h:
my_bool -> bool
sql/sql_class.h:
my_bool -> bool
sql/sql_insert.cc:
Change some assignments so that we don't initialize bool variables with int's.
sql/sql_prepare.cc:
my_bool -> bool
sql/table.h:
my_bool -> bool
storage/maria/ma_check.c:
Removed duplicate assignment
strings/decimal.c:
Fixed wrong variable usage.
Don't do complex arithmetic on bool when simple works.
sql/field.cc:
Remove feature of 'new_mode' that was never implemtented in a newer MySQL version.
sql/item_cmpfunc.cc:
Boyer more is stable; Don't have to be protected by --skip-new anymore
sql/mysqld.cc:
Don't disable some proven stable functions with --skip-new
sql/records.cc:
Don't disable record caching with --safe-mode anymore
sql/sql_delete.cc:
Do fast truncate even if --skip-new or --safe is used
sql/sql_parse.cc:
Use always mysql_optimizer() for optimizer (instead of mysql_recreate_table() in case of --safe or --skip-new)
sql/sql_select.cc:
Don't disable 'only_eq_ref_tables' if --safe is used.
sql/sql_yacc.yy:
Removed not meaningfull test of --old
Fixed crashing bug when doing ALTER TABLE RENAME with transactional tables.
client/mysqltest.cc:
Added errno to error message for system calls (delete, rename etc)
Write error message for failures of system calls
mysql-test/include/cleanup_fake_relay_log.inc:
Disable warnings for remove_file
mysql-test/include/diff_tables.inc:
Disable warnings for remove_file
mysql-test/include/maria_empty_logs.inc:
Disable warnings for remove_file
mysql-test/include/maria_make_snapshot.inc:
Disable warnings for remove_file
mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc:
Disable warnings for remove_file
mysql-test/include/mysqlhotcopy.inc:
Disable warnings for remove_file
mysql-test/include/ndb_backup.inc:
Disable warnings for remove_file
mysql-test/include/ndb_backup_print.inc:
Disable warnings for remove_file
mysql-test/r/alter_table_trans.result:
Test of crashing ALTER TABLE RENAME bug
mysql-test/t/alter_table_trans.test:
Test of crashing ALTER TABLE RENAME bug
mysql-test/t/mysqltest.test:
Disable warnings for remove_file and move_file
mysys/my_copy.c:
Fixed wrong error message
sql/sql_table.cc:
Fixed crashing bug when doing ALTER TABLE RENAME with transactional tables.
The problem could be demonstrated with an outer join of two single-row
tables where the values of the join attributes were null. Any query
with such a join could return a wrong result set if the where
condition of the query was not empty. For queries with empty
where conditions the result sets were correct.
This was the consequence of two bugs in the code:
- Item_equal objects for on conditions of outer joins were
not built if the processed query had no where condition
- the check for null values in the code that evaluated constant
Item_equal objects was incorrect.
Fixed both above problems.
Added a test case for the bug and adjusted results for some other
test cases.
When not-exists optimization was applied to a table that
happened to be an inner table of two outer joins, one
embedded into another, then setting the match flag for
the embedding outer join on could be skipped. This caused
generation of extra null complemented rows.
Made sure that the match flags are set correctly in all cases
when not-exists optimization is used.
Don't do UNDO or REDO on a crashed table.
More DBUG_PRINT
sql/sql_parse.cc:
Remove display of 'packet' which is not useful
storage/maria/ma_blockrec.c:
More DBUG_PRINT()
storage/maria/ma_key_recover.c:
Write page number instead of page position
storage/maria/ma_recovery.c:
Write message to stderr if recovery is not likely to succeed because we don't log records for batch inserts.
In normal cases this should never be an issue as we would recreate an empty table if MariaDB dies under batch insert.
This warning will be given if you remove all tables and try to recreate them with maria_read_log, which can't be done as
the log doesn't contain all data.
Don't do UNDO or REDO on a crashed table.
storage/maria/ma_write.c:
Write page number instead of page position.
Fixed typo that caused warnings from mysql-test-run
mysql-test/mysql-test-run.pl:
Fixed typo
sql/mysqld.cc:
Give a more precise warning why something fails.
Fixed test failures in buildbot
Don't write errors when failing to send ok packet
mysql-test/suite/pbxt/r/range.result:
Don't write number of rows as it varies.
mysql-test/suite/pbxt/t/range.test:
Don't write number of rows as it varies.
sql/mysqld.cc:
Don't write errors when failing to send ok packet
storage/maria/ma_bitmap.c:
Added DBUG_ASSERT to detect wrong bitmap pages
storage/maria/ma_blockrec.c:
Don't reset BLOCKUSED_USE_ORG_BITMAP flag. This fixed a bug where bitmap could be wrong after UNDO of row with blobs
Fixed bug in Aria when replacing short keys with long keys and a key tree both overflow and underflow at same time.
Fixed several bugs when generating recovery logs when using RGQ with replacing long keys with short keys and vice versa.
Lots of new DBUG_ASSERT()'s
Added more information to recovery log to make it easier to know from where log entry orginated.
Introduced MARIA_PAGE->org_size that tells what the size of the page was in last log entry. This allows us to find out if all key changes for index page was logged.
Small code cleanups:
- Introduced _ma_log_key_changes() to log crc of key page changes
- Added share->max_index_block_size as max size of data one can put in key block (block_size - KEYPAGE_CHECKSUM_SIZE)
This will later simplify adding a directory to index pages.
- Write page number instead of page postition to DBUG log
mysql-test/lib/v1/mysql-test-run.pl:
Use --general-log instead of --log to disable warning when using RQG
sql/mysqld.cc:
If we have already sent ok to client when we get an error, log this to stderr
Don't disable option --log-output if CSV engine is not supported.
storage/maria/ha_maria.cc:
Log queries to recovery log also in LOCK TABLES
storage/maria/ma_check.c:
If param->max_trid is set, use this value instead of max_trid_in_system().
This is used by recovery to set max_trid to max seen trid so far.
keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE -> max_index_block_size (Style optimization)
storage/maria/ma_delete.c:
Mark tables crashed early
Write page number instead of page position to debug log.
Added parameter to ma_log_delete() and ma_log_prefix() that is logged so that we can find where wrong log entries where generated.
Fixed bug where a page was not proplerly written when same key tree had both an overflow and underflow when deleting a key.
keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE => max_index_block_size (Style optimization)
ma_log_delete() now has extra parameter of how many bytes from end of page should be appended to log for page (for page overflows)
storage/maria/ma_key_recover.c:
Added extra parameter to ma_log_prefix() to indicate what caused log entry.
Update MARIA_PAGE->org_size when logging info about page.
Much more DBUG_ASSERT()'s.
Fix some bugs in maria_log_add() to handle page overflows.
Added _ma_log_key_changes() to log crc of key page changes.
If EXTRA_STORE_FULL_PAGE_IN_KEY_CHANGES is defines, log the resulting pages to log so one can trivally
see how the resulting page should have looked like (for errors in CRC values)
storage/maria/ma_key_recover.h:
Added _ma_log_key_changes() which is only called if EXTRA_DEBUG_KEY_CHANGES is defined.
Updated function prototypes.
storage/maria/ma_loghandler.h:
Added more values to en_key_debug, to get more exact location where things went wrong when logging to recovery log.
storage/maria/ma_open.c:
Initialize share->max_index_block_size
storage/maria/ma_page.c:
Added updating and testing of MARIA_PAGE->org_size
Write page number instead of page postition to DBUG log
Generate error if we read page with wrong data.
Removed wrong assert: key_del_current != share->state.key_del.
Simplify _ma_log_compact_keypage()
storage/maria/ma_recovery.c:
Set param.max_trid to max seen trid before running repair table (used for alter table to create index)
storage/maria/ma_rt_key.c:
Update call to _ma_log_delete()
storage/maria/ma_rt_split.c:
Use _ma_log_key_changes()
Update MARIA_PAGE->org_size
storage/maria/ma_unique.c:
Remove casts
storage/maria/ma_write.c:
keyinfo->block_length - KEYPAGE_CHECKSUM_SIZE => share->max_index_block_length.
Updated calls to _ma_log_prefix()
Changed code to use _ma_log_key_changes()
Update ma_page->org_size
Fixed bug in _ma_log_split() for pages that overflow
Added KEY_OP_DEBUG logging to functions
Log KEYPAGE_FLAG in all log entries
storage/maria/maria_def.h:
Added SHARE->max_index_block_size
Added MARIA_PAGE->org_size
storage/maria/trnman.c:
Reset flags for new transaction.
Made long file names from previous patch shorter
mysql-test/r/archive.result:
Added testing of repair (for upgrade) of 5.0 tables.
mysql-test/std_data/archive_5_0.ARM:
Archive table created in MySQL 5.0
mysql-test/std_data/archive_5_0.ARZ:
Archive table created in MySQL 5.0
mysql-test/std_data/archive_5_0.frm:
Archive table created in MySQL 5.0
mysql-test/std_data/long_table_name.MYD:
Made long file names shorter
mysql-test/std_data/long_table_name.MYI:
Made long file names shorter
mysql-test/std_data/long_table_name.frm:
Made long file names shorter
mysql-test/t/archive.test:
Added testing of repair (for upgrade) of 5.0 tables.
sql/sql_table.cc:
Allow recreate to open crashed tables.
sql/table.cc:
Fix error message if storage engine doesn't exists.
storage/archive/azio.c:
Reset status values in case archive is of old versions
storage/archive/ha_archive.cc:
Fix to allow one to open old versions of table during repair
Reset status variables for old version tables
If the the table is of old version, force upgrade with ALTER TABLE when doing repair
storage/archive/ha_archive.h:
Added variables to detect old versions