summaryrefslogtreecommitdiff
path: root/storage/myisam
Commit message (Collapse)AuthorAgeFilesLines
* Updated optimizer costs in multi_range_read_info_const() and sql_select.ccMonty2020-03-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - multi_range_read_info_const now uses the new records_in_range interface - Added handler::avg_io_cost() - Don't calculate avg_io_cost() in get_sweep_read_cost if avg_io_cost is not 1.0. In this case we trust the avg_io_cost() from the handler. - Changed test_quick_select to use TIME_FOR_COMPARE instead of TIME_FOR_COMPARE_IDX to align this with the rest of the code. - Fixed bug when using test_if_cheaper_ordering where we didn't use keyread if index was changed - Fixed a bug where we didn't use index only read when using order-by-index - Added keyread_time() to HEAP. The default keyread_time() was optimized for blocks and not suitable for HEAP. The effect was the HEAP prefered table scans over ranges for btree indexes. - Fixed get_sweep_read_cost() for HEAP tables - Ensure that range and ref have same cost for simple ranges Added a small cost (MULTI_RANGE_READ_SETUP_COST) to ranges to ensure we favior ref for range for simple queries. - Fixed that matching_candidates_in_table() uses same number of records as the rest of the optimizer - Added avg_io_cost() to JT_EQ_REF cost. This helps calculate the cost for HEAP and temporary tables better. A few tests changed because of this. - heap::read_time() and heap::keyread_time() adjusted to not add +1. This was to ensure that handler::keyread_time() doesn't give higher cost for heap tables than for normal tables. One effect of this is that heap and derived tables stored in heap will prefer key access as this is now regarded as cheap. - Changed cost for index read in sql_select.cc to match multi_range_read_info_const(). All index cost calculation is now done trough one function. - 'ref' will now use quick_cost for keys if it exists. This is done so that for '=' ranges, 'ref' is prefered over 'range'. - scan_time() now takes avg_io_costs() into account - get_delayed_table_estimates() uses block_size and avg_io_cost() - Removed default argument to test_if_order_by_key(); simplifies code
* Added page_range to records_in_range() to improve range statisticsMonty2020-03-276-18/+37
| | | | | | | | | | | | | | | | | | | | | | | Prototype change: - virtual ha_rows records_in_range(uint inx, key_range *min_key, - key_range *max_key) + virtual ha_rows records_in_range(uint inx, const key_range *min_key, + const key_range *max_key, + page_range *res) The handler can ignore the page_range parameter. In the case the handler updates the parameter, the optimizer can deduce the following: - If previous range's last key is on the same block as next range's first key - If the current key range is in one block - We can also assume that the first and last block read are cached! This can be used for a better calculation of IO seeks when we estimate the cost of a range index scan. The parameter is fully implemented for MyISAM, Aria and InnoDB. A separate patch will update handler::multi_range_read_info_const() to take the benefits of this change and also remove the double records_in_range() calls that are not anymore needed.
* Improve update handler (long unique keys on blobs)Monty2020-03-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | MDEV-21606 Improve update handler (long unique keys on blobs) MDEV-21470 MyISAM and Aria start_bulk_insert doesn't work with long unique MDEV-21606 Bug fix for previous version of this code MDEV-21819 2 Assertion `inited == NONE || update_handler != this' - Move update_handler from TABLE to handler - Move out initialization of update handler from ha_write_row() to prepare_for_insert() - Fixed that INSERT DELAYED works with update handler - Give an error if using long unique with an autoincrement column - Added handler function to check if table has long unique hash indexes - Disable write cache in MyISAM and Aria when using update_handler as if cache is used, the row will not be inserted until end of statement and update_handler would not find conflicting rows. - Removed not used handler argument from check_duplicate_long_entries_update() - Syntax cleanups - Indentation fixes - Don't use single character indentifiers for arguments
* Merge 10.4 into 10.5Marko Mäkelä2020-03-211-24/+25
|\
| * Merge 10.3 into 10.4Marko Mäkelä2020-03-201-24/+25
| |\
| | * Merge 10.2 into 10.3Marko Mäkelä2020-03-201-24/+25
| | |\ | | | | | | | | | | | | Also, clean up the test innodb_gis.geometry a little further.
| | | * MDEV-21981 Replace arithmetic + with bitwise OR when possibleMarko Mäkelä2020-03-191-24/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several macros such as sint2korr() and uint4korr() are using the arithmetic + operator while a bitwise or operator would suffice. GCC 5 and clang 5 and later can detect patterns consisting of bitwise or and shifts by multiples of 8 bits, such as those used in the InnoDB function mach_read_from_4(). They actually translate that verbose low-level code into high-level machine language (i486 bswap instruction or fused into the Haswell movbe instruction). We should do the same for MariaDB Server code that is outside InnoDB. Note: The Microsoft C compiler is lacking this optimization. There, we might consider using _byteswap_ushort(), _byteswap_ulong(), _byteswap_uint64(). But, those would lead to unaligned reads, which are bad for reasons stated in MDEV-20277. Besides, outside InnoDB, most data is already being stored in the native little-endian format of that compiler.
| | | * MDEV-21082: isnan/isinf compilation errors, isfinite warnings on MacOSVlad Lesin2019-11-192-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fix consists of three commits backported from 10.3: 1) Cleanup isnan() portability checks (cherry picked from commit 7ffd7fe9627d1f750a3712aebb4503e5ae8aea8e) 2) Cleanup isinf() portability checks Original problem reported by Wlad: re-compilation of 10.3 on top of 10.2 build would cache undefined HAVE_ISINF from 10.2, whereas it is expected to be 1 in 10.3. std::isinf() seem to be available on all supported platforms. (cherry picked from commit bc469a0bdf85400f7a63834f5b7af1a513dcdec9) 3) Use std::isfinite in C++ code This is addition to parent revision fixing build failures. (cherry picked from commit 54999f4e75f42baca484ae436b382ca8817df1dd)
| | | * MDEV-19740: Fix GCC 9.2.1 -Wmaybe-uninitialized on AMD64Marko Mäkelä2019-09-272-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For CMAKE_BUILD_TYPE=Debug, the default MYSQL_MAINTAINER_MODE=AUTO implies -Werror along with other flags in cmake/maintainer.cmake, which would break the debug builds when CMAKE_CXX_FLAGS include -O2. This fix includes a backport of 6dd3f24090ce2d237037eb09cf7db083ebbc92f9 from MariaDB 10.3.
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-03-171-1/+2
|\ \ \ \ | |/ / /
| * | | MDEV-16188: Fix clang 10 -Wimplicit-int-float-conversionMarko Mäkelä2020-03-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | mi_records_in_range(): Because HA_POS_ERROR cannot be accurately represented in double (it will be off by one), add an explicit cast to silence the warning.
* | | | MDEV-21743 Split up SUPER privilege to smaller privilegesAlexander Barkov2020-03-102-2/+2
| | | |
* | | | cleanup: PSI key is *always* the first argumentSergei Golubchik2020-03-102-6/+5
| | | |
* | | | perfschema memory related instrumentation changesSergei Golubchik2020-03-1019-57/+152
| | | |
* | | | Merge 10.4 into 10.5Marko Mäkelä2020-02-074-37/+32
|\ \ \ \ | |/ / /
| * | | MDEV-20001 Potential dangerous regression: INSERT INTO >=100 rows fail for ↵Sachin2020-02-033-36/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | myisam table with HASH indexes Problem:- So the issue is when we do bulk insert with rows > MI_MIN_ROWS_TO_DISABLE_INDEXES(100) , We try to disable the indexes to speedup insert. But current logic also disables the long unique indexes. Solution:- In ha_myisam::start_bulk_insert if we find long hash index (HA_KEY_ALG_LONG_HASH) we will not disable the index. This commit also refactors the mi_disable_indexes_for_rebuild function, Since this is function is called at only one place, it is inlined into start_bulk_insert mi_clear_key_active is added into myisamdef.h because now it is also used in ha_myisam.cc file. (Same is done for Aria Storage engine)
| * | | Fixed compiler warnings from gcc 7.4.1Monty2020-01-291-1/+2
| | | | | | | | | | | | | | | | - Fixed possible error in rocksdb/rdb_datadic.cc
* | | | MDEV-21581 Helper functions and methods for CHARSET_INFOAlexander Barkov2020-01-284-20/+22
| | | |
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-12-161-1/+1
|\ \ \ \ | |/ / /
| * | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-12-091-1/+1
| |\ \ \ | | |/ /
| | * | Lintian complains on spelling errorFaustin Lammler2019-12-021-1/+1
| | | | | | | | | | | | | | | | | | | | The lintian check complains on spelling error: https://salsa.debian.org/mariadb-team/mariadb-10.3/-/jobs/95739
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-11-191-3/+4
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2019-11-191-3/+4
| |\ \ \ | | |/ /
| | * | MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" ↵Sergei Petrunia2019-11-151-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | error Fix partitioning and DS-MRR to work together - In ha_partition::index_end(): take into account that ha_innobase (and other engines using DS-MRR) will have inited=RND when initialized for DS-MRR scan. - In ha_partition::multi_range_read_next(): if the MRR scan is using HA_MRR_NO_ASSOCIATION mode, it is not guaranteed that the partition's handler will store anything into *range_info. - In DsMrr_impl::choose_mrr_impl(): ha_partition will inquire partitions about how much memory their MRR implementation needs by passing *buffer_size=0. DS-MRR code didn't know about this (actually it used uint for buffer size calculation and would have an under-flow). Returning *buffer_size=0 made ha_partition assume that partitions do not need MRR memory and pass the same buffer to each of them. Now, this is fixed. If DS-MRR gets *buffer_size=0, it will return the amount of buffer space needed, but not more than about @@mrr_buffer_size. * Fix ha_{innobase,maria,myisam}::clone. If ha_partition uses MRR on its partitions, and partition use DS-MRR, the code will call handler->clone with TABLE (*NOT partition*) name as an argument. DS-MRR has no way of knowing the partition name, so the solution was to have the ::clone() function for the affected storage engine to ignore the name argument and get it elsewhere.
* | | | MDEV-12684 Show what config file a sysvar got a value fromSergei Golubchik2019-10-144-14/+15
| | | | | | | | | | | | | | | | | | | | change get_one_option() prototype to pass the filename and not to pass the redundant optid.
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-10-114-12/+0
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2019-10-104-12/+0
| |\ \ \ | | |/ /
| | * | Cleanup mman.h includesSergey Vojtovich2019-10-024-12/+0
| | | | | | | | | | | | | | | | As it is included from my_global.h already.
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-09-2519-29/+29
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2019-09-2519-29/+29
| |\ \ \ | | |/ /
| | * | Merge remote-tracking branch 'origin/10.2' into 10.3Alexander Barkov2019-09-2419-29/+29
| | |\ \ | | | |/
| | | * Merge remote-tracking branch 'origin/10.1' into 10.2Alexander Barkov2019-09-2419-29/+29
| | | |\
| | | | * Merge remote-tracking branch 'origin/5.5' into 10.1Alexander Barkov2019-09-2419-29/+29
| | | | |\
| | | | | * Fix spelling mistakes in MyISAM code commentsIan Gilfillan2019-09-2019-29/+29
| | | | | |
| | | | * | imporve clang buildEugene Kosov2019-06-252-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug Maintainer mode makes all warnings errors. This patch fix warnings. Mostly about deprecated `register` keyword. Too much warnings came from Mroonga and I gave up on it.
* | | | | | Merge 10.4 into 10.5Marko Mäkelä2019-09-061-1/+1
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.3 into 10.4, except for MDEV-20265Marko Mäkelä2019-08-231-1/+1
| |\ \ \ \ \ | | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MDEV-20265 commit e746f451d57def4be679caafc29976741b3e89f7 introduces DBUG_ASSERT(right_op == r_tbl) in st_select_lex::add_cross_joined_table(), and that assertion would fail in several tests that exercise joins. That commit was skipped in this merge, and a separate fix of MDEV-20265 will be necessary in 10.4.
| | * | | | MDEV-19740 Debug build of 10.3.15 FTBFSAleksey Midenkov2019-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replace LINT_INIT for non-struct types with ctor initializers; * Check BUILD_DEPS list is not empty so REMOVE_DUPLICATES won't throw error.
* | | | | | MDEV-20279 Increase Aria index length limitMonty2019-08-232-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Limit increased from 1000 to 2000. Avoiding stack overflow by only storing keys and pages on the stack in recursive functions if there is plenty of space on it. Other things: - Use less stack space for b-tree operations as we now only allocate as much space as needed instead of always allocating HA_MAX_KEY_LENGTH. - Replaced most usage of my_safe_alloca() in Aria with the stack_alloc interface. - Moved my_setstacksize() to mysys/my_pthread.c
* | | | | | Don't copy uninitialized bytes when copying varstringsMonty2019-08-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using field_conv(), which is called in case of field1=field2 copy in fill_records(), full varstring's was copied, including unitialized bytes. This caused valgrind to compilain about usage of unitialized bytes when using Aria static length records. Fixed by not using memcpy when copying varstrings but instead just copy the real bytes.
* | | | | | Revert "MDEV-20342 Turn Field::flags from a member to a method"Alexander Barkov2019-08-141-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e86010f909fb6b8c4ffd9d6df92991ac079e67e7. Reverting on Monty's request, as this change makes merging things from 10.5 to 10.2 much harder.
* | | | | | MDEV-20342 Turn Field::flags from a member to a methodAlexander Barkov2019-08-141-6/+5
| | | | | |
* | | | | | Merge 10.4 into 10.5Marko Mäkelä2019-08-133-3/+3
|\ \ \ \ \ \ | |/ / / / /
| * | | | | MDEV-19955 make argument of handler::ha_write_row() constEugene Kosov2019-07-053-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-19486 and one more similar bug appeared because handler::write_row() interface welcomes to modify buffer by storage engine. But callers are not ready for that thus bugs are possible in future. handler::write_row(): handler::ha_write_row(): make argument const
* | | | | | MDEV-17709 Remove handlerton::stateRobert Bindar2019-06-061-1/+0
|/ / / / /
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-1978-86/+79
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-15458 Segfault in heap_scan() upon UPDATE after ADD SYSTEM VERSIONINGSergei Golubchik2019-05-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | handler::write_row() should not destroy the state of the running index_search/index_next/... or rnd_init/rnd_next/... scan
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-05-1478-78/+78
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-05-1378-78/+78
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-1177-77/+77
| | | |\ \ | | | | |/