Commit graph

213 commits

Author SHA1 Message Date
Alexander Barkov
02ada41744 MDEV-12721 Wrong execution plan for WHERE (date_field <=> timestamp_expr AND TRUE) 2017-05-07 17:44:27 +04:00
Sergei Golubchik
29ed440d44 MDEV-11836 vcol.vcol_keys_myisam fails in buildbot and outside
move TABLE::key_read into handler. Because in index merge and DS-MRR
there can be many handlers per table, and some of them use
key read while others don't. "keyread" is really per handler,
not per TABLE property.
2017-02-13 18:12:04 +01:00
Monty
135e144479 MDEV-11598 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
Found and fixed 2 problems:

- Filesort addon fields didn't mark virtual columns properly
- multi-range-read calculated vcol bitmap but was not using it.
  This caused wrong vcol field to be calculated on read, which caused the assert.
2017-01-11 09:19:45 +02:00
Monty
260dd476b0 Removed TABLE->sort to make it possible to have multiple active calls to
filesort and init_read_record() for the same table.
This will simplify code for WINDOW FUNCTIONS (MDEV-6115)

- Filesort_info renamed to SORT_INFO and moved to filesort.h
- filesort now returns SORT_INFO
- init_read_record() now takes a SORT_INFO parameter.
- unique declaration is moved to uniques.h
- subselect caching of buffers is now more explicit than before
- filesort_buffer is now reusable even if rec_length has changed.
- filsort_free_buffers() and free_io_cache() calls are removed
- Remove one malloc() when using get_addon_fields()

Other things:
- Added --debug-assert-on-not-freed-memory option to make it easier to
  debug some not-freed-memory issues.
2016-03-22 23:44:52 +02:00
Sergey Vojtovich
13af8650a8 MDEV-8719 - Obsolete sql_memdup() in favor of THD::memdup() and thd_memdup() 2015-11-26 11:34:15 +04:00
Sergei Petrunia
9b9e36ed49 MDEV-8779: mysqld got signal 11 in sql/opt_range_mrr.cc:100(step_down_to)
The crash was caused by range optimizer using RANGE_OPT_PARAM::min_key
(and max_key) to store keys. Buffer size was a good upper bound for
range analysis and partition pruning, but not for EITS selectivity
calculations.

Fixed by making these buffers variable-size. The sizes are calculated
from [pseudo]indexes used for range analysis.
2015-09-21 17:08:27 +03:00
Alexander Barkov
60985e5375 MDEV-8610 "WHERE CONTAINS(indexed_geometry_column,1)" causes full table scan 2015-08-13 14:25:51 +04:00
Alexander Barkov
9d884fd3d3 MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer 2015-08-12 17:28:45 +04:00
Monty
7332af49e4 - Renaming variables so that they don't shadow others (After this patch one can compile with -Wshadow and get much fewer warnings)
- Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function.
- Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined.
- Removing calls to current_thd when we have access to thd

Part of this is optimization (not calling current_thd when not needed),
but part is bug fixing for error condition when current_thd is not defined
(For example on startup and end of mysqld)

Notable renames done as otherwise a lot of functions would have to be changed:
- In JOIN structure renamed:
   examined_rows -> join_examined_rows
   record_count -> join_record_count
- In Field, renamed new_field() to make_new_field()

Other things:
- Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe.
- Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly
- Added 'thd' as argument to a few functions to avoid calling current_thd.
2015-07-06 20:24:14 +03:00
Sergey Vojtovich
4d1ccc4289 MDEV-7951 - sql_alloc() takes 0.25% in OLTP RO
sql_alloc() has additional costs compared to direct mem_root allocation:
- function call: it is defined in a separate translation unit and can't be
  inlined
- it needs to call pthread_getspecific() to get THD::mem_root

It is called dozens of times implicitely at least by:
- List<>::push_back()
- List<>::push_front()
- new (for Sql_alloc derived classes)
- sql_memdup()

Replaced lots of implicit sql_alloc() calls with direct mem_root allocation,
passing through THD pointer whenever it is needed.

