public class AbstractQueryProtocol extends AbstractConnectProtocol implements Protocol
| Modifier and Type | Field and Description |
|---|---|
static ThreadPoolExecutor |
readScheduler |
activeStreamingResult, connected, currentHost, database, dataTypeMappingFlags, explicitClosed, hasWarnings, lock, moreResults, options, packetFetcher, proxy, readOnly, serverPrepareStatementCache, serverStatus, serverThreadId, socket, urlParser, writer| Constructor and Description |
|---|
AbstractQueryProtocol(UrlParser urlParser,
ReentrantLock lock)
Get a protocol instance.
|
| 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 |
closeExplicit() |
void |
executeBatch(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
Execute list of queries not rewritable.
|
void |
executeBatchMulti(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
List<ParameterHolder[]> parametersList)
Execute clientPrepareQuery batch.
|
void |
executeBatchMultiple(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
Execute list of queries.
|
void |
executeBatchRewrite(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parameterList,
boolean rewriteValues)
Specific execution for batch rewrite that has specific query for memory.
|
void |
executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
Execute a query that is already prepared.
|
void |
executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters)
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.
!!
|
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() |
int |
getMaxRows() |
void |
getResult(Results results) |
int |
getTimeout()
Returns the connection timeout in milliseconds.
|
int |
getTransactionIsolationLevel() |
boolean |
hasMoreResults() |
boolean |
inTransaction() |
boolean |
ping() |
ServerPrepareResult |
prepare(String sql,
boolean executeOnMaster)
Prepare query on server side.
|
ServerPrepareResult |
prepareAndExecute(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
String sql,
ParameterHolder[] parameters)
Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch.
|
ServerPrepareResult |
prepareAndExecutes(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
String sql,
List<ParameterHolder[]> parametersList)
Execute Prepare if needed, and execute COM_STMT_EXECUTE queries in batch.
|
void |
prolog(Results results,
int maxRows,
boolean hasProxy,
MariaDbConnection connection,
MariaDbStatement statement)
Preparation before command.
|
void |
prologProxy(ServerPrepareResult serverPrepareResult,
Results results,
int maxRows,
boolean hasProxy,
MariaDbConnection connection,
MariaDbStatement statement) |
QueryException |
readErrorPacket(Buffer buffer,
Results results)
Read ERR_Packet.
|
void |
readLocalInfilePacket(Buffer buffer,
Results results)
Read Local_infile Packet.
|
void |
readOkPacket(Buffer buffer,
Results results)
Read OK_Packet.
|
void |
readPacket(Results results)
Read server response packet.
|
void |
readResultSet(Buffer buffer,
Results results)
Read ResultSet Packet.
|
void |
releasePrepareStatement(ServerPrepareResult serverPrepareResult)
Deallocate prepare statement if not used anymore.
|
void |
resetStateAfterFailover(int maxRows,
int transactionIsolationLevel,
String database,
boolean autocommit)
Set current state after a failover.
|
void |
rollback()
Rollback transaction.
|
void |
setActiveFutureTask(FutureTask activeFutureTask) |
void |
setCatalog(String database) |
void |
setInternalMaxRows(int max)
Set max row retuen by a statement.
|
void |
setLocalInfileInputStream(InputStream inputStream) |
void |
setMaxRows(int max) |
void |
setTimeout(int timeout)
Sets the connection timeout.
|
void |
setTransactionIsolation(int level)
Set transaction isolation.
|
changeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, close, close, connect, connectWithoutProxy, enabledSslCipherSuites, enabledSslProtocolSuites, getActiveStreamingResult, getCalendar, getDatabase, getDataTypeMappingFlags, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getOptions, getPacketFetcher, getPassword, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReadonly, getServerData, getServerThreadId, getServerVersion, getUrlParser, getUsername, getWriter, hasWarnings, isClosed, isConnected, isExplicitClosed, isMasterConnection, isServerMariaDb, mustBeMasterConnection, noBackslashEscapes, prepareStatementCache, readEofPacket, releaseWriterBuffer, removeActiveStreamingResult, setActiveStreamingResult, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setMoreResults, setProxy, setReadonly, shouldReconnectWithoutProxy, skip, skipEofPacket, versionGreaterOrEqualclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchangeSocketSoTimeout, changeSocketTcpNoDelay, checkIfMaster, close, connect, connectWithoutProxy, getActiveStreamingResult, getCalendar, getDatabase, getDataTypeMappingFlags, getHost, getHostAddress, getLock, getMajorServerVersion, getMinorServerVersion, getOptions, getPacketFetcher, getPassword, getPinGlobalTxToPhysicalConnection, getPort, getProxy, getReadonly, getServerData, getServerThreadId, getServerVersion, getUrlParser, getUsername, getWriter, hasWarnings, isClosed, isConnected, isExplicitClosed, isMasterConnection, isServerMariaDb, mustBeMasterConnection, noBackslashEscapes, prepareStatementCache, readEofPacket, releaseWriterBuffer, removeActiveStreamingResult, setActiveStreamingResult, setHasWarnings, setHostAddress, setHostFailedWithoutProxy, setMoreResults, setProxy, setReadonly, shouldReconnectWithoutProxy, skip, skipEofPacket, versionGreaterOrEqualpublic static ThreadPoolExecutor readScheduler
public AbstractQueryProtocol(UrlParser urlParser, ReentrantLock lock)
urlParser - connection URL infoslock - the lock for thread synchronisationpublic void executeQuery(String sql) throws QueryException
executeQuery in interface ProtocolexecuteQuery in class AbstractConnectProtocolsql - sqlQueryException - in any exception occurpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql)
throws QueryException
executeQuery in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsql - the query to executeInternalQueryException - exceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
String sql,
Charset charset)
throws QueryException
executeQuery in interface ProtocolQueryExceptionpublic void executeQuery(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
ParameterHolder[] parameters)
throws QueryException
executeQuery in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsclientPrepareResult - clientPrepareResultparameters - parametersQueryException - exceptionpublic void executeBatchMulti(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult clientPrepareResult,
List<ParameterHolder[]> parametersList)
throws QueryException
executeBatchMulti in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultsclientPrepareResult - ClientPrepareResultparametersList - List of parametersQueryException - exceptionpublic void executeBatch(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
throws QueryException
executeBatch in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - result objectqueries - list of queriesQueryException - exceptionpublic ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws QueryException
For failover, two additional information are in the resultset 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 prepareStatementQueryException - if any error occur on connection.public void executeBatchMultiple(boolean mustExecuteOnMaster,
Results results,
List<String> queries)
throws QueryException
executeBatchMultiple in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - result objectqueries - list of queriesQueryException - exceptionpublic void executeBatchRewrite(boolean mustExecuteOnMaster,
Results results,
ClientPrepareResult prepareResult,
List<ParameterHolder[]> parameterList,
boolean rewriteValues)
throws QueryException
executeBatchRewrite in interface ProtocolmustExecuteOnMaster - was intended to be launched on master connectionresults - resultprepareResult - prepareResultparameterList - parametersrewriteValues - is rewritable flagQueryException - exceptionpublic ServerPrepareResult prepareAndExecutes(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, String sql, List<ParameterHolder[]> parametersList) throws QueryException
prepareAndExecutes in interface ProtocolmustExecuteOnMaster - must normally be executed on master connectionserverPrepareResult - prepare result. can be null if not prepared.results - execution resultssql - sql query if needed to be preparedparametersList - parameter listQueryException - if parameter error or connection error occur.public ServerPrepareResult prepareAndExecute(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, String sql, ParameterHolder[] parameters) throws QueryException
prepareAndExecute in interface ProtocolmustExecuteOnMaster - must normally be executed on master connectionserverPrepareResult - prepare result. can be null if not prepared.results - execution resultssql - sql query if needed to be preparedparameters - parametersQueryException - if parameter error or connection error occur.public void executePreparedQuery(boolean mustExecuteOnMaster,
ServerPrepareResult serverPrepareResult,
Results results,
ParameterHolder[] parameters)
throws QueryException
executePreparedQuery in interface ProtocolmustExecuteOnMaster - must execute on masterserverPrepareResult - prepare resultresults - execution resultparameters - parametersQueryException - exceptionpublic void rollback()
throws QueryException
rollback in interface ProtocolQueryExceptionpublic boolean forceReleasePrepareStatement(int statementId)
throws QueryException
forceReleasePrepareStatement in interface ProtocolstatementId - prepared statement Id to remove.QueryException - if connection exception.public void forceReleaseWaitingPrepareStatement()
throws QueryException
forceReleaseWaitingPrepareStatement in interface ProtocolQueryException - if connection occurpublic boolean ping()
throws QueryException
ping in interface ProtocolQueryExceptionpublic void setCatalog(String database) throws QueryException
setCatalog in interface ProtocolQueryExceptionpublic void cancelCurrentQuery()
throws QueryException,
IOException
cancelCurrentQuery in interface ProtocolQueryException - never thrownIOException - if Host is not respondingpublic boolean getAutocommit()
getAutocommit in interface Protocolpublic boolean inTransaction()
inTransaction in interface Protocolpublic boolean hasMoreResults()
hasMoreResults in interface ProtocolhasMoreResults in class AbstractConnectProtocolpublic void closeExplicit()
closeExplicit in interface Protocolpublic void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws QueryException
releasePrepareStatement in interface ProtocolserverPrepareResult - allocation resultQueryException - if deallocation failed.public void setInternalMaxRows(int max)
setInternalMaxRows in interface Protocolmax - row number max valuepublic int getMaxRows()
getMaxRows in interface Protocolpublic void setMaxRows(int max)
throws QueryException
setMaxRows in interface ProtocolQueryExceptionpublic void setLocalInfileInputStream(InputStream inputStream)
setLocalInfileInputStream in interface Protocolpublic int getTimeout()
throws SocketException
getTimeout in interface ProtocolSocketException - if there is an error in the underlying protocol, such as a TCP error.public 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 setTransactionIsolation(int level)
throws QueryException
setTransactionIsolation in interface Protocollevel - transaction level.QueryException - if transaction level is unknownpublic int getTransactionIsolationLevel()
getTransactionIsolationLevel in interface Protocolpublic void getResult(Results results) throws QueryException
getResult in interface ProtocolQueryExceptionpublic void readPacket(Results results) throws QueryException
results - result objectQueryException - if sub-result connection failpublic void readOkPacket(Buffer buffer, Results results) throws QueryException
buffer - current bufferresults - result objectQueryException - if sub-result connection failpublic QueryException readErrorPacket(Buffer buffer, Results results)
buffer - current bufferresults - result objectpublic void readLocalInfilePacket(Buffer buffer, Results results) throws QueryException
buffer - current bufferresults - result objectQueryException - if sub-result connection failpublic void readResultSet(Buffer buffer, Results results) throws QueryException
buffer - current bufferresults - result objectQueryException - if sub-result connection failpublic void prologProxy(ServerPrepareResult serverPrepareResult, Results results, int maxRows, boolean hasProxy, MariaDbConnection connection, MariaDbStatement statement) throws SQLException
prologProxy in interface ProtocolSQLExceptionpublic void prolog(Results results, int maxRows, boolean hasProxy, MariaDbConnection connection, MariaDbStatement statement) throws SQLException
prolog in interface Protocolresults - resultmaxRows - 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(int maxRows,
int transactionIsolationLevel,
String database,
boolean autocommit)
throws QueryException
resetStateAfterFailover in interface ProtocolmaxRows - current Max rowstransactionIsolationLevel - current transactionIsolationLeveldatabase - current databaseautocommit - current autocommit stateQueryException - if any error occur.public void setActiveFutureTask(FutureTask activeFutureTask)
setActiveFutureTask in interface ProtocolCopyright © 2017. All rights reserved.