maria:bb-11.3-bar-MDEV-12252

Last commit made on 2023-09-29
Get this branch:
git clone -b bb-11.3-bar-MDEV-12252 https://git.launchpad.net/maria

Branch merges

Branch information

Name:
bb-11.3-bar-MDEV-12252
Repository:
lp:maria

Recent commits

084bf22... by Alexander Barkov

MDEV-12252 ROW data type for stored function return values

Adding support for the ROW data type in the stored function RETURNS clause:

- explicit ROW(..members...) for both sql_mode=DEFAULT and sql_mode=ORACLE

  CREATE FUNCTION f1() RETURNS ROW(a INT, b VARCHAR(32)) ...

- anchored "ROW TYPE OF [db1.]table1" declarations for sql_mode=DEFAULT

  CREATE FUNCTION f1() RETURNS ROW TYPE OF test.t1 ...

- anchored "[db1.]table1%ROWTYPE" declarations for sql_mode=ORACLE

  CREATE FUNCTION f1() RETURN test.t1%ROWTYPE ...

Adding support for anchored scalar data types in RETURNS clause:

- "TYPE OF [db1.]table1.column1" for sql_mode=DEFAULT

  CREATE FUNCTION f1() RETURNS TYPE OF test.t1.column1;

- "[db1.]table1.column1" for sql_mode=ORACLE

  CREATE FUNCTION f1() RETURN test.t1.column1%TYPE;

Details:

- Adding a new sql_mode_t parameter to
    sp_head::create()
    sp_head::sp_head()
    sp_package::create()
    sp_package::sp_package()
  to guarantee early initialization of sp_head::m_sql_mode.
  Before this change, this member was not initialized at all during
  CREATE FUNCTION/PROCEDURE/PACKAGE statements, and was not used.
  Now it needs to be initialized to write properly the
  mysql.proc.returns column, according to the create time sql_mode.

- Moving the code from the loop body in sp_rcontext::init_var_items()
  into a separate member Spvar_definition::make_item_field_row(),
  to reuse this code for variable/parameter definitions
  and for the RETURNS clause.

- Changing the data type of sp_head::m_return_field_def
  from Column_definition to Spvar_definition.
  So now it supports not only SQL column field types,
  but also explicit ROW and anchored ROW data types.

- Cleanup: adding the const qualifier to Spvar_definition::m_column_type_ref.
  Fixing the following methods accordingly:
  * Qualified_column_ident::resolve_type_ref()
  * LEX::sp_variable_declarations_column_type_finalize()

- Modifying sql_yacc.yy to support the new grammar.
  Adding new helper methods:
    * sf_return_fill_definition_row()
    * sf_return_fill_definition_rowtype_of()
    * sf_return_fill_definition_type_of()

- Fixing tests in:
  * Virtual_tmp_table::setup_field_pointers() in sql_select.cc
  * Send_field::normalize() in field.h
  to prevent calling Type_handler_row::field_type(),
  which is implemented a DBUG_ASSERT(0).
  Before this patch the affected methods were called only
  for scalar data types. Now ROW is also possible.

- Adding a new virtual method Field::cols()

- Overriding methods:
   Item_func_sp::cols()
   Item_func_sp::element_index()
   Item_func_sp::check_cols()
   Item_func_sp::bring_value()
  to support the ROW data type.

- Extending sp_returns_type() to support
  * explicit ROW and anchored ROW data types
  * anchored scalar data types

- Overriding Field_row::sql_type() to print
  the data type of an explicit ROW.

e9573c0... by Nikita Malyavin

fix rdb_i_s.cc build

28b4037... by Nikita Malyavin

Merge branch '11.2' into 11.3

d75ef02... by Alexander Barkov

MDEV-32220 sql_yacc.yy: unify the drop_routine rule

- Removing two copies of the drop_routine.
  Adding a shared and much simplified version.

