[MDEV-19653] Add class Sql_cmd_create_table Created: 2019-05-31  Updated: 2020-08-25  Resolved: 2019-07-04

Status: Closed
Project: MariaDB Server
Component/s: Parser
Fix Version/s: 10.2.25, 10.1.41, 10.3.16, 10.4.6, 10.5.0

Type: Task Priority: Critical
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-17588 replicate-do filters cause errors whe... Closed

 Description   

To fix MDEV-17588, we need to postpone resolving of the storage engine to the handlerton pointer, from `mysql_parse()` time to `mysql_execute_command()` time.

So we need to pass the storage engine name, scanned in the ENGINE=XXX clause, through LEX.

Adding the storage engine name as a member to LEX (directly, or through its parts like HA_CREATE_INFO) is not nice:

  • LEX is already huge enough.
  • The logic of LEX initialization and updating is already too complex.

The easiest way to solve this would be moving the create table related code to a new class Sql_cmd_create_table, with a member:

  LEX_CSTRING m_storage_engine_name;

and adding the same member to Sql_cmd_alter_table.

Proposed changes

`mysql_execute_command()` changes

The `case SQLCMD_CREATE_TABLE` part of `mysql_execute_command()` will go to `Sql_cmd_create_table::execute()`.

Grammar changes to the `create_table_option` rule

This code in sql_yacc.yy:

create_table_option:
  ENGINE_SYM opt_equal storage_engines
  {
    Lex->create_info.db_type= $3;
    Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
  }

will change to:

create_table_option:
  ENGINE_SYM opt_equal ident_or_text
  {
    // Set m_storage_engine_name of the current Sql_cmd_create_table or Sql_cmd_alter_table.
  }

Grammar changes to the `storage_engine` rule

The code in the rule storage_engines: will go to a new method in THD:

  bool resolve_storage_engine(handlerton **ha, const LEX_CSTRING &name,
                              bool tmp_table);

so it can be reused by:

  • The `storage_engines` rule
  • Sql_cmd_create_table::execute()
  • Sql_cmd_alter_table::execute()

This change should fix MDEV-17588 automatically.



 Comments   
Comment by Marko Mäkelä [ 2019-06-13 ]

My initial merge of this to 10.3 will cause CREATE SEQUENCE to crash. I asked sanja to take over what I pushed to 10.3-merge.

Comment by Alexander Barkov [ 2019-07-04 ]

Hi juan.vera,
I pushed this change on May 31.
So it was included in the versions 10.1.41, 10.5.0, 10.4.6, 10.3.16, 10.2.25.

Comment by Juan [ 2019-07-04 ]

Hi bar - Got it. Thanks!

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