Class IntermediateStatement (0.22.1)

public class IntermediateStatement

Data type to store simple SQL statement with designated metadata. Allows manipulation of statement, such as execution, termination, etc. Represented as an intermediate representation for statements which does not belong directly to Postgres, Spanner, etc.

Inheritance

java.lang.Object > IntermediateStatement

Static Fields

PARSER

protected static final PostgreSQLStatementParser PARSER
Field Value
TypeDescription
PostgreSQLStatementParser

Constructors

IntermediateStatement(ConnectionHandler connectionHandler, OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement)

protected IntermediateStatement(ConnectionHandler connectionHandler, OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement)
Parameters
NameDescription
connectionHandlerConnectionHandler
optionsOptionsMetadata
parsedStatementParsedStatement
originalStatementcom.google.cloud.spanner.Statement

IntermediateStatement(OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement, ConnectionHandler connectionHandler)

public IntermediateStatement(OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement, ConnectionHandler connectionHandler)
Parameters
NameDescription
optionsOptionsMetadata
parsedStatementParsedStatement
originalStatementcom.google.cloud.spanner.Statement
connectionHandlerConnectionHandler

Fields

command

protected final String command
Field Value
TypeDescription
String

commandTag

protected String commandTag
Field Value
TypeDescription
String

connection

protected final Connection connection
Field Value
TypeDescription
Connection

connectionHandler

protected final ConnectionHandler connectionHandler
Field Value
TypeDescription
ConnectionHandler

described

protected boolean described
Field Value
TypeDescription
boolean

exception

protected PGException exception
Field Value
TypeDescription
PGException

executed

protected boolean executed
Field Value
TypeDescription
boolean

futureStatementResult

protected Future<StatementResult> futureStatementResult
Field Value
TypeDescription
Future<StatementResult>

hasMoreData

protected boolean hasMoreData
Field Value
TypeDescription
boolean

options

protected final OptionsMetadata options
Field Value
TypeDescription
OptionsMetadata

originalStatement

protected final Statement originalStatement
Field Value
TypeDescription
com.google.cloud.spanner.Statement

outputStream

protected final DataOutputStream outputStream
Field Value
TypeDescription
DataOutputStream

parsedStatement

protected final AbstractStatementParser.ParsedStatement parsedStatement
Field Value
TypeDescription
ParsedStatement

statementResult

protected StatementResult statementResult
Field Value
TypeDescription
StatementResult

Methods

close()

public void close()

Cleanly close the statement. Does nothing if the statement has not been executed or has no result.

Exceptions
TypeDescription
Exception

if closing fails server-side.

containsResultSet()

public boolean containsResultSet()
Returns
TypeDescription
boolean

True if this is a select statement, false otherwise.

createDataRowResponse(Converter converter)

public WireOutput createDataRowResponse(Converter converter)
Parameter
NameDescription
converterConverter
Returns
TypeDescription
WireOutput

createResultPrefix(ResultSet resultSet)

public WireOutput[] createResultPrefix(ResultSet resultSet)
Parameter
NameDescription
resultSetcom.google.cloud.spanner.ResultSet
Returns
TypeDescription
WireOutput[]

createResultSuffix()

public WireOutput[] createResultSuffix()
Returns
TypeDescription
WireOutput[]

describe()

public DescribeResult describe()

Moreso meant for inherited classes, allows one to call describe on a statement. Since raw statements cannot be described, throw an error.

Returns
TypeDescription
DescribeResult

describeAsync(BackendConnection backendConnection)

public Future<StatementResult> describeAsync(BackendConnection backendConnection)
Parameter
NameDescription
backendConnectionBackendConnection
Returns
TypeDescription
Future<StatementResult>

executeAsync(BackendConnection backendConnection)

public void executeAsync(BackendConnection backendConnection)
Parameter
NameDescription
backendConnectionBackendConnection

getCommand()

public String getCommand()
Returns
TypeDescription
String

the extracted command (first word) from the SQL statement.

getCommandTag()

public String getCommandTag()
Returns
TypeDescription
String

the extracted command (first word) from the really executed SQL statement.

getConnection()

public Connection getConnection()
Returns
TypeDescription
Connection

getConnectionHandler()

public ConnectionHandler getConnectionHandler()
Returns
TypeDescription
ConnectionHandler

getException()

public PGException getException()

Returns any execution exception registered for this statement.

Returns
TypeDescription
PGException

getResultFormatCode(int index)

public short getResultFormatCode(int index)

Moreso intended for inherited classes (prepared statements et al) which allow the setting of result format codes. Here we dafault to string.

Parameter
NameDescription
indexint
Returns
TypeDescription
short

getSql()

public String getSql()
Returns
TypeDescription
String

getStatement()

public String getStatement()
Returns
TypeDescription
String

getStatementResult()

public StatementResult getStatementResult()

Returns the result of this statement as a StatementResult. Fails if the result is not yet available.

Returns
TypeDescription
StatementResult

getStatementType()

public AbstractStatementParser.StatementType getStatementType()
Returns
TypeDescription
StatementType

getUpdateCount()

public long getUpdateCount()
Returns
TypeDescription
long

The number of items that were modified by this execution for DML. 0 for DDL and -1 for QUERY. Fails if the result is not yet available.

getUpdateCount(IntermediateStatement.ResultNotReadyBehavior resultNotReadyBehavior)

public long getUpdateCount(IntermediateStatement.ResultNotReadyBehavior resultNotReadyBehavior)
Parameter
NameDescription
resultNotReadyBehaviorIntermediateStatement.ResultNotReadyBehavior
Returns
TypeDescription
long

The number of items that were modified by this execution for DML. 0 for DDL and -1 for QUERY. Will block or fail depending on the given ResultNotReadyBehavior if the result is not yet available.

handleExecutionException(PGException exception)

public void handleExecutionException(PGException exception)

Clean up and save metadata when an exception occurs.

Parameter
NameDescription
exceptionPGException

The exception to store.

hasException()

public boolean hasException()
Returns
TypeDescription
boolean

True if at some point in execution an exception was thrown. Fails if execution has not yet finished.

hasException(IntermediateStatement.ResultNotReadyBehavior resultNotReadyBehavior)

public boolean hasException(IntermediateStatement.ResultNotReadyBehavior resultNotReadyBehavior)
Parameter
NameDescription
resultNotReadyBehaviorIntermediateStatement.ResultNotReadyBehavior
Returns
TypeDescription
boolean

True if at some point in execution an exception was thrown. Fails or blocks depending on the given ResultNotReadyBehavior if execution has not yet finished.

isBound()

public boolean isBound()

Whether this is a bound statement (i.e.: ready to execute)

Returns
TypeDescription
boolean

True if bound, false otherwise.

isDescribed()

public boolean isDescribed()
Returns
TypeDescription
boolean

isExecuted()

public boolean isExecuted()
Returns
TypeDescription
boolean

True if this statement was executed, False otherwise.

isHasMoreData()

public boolean isHasMoreData()
Returns
TypeDescription
boolean

True if only a subset of the available data has been returned.

setCommandTag(String commandTag)

public void setCommandTag(String commandTag)
Parameter
NameDescription
commandTagString

setFutureStatementResult(Future<StatementResult> result)

protected void setFutureStatementResult(Future<StatementResult> result)
Parameter
NameDescription
resultFuture<StatementResult>

setHasMoreData(boolean hasMoreData)

public void setHasMoreData(boolean hasMoreData)
Parameter
NameDescription
hasMoreDataboolean

setStatementResult(StatementResult statementResult)

public void setStatementResult(StatementResult statementResult)
Parameter
NameDescription
statementResultStatementResult