Commit graph

175537 commits

Author SHA1 Message Date
Marko Mäkelä
65b4d7457e Merge the test innodb.innodb_misc1 into innodb.innodb. 2016-12-13 11:52:23 +02:00
Alexey Botchkov
d26b9f670d MDEV-11470 JSON_KEYS accepts arguments in invalid format.
Now JSON functions return warnings if arguments are invalid.
2016-12-13 12:39:48 +04:00
Sergei Golubchik
1b7a794b73 MDEV-11540 Unexpected system threads in the process list
name innodb background threads as such
2016-12-12 22:33:27 +01:00
Sergei Golubchik
85416269c3 MDEV-11518 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed in Field_long::val_int()
QUICK_RANGE_SELECT::init_ror_merged_scan() should
also set and restore TABLE::vcol_set
2016-12-12 20:44:46 +01:00
Sergei Golubchik
c697ddc315 cleanup: remove unused handler table flag 2016-12-12 20:44:46 +01:00
Sergei Golubchik
b3e3356557 bugfix: reset MODE_NO_BACKSLASH_ESCAPES during vcol parsing 2016-12-12 20:44:46 +01:00
Sergei Golubchik
a9a362d3fd Aria: test for ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN
Aria supports virtual columns, but does not support indexes
on virtual columns. Let's issue an appropriate error in this case.
2016-12-12 20:44:46 +01:00
Sergei Golubchik
9d7c3cbe18 CONNECT: simple vcol test 2016-12-12 20:44:45 +01:00
Sergei Golubchik
5d5e83277f weird compilation fix
strangely enough, ?: variant does not link in some older gcc versions:

sql/sql_table.cc:6409: undefined reference to `Alter_inplace_info::ALTER_STORED_GCOL_EXPR'
sql/sql_table.cc:6409: undefined reference to `Alter_inplace_info::ALTER_VIRTUAL_GCOL_EXPR'
2016-12-12 20:44:45 +01:00
Sergei Golubchik
8c876adfb6 Item_func_like: print a not like b instead of !(a like b) 2016-12-12 20:44:45 +01:00
Sergei Golubchik
180065ebb0 Item::print(): remove redundant parentheses
by introducing new Item::precedence() method and using it
to decide whether parentheses are required
2016-12-12 20:44:41 +01:00
Sergei Golubchik
1db438c833 MDEV-11066 use MySQL terminology for "virtual columns" 2016-12-12 20:35:51 +01:00
Sergei Golubchik
6eaa5fd210 bugfix: InnoDB doesn't support ICP on vcols 2016-12-12 20:35:50 +01:00
Sergei Golubchik
44ca4993b8 bugfix: partitioning and keyread on an indexed vcol 2016-12-12 20:35:50 +01:00
Sergei Golubchik
2a0f7a34d6 bugfix: non-deterministic vcols in partitioning 2016-12-12 20:35:50 +01:00
Sergei Golubchik
d1f3763323 bugfix: non-deterministic vcols in indexes 2016-12-12 20:35:49 +01:00
Sergei Golubchik
6b0f4c24ab cleanup: unpack_vcol_info_from_frm
* 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
2016-12-12 20:35:49 +01:00
Sergei Golubchik
a72f1deb2d rename Virtual_column_info::expr_item
now, when expr_str is gone, expr_item can be unambiguously
renamed to expr.
2016-12-12 20:35:48 +01:00
Sergei Golubchik
a411d7f4f6 store/show vcols as item->print()
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.
2016-12-12 20:35:41 +01:00
Sergei Golubchik
8b3b6dc377 test how MDL blocks InnoDB purge
it must, because purge opens a table that might be being altered right now
2016-12-12 20:27:43 +01:00
Sergei Golubchik
1cae1af6f9 MDEV-5800 InnoDB support for indexed vcols
* remove old 5.2+ InnoDB support for virtual columns
  * enable corresponding parts of the innodb-5.7 sources
  * copy corresponding test cases from 5.7
  * copy detailed Alter_inplace_info::HA_ALTER_FLAGS flags from 5.7
     - and more detailed detection of changes in fill_alter_inplace_info()
  * more "innodb compatibility hooks" in sql_class.cc to
     - create/destroy/reset a THD (used by background purge threads)
     - find a prelocked table by name
     - open a table (from a background purge thread)

  * different from 5.7:
    - new service thread "thd_destructor_proxy" to make sure all THDs are
      destroyed at the correct point in time during the server shutdown
    - proper opening/closing of tables for vcol evaluations in
       + FK checks (use already opened prelocked tables)
       + purge threads (open the table, MDLock it, add it to tdc, close
         when not needed)
    - cache open tables in vc_templ
    - avoid unnecessary allocations, reuse table->record[0] and table->s->default_values
    - not needed in 5.7, because it overcalculates:
      + tell the server to calculate vcols for an on-going inline ADD INDEX
      + calculate vcols for correct error messages

  * update other engines (mroonga/tokudb) accordingly
