Commit graph

68472 commits

Author SHA1 Message Date
Sergey Petrunya
e2554b50cd BUG#951937: Wrong result (missing rows) with semijoin+materialization, IN subquery, InnoDB, TEMPTABLE view
- Fix equality propagation to work with SJM nests and OR clauses (full descirption of problem and
  solution in the comment in the patch)
(The second commit with post-review fixes)
2012-03-26 13:47:00 +04:00
Sergey Petrunya
d054709827 BUG#962667: Assertion `0' failed in QUICK_INDEX_SORT_SELECT::need_sorted_output()
- The problem was that
  = we've picked a LooseScan that used full index scan (tab->type==JT_ALL) on certain index.
  = there was also a quick select (tab->quick!=NULL), that used other indexes.
  = some old code assumes that (tab->type==JT_ALL && tab->quick) -> means that the
    quick select should be used, which is not true.
Fixed by discarding the quick select as soon as we know we're using LooseScan
without using the quick select.
2012-03-25 18:31:35 +04:00
unknown
f72e0e686b Improve filesort performance for small sorts: Don't write pointers to records that we will never use. 2012-03-24 17:08:59 +01:00
Michael Widenius
c36bdf1c88 Speedup:
- Don't call update_virtual_fields() if table->vfield is not set
- Don't prealloc memory for in open_tables() as this is very seldom used.


sql/records.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_base.cc:
  Don't prealloc memory for in open_tables() as this is very seldom used.
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_delete.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_handler.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_join_cache.cc:
  Don't call update_virtual_fields() if table->vfield is not set
  Move some frequent values to local variables
sql/sql_table.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_update.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/table.cc:
  Assert if update_virtual_fields is called with wrong parameters
2012-03-23 18:22:39 +02:00
Michael Widenius
8e825a2249 Fixes lp:941889 "JOIN constructors takes a long time in 5.3"
- Remove all references of MAX_TABLES from JOIN struct and make these dynamic
- Updated Join_plan_state to allocate just as many elements as it's needed


sql/opt_subselect.cc:
  Optimized version of Join_plan_state
sql/sql_select.cc:
  Set join->positions and join->best_positions dynamicly
  Don't call update_virtual_fields() if table->vfield is not set.
sql/sql_select.h:
  Remove all references of MAX_TABLES from JOIN struct and Join_plan_state and make these dynamic
2012-03-23 18:18:16 +02:00
Michael Widenius
de1765fb64 Speedups:
- Optimize away calls to hp_rec_hashnr() by cashing hash
- Try to get more rows / block (to minimize overhead of HP_PTRS) in HEAP tables.


storage/heap/_check.c:
  Optimize away calls to hp_rec_hashnr() by cashing hash.
  Print cleanups
storage/heap/heapdef.h:
  Added place to hold calculated hash value for row
storage/heap/hp_create.c:
  Try to get more rows / block (to minimize overhead of HP_PTRS)
storage/heap/hp_delete.c:
  Optimize away calls to hp_rec_hashnr() by cashing hash.
storage/heap/hp_hash.c:
  Optimize away calls to hp_rec_hashnr() by cashing hash.
  Remove some not needed DBUG_PRINT
storage/heap/hp_test2.c:
  Increased max table size as now heap tables takes a bit more space (a few %)
storage/heap/hp_write.c:
  Optimize away calls to hp_rec_hashnr() by cashing hash.
  Remove duplicated code
  More DBUG_PRINT
storage/maria/ma_create.c:
  More DBUG_PRINT
