[MDEV-8094] sql_yacc.yy: get rid of the rules "opt_if_not_exists_table_element" and "opt_if_exists_table_element" Created: 2015-05-04  Updated: 2021-05-11

Status: Open
Project: MariaDB Server
Component/s: Parser
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Alexander Barkov Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: duplicate-code

Issue Links:
Blocks
is blocked by MDEV-8093 sql_yacc.yy: add %type create_field f... Closed
is blocked by MDEV-14404 Don't use LEX::check_exists in ALTER ... Closed
Epic Link: Data type cleanups

 Description   

This is a clean-up task that can be easily done after MDEV-8093.

There are two pairs of very similar rules:

  • opt_if_exists vs opt_if_exists_table_element
  • opt_if_not_exists vs opt_if_not_exists_table_element

which all handle IF EXISTS and IF NOT EXISTS clauses.

The "opt_if_xxx_table_element" rules use Lex->check_exists as a storage and are used in column and key context of ALTER TABLE:

ALTER TABLE t1 DROP INDEX IF EXISTS f1;

The "opt_if_xxx" rules are based on DDL_options_st and used in a schema object context:

CREATE TABLE IF NOT EXISTS t1 (a int);
DROP FUNCTION IF EXISTS f1;

We'll modify sql_yacc.yy to use the DDL_options_st based rules in all contexts and will get rid of:

  • The "opt_if_exists_table_element" rule
  • The "opt_if_not_exists_table_element" rule
  • The "check_exists" member in LEX.

Generated at Thu Feb 08 07:24:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.