WL#2871: Prepare any SQL

Affects: Server-6.2   —   Status: Un-Assigned

Statement              Should be preparable?   Already is preparable?
---------              ---------------------   ----------------------

ALTER DATABASE         Y
ALTER EVENT            Y
ALTER FUNCTION         Y
ALTER LOGFILE GROUP    Y
ALTER PROCEDURE        Y
ALTER SERVER           Y
ALTER TABLE            Y
ALTER TABLESPACE       Y
ALTER VIEW             Y
ANALYZE                Y                       Y
ASSIGN TO KEYCACHE     Y
BACKUP                 Y
BACKUP TABLE           - (it's obsolete)
BEGIN ... END          -
CACHE INDEX            Y                       Y
CALL                   -
CASE                   -
CHANGE_DB i.e. USE     Y
CHANGE MASTER          Y                       Y
CHECK                  Y
CHECKSUM               Y                       Y
CLOSE                  -
COMMIT                 Y
CREATE DATABASE        Y                       Y
CREATE EVENT           Y
CREATE FUNCTION        Y
CREATE INDEX           Y
CREATE LOGFILE GROUP   Y
CREATE PROCEDURE       Y
CREATE SERVER          Y
CREATE TABLE           Y                       Y
CREATE TABLESPACE      Y
CREATE TRIGGER         Y
CREATE USER            Y                       Y
CREATE VIEW            Y
DEALLOCATE             -
DECLARE                -
DELETE                 Y                       Y
DELIMITER              - (it's for clients)
DESCRIBE i.e. SHOW     Y
DO                     Y
DROP DATABASE          Y
DROP EVENT             Y
DROP FUNCTION          Y
DROP INDEX             Y
DROP LOGFILE GROUP     Y
DROP PROCEDURE         Y
DROP SERVER            Y
DROP TABLE             Y
DROP TABLESPACE        Y
DROP TRIGGER           Y
DROP USER              Y                       Y
DROP VIEW              Y
EXECUTE                -
EXPLAIN                -
FETCH                  -
FLUSH                  Y
GRANT                  Y                       Y
HANDLER ...            Y
HELP                   Y
IF                     -
INSERT                 Y                       Y
INSTALL PLUGIN         Y                       Y
ITERATE                -
KILL                   Y                       Y
LEAVE                  -
LOAD DATA INFILE       Y
LOAD INDEX INTO CACHE  Y                       Y
LOAD MASTER DATA       Y
LOAD MASTER TABLE      Y
LOAD XML               Y
LOCK TABLES            Y
LOOP                   -
OPEN                   -
OPTIMIZE TABLE         Y                       Y
PRELOAD KEYS           Y
PREPARE                -
PURGE                  Y
PURGE BEFORE           Y
QUIT                   - (it's for clients)
RELEASE                Y
RENAME DATABASE        - (it's obsolete)       Y
RENAME TABLE           Y
RENAME USER            Y
REPAIR TABLE           Y                       Y
REPEAT                 -
REPLACE                Y                       Y
RESET                  Y                       Y
RESIGNAL               -
RESTORE                Y
RESTORE TABLE          - (it's obsolete)
RETURN                 -
REVOKE                 Y                       Y
REVOKE ALL             Y
ROLLBACK               Y
ROLLBACK TO SAVEPOINT  Y
SAVEPOINT              Y
SELECT                 Y                       Y
SET NAMES              Y
SET option             Y
SET PASSWORD           Y
SET TRANSACTION        Y
SET variable|parameter Y
SHOW ...               Y
SIGNAL                 -
SLAVE START            Y                       Y
SLAVE STOP             Y                       Y
START TRANSACTION      Y
TRUNCATE               Y
XA ...                 -
UNINSTALL PLUGIN       Y                       Y
UNLOCK TABLES          Y
UPDATE                 Y                       Y
WHILE                  -

Values in the "Statement" column should be a complete
list of possible statements, but this needs re-check.

Values in the "Should be preparable?" column are
mostly guesses. But things like "prepare a PREPARE"
would be a bit unusual.

Values in the "Already is preparable?" column come
from the MySQL 6.0 Reference Manual.

The SQL standard suggests that "diagnostic statements"
needn't be preparable, so MySQL perhaps should disallow
PREPARE stmt1 FROM 'SHOW ERRORS';
PREPARE stmt1 FROM 'SHOW WARNINGS';

WL#2073 "Schemas in ANSI style" mentions SET SCHEMA.
The SQL standard says that SET SCHEMA is preparable.
This might mean it can't be an equivalent of "USE".

For compound statements, the "delimiter" is the end of
the string.

There is no plan for quotes within quotes within quotes.

References:
BUG#31625 PREPARED STATEMENT syntax does not allow to create TRIGGERS
Remove the big switch, create an object in the parser which will represent every
command. Note that we don't plan to make every action an object, just that we
have an object for every action that tells us what functions to be called (i.e.
keep C style for functions like mysql_insert()). Move data from sql_lex to this
class to be better data locality and a smaller LEX.

This feature is needed for support of prepared statements, stored procedures, etc.