Class IntermediateStatement (0.5.0)

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

exception

protected SpannerException exception
Field Value
TypeDescription
com.google.cloud.spanner.SpannerException

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

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.

describe()

public DescribeMetadata<?> 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
DescribeMetadata<?>

describeAsync(BackendConnection backendConnection)

public Future<? extends DescribeMetadata<?>> describeAsync(BackendConnection backendConnection)
Parameter
NameDescription
backendConnectionBackendConnection
Returns
TypeDescription
Future<? extends com.google.cloud.spanner.pgadapter.metadata.DescribeMetadata<?>>

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

getException()

public Exception getException()
Returns
TypeDescription
Exception

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
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.

handleExecutionException(SpannerException exception)

protected void handleExecutionException(SpannerException exception)

Clean up and save metadata when an exception occurs.

Parameter
NameDescription
exceptioncom.google.cloud.spanner.SpannerException

The exception to store.

hasException()

public boolean hasException()
Returns
TypeDescription
boolean

True if at some point in execution, and exception was thrown.

isBound()

public boolean isBound()

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

Returns
TypeDescription
boolean

True if bound, false otherwise.

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.

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