Package com.mckoi.database.interpret
Class AlterTable
- java.lang.Object
-
- com.mckoi.database.interpret.Statement
-
- com.mckoi.database.interpret.AlterTable
-
public class AlterTable extends Statement
Logic for the ALTER TABLE SQL statement.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList
actions
The list of actions to perform in this alter statement.(package private) StatementTree
create_statement
The create statement that we use to alter the current table.(package private) CreateTable
create_stmt
The prepared create table statement.(package private) java.lang.String
table_name
The name of the table we are altering.private TableName
tname
The TableName object.
-
Constructor Summary
Constructors Constructor Description AlterTable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAction(AlterTableAction action)
Adds an action to perform in this alter statement.private void
checkColumnConstraint(java.lang.String col_name, java.lang.String[] cols, TableName table, java.lang.String constraint_name)
boolean
checkColumnNamesMatch(DatabaseConnection db, java.lang.String col1, java.lang.String col2)
Returns true if the column names match.Table
evaluate()
Evaluates the statement and returns a table that represents the result set.void
prepare()
Prepares the statement with the given Database object.-
Methods inherited from class com.mckoi.database.interpret.Statement
addTable, Debug, existsTableWithColumn, findTableInQuery, findTableWithColumn, init, reset, resolveAgainstAliases, resolveColumn, resolveExpression, resolveTableName, resolveTree, resolveVariableName
-
-
-
-
Field Detail
-
create_statement
StatementTree create_statement
The create statement that we use to alter the current table. This is only for compatibility reasons.
-
table_name
java.lang.String table_name
The name of the table we are altering.
-
actions
private java.util.ArrayList actions
The list of actions to perform in this alter statement.
-
tname
private TableName tname
The TableName object.
-
create_stmt
CreateTable create_stmt
The prepared create table statement.
-
-
Method Detail
-
addAction
public void addAction(AlterTableAction action)
Adds an action to perform in this alter statement.
-
checkColumnNamesMatch
public boolean checkColumnNamesMatch(DatabaseConnection db, java.lang.String col1, java.lang.String col2)
Returns true if the column names match. If the database is in case insensitive mode then the columns will match if the case insensitive search matches.
-
checkColumnConstraint
private void checkColumnConstraint(java.lang.String col_name, java.lang.String[] cols, TableName table, java.lang.String constraint_name)
-
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
-
-