WL#5047: SQL command class hierarchy
Status: In-Progress
Create classes for all supported SQL statements, and let them derive from a common base class Sql_cmd. The common base class has a virtual execute() function, which is implemented by each derived SQL command class. The switch on lex-sql_command inside mysql_execute_command() will gradually be replaced with calls to this function. The worklogs on SIGNAL/RESIGNAL (WL#2110 and WL#2265) introduced a hierarchy for SQL statement objects, and this worklog builds upon that work. This is part of refactoring code and data structures for query preparation (WL#4999) The main rationales for this work are: - to get rid of a big switch statement currently used to drive query execution. - to refactor the data in the monolithic LEX class into smaller chunks that fit with the SQL statements that they belong to. - to introduce an Abstract Syntax Tree (AST) into query preparation. The SQL statement classes are the top-level objects in the AST. This worklog provides the overall architecture for the statement classes. The work is divided into multiple subtasks that provide detailed design and implementation for for selected parts of the work: 1. Task 5070: Prepare Sql_cmd class for new statement classes. Prerequisite for the subsequent tasks. Creates the base class and required functions. 2. Task 5073: Create SQL command classes for transaction statements. Adds 12 classes for transaction, savepoint and XA transaction handling. 3. Task 5094: Create SQL command classes for DML statements. Adds classes for the data manipulation statements, such as SELECT, INSERT, UPDATE and DELETE. 4. Task 5078: Create SQL command classes for show statements. These classes are all derived from the Sql_cmd_select class. If separate preparation becomes available, this means that you can query for the header properties of the command. Adds 26 classes that are not using the query engine (execute() function is overridden). Adds xx classes that use the query engine (uses the same execute() implementation as Sql_cmd_select). 5. Task xxxx: Create SQL command classes for Schema statements. 6. Task xxxx: Create SQL command classes for administratve statements. 7. Task 5095: SQL command class extensions
WL#5070: Prepare Sql_cmd class for addition of new statement classes
WL#5073: Create SQL command classes for transaction statements
WL#5078: Create SQL command classes for show statements
WL#5094: Create SQL command classes for DML statements
WL#5095: SQL command class extensions
WL#5073: Create SQL command classes for transaction statements
WL#5078: Create SQL command classes for show statements
WL#5094: Create SQL command classes for DML statements
WL#5095: SQL command class extensions
This worklog creates a class hierarchy for executable SQL commands. The class hierarchy is part of an Abstract Syntax Tree that is created by the MySQL parser. 1. Scope of work Each SQL command is represented by a concrete class in the class hierarchy, however some SQL statements share the same class (this is at least true for some of the SHOW commands). This worklog is limited in scope to: - Definition of an SQL command class hierarchy. - Methods for creation and transformation of SQL command objects (future). - Methods for preparation of Sql commands (future). - Methods for execution of SQL commands. - Other utility functions for querying SQL command objects (future). 2. Sql_cmd base class Sql_cmd is a common base class for all SQL statements. Each concrete SQL statement will be represented by a class derived from Sql_statement. 2.1 Functions This chapter describes some high-level aspects of the methods defined for Sql_cmd. More details are found in the worklog tasks referred to from this task. 2.1.1 execute() execute() is used to prepare and execute a SQL command one time. This is a pure virtual function, so any derived class must implement this method. 2.1.2 sql_stmt_code() Virtual method that returns the enum_sql_command associated with the command. This function must be implemented by all derived classes. Note that there is not necessarily a one-to-one mapping between SQL command objects and statement code. For example, the single-table and multi-table DELETE commands have separate statement codes, but are implemented with the same Sql_cmd_delete class. 3. Classes of command statements Command are classified according to their function. The classification is based on the functional classification documented in the SQL standard (ISO-IEC 9075), but extended with additional classes required by the MySQL specification. 3.1 Schema statements 3.2 DML statements 3.3 Transaction statements 3.4 Connection statements 3.5 Session statements 3.6 Dynamic statements 3.7 Diagnostics statements 3.8 Replication statements 3.9 Lock statements (DML?) 4. SQL command class - functionality enhancements Worklog 5095 describe some extensions to the basic work outlined so far in this worklog. The work will be valuated separately after derived classes of Sql_cmd have been created for all SQL commands.
Copyright (c) 2000, 2024, Oracle Corporation and/or its affiliates. All rights reserved.