1. 17 Dec, 2016 2 commits
  2. 16 Dec, 2016 21 commits
    • Alexander Barkov's avatar
      MDEV-11503 Introduce Type_handler::make_in_vector() and... · 93bc7283
      Alexander Barkov authored
      MDEV-11503 Introduce Type_handler::make_in_vector() and Item_func_in_fix_comparator_compatible_types()
      
      This patch implements the task according to the description:
      
      1. The old code from Item_func_in::fix_length_and_dec() was decomposed
      into smaller methods:
      - all_items_are_consts()
      - compatible_types_scalar_bisection_possible()
      - compatible_types_row_bisection_possible()
      - fix_in_vector()
      - fix_for_scalar_comparison_using_bisection()
      - fix_for_scalar_comparison_using_cmp_items()
      - fix_for_row_comparison_using_bisection()
      - fix_for_row_comparison_using_cmp_items()
      
      The data type dependend pieces where moved as methods to Type_handler.
      
      2. Splits in_datetime into separate:
         - in_datetime, for DATETIME and DATE,
         - in_time, for TIME
         to make the code more symmetric across data types.
      
      Additionally:
      - Adds a test func_debug.test to see which calculation strategy
        (bisect or no bisect) is chosen to handle IN with various arguments.
      - Adds a new helper method (to avoid duplicate code):
        cmp_item_rows::prepare_comparators()
      - Changes the propotype for cmp_item_row::alloc_comparators(),
        to avoid duplicate code, and to use less current_thd.
      - Changes "friend" sections in cmp_item_row and in_row from
        an exact Item_func_in method to the entire class Item_func_in,
        as their internals are now needed in multiple Item_func_in methods.
      - Added more comments (e.g. on bisection, on the problem reported in MDEV-11511)
      93bc7283
    • Alexander Barkov's avatar
    • Alexander Barkov's avatar
      MDEV-11485 Split Item_func_between::val_int() into virtual methods in Type_handler · cfda0a71
      Alexander Barkov authored
      - Removes "Item_result Item_func_opt_neg::m_compare_type" and introduces
        "Type_handler_hybrid_field_type Item_func_opt_neg::m_comparator" instead.
      
      - Removes Item_func_between::compare_as_dates, because
        the new member m_comparator now contains the precise information
        about the data type that is used for comparison, which is important
        for TIME vs DATETIME.
      
      - Adds a new method:
        Type_handler_hybrid_field_type::aggregate_for_comparison(const Type_handler*),
        as a better replacement for item_cmp_type(), which additionally can handle
        TIME vs DATE/DATETIME/TIMESTAMP correctly. Additionally, it correctly
        handles TIMESTAMP which fixes the problem reported in MDEV-11482.
        The old compare_as_dates/find_date_time_item() based code didn't handle
        comparison between TIME and TIMESTAMP correctly and erroneously used TIME
        comparison instead of DATETIME comparison.
      
      - Adds a new method:
        Type_handler_hybrid_field_type::aggregate_for_comparison(Item **, uint nitems),
        as a better replacement for agg_cmp_type(), which can handle TIME.
      - Splits Item_func_between::val_int() into pieces val_int_cmp_xxx(),
        one new method per XXX_RESULT.
      - Adds a new virtual method Type_handler::Item_func_between_val_int()
        whose implementations use Item_func_between::val_int_cmp_xxx().
      - Makes type_handler_longlong and type_handler_newdecimal public,
        as they are now needed in item_cmpfunc.cc.
      
      Note:
      This patch does not change Item_func_in to use the new aggregation methods,
      so it still uses collect_cmp_type()/item_cmp_type() based aggregation.
      Item_func_in will be changed in a separate patch and item_cmp_type() will be
      removed.
      cfda0a71
    • Alexander Barkov's avatar
      Moving LEX::set_last_field_type() to Column_definition::set_attributes() · 1c1d8fe9
      Alexander Barkov authored
      This is an extraction from the patch for MDEV-10577, which is not
      directly related to %TYPE implementation. This patch does the following:
      - Moves LEX::set_last_field_type() to Column_definition::set_attributes()
      - Adds initialization of Column_definition members length, decimals,
        charset, on_update into the constructor.
      - Column_definition::set_attributes() now does not set length and decimal
        to 0 any more, as they are not initialized in the constructor.
      - Move Column_definition::prepare_interval_field() from field.h to field.cc,
        as it's too huge.
      1c1d8fe9
    • Alexander Barkov's avatar
    • Alexander Barkov's avatar
    • Alexander Barkov's avatar
      MDEV-11365 Split the data type and attribute related code in... · 9185f8d4
      Alexander Barkov authored
      MDEV-11365 Split the data type and attribute related code in Item_sum_hybrid::fix_fields into Type_handler::Item_sum_hybrid_fix_length_and_dec()
      
      This patch:
      - Implements the task according to the description
      - Adds a new class Type_handler_numeric as a common parent
        for Type_handler_real_result, Type_handler_int_result,
        Type_handler_decimal_result, to share the common code
        between numeric data type handlers.
      - Removes the dedundant call for collation.set(item->collation) in
        Item_sum_hybrid::setup_hybrid(), because setup_hybrid() is called
        either after fix_length_and_dec() or afte ther constructor
        Item_sum_hybrid(THD *thd, Item_sum_hybrid *item),
        so the collation is already properly set in all cases.
      9185f8d4
    • Alexander Barkov's avatar
      MDEV-11357 Split Item_cache::get_cache() into virtual methods in Type_handler · 749bbb3d
      Alexander Barkov authored
      This patch:
      - Adds a new virtual method Type_handler::Item_get_cache
      - Splits moves Item_cache::get_cache() into the new method, every
        "case XXX_RESULT" to the corresponding Type_handler_xxx::Item_get_cache.
      - Adds Item::get_cache as a convenience wrapper, to make the caller code
        shorter.
      - Changes the last argument of Arg_comparator::cache_converted_constant()
        from Item_result to "const Type_handler *".
      - Removes subselect_engine::cmp_type, subselect_engine::res_type,
        subselect_engine::res_field_type and derives subselect_engine
        from Type_handler_hybrid_field_type instead.
      - Makes Type_handler_varchar public, as it's now needed as the
        default data type handler for subselect_engine.
      749bbb3d
    • Alexander Barkov's avatar
      MDEV-11347 Move add_create_index_prepare(), add_key_to_list(),... · 352ff9cc
      Alexander Barkov authored
      MDEV-11347 Move add_create_index_prepare(), add_key_to_list(), set_trigger_new_row(), set_local_variable(), set_system_variable(), create_item_for_sp_var() as methods to LEX
      
      Moving another banch of functions implemented in sql_yacc.yy as methods to LEX,
      to be able to reuse them between sql_yacc.yy and sql_yacc_ora.yy easier.
      The list of functions:
      - add_create_index_prepare()
      - add_key_to_list()
      - set_trigger_new_row()
      - set_local_variable()
      - set_system_variable()
      - create_item_for_sp_var()
      352ff9cc
    • Alexander Barkov's avatar
      MDEV-11344 Split Arg_comparator::set_compare_func() into virtual methods in Type_handler · 26378280
      Alexander Barkov authored
      This patch:
      - Introduces a new virtuial method Type_handler::set_comparator_func
        and moves pieces of the code from the switch in
        Arg_comparator::set_compare_func into the corresponding
        Type_handler_xxx::set_comparator_func.
      - Adds Type_handler::get_handler_by_cmp_type()
      - Moves Type_handler_hybrid_field_type::get_handler_by_result_type() to
        a static method Type_handler::get_handler_by_result_type(),
        for symmetry with similar methods:
        * Type_handler::get_handler_by_field_type()
        * Type_handler::get_handler_by_real_type()
        * Type_handler::get_handler_by_cmp_type()
      - Introduces Type_handler_row, to unify the code for the scalar
        data types and the ROW data type (currently for comparison purposes only).
      - Adds public type_handler_row, as it's now needed in item_row.h
      - Makes type_handler_null public, as it's now needed in item_cmpfunc.h
        Note, other type_handler_xxx will become public as well later.
      - Removes the global variable Arg_comparator::comparator_matrix,
        as it's not needed any more.
      26378280
    • Alexander Barkov's avatar
      MDEV-11337 Split Item::save_in_field() into virtual methods in Type_handler · cb16d753
      Alexander Barkov authored
      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().
      cb16d753
    • Alexander Barkov's avatar
      MDEV-11346 Move functions case_stmt_xxx and add_select_to_union_list as methods to LEX · 4b4efb04
      Alexander Barkov authored
      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.
      4b4efb04
    • Alexander Barkov's avatar
      MDEV-11294 Move definitions of Derivation, DTCollation, Type_std_attributes... · cba00921
      Alexander Barkov authored
      MDEV-11294 Move definitions of Derivation, DTCollation, Type_std_attributes from field.h and item.h to sql_type.h
      cba00921
    • Alexander Barkov's avatar
      MDEV-11245 Move prepare_create_field and sp_prepare_create_field() as methods to Column_definition · 01546ee4
      Alexander Barkov authored
      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()
      01546ee4
    • Alexander Barkov's avatar
    • Alexander Barkov's avatar
      MDEV-11146 SP variables of the SET data type erroneously allow values with comma · e5dfe04d
      Alexander Barkov authored
      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.
      e5dfe04d
    • Alexander Barkov's avatar
      Starting the 10.3 branch · 239287b2
      Alexander Barkov authored
      239287b2
    • Alexey Botchkov's avatar
      MDEV-11572 JSON_DEPTH returns wrong results. · ce55094f
      Alexey Botchkov authored
              JSON depth calculation fixed.
      ce55094f
    • Alexey Botchkov's avatar
      MDEV-11569 JSON_ARRAY_INSERT produces an invalid result. · 30c231b0
      Alexey Botchkov authored
              String insertion fixed.
      30c231b0
    • Alexey Botchkov's avatar
      MDEV-JSON_CONTAINS_PATH returns incorrect results and produces wrong warning. · beded435
      Alexey Botchkov authored
              The Item_func_json_contains_path was mistakenly set with the
              no '*' paths limitation.
      beded435
    • Alexey Botchkov's avatar
      MDEV-11562 Assertion `js->state == JST_VALUE' failed in... · e5377be2
      Alexey Botchkov authored
      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.
      e5377be2
  3. 15 Dec, 2016 7 commits
  4. 14 Dec, 2016 3 commits
    • Igor Babaev's avatar
      Adjusted test results after merge. · 5cf6fd3e
      Igor Babaev authored
      5cf6fd3e
    • Igor Babaev's avatar
      Fixed bug mdev-11488. · 441fa005
      Igor Babaev authored
      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.
      441fa005
    • Daniel Black's avatar
      Travis: add lib{stemmer,xml2,pcre3}-dev · e9ada862
      Daniel Black authored
      e9ada862
  5. 13 Dec, 2016 3 commits
  6. 12 Dec, 2016 4 commits