Commit graph

232 commits

Author SHA1 Message Date
Igor Babaev
ca862231f7 Fixed LP bug #663840.
When adding a new record into the join buffer that is employed by
BNLH join algorithm the writing procedure JOIN_CACHE::write_record_data 
checks whether there is enough space for the record in the buffer.
When doing this it must take into account a possible new key entry
added to the buffer. It might happen, as it has been demonstrated by
the bug test case, that there is enough remaining space in the buffer
for the record, but not for the additional key entry for this record.
In this case the key entry overwrites the end of the record that might
cause a crash or wrong results.
Fixed by taking into account a possible addition of new key entry when
estimating the remaining free space in the buffer.
2010-10-22 10:53:29 -07:00
Igor Babaev
25f5debdc7 MWL#128: Added into EXPLAIN output info about types of the used join buffers and
about the employed join algorithms.
Refactored constructors of the JOIN_CACHE* classes.
2010-10-18 13:33:05 -07:00
Sergey Petrunya
51294f5948 Remove garbage comments 2010-10-10 22:43:19 +03:00
Sergey Petrunya
a285ce3e58 Post-merge fixes part 1 2010-10-10 17:38:17 +03: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
Igor Babaev
f1d42ec940 Applied the fix for bug #54235 taken from one of the mysql trees.
The fix aligns join_null_complements() with join_matching_records()
making both call generate_full_extensions().
There should not be any difference between how the WHERE clause
is applied to NULL-complemented records from a partial join and how
it is applied to other partially joined records:the latter happens in
join_matching_records(), precisely in generate_full_extensions().
2010-10-03 18:45:46 -07:00
Igor Babaev
f4503f39ee Fixed bug #52394 / LP bug #623209.
When an incremental join cache is used to join a table whose
fields are not referenced anywhere in the query the association
pointer to the last record in the such cache can be the same
as the pointer to the end of the buffer. 
The function JOIN_CACHE_BKA::get_next_key must take into 
consideration this when iterating over the keys of the records
from the join buffer. 
The assertion in JOIN_TAB_SCAN_MRR::next also must take this
into consideration.
Borrowed a slightly changed test case from a patch attached to the
bug #52394.
2010-09-21 16:41:53 -07:00
Igor Babaev
61e96a75a6 Fixed a typo bug in JOIN_CACHE::shrink_join_buffer_in_ratio. 2010-09-02 17:16:03 -07:00
Igor Babaev
4a9696a451 Made sure that JOIN_CACHE::max_records is not less than 10. 2010-09-02 07:42:47 -07:00
Igor Babaev
f83cc50793 Fixed an incorrect calculation of JOIN_CACHE::max_buff_size. 2010-09-01 23:11:14 -07:00
Igor Babaev
e268f224fb Fixes in function specs. 2010-08-31 22:30:54 -07:00
Igor Babaev
94cfcbd9df The main patch for MWL#128: Implement Block Nested Loop Hash Join. 2010-08-31 09:34:21 -07: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
psergey
3a9aabaa26 MWL#90: Subqueries: Inside-out execution for materialized non-sj subqueries
- Merge with MariaDB 5.3 -main
2010-07-11 19:18:43 +04:00
psergey
946aef4a58 MWL#90: code cleanup
- Remove deadcode
- Improve comments 
- Do small several small TODOs
2010-07-10 20:51:12 +03:00
Igor Babaev
0d734037cc Added missing calls of update_virtual_fields() in the
join cache module.
Without these calls SELECTs over tables with virtual columns
that used join cache could return wrong results. This could
be seen with the test case added into vcol_misc.test
2010-07-01 22:13:19 -07: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
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
26c3dc455b MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE
- Address feedback
- Code cleanup (not finished)
2010-06-08 18:22:31 +04:00
Sergey Petrunya
ef27f6c339 Buildbot fixes:
- Make join buffering take into account that join_tabs are not a 
  single linear array anymore
- Remove outer join + SJ-Materialization crash (OJ+SJ the processing
  is most likely still incorrect)
2010-06-05 22:43:27 +04:00
Sergey Petrunya
49568aefe7 MWL#90: Code cleanup: Unification of merged and non-merged SJM nests processing
- Make join buffering code to take into account that JOIN_TABs are not a 
  linear array anymore.
2010-06-05 12:37:16 +04:00
Sergey Petrunya
dad93f2c82 MWL#90, code movearound to unify merged and non-merged semi-join materialization processing
- First code, needs cleanup.
2010-06-04 17:40:57 +04:00
Sergey Petrunya
b9688830ec Subquery optimizations:
- Better comments
- Use more appropriate return types for functions
- Provide handling where it was missing.
2010-05-10 19:28:19 +04:00
Sergey Petrunya
2775f80f7d MWL#90: Subqueries: Inside-out execution for non-semijoin materialized
subqueries that are AND-parts of the WHERE
- First code (needs cleanup).
2010-04-06 00:16:45 +04:00
Sergey Petrunya
c2924e155e BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
- The problem was that DuplicateWeedout strategy setup code wasn't aware of the 
  fact that join buffering will be used and applied optimization that doesn't work
  together with join buffering. Fixed by making DuplicateWeedout setup code to have 
  a pessimistic check about whether there is a chance that join buffering will be 
  used.
- Make JOIN_CACHE_BKA::init() correctly process Copy_field elements that denote saving
  current rowids in the join buffer.

mysql-test/r/subselect_sj2.result:
  Update test results
mysql-test/r/subselect_sj2_jcl6.result:
  Update test results
mysql-test/r/subselect_sj_jcl6.result:
  Testcase
mysql-test/t/subselect_sj2.test:
  Update test results
mysql-test/t/subselect_sj_jcl6.test:
  Testcase
sql/opt_subselect.cc:
  - The problem was that DuplicateWeedout strategy setup code wasn't aware of the 
    fact that join buffering will be used and applied optimization that doesn't work
    together with join buffering. Fixed by making DuplicateWeedout setup code to have 
    a pessimistic check about whether there is a chance that join buffering will be 
    used.
sql/sql_join_cache.cc:
  Make JOIN_CACHE_BKA::init() correctly process Copy_field elements that denote saving current rowids in the join buffer.
sql/sql_select.cc:
  Added a question note
2010-03-07 18:41:45 +03:00
Igor Babaev
1c7ba7ba2f Fixed bug #51092.
The function JOIN_CACHE::read_all_record_fields could return 0
for an incremental join cache in two cases:
1. there were no more records in the associated join buffer
2. there was no table fields stored in the join buffer.
As a result the function JOIN_CACHE::get_record() could
return prematurely and did not read all needed fields from
join buffers into the record buffer.

Now the function JOIN_CACHE::read_all_record_fields returns
-1 if there are no more records in the associated join buffer.
2010-03-06 11:14:55 -08:00
Igor Babaev
3ccc1d6b1e Corrected Evgen's fix for bug #45191.
Made sure that join buffers could be used for inner tables of
any semi-join when the first match strategy is employed.
2010-03-05 10:54:48 -08:00
Sergey Petrunya
e0bb2f90a2 Subquery optimization backport:
- Factor out subquery code into sql/opt_subselect.{h,cc}
- Stop using the term "confluent" (was used due to misreading the dictionary)
2010-02-16 00:53:06 +03:00
Sergey Petrunya
742afd8eae Subquery optimizations: Backport into 5.3:
- Enable semi-join handling in the join cache code
2010-01-19 01:32:23 +03:00
Igor Babaev
4449a5f489 Backport into MariaDB-5.2 the following:
WL#2771 "Block Nested Loop Join and Batched Key Access Join"
2009-12-20 18:26:15 -08:00