public class AbstractQueryProtocol extends AbstractConnectProtocol implements Protocol
activeStreamingResult, autoCommit, autoIncrementIncrement, CHECK_GALERA_STATE_QUERY, connected, database, enableFullLinkTrace, eofDeprecated, exceptionFactory, explicitClosed, galeraAllowedStates, hasWarnings, lock, options, proxy, reader, readOnly, seed, serverCapabilities, serverPrepareStatementCache, serverStatus, serverThreadId, serverVersion, socket, socketTimeout, supportStmtPrepareExecute, traceCache, transactionIsolationLevel, urlParser, useNewExtraInfo, useOceanBaseProtocolV20, username, writer| Modifier and Type | Method and Description |
|---|---|
ServerPrepareResult |
addPrepareInCache(String key,
ServerPrepareResult serverPrepareResult) |
void |
cancelCurrentQuery()
Cancels the current query - clones the current protocol and executes a query using the new
connection.
|
void |
changeUser(String user,
String pwd) |
void |
clearNetworkStatistics() |
void |
closeExplicit() |
boolean |
executeBatchClient(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parametersList,
boolean hasLongData)
Execute clientPrepareQuery batch.
|
ServerPrepareResult |
executeBatchServer(ServerPrepareResult serverPrepareResult,
Results results,
String sql,
List<ParameterHolder[]> parametersList,
boolean hasLongData)
Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch.
|
void |
executeBatchStmt(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
Execute batch from Statement.executeBatch().
|
void |
executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
Execute a query that is already prepared.
|
ServerPrepareResult |
executePreparedQuery(int parameterCount,
ParameterHolder[] parameters,
ServerPrepareResult serverPrepareResult,
Results results)
Execute a query that is to be prepared on server in Oracle mode
|
void |
executePreparedQueryArrayBinding(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
List<ParameterHolder[]> queryParameters,
int queryParameterSize)
Protocol processing mechanism when prepareExecute is not used
|
ServerPrepareResult |
executePreparedQueryArrayBinding(int parameterCount,
boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
List<ParameterHolder[]> queryParameters,
int queryParamtersSize)
Protocol processing mechanism when prepareExecute is used.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters)
Execute a unique clientPrepareQuery.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters,
int queryTimeout)
Execute a unique clientPrepareQuery.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql)
Execute query directly to outputStream.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql,
Charset charset) |
void |
executeQuery(String sql)
Execute internal query.
|
ColumnDefinition[] |
fetchRowViaCursor(int cursorId,
int fetchSize,
Results results) |
ColumnDefinition[] |
fetchRowViaCursorForOracle(int cursorId,
int numRows,
byte offsetType,
int offset,
Results results) |
boolean |
forceReleasePrepareStatement(int statementId)
Force release of prepare statement that are not used.
|
void |
forceReleaseWaitingPrepareStatement()
Force release of prepare statement that are not used.
|
boolean |
getAutocommit()
Get current autocommit status.
|
int |
getAutoIncrementIncrement()
Get current auto increment increment.
|
String |
getCatalog() |
long |
getChecksum() |
int |
getExecuteMode() |
int |
getIterationCount() |
long |
getLastPacketCostTime() |
long |
getLastPacketResponseTimestamp() |
long |
getLastPacketSendTimestamp() |
long |
getMaxRows() |
boolean |
getNetworkStatisticsFlag() |
void |
getResult(Results results) |
ColumnDefinition[] |
getResultWithoutValue(Results results) |
int |
getTimeout()
Returns the connection timeout in milliseconds.
|
int |
getTransactionIsolationLevel() |
SQLException |
handleIoException(Exception initialException)
Handle IoException (reconnect if Exception is due to having send too much data, making server
close the connection.
|
void |
interrupt() |
boolean |
inTransaction() |
boolean |
isInterrupted() |
boolean |
isValid(int timeout)
Check that connection is valid.
|
boolean |
ping() |
ServerPrepareResult |
prepare(String sql,
boolean executeOnMaster)
Prepare query on server side.
|
void |
prolog(long maxRows,
boolean hasProxy,
OceanBaseConnection connection,
OceanBaseStatement statement)
Preparation before command.
|
void |
prologProxy(ServerPrepareResult serverPrepareResult,
long maxRows,
boolean hasProxy,
OceanBaseConnection connection,
OceanBaseStatement statement) |
SQLException |
readErrorPacket(Buffer buffer,
Results results)
Read ERR_Packet.
|
void |
readOkPacket(Buffer buffer,
Results results)
Read OK_Packet.
|
void |
readResultSet(ColumnDefinition[] ci,
Results results)
Read ResultSet Packet.
|
void |
releasePrepareStatement(ServerPrepareResult serverPrepareResult)
Deallocate prepare statement if not used anymore.
|
void |
reset()
Reset connection state.
|
void |
resetChecksum() |
void |
resetDatabase() |
void |
resetStateAfterFailover(long maxRows,
int transactionIsolationLevel,
String database,
boolean autocommit)
Set current state after a failover.
|
void |
rollback()
Rollback transaction.
|
void |
setActiveFutureTask(FutureTask activeFutureTask) |
void |
setAutoCommit(boolean autoCommit) |
void |
setCatalog(String database) |
void |
setChecksum(long checksum) |
void |
setComStmtPrepareExecuteField(int iterationCount,
int executeMode,
long checksum) |
void |
setExecuteMode(int executeMode) |
void |
setIterationCount(int iterationCount) |
void |
setLocalInfileInputStream(InputStream inputStream) |
void |
setMaxRows(long max) |
void |
setNetworkStatisticsFlag(boolean flag) |
void |
setReadonly(boolean readOnly)
Puts this connection in read-only / read-write mode
|
void |
setTimeout(int timeout)
Sets the connection timeout.
|
void |
setTransactionIsolation(int level)
Set transaction isolation.
|
void |
setUsername(String username) |
void |
stopIfInterrupted()
Throw TimeoutException if timeout has been reached.
|
abort, changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, cleanMemory, close, connect, connectWithoutProxy, destroySocket, getActiveStreamingResult, getDatabase, getEncoding, getFullLinkTraceAction, getFullLinkTraceClientInfo, getFullLinkTraceIdentifier, getFullLinkTraceLevel, getFullLinkTraceModule, getFullLinkTracePrintSamplePercentage, getFullLinkTraceRecordPolicy, getFullLinkTraceSamplePercentage, getFullLinkTraceSlowQueryThreshold, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getObServerVersion, getOptions, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReader, getReadonly, getServerThreadId, getServerTimeZone, getServerVersion, getSocket, getTimeZone, getTraces, getUrlParser, getUsername, getWriter, hasMoreResults, hasWarnings, isClosed, isConnected, isEofDeprecated, isExplicitClosed, isMasterConnection, isOracleMode, isServerMariaDb, isTZTablesImported, mustBeMasterConnection, noBackslashEscapes, parseVersion, postConnectionQueries, prepareStatementCache, readEofPacket, readPipelineCheckMaster, removeActiveStreamingResult, removeHasMoreResults, sessionStateAware, setActiveStreamingResult, setFullLinkTraceAction, setFullLinkTraceClientInfo, setFullLinkTraceIdentifier, setFullLinkTraceModule, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setObServerVersion, setOracleMode, setProxy, setServerStatus, shouldReconnectWithoutProxy, skip, skipEofPacket, supportFetchWithOffset, supportStmtPrepareExecute, useOceanBaseProtocolV20, versionGreaterOrEqualclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitabort, changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, close, connect, connectWithoutProxy, getActiveStreamingResult, getDatabase, getEncoding, getFullLinkTraceAction, getFullLinkTraceClientInfo, getFullLinkTraceIdentifier, getFullLinkTraceLevel, getFullLinkTraceModule, getFullLinkTracePrintSamplePercentage, getFullLinkTraceRecordPolicy, getFullLinkTraceSamplePercentage, getFullLinkTraceSlowQueryThreshold, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getObServerVersion, getOptions, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReader, getReadonly, getServerThreadId, getServerVersion, getSocket, getTimeZone, getTraces, getUrlParser, getUsername, getWriter, hasMoreResults, hasWarnings, isClosed, isConnected, isEofDeprecated, isExplicitClosed, isMasterConnection, isOracleMode, isServerMariaDb, isTZTablesImported, mustBeMasterConnection, noBackslashEscapes, parseVersion, prepareStatementCache, readEofPacket, removeActiveStreamingResult, removeHasMoreResults, sessionStateAware, setActiveStreamingResult, setFullLinkTraceAction, setFullLinkTraceClientInfo, setFullLinkTraceIdentifier, setFullLinkTraceModule, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setObServerVersion, setProxy, setServerStatus, shouldReconnectWithoutProxy, skip, skipEofPacket, supportFetchWithOffset, supportStmtPrepareExecute, useOceanBaseProtocolV20, versionGreaterOrEqualpublic void reset()
throws SQLException
reset in interface ProtocolSQLException - if command failedpublic ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws SQLException
For failover, two additional information are in the result-set object : - current connection : Since server maintain a state of this prepare statement, all query will be executed on this particular connection. - executeOnMaster : state of current connection when creating this prepareStatement (if was on master, will only be executed on master. If was on a slave, can be execute temporary on master, but we keep this flag, so when a slave is connected back to relaunch this query on slave)
prepare in interface Protocolsql - the queryexecuteOnMaster - state of current connection when creating this prepareStatementSQLException - if any error occur on connection.public void executeQuery(String sql) throws SQLException
!! will not support multi values queries !!
executeQuery in interface ProtocolexecuteQuery in class AbstractConnectProtocolsql - sqlSQLException - in any exception occurpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql)
throws SQLException
executeQuery in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsql - the query to executeInternalSQLException - exceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql,
Charset charset)
throws SQLException
executeQuery in interface ProtocolSQLExceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters)
throws SQLException
executeQuery in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsclientPrepareResult - clientPrepareResultparameters - parametersSQLException - exceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters,
int queryTimeout)
throws SQLException
executeQuery in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsclientPrepareResult - clientPrepareResultparameters - parametersqueryTimeout - if timeout is set and must use max_statement_timeSQLException - exceptionpublic void executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
throws SQLException
executePreparedQuery in interface ProtocolmustExecuteOnMaster - must execute on masterserverPrepareResult - prepare resultresults - execution resultparameters - parametersSQLException - exceptionpublic ServerPrepareResult executePreparedQuery(int parameterCount, ParameterHolder[] parameters, ServerPrepareResult serverPrepareResult, Results results) throws SQLException
executePreparedQuery in interface ProtocolSQLException - exceptionpublic boolean executeBatchClient(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parametersList,
boolean hasLongData)
throws SQLException
executeBatchClient in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsprepareResult - ClientPrepareResultparametersList - List of parametershasLongData - has parameter with long data (stream)SQLException - exceptionpublic void executeBatchStmt(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
throws SQLException
executeBatchStmt in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsqueries - queriesSQLException - if any exception occurpublic ServerPrepareResult executeBatchServer(ServerPrepareResult serverPrepareResult, Results results, String sql, List<ParameterHolder[]> parametersList, boolean hasLongData) throws SQLException
executeBatchServer in interface ProtocolserverPrepareResult - prepare result. can be null if not prepared.results - execution resultssql - sql query if needed to be preparedparametersList - parameter listhasLongData - has long data (stream)SQLException - if parameter error or connection error occur.public ColumnDefinition[] fetchRowViaCursor(int cursorId, int fetchSize, Results results) throws SQLException
fetchRowViaCursor in interface ProtocolSQLExceptionpublic ColumnDefinition[] fetchRowViaCursorForOracle(int cursorId, int numRows, byte offsetType, int offset, Results results) throws SQLException
fetchRowViaCursorForOracle in interface ProtocolSQLExceptionpublic void executePreparedQueryArrayBinding(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
List<ParameterHolder[]> queryParameters,
int queryParameterSize)
throws SQLException
executePreparedQueryArrayBinding in interface ProtocolmustExecuteOnMaster - serverPrepareResult - results - queryParameters - queryParameterSize - SQLExceptionpublic ServerPrepareResult executePreparedQueryArrayBinding(int parameterCount, boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, List<ParameterHolder[]> queryParameters, int queryParamtersSize) throws SQLException
executePreparedQueryArrayBinding in interface ProtocolparameterCount - is count of parameters.mustExecuteOnMaster - serverPrepareResult - results - queryParameters - is sublist of parameters list.queryParamtersSize - SQLExceptionpublic long getLastPacketCostTime()
throws SQLException
getLastPacketCostTime in interface ProtocolSQLExceptionpublic boolean getNetworkStatisticsFlag()
getNetworkStatisticsFlag in interface Protocolpublic void setNetworkStatisticsFlag(boolean flag)
setNetworkStatisticsFlag in interface Protocolpublic long getLastPacketResponseTimestamp()
getLastPacketResponseTimestamp in interface Protocolpublic long getLastPacketSendTimestamp()
getLastPacketSendTimestamp in interface Protocolpublic void clearNetworkStatistics()
clearNetworkStatistics in interface Protocolpublic void changeUser(String user, String pwd) throws SQLException
changeUser in interface ProtocolSQLExceptionpublic void rollback()
throws SQLException
rollback in interface ProtocolSQLExceptionpublic void setUsername(String username)
setUsername in interface Protocolpublic boolean forceReleasePrepareStatement(int statementId)
throws SQLException
forceReleasePrepareStatement in interface ProtocolstatementId - prepared statement Id to remove.SQLException - if connection exception.public void forceReleaseWaitingPrepareStatement()
throws SQLException
forceReleaseWaitingPrepareStatement in interface ProtocolSQLException - if connection occurpublic boolean ping()
throws SQLException
ping in interface ProtocolSQLExceptionpublic boolean isValid(int timeout)
throws SQLException
isValid in interface Protocoltimeout - timeout in millisecondsSQLException - if any error occurpublic String getCatalog() throws SQLException
getCatalog in interface ProtocolSQLExceptionpublic void setCatalog(String database) throws SQLException
setCatalog in interface ProtocolSQLExceptionpublic void resetDatabase()
throws SQLException
resetDatabase in interface ProtocolSQLExceptionpublic void cancelCurrentQuery()
throws SQLException
cancelCurrentQuery in interface ProtocolSQLException - never thrownpublic boolean getAutocommit()
getAutocommit in interface Protocolpublic void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ProtocolSQLExceptionpublic boolean inTransaction()
inTransaction in interface Protocolpublic void closeExplicit()
closeExplicit in interface Protocolpublic void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws SQLException
releasePrepareStatement in interface ProtocolserverPrepareResult - allocation resultSQLException - if de-allocation failed.public long getMaxRows()
getMaxRows in interface Protocolpublic void setMaxRows(long max)
throws SQLException
setMaxRows in interface ProtocolSQLExceptionpublic void setLocalInfileInputStream(InputStream inputStream)
setLocalInfileInputStream in interface Protocolpublic int getTimeout()
getTimeout in interface Protocolpublic void setTimeout(int timeout)
throws SocketException
setTimeout in interface Protocoltimeout - the timeout, in millisecondsSocketException - if there is an error in the underlying protocol, such as a TCP error.public void setReadonly(boolean readOnly)
throws SQLException
setReadonly in interface ProtocolreadOnly - true enables read-only mode; false disables itSQLException - If socket error.public void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation in interface Protocollevel - transaction level.SQLException - if transaction level is unknownpublic int getTransactionIsolationLevel()
getTransactionIsolationLevel in interface Protocolpublic void getResult(Results results) throws SQLException
getResult in interface ProtocolSQLExceptionpublic ColumnDefinition[] getResultWithoutValue(Results results) throws SQLException
SQLExceptionpublic int getAutoIncrementIncrement()
throws SQLException
getAutoIncrementIncrement in interface ProtocolSQLException - if cannot retrieve auto increment valuepublic void readOkPacket(Buffer buffer, Results results)
readOkPacket in interface Protocolbuffer - current bufferresults - result objectpublic SQLException readErrorPacket(Buffer buffer, Results results)
readErrorPacket in interface Protocolbuffer - current bufferresults - result objectpublic void readResultSet(ColumnDefinition[] ci, Results results) throws SQLException
readResultSet in interface Protocolresults - result objectSQLException - if sub-result connection failpublic void prologProxy(ServerPrepareResult serverPrepareResult, long maxRows, boolean hasProxy, OceanBaseConnection connection, OceanBaseStatement statement) throws SQLException
prologProxy in interface ProtocolSQLExceptionpublic void prolog(long maxRows,
boolean hasProxy,
OceanBaseConnection connection,
OceanBaseStatement statement)
throws SQLException
prolog in interface ProtocolmaxRows - query max rowshasProxy - has proxyconnection - current connectionstatement - current statementSQLException - if any error occur.public ServerPrepareResult addPrepareInCache(String key, ServerPrepareResult serverPrepareResult)
addPrepareInCache in interface Protocolpublic void resetStateAfterFailover(long maxRows,
int transactionIsolationLevel,
String database,
boolean autocommit)
throws SQLException
resetStateAfterFailover in interface ProtocolmaxRows - current Max rowstransactionIsolationLevel - current transactionIsolationLeveldatabase - current databaseautocommit - current autocommit stateSQLException - if any error occur.public SQLException handleIoException(Exception initialException)
There is 3 kind of IOException :
handleIoException in interface ProtocolinitialException - initial Io errorpublic void setActiveFutureTask(FutureTask activeFutureTask)
setActiveFutureTask in interface Protocolpublic boolean isInterrupted()
isInterrupted in interface Protocolpublic void stopIfInterrupted()
throws SQLTimeoutException
stopIfInterrupted in interface ProtocolSQLTimeoutException - to indicate timeout exception.public long getChecksum()
getChecksum in interface Protocolpublic void setChecksum(long checksum)
setChecksum in interface Protocolpublic void resetChecksum()
resetChecksum in interface Protocolpublic int getIterationCount()
getIterationCount in interface Protocolpublic void setIterationCount(int iterationCount)
setIterationCount in interface Protocolpublic int getExecuteMode()
getExecuteMode in interface Protocolpublic void setExecuteMode(int executeMode)
setExecuteMode in interface Protocolpublic void setComStmtPrepareExecuteField(int iterationCount,
int executeMode,
long checksum)
setComStmtPrepareExecuteField in interface ProtocolCopyright © 2022 oceanbase.com. All rights reserved.