Package org.h2.command
Class CommandContainer
- java.lang.Object
-
- org.h2.command.Command
-
- org.h2.command.CommandContainer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,CommandInterface
public class CommandContainer extends Command
Represents a single SQL statements. It wraps a prepared statement.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CommandContainer.GeneratedKeysCollector
Collector of generated keys.
-
Field Summary
Fields Modifier and Type Field Description private Prepared
prepared
private boolean
readOnly
private boolean
readOnlyKnown
-
Fields inherited from class org.h2.command.Command
session, startTimeNanos
-
Fields inherited from interface org.h2.command.CommandInterface
ALTER_DOMAIN_ADD_CONSTRAINT, ALTER_DOMAIN_DEFAULT, ALTER_DOMAIN_DROP_CONSTRAINT, ALTER_DOMAIN_ON_UPDATE, ALTER_DOMAIN_RENAME, ALTER_DOMAIN_RENAME_CONSTRAINT, ALTER_INDEX_RENAME, ALTER_SCHEMA_RENAME, ALTER_SEQUENCE, ALTER_TABLE_ADD_COLUMN, ALTER_TABLE_ADD_CONSTRAINT_CHECK, ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY, ALTER_TABLE_ADD_CONSTRAINT_REFERENTIAL, ALTER_TABLE_ADD_CONSTRAINT_UNIQUE, ALTER_TABLE_ALTER_COLUMN_CHANGE_TYPE, ALTER_TABLE_ALTER_COLUMN_DEFAULT, ALTER_TABLE_ALTER_COLUMN_DEFAULT_ON_NULL, ALTER_TABLE_ALTER_COLUMN_DROP_EXPRESSION, ALTER_TABLE_ALTER_COLUMN_DROP_IDENTITY, ALTER_TABLE_ALTER_COLUMN_DROP_NOT_NULL, ALTER_TABLE_ALTER_COLUMN_NOT_NULL, ALTER_TABLE_ALTER_COLUMN_ON_UPDATE, ALTER_TABLE_ALTER_COLUMN_RENAME, ALTER_TABLE_ALTER_COLUMN_SELECTIVITY, ALTER_TABLE_ALTER_COLUMN_VISIBILITY, ALTER_TABLE_DROP_COLUMN, ALTER_TABLE_DROP_CONSTRAINT, ALTER_TABLE_RENAME, ALTER_TABLE_RENAME_CONSTRAINT, ALTER_TABLE_SET_REFERENTIAL_INTEGRITY, ALTER_USER_ADMIN, ALTER_USER_RENAME, ALTER_USER_SET_PASSWORD, ALTER_VIEW, ANALYZE, BACKUP, BEGIN, CALL, CHECKPOINT, CHECKPOINT_SYNC, COMMENT, COMMIT, COMMIT_TRANSACTION, CREATE_AGGREGATE, CREATE_ALIAS, CREATE_CONSTANT, CREATE_DOMAIN, CREATE_INDEX, CREATE_LINKED_TABLE, CREATE_ROLE, CREATE_SCHEMA, CREATE_SEQUENCE, CREATE_SYNONYM, CREATE_TABLE, CREATE_TRIGGER, CREATE_USER, CREATE_VIEW, DEALLOCATE, DELETE, DROP_AGGREGATE, DROP_ALIAS, DROP_ALL_OBJECTS, DROP_CONSTANT, DROP_DOMAIN, DROP_INDEX, DROP_ROLE, DROP_SCHEMA, DROP_SEQUENCE, DROP_SYNONYM, DROP_TABLE, DROP_TRIGGER, DROP_USER, DROP_VIEW, EXECUTE, EXECUTE_IMMEDIATELY, EXPLAIN, EXPLAIN_ANALYZE, GRANT, HELP, INSERT, MERGE, NO_OPERATION, PREPARE, PREPARE_COMMIT, REPLACE, REVOKE, ROLLBACK, ROLLBACK_TO_SAVEPOINT, ROLLBACK_TRANSACTION, RUNSCRIPT, SAVEPOINT, SCRIPT, SELECT, SET, SET_AUTOCOMMIT_FALSE, SET_AUTOCOMMIT_TRUE, SHUTDOWN, SHUTDOWN_COMPACT, SHUTDOWN_DEFRAG, SHUTDOWN_IMMEDIATELY, TRUNCATE_TABLE, UNKNOWN, UPDATE
-
-
Constructor Summary
Constructors Constructor Description CommandContainer(SessionLocal session, java.lang.String sql, Prepared prepared)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canReuse()
Whether the command is already closed (in which case it can be re-used).(package private) void
clearCTE()
Clean up any associated CTE.(package private) static void
clearCTE(SessionLocal session, java.util.List<TableView> views)
Clears CTE views.(package private) static void
clearCTE(SessionLocal session, Prepared prepared)
Clears CTE views for a specified statement.private ResultWithGeneratedKeys
executeUpdateWithGeneratedKeys(DataChangeStatement statement, java.lang.Object generatedKeysRequest)
int
getCommandType()
Get command type.java.util.Set<DbObject>
getDependencies()
java.util.ArrayList<? extends ParameterInterface>
getParameters()
Get the list of parameters.boolean
isCacheable()
protected boolean
isCurrentCommandADefineCommand()
Is the command we just tried to execute a DefineCommand (i.e.boolean
isQuery()
Check if this command is a query.boolean
isReadOnly()
Check if this command is read only.boolean
isTransactional()
Check if this command is transactional.ResultInterface
query(long maxrows)
Execute a query statement, if this is possible.ResultInterface
queryMeta()
Get an empty result set containing the meta data.private void
recompileIfRequired()
void
stop()
Stop the command execution, release all locks and resourcesResultWithGeneratedKeys
update(java.lang.Object generatedKeysRequest)
Execute an updating statement (for example insert, delete, or update), if this is possible.-
Methods inherited from class org.h2.command.Command
cancel, checkCanceled, close, executeQuery, executeUpdate, getMetaData, reuse, setCanReuse, setProgress, start, toString
-
-
-
-
Field Detail
-
prepared
private Prepared prepared
-
readOnlyKnown
private boolean readOnlyKnown
-
readOnly
private boolean readOnly
-
-
Constructor Detail
-
CommandContainer
public CommandContainer(SessionLocal session, java.lang.String sql, Prepared prepared)
-
-
Method Detail
-
clearCTE
static void clearCTE(SessionLocal session, Prepared prepared)
Clears CTE views for a specified statement.- Parameters:
session
- the sessionprepared
- prepared statement
-
clearCTE
static void clearCTE(SessionLocal session, java.util.List<TableView> views)
Clears CTE views.- Parameters:
session
- the sessionviews
- list of view
-
getParameters
public java.util.ArrayList<? extends ParameterInterface> getParameters()
Description copied from class:Command
Get the list of parameters.- Specified by:
getParameters
in interfaceCommandInterface
- Specified by:
getParameters
in classCommand
- Returns:
- the list of parameters
-
isTransactional
public boolean isTransactional()
Description copied from class:Command
Check if this command is transactional. If it is not, then it forces the current transaction to commit.- Specified by:
isTransactional
in classCommand
- Returns:
- true if it is
-
isQuery
public boolean isQuery()
Description copied from class:Command
Check if this command is a query.- Specified by:
isQuery
in interfaceCommandInterface
- Specified by:
isQuery
in classCommand
- Returns:
- true if it is
-
recompileIfRequired
private void recompileIfRequired()
-
update
public ResultWithGeneratedKeys update(java.lang.Object generatedKeysRequest)
Description copied from class:Command
Execute an updating statement (for example insert, delete, or update), if this is possible.- Specified by:
update
in classCommand
- Parameters:
generatedKeysRequest
-false
if generated keys are not needed,true
if generated keys should be configured automatically,int[]
to specify column indices to return generated keys from, orString[]
to specify column names to return generated keys from- Returns:
- the update count and generated keys, if any
-
executeUpdateWithGeneratedKeys
private ResultWithGeneratedKeys executeUpdateWithGeneratedKeys(DataChangeStatement statement, java.lang.Object generatedKeysRequest)
-
query
public ResultInterface query(long maxrows)
Description copied from class:Command
Execute a query statement, if this is possible.
-
stop
public void stop()
Description copied from interface:CommandInterface
Stop the command execution, release all locks and resources- Specified by:
stop
in interfaceCommandInterface
- Overrides:
stop
in classCommand
-
canReuse
public boolean canReuse()
Description copied from class:Command
Whether the command is already closed (in which case it can be re-used).
-
isReadOnly
public boolean isReadOnly()
Description copied from class:Command
Check if this command is read only.- Specified by:
isReadOnly
in classCommand
- Returns:
- true if it is
-
queryMeta
public ResultInterface queryMeta()
Description copied from class:Command
Get an empty result set containing the meta data.
-
isCacheable
public boolean isCacheable()
- Overrides:
isCacheable
in classCommand
-
getCommandType
public int getCommandType()
Description copied from interface:CommandInterface
Get command type.- Returns:
- one of the constants above
-
clearCTE
void clearCTE()
Clean up any associated CTE.
-
getDependencies
public java.util.Set<DbObject> getDependencies()
- Specified by:
getDependencies
in classCommand
-
isCurrentCommandADefineCommand
protected boolean isCurrentCommandADefineCommand()
Description copied from class:Command
Is the command we just tried to execute a DefineCommand (i.e. DDL).- Specified by:
isCurrentCommandADefineCommand
in classCommand
- Returns:
- true if yes
-
-