Package com.mckoi.database.interpret
Class Insert
- java.lang.Object
-
- com.mckoi.database.interpret.Statement
-
- com.mckoi.database.interpret.Insert
-
public class Insert extends Statement
The instance class that stores all the information about an insert statement for processing.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
col_index_list
For 'from_values' and 'from_select', this is a list of indices into the 'insert_table' for the columns that we are inserting data into.(package private) java.util.ArrayList
col_list
private Variable[]
col_var_list
The list of Variable objects the represent the list of columns being inserted into in this query.(package private) java.util.ArrayList
column_sets
(package private) boolean
from_select
(package private) boolean
from_set
(package private) boolean
from_values
private DataTable
insert_table
The table we are inserting stuff to.private Select
prepared_select
If this is a 'from_select' insert, the prepared Select object.private java.util.ArrayList
relationally_linked_tables
Tables that are relationally linked to the table being inserted into, set after 'prepare'.(package private) StatementTree
select
(package private) java.lang.String
table_name
private TableName
tname
The TableName we are inserting into.(package private) java.util.ArrayList
values_list
-
Constructor Summary
Constructors Constructor Description Insert()
-
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
-
col_list
java.util.ArrayList col_list
-
values_list
java.util.ArrayList values_list
-
select
StatementTree select
-
column_sets
java.util.ArrayList column_sets
-
from_values
boolean from_values
-
from_select
boolean from_select
-
from_set
boolean from_set
-
insert_table
private DataTable insert_table
The table we are inserting stuff to.
-
col_index_list
private int[] col_index_list
For 'from_values' and 'from_select', this is a list of indices into the 'insert_table' for the columns that we are inserting data into.
-
col_var_list
private Variable[] col_var_list
The list of Variable objects the represent the list of columns being inserted into in this query.
-
tname
private TableName tname
The TableName we are inserting into.
-
prepared_select
private Select prepared_select
If this is a 'from_select' insert, the prepared Select object.
-
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.
-
-
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
-
-