- Removing LEX metods:
      bool stmt_drop_function(const DDL_options_st &options,
                              const Lex_ident_sys_st &db,
                              const Lex_ident_sys_st &name);

      bool stmt_drop_function(const DDL_options_st &options,
                              const Lex_ident_sys_st &name);

      bool stmt_drop_procedure(const DDL_options_st &options,
                               sp_name *name);

  The code inside the methods was very similar.
  Adding one method instead:

      bool stmt_drop_routine(const Sp_handler *sph,
                          const DDL_options_st &options,
                          const Lex_ident_sys_st &db,
                          const Lex_ident_sys_st &name);

- Adding a new virtual method Sp_handler:sqlcom_drop().
  It helped to unify the code inside the new stmt_drop_routine().

1988512... by Alexander Barkov

MDEV-32219 Shift/reduce grammar conflict: GRANT .. ON FUNCTION

Resolving the shift/reduce conflict conflict in:

GRANT .. ON /*ambiguity*/ FUNCTION f1 TO foo@localhost;
GRANT ... ON /*ambiguity*/ [TABLE] function TO foo@localhost;

and in

REVOKE .. ON /*ambiguity*/ FUNCTION f1 TO foo@localhost;
REVOKE ... ON /*ambiguity*/ [TABLE] function TO foo@localhost;

using a new %prec directive.

8d9bc61... by Andrew Hutchings

Update mysqltest-break.test

This test does not work in embedded and I cannot see an obvious way of fixing that. The test not running in embedded is not the end of the world here.

9f8c5e0... by IGOR BALASHENKO

Add break statement in mysqltest

f5aae71... by Alexander Barkov

MDEV-31606 Refactor check_db_name() to get a const argument

Problem:
Under terms of MDEV-27490, we'll update Unicode version used
to compare identifiers to 14.0.0. Unlike in the old Unicode version,
in the new version a string can grow during lower-case. We cannot
perform check_db_name() inplace any more.

Change summary:

- Allocate memory to store lower-cased identifiers in memory root

- Removing check_db_name() performing both in-place lower-casing and validation
  at the same time. Splitting it into two separate stages:
  * creating a memory-root lower-cased copy of an identifier
    (using new MEM_ROOT functions and Query_arena wrapper methods)
  * performing validation on a constant string
    (using Lex_ident_fs methods)

Implementation details:

- Adding a mysys helper function to allocate lower-cased strings on MEM_ROOT:

    lex_string_casedn_root()

  and a Query_arena wrappers for it:

    make_ident_casedn()
    make_ident_opt_casedn()

- Adding a Query_arena method to perform both MEM_ROOT lower-casing and
  database name validation at the same time:

    to_ident_db_internal_with_error()

  This method is very close to the old (pre-11.3) check_db_name(),
  but performs lower-casing to a newly allocated MEM_ROOT
  memory (instead of performing lower-casing the original string in-place).

- Adding a Table_ident method which additionally handles derived table names:

    to_ident_db_internal_with_error()

- Removing the old check_db_name()

e987b93... by Sergey Petrunia

MDEV-31496: Make optimizer handle UCASE(varchar_col)=...

(Review input addressed)
(Added handling of UPDATE/DELETE and partitioning w/o index)

If the properties of the used collation allow, do the following
equivalent rewrites:

1. UPPER(key_col)=expr -> key_col=expr
   expr=UPPER(key_col) -> expr=key_col
   (also rewrite both sides of the equality at the same time)

2. UPPER(key_col) IN (constant-list) -> key_col IN (constant-list)

- Mark utf8mb{3,4}_general_ci as collations that allow this.
- Add optimizer_switch='sargable_casefold=ON' to control this.
  (ON by default in this patch)
- Cover the rewrite in Optimizer Trace, rewrite name is
  "sargable_casefold_removal".

eece7f1... by THIRUNARAYANAN BALATHANDAYUTHAPANI

- Rename the DBUG_EXECUTE_IF from sys_shrink_buffer_pool_full to
sys_shrink_buffer_pool to make it as generic name.