summaryrefslogtreecommitdiff
path: root/sql/table.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.1' into 10.2Sergei Golubchik2017-03-301-1/+1
|\
| * Merge branch '10.0' into 10.1Sergei Golubchik2017-03-211-1/+1
| |\
| | * MDEV-12261 build failure without P_SSergei Golubchik2017-03-151-1/+1
| | | | | | | | | | | | | | | restore mysql_file_delete_with_symlink() but let it use new my_handler_delete_with_symlink() mysys helper.
| * | Merge 10.0 into 10.1Marko Mäkelä2017-03-091-1/+1
| |\ \ | | |/ | | | | | | | | | | | | | | | | | | | | | Also, implement MDEV-11027 a little differently from 5.5 and 10.0: recv_apply_hashed_log_recs(): Change the return type back to void (DB_SUCCESS was always returned). Report progress also via systemd using sd_notifyf().
| | * Merge branch '5.5' into 10.0Vicențiu Ciorbaru2017-03-031-1/+1
| | |\
* | | | MDEV-11115 CHECK constraints are not shown in I_S.TABLE_CONSTRAINTSbb-10.2-MDEV-11115Jacob Mathew2017-03-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Added CHECK constraints to I_S.TABLE_CONSTRAINTS. Fixed a bug regarding virtual column definitions whose name is the field name. Added test case: check_constraint_show
* | | | MDEV-11114 Cannot drop column referenced by CHECK constraint: Unknown column ↵Sergei Golubchik2017-03-291-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | 'a' in 'virtual column function' clarify the error message
* | | | MDEV-10370 Check constraints on virtual columns fails on INSERT when column ↵Sergei Golubchik2017-03-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | not specified add columns needed for CHECK constraints not only to read_set, but also to vcol_set.
* | | | MDEV-11704 InnoDB: Failing assertion: dfield_is_null(dfield2) || dfield2->dataSergei Golubchik2017-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | relax innodb assertion, because Field_blob::store() clearly says that a data pointer can be zero if the length is zero.
* | | | MDEV-11640 gcol.gcol_select_myisam fails in buildbot on PowerSergei Golubchik2017-02-131-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JOIN_CACHE's were initialized in check_join_cache_usage() from make_join_readinfo(). After that make_join_readinfo() was looking whether it's possible to use keyread. Later, after make_join_readinfo(), optimizer decided whether to use filesort. And even later, at the execution time, from join_read_first(), keyread was actually enabled. The problem is, that if a query uses a vcol, base columns that it depends on are automatically added to the read_set - because they're needed to calculate the vcol. But if we're doing keyread, vcol is taken from the index, not calculated, and base columns do not need to be in the read set (even should not be - as they aren't getting values). The bug was that JOIN_CACHE used read_set with base columns, they were not read because of keyread, so it was caching garbage. So read_set is only known after the keyread was decided. And after the filesort was decided, as filesort doesn't use keyread. But check_join_cache_usage() needs to be done in make_join_readinfo(), as the code below depends on these checks, Fix: keep JOIN_CACHE checks where they were, but move initialization down to the very end of JOIN::optimize_inner. If keyread was enabled, update the read_set to include only columns that are part of the index. Copy the keyread logic from join_read_first() to happen at optimize time.
* | | | cleanup: handler::key_readSergei Golubchik2017-02-131-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | * rename to "keyread" (to avoid conflicts with tokudb), * change from bool to uint and store the keyread index number there * provide a bool accessor to check if keyread is enabled
* | | | cleanup: TABLE::mark_columns_used_by_index()Sergei Golubchik2017-02-131-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mark_columns_used_by_index used to do reset + mark_columns_used_by_index_no_reset + start keyread + set bitmaps Now prepare_for_keyread does that, while mark_columns_used_by_index does only reset + mark_columns_used_by_index_no_reset, just as its name suggests.
* | | | bugfix: don't calculate vcols if doing keyreadSergei Golubchik2017-02-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | old code didn't calculate vcols that were part of keyread, but calculated other vcols. It was wrong - there was no guarantee that vcol's base columns were part of keyread. Technically it's possible for the vcol not be a part of keyread, but all its base columns being part of keyread. But currently the optimizer doesn't do that, keyread is only used if it covers all columns used in the query. This fixes crashes of vcol.vcol_trigger_sp_innodb
* | | | cleanup: remove TABLE::add_read_columns_used_by_indexSergei Golubchik2017-02-131-24/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TABLE::add_read_columns_used_by_index() is conceptually wrong, it *adds* columns used by index to the bitmap, without clearing it first. But it also enables keyread, meaning that *only* columns from the index will be read. It is supposed to be used to add columns used by an index to a bitmap that already has columns of a primary key - for engines where a primary key is part of every index. The correct fix is to change mark_columns_used_by_index() to take into account extended keys. this reverts 1d0acc7754a44613d2ad and cf97cbd1db762c443aa3
* | | | bugfix: TABLE::mark_columns_used_by_index_no_resetSergei Golubchik2017-02-131-6/+0
| | | | | | | | | | | | | | | | | | | | it should not mark base columns that a vcol depends on, because keyread (on a vcol) will not read them
* | | | cleanup: mark_columns_used_by_index_no_reset in handler::get_auto_incrementSergei Golubchik2017-02-131-6/+6
| | | | | | | | | | | | | | | | use table->mark_columns_used_by_index, don't copy it
* | | | cleanup: mark_columns_used_by_index_no_reset in opt_range.ccSergei Golubchik2017-02-131-6/+5
| | | | | | | | | | | | | | | | use table->mark_columns_used_by_index, don't copy it
* | | | bugfix: TABLE::mark_columns_used_by_indexSergei Golubchik2017-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Do *not* modify write_set. keyread only affects what columns are *read*, UPDATE statement can *write* into columns that aren't part of the keyread.
* | | | cleanup: TABLE::non_determinstic_insertSergei Golubchik2017-02-131-13/+2
| | | | | | | | | | | | | | | | move the check where it make sense, remove incorrect comment
* | | | MDEV-11836 vcol.vcol_keys_myisam fails in buildbot and outsideSergei Golubchik2017-02-131-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge branch 'bb-10.2-serg-merge' into 10.2Sergei Golubchik2017-02-111-23/+17
|\ \ \ \
| * \ \ \ Merge branch '10.1' into 10.2Sergei Golubchik2017-02-101-23/+17
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.0' into 10.1mariadb-10.1.21Sergei Golubchik2017-01-171-2/+4
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.0Sergei Golubchik2017-01-171-2/+4
| | | |\ \ | | | | |/
| | | | * bugfix: cmp_item_row::alloc_comparators() allocated on the wrong arenaSergei Golubchik2017-01-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it used current_thd->alloc() and allocated on the thd's execution arena, not on table->expr_arena. Remove THD::arena_for_cached_items that is temporarily set in update_virtual_fields(), and replaces THD arena in get_datetime_value(). Instead set THD arena to table->expr_arena for the whole duration of update_virtual_fields()
| | * | | Merge branch '10.0' into 10.1Vicențiu Ciorbaru2017-01-161-8/+5
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.0Vicențiu Ciorbaru2017-01-141-8/+5
| | | |\ \ | | | | |/
| | | | * MDEV-11706 Assertion `is_stat_field || !table || (!table->write_set || ↵Sergei Golubchik2017-01-111-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bitmap_is_set(table->write_set, field_index) || (table->vcol_set && bitmap_is_set(table->vcol_set, field_index)))' failed in Field_time::store_TIME_with_warning vcols and triggers. Revert 094f4cf77890c5a747a57cf2bed149b0b6933507, backport the correct fix (Table_triggers_list::mark_fields_used() not marking vcols) from 10.2.
* | | | | MDEV-10554: Assertion ↵Oleksandr Byelkin2017-02-101-1/+3
|/ / / / | | | | | | | | | | | | | | | | | | | | `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed in TABLE_LIST::set_check_merged() Mark and check excluded because of merging derived tables and views.
* | | | MDEV-11597 Assertion when doing select from virtual column with impossible valueMonty2017-01-111-4/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changed error handlers interface so that they can change error level in the handler - Give warnings and errors when calculating virtual columns - On insert/update error is fatal in strict mode. - SELECT and DELETE will only give a warning if a virtual field generates an error - Added VCOL_UPDATE_FOR_DELETE and VCOL_UPDATE_INDEX_FOR_REPLACE to be able to easily detect in update_virtual_fields() if we should use an error handler to mask errors or not.
* | | | Fixes for failures in test scripts and removal of some compiler warningsMonty2017-01-111-2/+3
| | | | | | | | | | | | | | | | | | | | - rpl_gtid_stop_start: Random failure - sysvars_innodb,32bit: Fixes for 32 bit
* | | | New simpler bugfix for UPDATE and virtual BLOBsMonty2017-01-111-10/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When updating a table with virtual BLOB columns, the following might happen: - an old record is read from the table, it has no virtual blob values - update_virtual_fields() is run, vcol blob gets its value into the record. But only a pointer to the value is in the table->record[0], the value is in Field_blob::value String (but it doesn't have to be! it can be in the record, if the column is just a copy of another columns: ... b VARCHAR, c BLOB AS (b) ...) - store_record(table,record[1]), old record now is in record[1] - fill_record() prepares new values in record[0], vcol blob is updated, new value replaces the old one in the Field_blob::value - now both record[1] and record[0] have a pointer that points to the *new* vcol blob value. Or record[1] has a pointer to nowhere if Field_blob::value had to realloc. To fix this I have introduced a new String object 'read_value' in Field_blob. When updating virtual columns when a row has been read, the allocated value is stored in 'read_value' instead of 'value'. The allocated blobs for the new row is stored in 'value' as before. I also made, as a safety precaution, the insert delayed handling of blobs more general by using value to store strings instead of the record. This ensures that virtual functions on delayed insert should work in as in the case of normal insert. Triggers are now properly updating the read, write and vcol maps for used fields. This means that we don't need VCOL_UPDATE_FOR_READ_WRITE anymore and there is no need for any other special handling of triggers in update_virtual_fields(). To be able to test how many times virtual fields are invoked, I also relaxed rules that one can use local (@) variables in DEFAULT and non persistent virtual field expressions.
* | | | Fixed bugs found by mysql-test-run:Monty2017-01-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | - privilege_table_io.test didn't properly reset roles_mapping - Fixed memory allocation problem with CHECK CONSTRAINT, found when running --valgrind main.check_constraint
* | | | Fixed bug mdev-11674.Igor Babaev2017-01-041-11/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. The rows of a recursive CTE at some point may overflow the HEAP temporary table containing them. At this point the table is converted to a MyISAM temporary table and the new added rows are placed into this MyISAM table. A bug in the of select_union_recursive::send_data prevented the server from writing the row that caused the overflow into the temporary table used for the result of the iteration steps. This could lead, in particular,to a premature end of the iterations. 2. The method TABLE::insert_all_rows_into() that was used to copy all rows of one temporary table into another did not take into account that the destination temporary table must be converted to a MyISAM table at some point. This patch fixed this problem. It also renamed the method into TABLE::insert_all_rows_into_tmp_table() and added an extra parameter needed for the conversion.
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-12-291-0/+9
|\ \ \ \ | |/ / /
| * | | MDEV-10435 crash with bad stat tables.Alexey Botchkov2016-12-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Functions from sql/statistics.cc don't seem to expect stat tables to fail or to have inadequate structure. Table open errors suppressed and some validity checks added. Invalid tables reported to the server log.
* | | | buildbot issuesSergei Golubchik2016-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * rpm upgrade fix * update test results * valgrind warning
* | | | bugfix: reset MODE_NO_BACKSLASH_ESCAPES during vcol parsingSergei Golubchik2016-12-121-0/+3
| | | |
* | | | bugfix: non-deterministic vcols in partitioningSergei Golubchik2016-12-121-0/+2
| | | |
* | | | cleanup: unpack_vcol_info_from_frmSergei Golubchik2016-12-121-102/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * do setup/cleanup for charset and arena only once per table not for every vcol * don't copy every vcol expression into table's memroot for parsing, do it in a temporary String buffer that is freed at the end * add asserts
* | | | rename Virtual_column_info::expr_itemSergei Golubchik2016-12-121-23/+23
| | | | | | | | | | | | | | | | | | | | now, when expr_str is gone, expr_item can be unambiguously renamed to expr.
* | | | store/show vcols as item->print()Sergei Golubchik2016-12-121-182/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | otherwise we'd need to store sql_mode *per vcol* (consider CREATE INDEX...) and how SHOW CREATE TABLE would support that? Additionally, get rid of vcol::expr_str, just to make sure the string is always generated and never leaked in the original form.
* | | | cleanup: FOREIGN_KEY_INFOSergei Golubchik2016-12-121-0/+14
| | | | | | | | | | | | | | | | | | | | instead of returning strings for CASCADE/RESTRICT from every storage engine, use enum values
* | | | bugfix: remove broken insert t values () optimizationSergei Golubchik2016-12-121-1/+0
| | | | | | | | | | | | | | | | | | | | * wrong results for 5.7 and 10.1- vcols, and for indexed vcols * only helps in rare cases and only minimally
* | | | cleanup: remove now-unused TABLE::merge_keysSergei Golubchik2016-12-121-1/+0
| | | |
* | | | bugfix: mark_columns_needed_for_updateSergei Golubchik2016-12-121-11/+25
| | | | | | | | | | | | | | | | | | | | | | | | cannot use TABLE:merge_keys for that, because Field::part_of_key was designed to mark fields for KEY_READ, so a field is not a "part of key", if only prefix of the field is.
* | | | MDEV-5800 MyISAM support for indexed vcolsSergei Golubchik2016-12-121-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * don't issue an error for ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN * support keyread on vcols * callback into the server to compute vcol values from mi_check/mi_repair * DMLs just work. Automatically.
* | | | TABLE::update_virtual_field to compute just one vcolSergei Golubchik2016-12-121-0/+12
| | | | | | | | | | | | | | | | | | | | will be used later by storage engines (e.g. in MyISAM repair or in InnoDB purge)
* | | | cleanup: set_field_ptr()Sergei Golubchik2016-12-121-0/+12
| | | |
* | | | cleanup: TABLE::update_virtual_fieldsSergei Golubchik2016-12-121-21/+17
| | | | | | | | | | | | | | | | | | | | Make update_virtual_fields() a method of TABLE, to be consistent with TABLE::update_default_fields().