Package com.mckoi.database.interpret
Class UpdateTable
- java.lang.Object
-
- com.mckoi.database.interpret.Statement
-
- com.mckoi.database.interpret.UpdateTable
-
public class UpdateTable extends Statement
The instance class that stores all the information about an update statement for processing.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.ArrayList
column_sets
An array of Assignment objects which represent what we are changing.(package private) int
limit
The limit of the number of rows that are updated by this statement.private QueryPlanNode
plan
The plan for the set of records we are updating in this query.private java.util.ArrayList
relationally_linked_tables
Tables that are relationally linked to the table being inserted into, set after 'prepare'.(package private) java.lang.String
table_name
The name the table that we are to update.private TableName
tname
The TableName object set during 'prepare'.private DataTable
update_table
The DataTable we are updating.(package private) SearchExpression
where_condition
If the update statement has a 'where' clause, then this is set here.
-
Constructor Summary
Constructors Constructor Description UpdateTable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
table_name
java.lang.String table_name
The name the table that we are to update.
-
column_sets
java.util.ArrayList column_sets
An array of Assignment objects which represent what we are changing.
-
where_condition
SearchExpression where_condition
If the update statement has a 'where' clause, then this is set here. If it has no 'where' clause then we apply to the entire table.
-
limit
int limit
The limit of the number of rows that are updated by this statement. A limit of -1 means there is no limit.
-
relationally_linked_tables
private java.util.ArrayList relationally_linked_tables
Tables that are relationally linked to the table being inserted into, set after 'prepare'. This is used to determine the tables we need to read lock because we need to validate relational constraints on the tables.
-
update_table
private DataTable update_table
The DataTable we are updating.
-
tname
private TableName tname
The TableName object set during 'prepare'.
-
plan
private QueryPlanNode plan
The plan for the set of records we are updating in this query.
-
-
Method Detail
-
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
-
-