2012-03-23 18:11:29 +02:00
Igor Babaev
da9aabbbb6 Fixed LP bug #954900.
If the first component of a ref key happened to be a constant appeared
after constant row substitution then no store_key element should be
created for such a component. Yet create_ref_for_key() erroneously could
create such an element that caused construction of invalid ref keys and
wrong results for some joins.
2012-03-22 19:56:17 -07:00
unknown
65528b783f Automerge. 2012-03-22 13:23:55 +01:00
unknown
8e0afbd8af Backport some simple performance patches from 5.5. 2012-03-22 13:21:15 +01:00
Sergei Golubchik
e6c213897d merge 2012-03-21 19:15:29 +01:00
Sergei Golubchik
c88e2679c6 merge 2012-03-21 18:30:34 +01:00
Sergei Golubchik
d1f3117999 lp:933959 Assertion `0' failed in net_end_statement(THD*) on concurrent SELECT FROM I_S.INNODB_SYS_INDEXES and ALTER TABLE
Workaround: report a generic error if an I_S plugin failed silently.
2012-03-21 18:22:02 +01:00
Sergei Golubchik
3920d97819 mdev-191 SHOW TABLES was unnecessary opening .frm files
mark the corresponding I_S table as OPTIMIZE_I_S_TABLE, to let the I_S optimizer
figure out whether files need to be opened, and don't open the tables unless
I_S optimizer says so.
2012-03-21 10:59:20 +01:00
Sergey Petrunya
1153d656a9 Merge BUG#952372 2012-03-21 11:18:20 +04:00
Igor Babaev
357331af8a Fixed LP bug #954262.
This bug in the constructor SEL_IMERGE::SEL_IMERGE could 
cause huge excessive memory requests.
2012-03-20 17:03:28 -07:00
Sergey Petrunya
91d17a9c20 BUG#952583: Server crashes in Item_field::fix_after_pullout on INSERT .. SELECT
- Take into account that there may exist Item_field objects with context==NULL.
2012-03-19 01:04:55 +04:00
Sergey Petrunya
5805908bf9 BUG#952372: Server crashes on 2nd execution of PS in find_field_in_tables with semijoin+materialization
- The problem was that convert_subq_to_jtbm() attached the semi-join
  TABLE_LIST object into the wrong list: they used to attach it to the 
  end of parent_lex->leaf_tables.head()->next_local->...->next_local.
  This was apparently inccorect, as one can construct an example where 
  JTBM nest is attached to a table that is inside some mergeable VIEW, which
  breaks (causes crash) for name resolution on the subsequent statement
  re-execution.
- Solution: Attach to the "right" list. The "wording" was copied from
  st_select_lex::handle_derived.
2012-03-18 23:58:20 +04:00
Vladislav Vaintroub
eb30253d69 Fix access to uninitialized variable in innodb error message in case WriteFile() fails. 2012-03-15 15:06:06 +01:00
Sergei Golubchik
44ea4e7c1f restore my_safe_printf_stderr for "crash-safe sigsegv handler"
use vsnprintf()
use write() on windows, not WriteFile or fwrite()
localtime_r is still a problem
2012-03-14 21:16:24 +01:00
unknown
5338a28912 Merge 5.2->5.3 2012-03-14 13:58:18 +02:00
unknown
e638e60589 test suite for LP bug#694450 2012-03-14 12:09:03 +02:00
Igor Babaev
0f3b8ef28e Merge. 2012-03-13 13:49:18 -07:00
Igor Babaev
c1f5e25c04 Fixed LP bug #953649.
Do not call, directly or indirectly, SQL_SELECT::test_quick_select()
for derived materialized tables / views when optimizing joins referring
to these tables / views to get cost estimates of materialization.
The current code does not create B-tree indexes for materialized 
derived tables / views. So now it's not possible to get any estimates
for ranges conditions over the results of the materialization.

The function mysql_derived_create() must take into account the fact
that array of the KEY structures specifying the keys over a derived
table / view may be moved after the optimization phase if the
derived table / view  is materialized.
2012-03-13 13:34:20 -07:00
Michael Widenius
6f06cef02b Fixed bug lp:917689 "Archive table corruption crashing MariaDB signal 11"
Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
Change ha_archive::unpack_row() to detect wrong field lengths.
Replication code changed to detect wrong field information in events.


mysql-test/r/archive.result:
  dded test case for lp:917689
sql/field.cc:
  Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
  Removed not used 'unpack_key' functions.
sql/field.h:
  Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
  Removed not used 'unpack_key' functions.
  Removed some not needed unpack() functions.
sql/filesort.cc:
  Added buffer end parameter to unpack_addon_fields()
sql/log_event.h:
  Added end of buffer argument to unpack_row()
sql/log_event_old.cc:
  Added end of buffer argument to unpack_row()
sql/log_event_old.h:
  Added end of buffer argument to unpack_row()
sql/records.cc:
  Added buffer end parameter to unpack_addon_fields()
sql/rpl_record.cc:
  Added end of buffer argument to unpack_row()
  Added detection of wrong field information in events
sql/rpl_record.h:
  Added end of buffer argument to unpack_row()
sql/rpl_record_old.cc:
  Added end of buffer argument to unpack_row()
  Added detection of wrong field information in events
sql/rpl_record_old.h:
  Added end of buffer argument to unpack_row()
sql/table.h:
  Added buffer end parameter to unpack()
storage/archive/ha_archive.cc:
  Change ha_archive::unpack_row() to detect wrong field lengths.
  This fixes lp:917689
2012-03-13 16:38:43 +02:00
Sergey Petrunya
223483aedf Merge 2012-03-12 18:21:14 +04:00
Sergey Petrunya
4ac230e557 Better comments 2012-03-12 18:20:30 +04:00
Sergey Petrunya
50ff30d892 Merge 2012-03-12 18:08:40 +04:00
Sergey Petrunya
d028d986a9 BUG#952297: Server crashes on 2nd execution of PS in Field::is_null with semijoin+materialization
- The bug would show up 
   - when using PS (so that we get re-execution)
   - the left_expr of the subquery is a reference to viewname.column_name, so that it crashes
      when one tries to use it without having called fix_fields for it.
   - when using SJ-Materialization, which makes use of sj_subq_pred->left_expr expression

- The fix is to have setup_conds() fix sj_subq_pred->left_expr for semi-join nests it finds.
2012-03-12 17:41:22 +04:00
Vladislav Vaintroub
32d45425e9 merge 2012-03-12 12:15:55 +01:00
Vladislav Vaintroub
3886fdf009 LP952607: Do not show MySQL services preinstalled by Dell in the upgrade wizard 2012-03-12 12:14:04 +01:00
Vladislav Vaintroub
8245178f5d LP953714: Fix formatting of the crash messages in signal/exception handler 2012-03-12 11:31:40 +01:00
Igor Babaev
8c08349882 Fixed LP bug #930814.
This bug was introduced into mariadb 5.2 in the December 2010 with
the patch that added a new engine property: the ability to support
virtual columns.    
As a result of this bug the information from frm files for tables 
that contained virtual columns did not appear in the information schema
tables.
2012-03-09 15:37:16 -08:00
Michael Widenius
028523e94d Added test case for lp:905782 "Assertion `pageno < ((1ULL) << 40)' failed at ma_pagecache.c:3438: pagecache_read or table corruption on INSERT into a ucs2 table"
The orignal bug has been fixed earlier
2012-03-09 14:28:02 +02:00
unknown
ea736c9375 Added ucs2 test moved from maria3.test. (MDEV-167) 2012-03-09 14:06:17 +02:00
Igor Babaev
af7213d5d4 Fixed LP bug #884175.
If in the where clause of the a query some comparison conditions on the
field under a MIN/MAX aggregate function contained constants whose sizes
exceeded the size of the field then the query could return a wrong result
when the optimizer had chosen to apply the MIN/MAX optimization.
With such conditions the MIN/MAX optimization still could be applied, yet
it would require a more thorough analysis of the keys built to find
the value of MIN/MAX aggregate functions with index look-ups.   
The current patch just prohibits using the MIN/MAX optimization in this
situation.
2012-03-08 22:33:01 -08:00
Igor Babaev
f92cfdb8a9 Merge. 2012-03-05 22:33:46 -08:00
Igor Babaev
04ee30e75a Fixed LP bug #946055.
The function create_hj_key_for_table() that builds the descriptor of
the hash join key to access a table of a materialized subquery must
ignore any equi-join predicate depending on the tables not belonging
to the subquery.
2012-03-05 20:32:28 -08:00
Vladislav Vaintroub
026161370f merge 2012-03-06 01:48:38 +01:00
Vladislav Vaintroub
be8cd3e8df LP947631: Uninstall wipes HeidiSQL settings, even if HeidiSQL is installed prior to MariaDB
Fixed detection of installed HeidiSQL in the machine, prevent installing own copy if HeidiSQL is already installed.

