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
Type Description
PostgreSQLStatementParser

Constructors

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

protected IntermediateStatement(ConnectionHandler connectionHandler, OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement)
Parameters
Name Description
connectionHandler ConnectionHandler
options OptionsMetadata
parsedStatement ParsedStatement
originalStatement com.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
Name Description
options OptionsMetadata
parsedStatement ParsedStatement
originalStatement com.google.cloud.spanner.Statement
connectionHandler ConnectionHandler

Fields

command

protected final String command
Field Value
Type Description
String

commandTag

protected String commandTag
Field Value
Type Description
String

connection

protected final Connection connection
Field Value
Type Description
Connection

connectionHandler

protected final ConnectionHandler connectionHandler
Field Value
Type Description
ConnectionHandler

described

protected boolean described
Field Value
Type Description
boolean

exception

protected PGException exception
Field Value
Type Description
PGException

executed

protected boolean executed
Field Value
Type Description
boolean

futureStatementResult

protected Future<StatementResult> futureStatementResult
Field Value
Type Description
Future<StatementResult>

hasMoreData

protected boolean hasMoreData
Field Value
Type Description
boolean

options

protected final OptionsMetadata options
Field Value
Type Description
OptionsMetadata

originalStatement

protected final Statement originalStatement
Field Value
Type Description
com.google.cloud.spanner.Statement

outputStream

protected final DataOutputStream outputStream
Field Value
Type Description
DataOutputStream

parsedStatement

protected final AbstractStatementParser.ParsedStatement parsedStatement
Field Value
Type Description
ParsedStatement

statementResult

protected StatementResult statementResult
Field Value
Type Description
StatementResult

Methods

close()

public void close()

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

Exceptions
Type Description
Exception

if closing fails server-side.

containsResultSet()

public boolean containsResultSet()
Returns
Type Description
boolean

True if this is a select statement, false otherwise.

createDataRowResponse(Converter converter)

public WireOutput createDataRowResponse(Converter converter)
Parameter
Name Description
converter Converter
Returns
Type Description
WireOutput

createResultPrefix(ResultSet resultSet)

public WireOutput[] createResultPrefix(ResultSet resultSet)
Parameter
Name Description
resultSet com.google.cloud.spanner.ResultSet
Returns
Type Description
WireOutput[]

createResultSuffix()

public WireOutput[] createResultSuffix()
Returns
Type Description
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
Type Description
DescribeResult

describeAsync(BackendConnection backendConnection)

public Future<StatementResult> describeAsync(BackendConnection backendConnection)
Parameter
Name Description
backendConnection BackendConnection
Returns
Type Description
Future<StatementResult>

executeAsync(BackendConnection backendConnection)

public void executeAsync(BackendConnection backendConnection)
Parameter
Name Description
backendConnection BackendConnection

getCommand()

public String getCommand()
Returns
Type Description
String

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

getCommandTag()

public String getCommandTag()
Returns
Type Description
String

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

getConnection()

public Connection getConnection()
Returns
Type Description
Connection

getConnectionHandler()

public ConnectionHandler getConnectionHandler()
Returns
Type Description
ConnectionHandler

getException()

public PGException getException()

Returns any execution exception registered for this statement.

Returns
Type Description
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
Name Description
index int
Returns
Type Description
short

getSql()

public String getSql()
Returns
Type Description
String

getStatement()

public String getStatement()
Returns
Type Description
String

getStatementResult()

public StatementResult getStatementResult()

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

Returns
Type Description
StatementResult

getStatementType()

public AbstractStatementParser.StatementType getStatementType()
Returns
Type Description
StatementType

getUpdateCount()

public long getUpdateCount()
Returns
Type Description
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
Name Description
resultNotReadyBehavior IntermediateStatement.ResultNotReadyBehavior
Returns
Type Description
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
Name Description
exception PGException

The exception to store.

hasException()

public boolean hasException()
Returns
Type Description
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
Name Description
resultNotReadyBehavior IntermediateStatement.ResultNotReadyBehavior
Returns
Type Description
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
Type Description
boolean

True if bound, false otherwise.

isDescribed()

public boolean isDescribed()
Returns
Type Description
boolean

isExecuted()

public boolean isExecuted()
Returns
Type Description
boolean

True if this statement was executed, False otherwise.

isHasMoreData()

public boolean isHasMoreData()
Returns
Type Description
boolean

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

setCommandTag(String commandTag)

public void setCommandTag(String commandTag)
Parameter
Name Description
commandTag String

setFutureStatementResult(Future<StatementResult> result)

protected void setFutureStatementResult(Future<StatementResult> result)
Parameter
Name Description
result Future<StatementResult>

setHasMoreData(boolean hasMoreData)

public void setHasMoreData(boolean hasMoreData)
Parameter
Name Description
hasMoreData boolean

setStatementResult(StatementResult statementResult)

public void setStatementResult(StatementResult statementResult)
Parameter
Name Description
statementResult StatementResult