PL/SQL parser (MDEV-10142)

[MDEV-14212] Add Field_row for SP ROW variables Created: 2017-10-30  Updated: 2023-10-09  Resolved: 2017-10-30

Status: Closed
Project: MariaDB Server
Component/s: Stored routines
Affects Version/s: 10.3
Fix Version/s: 10.3.3

Type: Technical task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: refactoring

Issue Links:
Blocks
blocks MDEV-13418 Compatibility: The order of evaluatio... Stalled
Relates
relates to MDEV-14139 Anchored data types for variables Closed
relates to MDEV-31250 ROW variables do not get assigned fro... Closed
relates to MDEV-32380 Array data type for stored routnes Stalled
Sprint: 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

 Description   

We'll solve MDEV-13418 by translating:

SELECT  1, a INTO a, b FROM dual;

into

DECLARE a_tmp TYPE OF a;
DECLARE b_tmp TYPE OF b;
SELECT  1, a INTO a, b FROM dual;
SET a=a_tmp;
SET b=b_tmp;

Notice, this will need auto-generated assignments between SP variables (a=a_tmp and b=b_tmp).
Normally assignment is done via sp_instr_set, but it does not suite well here because it needs:

  • an Item for the assignment source
  • a LEX containing this Item

Instead of creating an Item and a LEX (whose sizeof are 208 and 5896 bytes respectively),
we'll introduce a new sp_instr_setvar which will copy between two variables directly, with no Item and LEX, using their offsets in sp_rcontext::m_var_table.

In order to implement this, we'll need some changes for ROW-type SP variables.
Currently ROW variables store their members inside Item_splocal_row::m_table.
We'll do the following:

  • Create a new class Field_row and move m_table from Item_splocal_row to Field_row

    class Field_row: public Field_null
    {
      class Virtual_tmp_table *m_table;
    public:
      Field_row(uchar *ptr_arg, const LEX_CSTRING *field_name_arg)
        :Field_null(ptr_arg, 0, Field::NONE, field_name_arg, &my_charset_bin),
         m_table(NULL)
        {}
    };
    

  • Remove the class Item_splocal_row and use Item_splocal instead by passing &type_handler_row to the constructor.
  • Change Item_splocal::Item_splocal to accept const Type_handler *handler instead of enum_field_types sp_var_type.
  • Remove the class Item_spvar_args and derive Item_field_row directly from Item_args
  • Move row_create_items() and get_row_field() from Item_spvar_args to Item_field_row and fix them to use Field_row::m_table instead of Item_spvar_args::m_table.
  • Replace DBUG_ASSERT in Type_handler_row::Column_definition_fix_attributes(), Type_handler_row::Column_definition_prepare_stage1(), Type_handler_row::Column_definition_prepare_stage2() to real appropriate implementations.

Generated at Thu Feb 08 08:11:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.