Class Command

    • Field Detail

      • session

        protected final SessionLocal session
        The session.
      • startTimeNanos

        protected long startTimeNanos
        The last start time.
      • trace

        private final Trace trace
        The trace module.
      • cancel

        private volatile boolean cancel
        If this query was canceled.
      • sql

        private final java.lang.String sql
      • canReuse

        private boolean canReuse
    • Constructor Detail

      • Command

        Command​(SessionLocal session,
                java.lang.String sql)
    • Method Detail

      • isTransactional

        public abstract boolean isTransactional()
        Check if this command is transactional. If it is not, then it forces the current transaction to commit.
        Returns:
        true if it is
      • isQuery

        public abstract boolean isQuery()
        Check if this command is a query.
        Specified by:
        isQuery in interface CommandInterface
        Returns:
        true if it is
      • isReadOnly

        public abstract boolean isReadOnly()
        Check if this command is read only.
        Returns:
        true if it is
      • queryMeta

        public abstract ResultInterface queryMeta()
        Get an empty result set containing the meta data.
        Returns:
        an empty result set
      • update

        public abstract ResultWithGeneratedKeys update​(java.lang.Object generatedKeysRequest)
        Execute an updating statement (for example insert, delete, or update), if this is possible.
        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, or String[] to specify column names to return generated keys from
        Returns:
        the update count and generated keys, if any
        Throws:
        DbException - if the command is not an updating statement
      • query

        public abstract ResultInterface query​(long maxrows)
        Execute a query statement, if this is possible.
        Parameters:
        maxrows - the maximum number of rows returned
        Returns:
        the local result set
        Throws:
        DbException - if the command is not a query
      • start

        void start()
        Start the stopwatch.
      • setProgress

        void setProgress​(int state)
      • checkCanceled

        protected void checkCanceled()
        Check if this command has been canceled, and throw an exception if yes.
        Throws:
        DbException - if the statement has been canceled
      • stop

        public void stop()
        Description copied from interface: CommandInterface
        Stop the command execution, release all locks and resources
        Specified by:
        stop in interface CommandInterface
      • executeQuery

        public ResultInterface executeQuery​(long maxrows,
                                            boolean scrollable)
        Execute a query and return the result. This method prepares everything and calls query(long) finally.
        Specified by:
        executeQuery in interface CommandInterface
        Parameters:
        maxrows - the maximum number of rows to return
        scrollable - if the result set must be scrollable (ignored)
        Returns:
        the result set
      • executeUpdate

        public ResultWithGeneratedKeys executeUpdate​(java.lang.Object generatedKeysRequest)
        Description copied from interface: CommandInterface
        Execute the statement
        Specified by:
        executeUpdate in interface CommandInterface
        Parameters:
        generatedKeysRequest - null or 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, or String[] to specify column names to return generated keys from
        Returns:
        the update count and generated keys, if any
      • commitIfNonTransactional

        private void commitIfNonTransactional()
      • filterConcurrentUpdate

        private long filterConcurrentUpdate​(DbException e,
                                            long start)
      • close

        public void close()
        Description copied from interface: CommandInterface
        Close the statement.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface CommandInterface
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isCacheable

        public boolean isCacheable()
      • canReuse

        public boolean canReuse()
        Whether the command is already closed (in which case it can be re-used).
        Returns:
        true if it can be re-used
      • reuse

        public void reuse()
        The command is now re-used, therefore reset the canReuse flag, and the parameter values.
      • setCanReuse

        public void setCanReuse​(boolean canReuse)
      • getDependencies

        public abstract java.util.Set<DbObject> getDependencies()
      • isCurrentCommandADefineCommand

        protected abstract boolean isCurrentCommandADefineCommand()
        Is the command we just tried to execute a DefineCommand (i.e. DDL).
        Returns:
        true if yes