Number of sql_alloc() calls reduced 345 -> 41 per OLTP RO transaction.
pthread_getspecific() overhead dropped 0.76 -> 0.59
sql_alloc() overhed dropped 0.25 -> 0.06
2015-05-13 10:43:14 +04:00
Alexander Barkov
8a01a0acb3 MDEV-7920 main.group_min_max fails in buildbot with valgrind 2015-04-13 11:26:49 +04:00
Sergei Golubchik
f62c12b405 Merge 10.0.14 into 10.1 2014-10-15 12:59:13 +02:00
Sergei Petrunia
be00e279c6 MDEV-6480: Remove conditions for which range optimizer returned SEL_ARG::IMPOSSIBLE
Let range optimizer remove parts of OR-clauses for which range analysis
produced SEL_TREE(IMPOSSIBLE).
There is no need to remove parts of AND-clauses: either they are inside
of OR (and the whole AND-clause will be removed), or the AND-clause is
at the top level, in which case the whole WHERE (or ON) is always FALSE
and this is a degenerate case which receives special treatment.

The removal process takes care not to produce 1-way ORs (in that case
we substitute the OR for its remaining member).
2014-08-27 18:47:33 +04:00
Sergei Golubchik
6fb17a0601 5.5.39 merge 2014-08-07 18:06:56 +02:00
Sergey Petrunya
07c0b1d8d0 MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
- Filesort has an optmization where it reads only columns that are 
  needed before the sorting is done.
- When ref(_or_null) is picked by the join optimizer, it may remove parts
  of WHERE clause that are guaranteed to be true.
- However, if we use quick select, we must put all of the range columns into the 
  read set. Not doing so will may cause us to fail to detect the end of the range.
2014-07-22 15:52:49 +04:00
Sergey Vojtovich
d12c7adf71 MDEV-5314 - Compiling fails on OSX using clang
This is port of fix for MySQL BUG#17647863.

revno: 5572
revision-id: jon.hauglid@oracle.com-20131030232243-b0pw98oy72uka2sj
committer: Jon Olav Hauglid <jon.hauglid@oracle.com>
timestamp: Thu 2013-10-31 00:22:43 +0100
message:
  Bug#17647863: MYSQL DOES NOT COMPILE ON OSX 10.9 GM

  Rename test() macro to MY_TEST() to avoid conflict with libc++.
2014-02-19 14:05:15 +04:00
Sergey Petrunya
e5d13c1567 Merge 10.0-base -> 10.0 2013-10-16 13:38:42 +04:00
Sergey Petrunya
69e6a2bb22 MDEV-3798: EXPLAIN UPDATE/DELETE
- Update test results after last few csets
- Generate correct value for `possible_keys` column for single table UPDATE/DELETE.
2013-10-08 16:13:49 +04:00
Sergey Petrunya
69393db3d1 MDEV-3798: EXPLAIN UPDATE/DELETE
- Better EXPLAIN-saving methods for quick selects
2013-10-07 13:58:47 +04:00
Sergey Petrunya
72bc6d7364 MDEV-3798: EXPLAIN UPDATE/DELETE
- Address review feedback: more renames
2013-10-05 13:19:45 +04:00
Sergey Petrunya
fedf769f0b MDEV-3798: EXPLAIN UPDATE/DELETE
- Address review feedback: rename nearly any name used by the new EXPLAIN code.
2013-10-05 09:58:22 +04:00
Sergey Petrunya
0b69c44e94 MDEV-5067: Valgrind warnings (Invalid read) in QPF_table_access::print_explain
- Query plan footprint (in new terms, "EXPLAIN structure") should always keep 
  a copy of key_name.  This is because the table might be a temporary table which
  may be already freed by the time we use query plan footprint.
2013-09-26 14:42:30 +04:00
Sergey Petrunya
abf4a910f2 [SHOW] EXPLAIN UPDATE/DELETE
- Make QPF structures store data members, not strings. 
  This is not fully possible, because table names (and hence 
  key names, etc) can be deleted, and we have to store strings.
