Commit graph

175559 commits

Author SHA1 Message Date
Alexander Barkov
cb16d753b2 MDEV-11337 Split Item::save_in_field() into virtual methods in Type_handler
Also fixes:
MDEV-11331 Wrong result for INSERT INTO t1 (datetime_field) VALUES (hybrid_function_of_TIME_data_type)
MDEV-11333 Expect "Impossible where condition" for WHERE timestamp_field>=DATE_ADD(TIMESTAMP'9999-01-01 00:00:00',INTERVAL 1000 YEAR)

This patch does the following:
1. Splits the function Item::save_in_field() into pieces:
- Item::save_str_in_field()
- Item::save_real_in_field()
- Item::save_decimal_in_field()
- Item::save_int_in_field()

2. Adds the missing "no_conversion" parameters to
   Item::save_time_in_field() and Item::save_date_in_field(),
   so this parameter is now correctly passed to
   set_field_to_null_with_conversions().
   This fixes the problem reported in 11333.

3. Introduces a new virtual method Type_handler::Item_save_in_field()
   and uses the methods Item::save_xxx_in_field() from the implementations
   of Type_handler_xxx::Item_save_in_field().

These changes additionally fix the problem reported in MDEV-11331,
as the old code erroneously handled expressions like
COALESE(datetime-expression) through the STRING_RESULT branch of
Item::save_in_field() and therefore they looked like string type expressions
for the target fields. Now such expressions are correctly handled by
Item::save_date_in_field().
2016-12-16 18:23:20 +04:00
Alexander Barkov
4b4efb0485 MDEV-11346 Move functions case_stmt_xxx and add_select_to_union_list as methods to LEX
The full list of functions moved:
int case_stmt_action_expr(LEX *, Item* expr);
int case_stmt_action_when(LEX *, Item *when, bool simple);
int case_stmt_action_then(LEX *);
bool add_select_to_union_list(LEX *,bool is_union_distinct,  bool is_top_level);

This is a preparatory change for "MDEV-10142 PL/SQL parser",
to reuse the code easier between sql_yacc.yy and coming soon sql_yacc_ora.yy.
2016-12-16 18:23:20 +04:00
Alexander Barkov
cba0092196 MDEV-11294 Move definitions of Derivation, DTCollation, Type_std_attributes from field.h and item.h to sql_type.h 2016-12-16 18:23:20 +04:00
Alexander Barkov
01546ee403 MDEV-11245 Move prepare_create_field and sp_prepare_create_field() as methods to Column_definition
Some upcoming tasks, e.g.:
- MDEV-10577 sql_mode=ORACLE: %TYPE in variable declarations
- MDEV-10914 ROW data type for stored routine variables

will need to reuse the code implemented in prepare_create_field(),
sp_prepare_create_field(), prepare_blob_field().

Before reusing this code, it's a good idea to move these global functions
as methods to Column_definition.

This patch:
- actually moves prepare_create_field(), sp_prepare_create_field(),
  prepare_blob_field() as methods to Column_definition
- makes sp_prepare_create_field() call prepare_create_field() at the end,
  to avoid duplicate code in MDEV-10577 and MDEV-10914.
- changes the return data type for prepare_create_field() from int to bool,
  to make it consistent with all other functions returning "ok" or "error".
- moves the implementation sp_head::fill_field_definition() from sp_head.cc
  to sp_head.h, as it now uses globally visible Column_definition methods,
  and is very simple, so inlining is now possible.
- removes the unused "LEX*" argument from sp_head::fill_field_definition()
2016-12-16 18:23:16 +04:00
Alexander Barkov
8b4f181c60 MDEV-10811 Change design from "Item is Type_handler" to "Item has Type_handler" 2016-12-16 17:31:40 +04:00
Alexander Barkov
e5dfe04da0 MDEV-11146 SP variables of the SET data type erroneously allow values with comma
There was a duplicate code to create TYPELIB from List<String>:
- In typelib() and mysql_prepare_create_table(), which was used to initialize
  table fields.
- create_typelib() and sp_prepare_create_field(), which was used to initialize
  SP variables.
create_typelib() was incomplete and didn't check for wrong SET values.

