Commit graph

138 commits

Author SHA1 Message Date
Sergey Petrunya
997445bc8e Make EXPLAIN better at displaying MRR/BKA:
- "Using MRR" is no longer shown with range access.
- Instead, both range and BKA accesses will show one of the following:
  = "Rowid-ordered scan"
  = "Key-ordered scan"
  = "Key-ordered Rowid-ordered scan"
depending on whether DS-MRR implementation will do scan keys in order, rowids in order,
or both.
- The patch also introduces a way for other storage engines/MRR implementations to
  pass information to EXPLAIN output about the properties of employed MRR scans.
2011-04-02 14:04:45 +04:00
Sergey Petrunya
e6bd643c75 MRR interface: change range_info's type from char* to range_id_t typedef. The goals are:
- cleaner code
- ability to change from using pointers to offsets at some point
2011-03-04 12:06:03 +03:00
Sergey Petrunya
cdd214de1c Merge fix for BUG#693747 2011-03-04 01:30:25 +03:00
Sergey Petrunya
8ef094fe4f BUG#707925: Wrong result with join_cache_level=6 optimizer_use_mrr = force (incremental, BKA join)
- The problem was that Mrr_ordered_index_reader's interrupt_read() and resume_read() would 
  save and restore 1) index tuple  2) the rowid (as bytes returned by handler->position()).  Clustered 
  primary key columns were not saved/restored. 
  They are not explicitly present in the index tuple (i.e. table->key_info[secondary_key].key_parts 
  doesn't list them), but they are actually there, in particular 
  table->field[clustered_primary_key_member].part_of_key(secondary_key) == 1. Index condition pushdown
  code [correctly] uses the latter as inidication that pushed index condition can refer to clustered PK
  members. 

  The fix was to make interrupt_read()/resume_read() to save/restore clustered primary key members as well,
  so that we get correct values for them when evaluating pushed index condition.
[3rd attempt: remove the debugging aids, fix comments in testcase]
2011-03-04 00:54:10 +03:00
Sergey Petrunya
9faf5452a1 BUG#693747: Assertion multi_range_read.cc:908: int DsMrr_impl::dsmrr_init
- Make DsMrr_impl::dsmrr_init() handle the case of 
   1. 1st MRR scan using DS-MRR strategy (i.e. doing key sorting and rowid sorting)
   2. 2nd MRR scan getting a buffer that's too small to fit one key element 
      and one rowid element, and so falling back to default MRR implementation
  In this case, dsmrr_init() is invoked with {primary_handler, secondary_handler}
  initialized for DS-MRR scan and have to reset them to be initialized for the
  default MRR scan.
(attempt 2, with simplified testcase)
2011-03-02 23:08:13 +03:00
Vladislav Vaintroub
019256c9fc Fix numerous warnings introduced in the last pushes on Windows 2011-02-18 23:31:01 +01:00
Michael Widenius
2813f568b7 Merge with bugfix
sql/multi_range_read.cc:
  Added printing of error if something goes wrong in get_next()
  (Not critical for this bug fix, but this was something that I noticed while testing and found missing)
storage/myisam/mi_rkey.c:
  Fixed wrong error number in mi_yield_and_check_if_killed()
2011-02-18 21:45:32 +02:00
Michael Widenius
b12e3796dc Fix for lp:711565 "Index Condition Pushdown can make a thread hold MyISAM locks as well as be unKILLable for long time"
- In Maria/MyISAM: Release/re-acquire locks to give queries that wait on them a chance to make progress
- In Maria/MyISAM: Change from numeric constants to ICP_RES values.
- In Maria: Do check index condition in maria_rprev() (was lost in the merge/backport?)
- In Maria/MyISAM/XtraDB: Check if the query was killed, and return immediately if it was.

Added new storage engine error: HA_ERR_ABORTED_BY_USER, for handler to signal that it detected a kill of the query and aborted

Authors: Sergey Petrunia & Monty

include/my_base.h:
  Added HA_ERR_ABORTED_BY_USER, for handler to signal that it detected a kill of the query and aborted
include/my_handler.h:
  Added comment
mysql-test/r/myisam_icp.result:
  Updated test
mysql-test/t/myisam_icp.test:
  Drop used tables at start of test
  Added test case that can help with manual testing of killing index condition pushdown query.
mysys/my_handler_errors.h:
  Text for new storage engine error
sql/handler.cc:
  If engine got HA_ERR_ABORTED_BY_USER, send kill message.
sql/multi_range_read.cc:
  Return error code
storage/maria/ha_maria.cc:
  Added ma_killed_in_mariadb() to detect kill.
  Ensure that file->external_ref points to TABLE object.
storage/maria/ma_extra.c:
  Dummy test-if-killed for standalone
storage/maria/ma_key.c:
  If ma_check_index_cond() fails, set my_errno and info->cur_row.lastpos
storage/maria/ma_rkey.c:
  Release/re-acquire locks to give queries that wait on them a chance to make progress
  Check if the query was killed, and return immediately if it was
storage/maria/ma_rnext.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_ma_writeinfo(info)
storage/maria/ma_rnext_same.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_ma_writeinfo(info)
storage/maria/ma_rprev.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_ma_writeinfo(info) and ma_check_index_cond()
storage/maria/ma_search.c:
  Give error message if we find a wrong key
storage/maria/ma_static.c:
  Added pointer to test-if-killed function
storage/maria/maria_def.h:
  New prototypes
storage/myisam/ha_myisam.cc:
  Added mi_killed_in_mariadb()
  Ensure that file->external_ref points to TABLE object.
storage/myisam/mi_extra.c:
  Dummy test-if-killed for standalone
storage/myisam/mi_key.c:
  If ma_check_index_cond() fails, set my_errno and info->lastpos
storage/myisam/mi_rkey.c:
  Ensure that info->lastpos= HA_OFFSET_ERROR in case of error
  Release/re-acquire locks to give queries that wait on them a chance to make progress
  Check if the query was killed, and return immediately if it was
  Reorder code to do less things in case of error.
  Added missing fast_mi_writeinfo()
storage/myisam/mi_rnext.c:
  Check if the query was killed, and return immediately if it was
  Simplify old ICP code
  Added missing fast_ma_writeinfo(info)
storage/myisam/mi_rnext_same.c:
  Check if the query was killed, and return immediately if it was
  Added missing fast_mi_writeinfo(info)
storage/myisam/mi_rprev.c:
  Check if the query was killed, and return immediately if it was
  Simplify error handling of ICP
  Added missing fast_mi_writeinfo(info)
storage/myisam/mi_search.c:
  Give error message if we find a wrong key
storage/myisam/mi_static.c:
  Added pointer to test-if-killed function
storage/myisam/myisamdef.h:
  New prototypes
storage/xtradb/handler/ha_innodb.cc:
  Added DB_SEARCH_ABORTED_BY_USER and ha_innobase::is_thd_killed()
  Check if the query was killed, and return immediately if it was
storage/xtradb/handler/ha_innodb.h:
  Added prototype
storage/xtradb/include/db0err.h:
  Added DB_SEARCH_ABORTED_BY_USER
storage/xtradb/include/row0mysql.h:
  Added possible ICP errors
storage/xtradb/row/row0sel.c:
  Use ICP errors instead of constants.
  Detect if killed and return B_SEARCH_ABORTED_BY_USER
2011-02-18 17:43:59 +02:00
Sergey Petrunya
f51a26885f Fix compile error on Windows: instead of round(X) use floor(X+0.5) 2010-12-22 02:26:35 +03:00
Sergey Petrunya
9d480f6af3 BUG#670417: Diverging results in maria-5.3-mwl128-dsmrr-cpk with join buffer
- Fixes for the second fix: take into account case where we don't need to save/restore the scan.
2010-12-20 14:40:12 +03:00
Sergey Petrunya
09a84dc470 BUG#670417: Diverging results in maria-5.3-mwl128-dsmrr-cpk with join buffer
Switch from "Disable identical key handling optimization when
  IndexConditionPushdown is used" approach
To 
 an approach where we save/restore index tuple and so can use index condition pushdown.
2010-12-19 13:56:12 +03:00
Sergey Petrunya
81eb82b47d Fix a compiler warning on sparc32 2010-12-17 14:58:08 +03:00
Sergey Petrunya
80cbf3a1c2 Small code cleanups 2010-12-17 13:06:21 +03:00
Sergey Petrunya
8dc612e6ab MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, portion 3
2010-12-16 23:37:26 +03:00
Sergey Petrunya
3e633eea66 MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, portion 2
2010-12-16 21:18:35 +03:00
Sergey Petrunya
802db7a64b - Fix compiler warning
- Better warnings
2010-12-15 10:45:08 +03:00
Sergey Petrunya
eafc4bef33 MWL#121-125 DS-MRR improvements
- Address review feedback: change return type of RANGE_SEQ_IF::next()
2010-12-13 20:01:32 +03:00
Sergey Petrunya
58b646001a Merge DS-MRR/CPK improvements into 5.3-main 2010-12-13 13:42:40 +03:00
Igor Babaev
7f52af655a Merge. 2010-12-10 23:23:34 -08:00
Sergey Petrunya
14ca046833 Fix crashes on sparc-32 bit: use memcpy when we need to access non-aligned
pointers.
2010-12-10 20:18:12 +03:00
Sergey Petrunya
a86599e1e4 BUG#671340: Diverging results in with mrr_sort_keys=ON|OFF and join_cache_level=5
- Make Mrr_ordered_index_reader() save the rowid across scan interruptions

Also
- Fix compiler warning for setup_buffer_sizes()
- Add commented key_copy/key_restore for better handling of a similar issue
  with index record being destroyed by scan interruption (which causes 
  incorrect evaluation of pushed index condition later on).
2010-12-09 00:47:33 +03:00
Sergey Petrunya
1c7c67d584 MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 6: rename "handler *h" variable in all
  DS-MRR classes to something else.
2010-12-02 16:21:52 +03:00
Sergey Petrunya
44be131cd3 MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 5
2010-12-02 14:10:52 +03:00
Michael Widenius
ab5e4eefd5 Fixed some compiler warnings found when compiling for windows.
Changed rows_read and rows_sent status variables to be longlong (to avoid compiler warnings)


sql/item_func.cc:
  Fixed wrong usage of alias
sql/item_subselect.cc:
  Changed buffer size to ulonglong to be able detect buffers bigger than size_t
sql/item_subselect.h:
  Changed buffer size to ulonglong to be able detect buffers bigger than size_t
sql/multi_range_read.cc:
  Fixed compiler warning by using correct type for function argument
sql/mysqld.cc:
  Changed rows_read and rows_sent status variables to be longlong
sql/opt_subselect.h:
  Fixed compiler warning by using correct type for function argument
sql/sql_class.cc:
  Changed rows_read and rows_sent status variables to be longlong
sql/sql_class.h:
  Changed rows_read and rows_sent status variables to be longlong
  Changed max_nulls_in_row to uint as this is number of columns in row.
  This fixed some compiler warnings.
sql/sql_select.cc:
  Added casts to avoid compiler warnings
storage/heap/ha_heap.cc:
  Initilize different types separate
storage/oqgraph/ha_oqgraph.cc:
  Fixed argument to store(longlong) to avoid compiler warnings
2010-11-30 01:27:14 +02:00
Sergey Petrunya
cee6e4565d Fix trivial error in previous push 2010-11-29 17:27:23 +03:00
Sergey Petrunya
a6d47ab1d3 Fix buildbot failure: keep rowid_buf_elem_size to its original value, otherwise
subsequent asserts have the wrong meaning.
2010-11-28 23:55:08 +03:00
Sergey Petrunya
8604dc78e2 Fix trivial error 2010-11-26 15:45:46 +03:00
Sergey Petrunya
40822c8149 Fix buildbot failure 2010-11-26 00:30:39 +03:00
Sergey Petrunya
92442fc598 Merge MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 4
2010-11-25 14:35:21 +03:00
Sergey Petrunya
fad2ec7499 MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 3
2010-11-23 18:08:11 +03:00
Sergey Petrunya
a6c1d56e08 MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 1
- Fix buildbot failure
2010-11-22 19:34:03 +03:00
Sergey Petrunya
2ec43747f5 Merge MWL#121-125 DS-MRR improvements
- Address Monty's review feedback, part 1
2010-11-22 17:08:22 +03:00
Sergey Petrunya
3d698ac616 BUG#671361: virtual int Mrr_ordered_index_reader::refill_buffer(): Assertion `!know_key_tuple_params
- Make sure we have enough space for both rowids and keys.
2010-11-09 18:02:08 +02:00
Sergey Petrunya
0fb342ba56 BUG#670417: Diverging results in maria-5.3-mwl128-dsmrr-cpk with join buffer, attempt 4
- Disable identical key handling optimization when
  IndexConditionPushdown is used
2010-11-08 20:37:01 +03:00
Sergey Petrunya
197c99427d DS-MRR improvements
- Code cleanup
- Always propagate the error code we got from storage engine all the way up
2010-11-08 15:15:50 +03:00
Sergey Petrunya
d6ec99d0b6 Merge {DS-DRR improvements:code cleanup} into MWL#128+DS-MRR tree 2010-11-03 11:03:07 +03:00
Sergey Petrunya
c46450de72 Code cleanup 2010-11-03 00:09:28 +03:00
Sergey Petrunya
1654780f2d Code cleanup 2010-11-02 23:25:35 +03:00
Sergey Petrunya
59db1d7a39 Address problems uncovered by buildbot
- Update test results
- Handle the case where MRR implementation doesn't get any key tuples at all
2010-11-02 19:32:26 +03:00
Sergey Petrunya
6c15806b68 MWL#121-124 DS-MRR support for key-ordered retrieval, etc
- Merge into 5.3-main
2010-11-01 18:49:59 +03:00
Sergey Petrunya
b76a8595c6 Re-initialization reworked 2010-11-01 13:52:10 +03:00
Sergey Petrunya
430f63c271 use DBUG_RETURN with DBUG_ENTER 2010-11-01 00:04:34 +03:00
Sergey Petrunya
d9a8dd22b2 DS-MRR/CPK improvements: correct buffer exhaustion handling 2010-10-31 22:00:15 +03:00
Igor Babaev
0b72fd88a1 Merge. 2010-10-30 06:07:45 -07:00
Sergey Petrunya
8e4c627ef8 DS-MRR improvements:
- Correct buffer re-allocation
2010-10-29 20:21:26 +04:00
Sergey Petrunya
1e82320d27 DS-MRR improvements
- buildbot test failure fixes: don't try to get more records from SimpleIndexReader
  if we've already got EOF for it.
2010-10-29 13:42:48 +04:00
Sergei Golubchik
8e7ebfbce8 5.2 merge 2010-10-28 19:04:23 +02:00
Sergey Petrunya
a88bd5cf56 DS-MRR improvements:
- address the review feedback (class/var renames)
- fix wrong test result (bug in buffer refill logic)
2010-10-28 20:48:16 +04:00
Sergey Petrunya
d8efc3b155 DS-MRR improvements: address review feedback for R3 version of the patch 2010-10-26 15:35:13 +04:00
Igor Babaev
79087c9e07 Ported the fix for bug #57024 (a performance issue for outer joins).
Employed the same kind of optimization as in the fix for the cases
when join buffer is used.
The optimization performs early evaluation of the conditions from 
on expression with table references to only outer tables of
an outer join.
2010-10-06 13:27:12 -07:00
Sergey Petrunya
ac8a79b944 Code cleanup 2010-10-04 10:31:40 +04:00
Sergey Petrunya
d4f2e7a9a9 Fix failures introduced in the previous push 2010-10-04 00:37:30 +04:00
Sergey Petrunya
5156457506 Address review feedback
- One iterator class
- Switch back from state automaton into two-nested-iterators approach..
2010-10-03 14:48:42 +04:00
Sergey Petrunya
22d5323fac DS-MRR/CPK improvements: more of addressing review feedback 2010-10-01 15:54:35 +04:00
Sergey Petrunya
61f26f0c62 DS-MRR improvements: address review feedback
- change dsmrr_next_from_index() to a switch-based state automaton-like structure.
2010-09-28 20:20:09 +04:00
Sergey Petrunya
4f56acb676 Better comments, move Lifo_buffer to separate file. 2010-09-28 12:19:50 +04:00
Sergey Petrunya
3066c37718 DS-MRR improvements: review feedback
- Switch from one bi-directional buffer class to two 
  virtual inheritance-based forward and backward buffer classes.
2010-09-21 20:19:54 +04:00
Sergey Petrunya
2121ab1eb4 DS-MRR improvements: remove write_size/read_size, have the same size
for writing and reading
2010-09-20 13:23:51 +04:00
Sergey Petrunya
189555f39a DS-MRR improvements: more code cleanup
- better comments
- rename variables to better reflect their meaning
2010-09-20 13:02:17 +04:00
Sergey Petrunya
18a348503a DS-MRR improvements: better comments, use symbolic name instead of +1/-1 constants. 2010-09-19 01:05:47 +04:00
Sergey Petrunya
499b142ad5 BUG#628785: multi_range_read.cc:430: int DsMrr_impl::dsmrr_init(): Assertion `do_sort_keys || do_rowid_fetch' failed
- Make Ds_MrrImpl::check_cpk_scan() follow the execution code' logic: don't
  do MRR scans on clustered PK when mrr_sort_keys=off.
2010-09-15 16:58:01 +04:00
Sergey Petrunya
188de43db1 - Fixed BUG#623285: Crash in quick_range_seq_next() in maria-5.3-dsmrr-cpk
- Relax overly-strict assert added in previous commit
- Run generic MRR testsuite for Maria engine, too.
2010-09-13 19:45:41 +04:00
Sergey Petrunya
b9e5125050 Remove garbage comments, coding style conformance (no functional changes). 2010-09-12 13:21:25 +04:00
Sergey Petrunya
a730bb9caf Fix a typo bug in SimpleBuffer.read() 2010-09-11 21:56:43 +04:00
Sergey Petrunya
9b04caffd4 Commit for buildbot checks 2010-09-10 20:48:11 +04:00
Sergey Petrunya
dbc63bed22 MWL#121-125: DS-MRR improvements
- Address review feedback, step 1
2010-09-05 14:32:14 +04:00
Sergey Petrunya
fae27347d1 Fix one more problem with buffer exhaustion scenario 2010-08-19 19:52:58 +02:00
Sergey Petrunya
d4f057f256 More valgrind fixes 2010-08-15 22:30:18 +04:00
Sergey Petrunya
3b85e019ab Fix another (possibly dangerous) valgrind failure. 2010-08-15 07:59:39 +04:00
Sergey Petrunya
889e6170fe Fix [harmless] valgrind failure 2010-08-15 06:59:23 +04:00
Sergey Petrunya
c964cb1b62 key/rowid buffer overflow fixes for various tricky cases. 2010-08-14 18:56:37 +04:00
Sergey Petrunya
d098596ba5 Fix a number of problems with reverse buffer use 2010-08-12 23:59:29 +04:00
Sergey Petrunya
8d07c16ad9 Do dynamic buffer growing/shrinking. 2010-08-12 21:18:41 +04:00
Sergey Petrunya
8dc81f47ef Use reverse/backwards buffer for keys (now works)
- don't allocate space for rowid buffer when we don't really need it.
- fix buffer iterator
2010-08-11 14:54:34 +04:00
Sergey Petrunya
57c17e18af Fix valgrind failure 2010-08-09 00:38:42 +04:00
Sergey Petrunya
a2e29a83aa We can't check that assertion at the first iteration 2010-08-08 15:44:32 +04:00
Sergey Petrunya
758b68a980 Fix valgrind failure: don't access key_buffer if we haven't set it up yet. 2010-08-08 12:30:48 +04:00
Sergey Petrunya
e25db795bd DS-MRR, key-ordered retrievals: commit for buildbot 2010-08-08 11:13:54 +04:00
Sergey Petrunya
7391175d7e DS-MRR support improvements (MWL#123, MWL#124, MWL#125)
- Let DS-MRR/CPK take advantage of materialized keys, when possible
2010-07-18 01:05:44 +04:00
Sergey Petrunya
e0999cdf7c DS-MRR support improvements (MWL#123, MWL#124, MWL#125)
- Lots of TODO comments
- add mrr_sort_keys flag to @@optimizer_switch
- [from Igor] SQL layer part passes HA_MRR_MATERIALIZED_KEYS flag
- Don't call rnd_pos() many times in a row if sorted rowid buffer
  has the same rowid value for multiple consequive (rowid, range_id) pairs.
2010-07-17 18:03:50 +04:00
Sergey Petrunya
e1006e9e1f MWL#121: DS-MRR support for clustered primary keys
- Merge with current 5.3
2010-07-16 13:38:23 +04:00
Sergey Petrunya
27f9fc063c MariaDB 5.2 -> MariaDB 5.3 merge 2010-06-26 14:05:41 +04:00
Sergey Petrunya
488d352a66 MWL#121: DS-MRR support for clustered primary keys
- Remove back key_parts from multi_range_read_init() parameters
- Related code simplification/cleanup
2010-06-22 23:26:11 +04:00
Sergey Petrunya
b45748f058 MWL#121: DS-MRR support for clustered primary keys
- Fix the code to work with IndexConditionPushdown+BKA (EXPLAIN is still 
  incorrect, see comments in the patch)
- Test coverage for ICP+BKA
2010-06-22 22:38:52 +04:00
Sergey Petrunya
16e197f5b1 MWL#121: DS-MRR support for clustered primary keys
- Add testcases
- Code cleanup: garbage removal, better comments, make members private where possible
2010-06-22 21:24:22 +04:00
Sergey Petrunya
82f8ed17e1 MWL#121: DS-MRR support for clustered primary keys
- Add testcases
2010-06-21 12:34:31 +04:00
Sergey Petrunya
925e508a2e MWL#121: DS-MRR support for clustered primary keys
- First code (will need code cleanup)
2010-06-19 15:40:19 +04:00
Sergey Petrunya
da5edf5057 MWL#67: MRR backport
- Make index condition pushdown be controlled by an @@optimizer_switch flag,
  not by @@engine_condition_pushdown
- Make MRR buffer size be controlled by @@mrr_buffer_size, not 
  by @@read_rnd_buffer_size
- Move parts of code to separate files
- Code cleanup
- Add --sorted_result to some SELECTs in tests.
2009-12-22 15:33:21 +03:00
Renamed from sql/ds_mrr.cc (Browse further)