parser for parsing create table statements

Registered by neh

A parser should be created using PLY.

http://dev.mysql.com/doc/refman/5.0/en/create-table.html

Steps to take:

1) Split out the classes that compose statements into a separate file (/helpers/statement_nodes.py) and include this file in the parser file
2) Create a new statement node class CreateTableStatement that will house all of the member data about a CREATE TABLE statement. This class should have information on the TEMPORARY keyword, the IF NOT EXISTS keyword, the table identifier, the list of field definitions, the list of key constraint definitions, and more..
3) Create a new test case file: /tests/parse_createtable_test.py - DONE.
4) Create new test cases for all of the following BAD syntaxes:

CREATE TABLE 1; // bad identifier
CREATE TABLE t1 (); // no field list
CREATE TABLE t1 (f1 NOT NULL); // missing column type
CREATE TABLE t1 (INT NOT NULL); // missing column identifier
CREATE TABLE t1 (t1.field1 INT NOT NULL); // column identifier cannot be qualified

5) Create new test cases for all of the following GOOD syntaxes:

CREATE TABLE t1 (field1 INT NOT NULL);
CREATE TABLE IF NOT EXISTS t1 (field1 INT NOT NULL);
CREATE TEMPORARY TABLE t1 (field1 INT NOT NULL);
CREATE TEMPORARY TABLE IF NOT EXISTS t1 (field1 INT NOT NULL);
CREATE TABLE test.t1 (field1 INT NOT NULL); // Note schema name qualifying table name...
CREATE TABLE t1 (field1 INT NOT NULL, PRIMARY KEY field1);

// Use of the REFERENCES clause... all of these are valid

CREATE TABLE t1 (t1_pk INT NOT NULL PRIMARY KEY, t1_fk INT NOT NULL FOREIGN KEY (field2) REFERENCES t2 (t2_pk);
CREATE TABLE t1 (t1_pk INT NOT NULL PRIMARY KEY, t1_fk INT NOT NULL CONSTRAINT c_fk_t2 FOREIGN KEY fk_t2 (field2) REFERENCES t2 (t2_pk); // Shows optional constraint name for the foreign key
CREATE TABLE t1 (t1_pk INT NOT NULL PRIMARY KEY, t1_fk INT NOT NULL FOREIGN KEY fk_t2 (field2) REFERENCES t2 (t2_pk); // Shows optional name for the index on the foreign key
CREATE TABLE t1 (t1_pk INT NOT NULL PRIMARY KEY, t1_fk INT NOT NULL FOREIGN KEY (field2) REFERENCES t2 (t2_pk) ON UPDATE CASCADE; // Shows optional ON UPDATE clause
CREATE TABLE t1 (t1_pk INT NOT NULL PRIMARY KEY, t1_fk INT NOT NULL FOREIGN KEY (field2) REFERENCES t2 (t2_pk) ON DELETE CASCADE; // Shows optional ON DELETE clause

Blueprint information

Status:
Started
Approver:
Jay Pipes
Priority:
Essential
Drafter:
Jay Pipes
Direction:
Approved
Assignee:
neh
Definition:
Approved
Series goal:
Accepted for 1.0
Implementation:
Started
Milestone target:
milestone icon 2010-07-05
Started by
Jay Pipes

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.