On deinstallation, do not remove settings if official HeidiSQL is detected.
2012-03-06 01:46:32 +01:00
Michael Widenius
4ab7a33e1e Automatic merge 2012-03-05 22:00:24 +02:00
Michael Widenius
c437506826 Ensure that we mark all processed tables as 'properly closed'.
This is needed as last log entry may be a DDL that is not processed and then a table may be left in 'not properly closed state' even if information is correct in it.
2012-03-05 21:59:00 +02:00
unknown
8a5940c477 Fix for LP BUG#944504
Problem is that subquery execution can't be called during prepare/optimize phase.

Also small fix for subquery test suite.
2012-03-05 15:48:12 +02:00
Igor Babaev
6f3c39a057 Fixed LP bug #944782.
This bug in the function JOIN::drop_unused_derived_keys() could
leave the internal structures for a materialized derived table
in an inconsistent state. This led to a not quite correct EXPLAIN
output when no additional key had been created to access the table.
It also may lead to more serious consequences: so, the test case
added with this fix caused a crash in mariadb-5.5.20.
2012-03-04 22:38:17 -08:00
Igor Babaev
000deedf3b Fixed LP bug #943543.
This bug appeared after the patch for bug 939009 that in the
function merge_key_fields forgot to reset a proper value for
the val field in the result of the merge operation of the key
field created for a regular key access and  the key field
created to look for a NULL key.

