Package com.mckoi.database.interpret
Class CreateTable
- java.lang.Object
-
- com.mckoi.database.interpret.Statement
-
- com.mckoi.database.interpret.CreateTable
-
public class CreateTable extends Statement
A parsed state container for the 'create' statement.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.ArrayList
columns
List of column declarations (ColumnDef)(package private) java.util.ArrayList
constraints
List of table constraints (ConstraintDef)(package private) boolean
only_if_not_exists
Only create if table doesn't exist.(package private) java.lang.String
table_name
The name of the table to create.(package private) boolean
temporary
Set to true if this create statement is for a temporary table.private TableName
tname
The TableName object.
-
Constructor Summary
Constructors Constructor Description CreateTable()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addConstraintDef(ConstraintDef constraint)
Adds a new ConstraintDef object to this create statement.(package private) static void
addSchemaConstraint(DatabaseConnection manager, TableName table, ConstraintDef constraint)
Adds a schema constraint to the rules for the schema represented by the manager.(package private) static DataTableColumnDef
convertColumnDef(ColumnDef cdef)
Returns a com.mckoi.database.interpret.ColumnDef object a a com.mckoi.database.DataTableColumnDef object.(package private) DataTableDef
createDataTableDef()
Creates a DataTableDef that describes the table that was defined by this create statement.Table
evaluate()
Evaluates the statement and returns a table that represents the result set.void
prepare()
Prepares the statement with the given Database object.(package private) void
setupAllConstraints()
Sets up all constraints specified in this create statement.-
Methods inherited from class com.mckoi.database.interpret.Statement
addTable, Debug, existsTableWithColumn, findTableInQuery, findTableWithColumn, init, reset, resolveAgainstAliases, resolveColumn, resolveExpression, resolveTableName, resolveTree, resolveVariableName
-
-
-
-
Field Detail
-
temporary
boolean temporary
Set to true if this create statement is for a temporary table.
-
only_if_not_exists
boolean only_if_not_exists
Only create if table doesn't exist.
-
table_name
java.lang.String table_name
The name of the table to create.
-
columns
java.util.ArrayList columns
List of column declarations (ColumnDef)
-
constraints
java.util.ArrayList constraints
List of table constraints (ConstraintDef)
-
tname
private TableName tname
The TableName object.
-
-
Method Detail
-
addConstraintDef
void addConstraintDef(ConstraintDef constraint)
Adds a new ConstraintDef object to this create statement. A ConstraintDef object describes any constraints for the new table we are creating.
-
createDataTableDef
DataTableDef createDataTableDef() throws DatabaseException
Creates a DataTableDef that describes the table that was defined by this create statement. This is used by the 'alter' statement.- Throws:
DatabaseException
-
addSchemaConstraint
static void addSchemaConstraint(DatabaseConnection manager, TableName table, ConstraintDef constraint) throws DatabaseException
Adds a schema constraint to the rules for the schema represented by the manager.- Throws:
DatabaseException
-
convertColumnDef
static DataTableColumnDef convertColumnDef(ColumnDef cdef)
Returns a com.mckoi.database.interpret.ColumnDef object a a com.mckoi.database.DataTableColumnDef object.
-
setupAllConstraints
void setupAllConstraints() throws DatabaseException
Sets up all constraints specified in this create statement.- Throws:
DatabaseException
-
prepare
public void prepare() throws DatabaseException
Description copied from class:Statement
Prepares the statement with the given Database object. This is called before the statement is evaluated. The prepare statement queries the database and resolves information about the statement (for example, it resolves column names and aliases and determines the tables that are touched by this statement so we can lock the appropriate tables before we evaluate).NOTE: Care must be taken to ensure that all methods called here are safe in as far as modifications to the data occuring. The rules for safety should be as follows. If the database is in EXCLUSIVE mode, then we need to wait until it's switched back to SHARED mode before this method is called. All collection of information done here should not involve any table state info. except for column count, column names, column types, etc. Queries such as obtaining the row count, selectable scheme information, and certainly 'getCellContents' must never be called during prepare. When prepare finishes, the affected tables are locked and the query is safe to 'evaluate' at which time table state is safe to inspect.
- Specified by:
prepare
in classStatement
- Throws:
DatabaseException
-
evaluate
public Table evaluate() throws DatabaseException
Description copied from class:Statement
Evaluates the statement and returns a table that represents the result set. This is called after 'prepare'.- Specified by:
evaluate
in classStatement
- Throws:
DatabaseException
-
-