2016-12-12 20:27:42 +01:00
Sergei Golubchik
7fca91f2b4 cleanup: InnoDB, dict_create_add_foreign_to_dictionary()
remove 'table' argument, remnant of 5.6, does not exist in 5.7
2016-12-12 20:27:42 +01:00
Sergei Golubchik
528dd5f20c cleanup: InnoDB, remove index_field_t::col_name
* remnant of 5.6, does not exist in 5.7. bad merge?
* also remove dict_table_get_col_name_for_mysql(), it was only
  used when index_field_t::col_name was not NULL
2016-12-12 20:27:41 +01:00
Sergei Golubchik
b66976abb4 cleanup: InnoDB, various minor issues
* fix "unused pending_checkpoint_mutex_key" compiler warning
* clarify/simplify get_field_offset()
* typos, comments
* unused (forgotten) declaration of create_options_are_invalid()
* fix my_error(ER_WRONG_KEY_COLUMN) calls
* crash in row_upd_sec_index_entry()
* double if (ret != 0)
* don't duplucate PSI_INSTRUMENT_ME lines
* useless break; after return();
* remove unused xtradb-only "cursor_read_view" stuff
* code formatting
* simplify dropped column detection
* redundant assignment
2016-12-12 20:27:41 +01:00
Sergei Golubchik
a6f05b9292 cleanup: redundant casts in THD::dec_thread_count
and THD::inc_thread_count
2016-12-12 20:27:41 +01:00
Sergei Golubchik
0d6a773ae1 cleanup: unused handler::check_if_supported_virtual_columns() 2016-12-12 20:27:40 +01:00
Sergei Golubchik
2614a0ab0f extend prelocking to FK-accessed tables 2016-12-12 20:27:40 +01:00
Sergei Golubchik
f136291098 cleanup: sp_head::add_used_tables_to_table_list()
Use TABLE::init_one_table(), don't duplicate it.
Put additional initializations into TABLE::init_one_table_for_prelocking()
2016-12-12 20:27:40 +01:00
Sergei Golubchik
a3614d33e8 cleanup: FOREIGN_KEY_INFO
instead of returning strings for CASCADE/RESTRICT
from every storage engine, use enum values
2016-12-12 20:27:39 +01:00
Sergei Golubchik
94462aa9e6 bugfix: remove broken insert t values () optimization
* wrong results for 5.7 and 10.1- vcols, and for indexed vcols
* only helps in rare cases and only minimally
2016-12-12 20:27:39 +01:00
Sergei Golubchik
56c1f8da4b bugfix: table->get_fields_in_item_tree=true
partitioning was setting subj as a partitioning-specific
hack (GET_FIXED_FIELDS_FLAG field flag to detect partitioning fields)
inside init_lex_with_single_table(). But vcols also use
init_lex_with_single_table(), they run fix_fields()
in open_table_from_share() before partitioning and this messes up
partitioning GET_FIXED_FIELDS_FLAG logic.
2016-12-12 20:27:39 +01:00
Sergei Golubchik
f73bdb685d bugfix: UPDATE and virtual BLOBs
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 resolve this we unlink vcol blobs from the pointer to the
data (in the record[1]). Because the value is not *always* in
the Field_blob::value String, we need to remember what blobs
were unlinked. The orphan memory must be freed manually.

