Parsing CREATE SCHEMA statements

Registered by Jay Pipes

A parser should be created using PLY.

Place the parser in the helpers/ folder and make it as modular as you can. Think about the interface that you will use to call your parser. The parser should accept a blob of text and return a representation of the text as a parsed set of statements.

To start with, begin by parsing just the CREATE SCHEMA and CREATE DATABASE statements.

Create tests for all of this that read in a file containing a few CREATE SCHEMA statements, both well and inproperly formatted, and test the parser correctly parses the statements.

We want to be able to understand the CREATE SCHEMA statement that mysqldump outputs, and therefore the syntax of CREATE SCHEMA from the manual must be understood:

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

The following statement variations should have separate test cases written for them:

CREATE SCHEMA test;
CREATE SCHEMA IF NOT EXISTS test;
CREATE DATABASE test;
CREATE SCHEMA `test`;
CREATE SCHEMA test2;
CREATE SCHEMA /* here is a comment */ test;
CREATE SCHEMA 'test schema';
CREATE SCHEMA "test schema";
CREATE SCHEMA test CHARACTER SET utf8;
CREATE SCHEMA test DEFAULT CHARACTER SET utf8;
CREATE SCHEMA test CHARACTER SET 'utf8';
CREATE SCHEMA test CHARACTER SET utf8 COLLATE utf8_bin;

All of the following should FAIL with syntax errors. Please also create tests for these:

CREATE SCHEMA "test schema'; // mismatched single and double quotes
CREATE SCHEMA LENGTH("test"); // invalid for a function to be name of schema
CREATE SCHEMA too_long_schema_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
CREATE SCHEMA test DEF CHARACTER SET utf8; <-- DEF is not a keyword. DEFAULT is...
CREATE SCHEMA IF EXISTS test; <-- Should be IF NOT EXISTS, not IF EXISTS...

For now, don't worry about Unicode. We will tackle Unicode in a separate blueprint.

Blueprint information

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

Related branches

Sprints

Whiteboard

implemented

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.