Adjusted the results of the test case for bug 939009 that
actually were incorrect.
2012-02-29 23:28:16 -08:00
unknown
bb4b0c1a44 Return original checksum value inside the test.
Move ucs2 test in separate file (MDEV-167).
2012-03-01 09:27:42 +02:00
Michael Widenius
e4e85cd2ef Fixed lp:925377 "Querying myisam table metadata while 'alter table..enable keys' is running may corrupt the table"
Fixed wrong mutex order bug in Aria when flush_log_for_bitmap() was called when table is not yet marked for change.

include/my_base.h:
  Added flag that table is opened only for status
mysql-test/r/myisam-big.result:
  Test case for lp:925377
mysql-test/t/myisam-big.test:
  Test case for lp:925377
sql/sql_base.cc:
  If thd->version == 0 (happens only when we are opening a table that is flushed under  MYSQL_LOCK_IGNORE_FLUSH), open the table in HA_OPEN_FOR_STATUS mode
storage/maria/ma_bitmap.c:
  Fixed wrong mutex order bug in Aria when flush_log_for_bitmap() was called when table is not yet marked for change.
storage/maria/ma_dbug.c:
  Ignore last_version <= 1 as these are either flushed or only opened for status
storage/maria/ma_open.c:
  Use last_version=1 as a marker that table was opened with HA_OPEN_FOR_STATUS.
  In this case we just open a new version of the table in read only mode.
storage/myisam/mi_create.c:
  Update prototype
storage/myisam/mi_dbug.c:
  Ignore last_version <= 1 as these are either flushed or only opened for status
storage/myisam/mi_open.c:
  Use last_version=1 as a marker that table was opened with HA_OPEN_FOR_STATUS.
  If HA_OPEN_FOR_STATUS is used, we will not assert if there is an old not-to-be-used version of the table existing.
  In this case we just open a new version of the table in read only mode.
storage/myisam/myisamdef.h:
  Updated prototype
2012-02-28 23:18:52 +02:00
Sergei Golubchik
54f9fe6c8b lp:938977 - Query performance with join/index super slow on MariaDB 5.3.4RC
make sure that stored routines are evaluated (that is, de facto - cached) in convert_const_to_int().
revert the fix for lp:806943 because it cannot be repeated anymore.
add few tests for convert_const_to_int()
2012-02-28 15:41:55 +01:00
Sergei Golubchik
45faabf44f merge 2012-02-28 15:04:31 +01:00
Michael Widenius
adf3deda88 Automatic merge 2012-02-28 13:50:30 +02:00
Michael Widenius
cf06b29f60 Fixed lp:905716 "Assertion `page->size <= share->max_index_block_size'"
The issue was that Aria allowed too long keys to be created (so that the internal buffer was not big enough to hold the whole key).
Key lengths is now limited to HA_MAX_KEY_LENGTH (1000), as for MyISAM.
Fixed failure in  "_ma_apply_redo_index: Assertion `new_page_length == 0", as found by buildbot.

mysql-test/suite/maria/r/maria.result:
  Updated results
mysql-test/suite/maria/r/maria3.result:
  Updated results. Added test for bug fix
mysql-test/suite/maria/t/maria3.test:
  Updated results. Added test for bug fix
mysql-test/suite/maria/t/optimize.test:
  Updated test for new max key length
storage/maria/ha_maria.cc:
  Limit key to HA_MAX_KEY_LENGTH.
storage/maria/ma_key_recover.c:
  Limit used page length to max page size (this is in line with the code that writes the entry to the log).
  This fixes failure in  "_ma_apply_redo_index: Assertion `new_page_length == 0", as found by buildbot.
storage/maria/ma_search.c:
  Extra DBUG
storage/maria/ma_write.c:
  Added test to detect errors earlier.
2012-02-28 13:39:02 +02:00