2013-09-17 15:01:34 +04:00
Sergei Golubchik
b7b5f6f1ab 10.0-monty merge
includes:
* remove some remnants of "Bug#14521864: MYSQL 5.1 TO 5.5 BUGS PARTITIONING"
* introduce LOCK_share, now LOCK_ha_data is strictly for engines
* rea_create_table() always creates .par file (even in "frm-only" mode)
* fix a 5.6 bug, temp file leak on dummy ALTER TABLE
2013-07-21 16:39:19 +02:00
Sergey Petrunya
ef47cc1f09 [SHOW] EXPLAIN UPDATE/DELETE, code re-structuring
- Merge with 10.0-base
2013-06-27 18:28:14 +04:00
Sergey Petrunya
befacafd73 [SHOW] EXPLAIN UPDATE/DELETE, code re-structuring
- Let Query Plan Footprint store join buffer type 
  in binary form, not string.
- Same for LooseScan type.
2013-06-27 17:56:49 +04:00
Sergei Golubchik
935817e985 Fix to compile without partitioning.
Remove few ifdef's
2013-06-15 19:09:40 +02:00
unknown
1a8486a842 MDEV-4345: fixed optimizer_selectivity_sampling_limit default value. 2013-04-19 19:35:13 +03:00
unknown
9441e53653 MDEV-4345
Sampling of selectivity of LIKE predicate.
2013-04-18 22:22:04 +03:00
Igor Babaev
f4cd2b37b1 Merge 10.0-base -> mwl253 2013-04-15 09:16:54 -07:00
Sergey Petrunya
7868367270 Merge 5.3 -> 5.5 2013-04-03 18:51:29 +04:00
Sergey Petrunya
763af1a8a3 MDEV-4240: mariadb 5.3.12 using more memory than MySQL 5.1 for an inefficient query
- Let index_merge allocate table handlers on quick select's MEM_ROOT,
  not on statement's MEM_ROOT. 
  This is crucial for big "range checked for each record" queries, where 
  index_merge can be created and deleted many times during query exection. 
  We should not make O(#rows) allocations on statement's MEM_ROOT.
2013-04-01 18:03:14 +04:00
Michael Widenius
068c61978e Temporary commit of 10.0-merge 2013-03-26 00:03:13 +02:00
Igor Babaev
fc1c8ffdad The pilot patch for mwl#253. 2013-03-11 07:44:24 -07:00
unknown
f65e5841d7 Fix for MDEV-3948, and backport of the following collection of fixes and backports
from MariaDB 10.0.
  
The bug in mdev-3948 was an instance of the problem fixed by Sergey's patch
in 10.0 - namely that the range optimizer could change table->[read | write]_set,
and not restore it.
  
revno: 3471
committer: Sergey Petrunya <psergey@askmonty.org>
branch nick: 10.0-serg-fix-imerge
timestamp: Sat 2012-11-03 12:24:36 +0400
message:
  # MDEV-3817: Wrong result with index_merge+index_merge_intersection, InnoDB table, join, AND and OR conditions
  Reconcile the fixes from:
  #
  # guilhem.bichot@oracle.com-20110805143029-ywrzuz15uzgontr0
  # Fix for BUG#12698916 - "JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
  # AFTER FLUSH TABLES [-INT VS NULL]"
  #
  # guilhem.bichot@oracle.com-20111209150650-tzx3ldzxe1yfwji6
  # Fix for BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == SAVE_READ_SET
  # and
  #
  and related fixes from: BUG#1006164, MDEV-376:
  
  Now, ROR-merged QUICK_RANGE_SELECT objects make no assumptions about the values
  of table->read_set and table->write_set.
  Each QUICK_ROR_SELECT has (and had before) its own column bitmap, but now, all 
  QUICK_ROR_SELECT's functions that care: reset(), init_ror_merged_scan(), and 
  get_next()  will set table->read_set when invoked and restore it back to what 
  it was before the call before they return.

  This allows to avoid the mess when somebody else modifies table->read_set for 
  some reason.
2013-01-28 15:13:39 +02:00
Sergey Petrunya
be0be7af47 # MDEV-3817: Wrong result with index_merge+index_merge_intersection, InnoDB table, join, AND and OR conditions
Reconcile the fixes from:
#
# guilhem.bichot@oracle.com-20110805143029-ywrzuz15uzgontr0
# Fix for BUG#12698916 - "JOIN QUERY GIVES WRONG RESULT AT 2ND EXEC. OR
# AFTER FLUSH TABLES [-INT VS NULL]"
#
# guilhem.bichot@oracle.com-20111209150650-tzx3ldzxe1yfwji6
# Fix for BUG#12912171 - ASSERTION FAILED: QUICK->HEAD->READ_SET == SAVE_READ_SET
# and
#
and related fixes from: BUG#1006164, MDEV-376:

Now, ROR-merged QUICK_RANGE_SELECT objects make no assumptions about the values
of table->read_set and table->write_set.
Each QUICK_ROR_SELECT has (and had before) its own column bitmap, but now, all 
QUICK_ROR_SELECT's functions that care: reset(), init_ror_merged_scan(), and 
get_next()  will set table->read_set when invoked and restore it back to what 
it was before the call before they return.

This allows to avoid the mess when somebody else modifies table->read_set for 
some reason.
2012-11-03 12:24:36 +04:00
Igor Babaev
2954ed1ec9 Merge 5.3->5.5. 2012-06-24 09:10:11 -07:00
Sergey Petrunya
e7bfda3b3c Added comment about QUICK_RANGE_SELECT::free_cond being unused. 2012-06-22 14:14:22 +04:00
Sergei Golubchik
4f435bddfd 5.3 merge 2012-01-13 15:50:02 +01:00
Michael Widenius
6d4224a31c Merge with 5.2.
no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
2011-12-11 11:34:44 +02:00
Michael Widenius
6920457142 Merge with MariaDB 5.1 2011-11-24 18:48:58 +02:00
Sergei Golubchik
d2755a2c9c 5.3->5.5 merge 2011-11-22 18:04:38 +01:00
Michael Widenius
a8d03ab235 Initail merge with MySQL 5.1 (XtraDB still needs to be merged)
Fixed up copyright messages.
2011-11-21 19:13:14 +02:00
Sergei Golubchik
0e007344ea mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
Sergey Petrunya
57b3fefa03 BUG#882994: Crash in QUICK_RANGE_SELECT::reset with derived_with_keys
- The bug was caused by the following scenario:
  = a quick select is created with get_quick_select_for_ref. The quick 
    select refers to temporary (derived) table. It saves table->file, which
    refers to a ha_heap object.
  = When temp table is populated, ha_heap reaches max. size and is converted
    to a ha_myisam.  However, quick->file remains pointing to where ha_heap 
    was. 
  = Attempt to use the quick select causes crash.
- Fixed by introducing QUICK_SELECT_I::replace_handler(). Note that it will 
  not work for index_merge quick selects. Which is fine, because these
  quick selects are never created for derived tables.
2011-10-31 15:07:43 +04:00
Sergei Golubchik
76f0b94bb0 merge with 5.3
sql/sql_insert.cc:
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
  ******
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
sql/sql_table.cc:
  small cleanup
  ******
  small cleanup
2011-10-19 21:45:18 +02:00
unknown
ef2b4b14e1 Merge from 5.2 2011-07-21 15:50:25 +03:00
unknown
f675536aa4 Merge 5.1->5.2 2011-07-21 13:15:09 +03:00
unknown
ee06e4d65e Removed incorrect fix and its test suite (the test suit is duplicate).
Fixed explains of previous patch.

mysql-test/r/explain.result:
  Fixed explains of previous patch.
mysql-test/r/join_outer.result:
  Fixed explains of previous patch.
mysql-test/r/negation_elimination.result:
  Fixed explains of previous patch.
mysql-test/r/view.result:
  Fixed explains of previous patch.
mysql-test/suite/innodb/r/innodb_mysql.result:
  Removed duplicate test suite.
mysql-test/suite/innodb/t/innodb_mysql.test:
  Removed duplicate test suite.
mysql-test/suite/innodb_plugin/r/innodb_mysql.result:
  Removed duplicate test suite.
mysql-test/suite/innodb_plugin/t/innodb_mysql.test:
  Removed duplicate test suite.
sql/opt_range.h:
  Removed incorrect fix.
sql/records.cc:
  Removed incorrect fix.
2011-07-21 12:29:00 +03:00
Sergei Golubchik
9809f05199 5.5-merge 2011-07-02 22:08:51 +02:00