To complicate the matter, ha_update_row() is also used in
multi-update, in REPLACE, in INSERT ... ON DUPLICATE KEY UPDATE,
also on REPLACE ... SELECT, REPLACE DELAYED, and LOAD DATA REPLACE, etc
2016-12-12 20:27:38 +01:00
Sergei Golubchik
aebb1038aa bugfix: multi-UPDATE, vcols, const tables
multi-update was setting up read_set/vcol_set in
multi_update::initialize_tables() that is invoked after
the optimizer (JOIN::optimize_inner()). But some rows - if they're from
const tables - will be read already in the optimizer, and these rows
will not have all necessary column/vcol values.

* multi_update::initialize_tables() uses results from the optimizer
  and cannot be moved to be called earlier.
* multi_update::prepare() is called before the optimizer, but
  it cannot set up read_set/vcol_set, because the optimizer
  might reset them (see SELECT_LEX::update_used_tables()).

As a fix I've added a new method, select_result::prepare_to_read_rows(),
it's called from inside the optimizer just before make_join_statistics().
2016-12-12 20:27:38 +01:00
Sergei Golubchik
0e401bf7bf bugfix: move vcol calculations down into the handler
This fixes a bug where handler::read_range_first (for example)
needed to compare vcol values that were not calculated yet.

As a bonus it fixes few cases where vcols were calculated twice
2016-12-12 20:27:38 +01:00
Sergei Golubchik
b8f51c04d3 bugfix: update-behind-insert
sql_insert.cc calls handler->ha_update_row() for
REPLACE and INSERT... ON DUPLICATE KEY UPDATE
2016-12-12 20:27:37 +01:00
Sergei Golubchik
54ab7db733 cleanup: remove now-unused TABLE::merge_keys 2016-12-12 20:27:37 +01:00
Sergei Golubchik
b38ff28ade bugfix: mark_columns_needed_for_update
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.
2016-12-12 20:27:36 +01:00
Sergei Golubchik
d137b4dbba MDEV-5800 MyISAM support for indexed vcols
* 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.
2016-12-12 20:27:36 +01:00
Sergei Golubchik
a418c99200 gcol mysql-test suite from 5.7
update tests and results, fix bugs
2016-12-12 20:27:36 +01:00
Sergei Golubchik
4136968ca0 enable spatial indexes in innodb vcol tests 2016-12-12 20:27:35 +01:00
Sergei Golubchik
c2b2cb8acd TABLE::update_virtual_field to compute just one vcol
will be used later by storage engines (e.g. in MyISAM repair or in
InnoDB purge)
2016-12-12 20:27:35 +01:00
Sergei Golubchik
2cdcf141f5 make myisamchk -d ignore HA_CREATE_RELIES_ON_SQL_LAYER
because it's only doing to show the table structure, not look
at the data.
2016-12-12 20:27:35 +01:00
Sergei Golubchik
5d6aab809d cleanup: minor issues in MyISAM 2016-12-12 20:27:35 +01:00
Sergei Golubchik
961fc6a673 cleanup: T_REP/T_REP_BY_SORT/T_REP_PARALLEL in MyISAM
always set them according to the repair method used
2016-12-12 20:27:34 +01:00
Sergei Golubchik
b634bd50ed cleanup: move all Item processors together 2016-12-12 20:27:34 +01:00
Sergei Golubchik
acfc3ba54b cleanup: remove ONLY_FOR_MYSQL_CLOSED_SOURCE_SCHEDULED 2016-12-12 20:27:34 +01:00
Sergei Golubchik
d4170f64fc cleanup: set_field_ptr() 2016-12-12 20:27:33 +01:00
Sergei Golubchik
65e53c8bc6 cleanup: Field_blob::get_ptr()
and declare few other Field getters to be 'const'
2016-12-12 20:27:33 +01:00
Sergei Golubchik
9a3ec79b53 cleanup: TABLE::update_virtual_fields
Make update_virtual_fields() a method of TABLE, to be consistent
with TABLE::update_default_fields().
2016-12-12 20:27:33 +01:00
Sergei Golubchik
8b6c0542db bugfix: stored column depends on virtual depends on updated
TABLE::mark_virtual_col() was polluting table->vcol_set
and that confused the following mark_virtual_col()
2016-12-12 20:27:32 +01:00