Fix:
- Moving the code from create_typelib() and mysql_prepare_create_field()
  to news methods Column_definition::create_interval_from_interval_list()
  and Column_definition::prepare_interval_field().
- Moving the code from calculate_interval_lengths() in sql_table.cc
  to a new method Column_definition::calculate_interval_lengths(), as it's now
  needed only in Column_definition::create_interval_from_interval_list()
- Reusing the new method Column_definition::prepare_interval_field() in both
  mysql_prepare_create_table() and sp_prepare_create_field(), instead of the
  old duplicate code pieces
- Removing global functions typelib() and create_typelib()

This patch also fixes:
MDEV-11155 Bad error message when creating a SET column with comma and non-ASCII characters
The problem was that ErrCongString() was called with a wrong "charset" parameter.
2016-12-16 17:31:40 +04:00
Alexander Barkov
239287b22e Starting the 10.3 branch 2016-12-16 17:31:40 +04:00
Alexey Botchkov
ce55094f4f MDEV-11572 JSON_DEPTH returns wrong results.
JSON depth calculation fixed.
2016-12-16 14:06:12 +04:00
Alexey Botchkov
30c231b03a MDEV-11569 JSON_ARRAY_INSERT produces an invalid result.
String insertion fixed.
2016-12-16 13:51:35 +04:00
Alexey Botchkov
beded4350f MDEV-JSON_CONTAINS_PATH returns incorrect results and produces wrong warning.
The Item_func_json_contains_path was mistakenly set with the
        no '*' paths limitation.
2016-12-16 12:43:44 +04:00
Alexey Botchkov
e5377be211 MDEV-11562 Assertion `js->state == JST_VALUE' failed in check_contains(json_engine_t*, json_engine_t*).
check_contains() fixed. When an item of an array is a complex
        structure, it can be half-read after the end of the recursive
        check_contains() call. So we just manually get to it's ending.
2016-12-16 12:32:56 +04:00
Sergei Golubchik
8938031bc7 InnoDB: don't stop purge threads if there's work to do
in slow shutdown mode don't stop purge threads until they've
purged everything there is
2016-12-15 09:35:25 +01:00
Sergei Golubchik
8d770859c9 InnoDB purge thread and other bg threads
in slow shutdown mode stop all bg threads that might generate
new undo records to purge before stopping purge threads.
2016-12-15 09:34:37 +01:00
Sergei Golubchik
eabb0aef12 sporadic crashes of innodb.innodb_prefix_index_restart_server
in slow shutdown mode purge threads really must exit only when there is
nothing to purge. Restore the trx_commit_disallowed check and
don't stop purge threads until all connection thread transactions
are gone.
2016-12-15 09:33:59 +01:00
Daniel Black
a8e0c6fd9b Travis: add refs for future capability - when travis catches up 2016-12-15 10:36:11 +04:00
Daniel Black
e14bdcb81c travis: gcc-5 and gcc-6 2016-12-15 10:36:11 +04:00
Elena Stepanova
9213ac8fd8 Follow-up for a411d7f4f6 - change in formatting of SHOW CREATE TABLE 2016-12-15 02:35:31 +02:00
Elena Stepanova
a1833ac5cc Follow-up for 180065ebb0 - removal of redundant parentheses 2016-12-15 02:34:02 +02:00
Igor Babaev
5cf6fd3e39 Adjusted test results after merge. 2016-12-14 12:11:02 -08:00
Igor Babaev
441fa0056d Fixed bug mdev-11488.
The patch for bug mdev-10882 tried to fix it by providing an
implementation of the virtual method build_clone for the class
Item_cache. It's turned out that it is not easy provide a valid
implementation for Item_cache::build_clone(). At the same time
if the condition that can be pushed into a materialized view
contains a cached item this item can be substituted for a basic
constant of the same value. In such a way we can avoid building
proper clones for Item_cache objects when constructing pushdown
conditions.
2016-12-14 10:13:52 -08:00
Daniel Black
e9ada86265 Travis: add lib{stemmer,xml2,pcre3}-dev 2016-12-14 10:54:03 +04:00
Sergei Golubchik
44e799590e buildbot issues
* rpm upgrade fix
* update test results
* valgrind warning
2016-12-13 21:42:30 +01:00
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