Package com.mysql.cj
Class ServerPreparedQuery
java.lang.Object
- All Implemented Interfaces:
PreparedQuery<ServerPreparedQueryBindings>
,Query
- Direct Known Subclasses:
ServerPreparedQueryTestcaseGenerator
public class ServerPreparedQuery extends AbstractPreparedQuery<ServerPreparedQueryBindings>
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static int
BLOB_STREAM_READ_BUF_SIZE
protected NativeMessageBuilder
commandBuilder
protected RuntimeProperty<java.lang.Boolean>
explainSlowQueries
protected boolean
gatherPerfMetrics
The "gatherPerfMetrics" connection property valueprotected boolean
logSlowQueries
The "logSlowQueries" connection property valuestatic byte
OPEN_CURSOR_FLAG
protected boolean
profileSQL
The "profileSQL" connection property valueprotected boolean
queryWasSlow
protected RuntimeProperty<java.lang.Integer>
slowQueryThresholdMillis
protected boolean
useCursorFetch
Fields inherited from class com.mysql.cj.AbstractPreparedQuery
autoClosePStmtStreams, batchCommandIndex, originalSql, parameterCount, parseInfo, queryBindings, useStreamLengthsInPrepStmts
Fields inherited from class com.mysql.cj.AbstractQuery
batchedArgs, cancelTimeoutMutex, charEncoding, clearWarningsCalled, currentDb, fetchSize, maxAllowedPacket, resultSetType, session, statementExecuting, statementId, timeoutInMillis
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServerPreparedQuery(NativeSession sess)
-
Method Summary
Modifier and Type Method Description void
clearParameters(boolean clearServerParameters)
void
closeQuery()
protected long[]
computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)
Computes the maximum parameter set size and the size of the entire batch given the number of arguments in the batch.<M extends Message>
MfillSendPacket()
Creates the packet that contains the query to be sent to the server.<M extends Message>
MfillSendPacket(QueryBindings<?> bindings)
Creates the packet that contains the query to be sent to the server.static ServerPreparedQuery
getInstance(NativeSession sess)
Field[]
getParameterFields()
ColumnDefinition
getResultFields()
long
getServerStatementId()
NativePacketPayload
prepareExecutePacket()
<T extends Resultset>
TreadExecuteResult(NativePacketPayload resultPacket, int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory, java.lang.String queryAsString)
NativePacketPayload
sendExecutePacket(NativePacketPayload packet, java.lang.String queryAsString)
<T extends Resultset>
TserverExecute(int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory)
void
serverPrepare(java.lang.String sql)
void
serverResetStatement()
void
setParameterFields(Field[] parameterFields)
void
setResultFields(ColumnDefinition resultFields)
void
setServerStatementId(long serverStatementId)
void
statementBegins()
void
storeReader(int parameterIndex, NativePacketPayload packet, java.io.Reader inStream)
void
storeStream(int parameterIndex, NativePacketPayload packet, java.io.InputStream inStream)
Methods inherited from class com.mysql.cj.AbstractPreparedQuery
asSql, asSql, checkNullOrEmptyQuery, computeBatchSize, getBatchCommandIndex, getOriginalSql, getParameterCount, getParseInfo, getQueryBindings, setBatchCommandIndex, setOriginalSql, setParameterCount, setParseInfo, setQueryBindings
Methods inherited from class com.mysql.cj.AbstractQuery
addBatch, checkCancelTimeout, clearBatchedArgs, getBatchedArgs, getCancelTimeoutMutex, getCurrentDatabase, getExecuteTime, getId, getResultFetchSize, getResultSetFactory, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, isClearWarningsCalled, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setExecuteTime, setResultFetchSize, setResultType, setTimeoutInMillis, startQueryTimer, stopQueryTimer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.mysql.cj.Query
addBatch, checkCancelTimeout, clearBatchedArgs, getBatchedArgs, getCancelTimeoutMutex, getCurrentDatabase, getExecuteTime, getId, getResultFetchSize, getResultSetFactory, getResultType, getSession, getStatementExecuting, getTimeoutInMillis, isClearWarningsCalled, resetCancelledState, setCancelStatus, setClearWarningsCalled, setCurrentDatabase, setExecuteTime, setResultFetchSize, setResultType, setTimeoutInMillis, startQueryTimer, stopQueryTimer
-
Field Details
-
BLOB_STREAM_READ_BUF_SIZE
public static final int BLOB_STREAM_READ_BUF_SIZE- See Also:
- Constant Field Values
-
OPEN_CURSOR_FLAG
public static final byte OPEN_CURSOR_FLAG- See Also:
- Constant Field Values
-
profileSQL
protected boolean profileSQLThe "profileSQL" connection property value -
gatherPerfMetrics
protected boolean gatherPerfMetricsThe "gatherPerfMetrics" connection property value -
logSlowQueries
protected boolean logSlowQueriesThe "logSlowQueries" connection property value -
slowQueryThresholdMillis
-
explainSlowQueries
-
useCursorFetch
protected boolean useCursorFetch -
queryWasSlow
protected boolean queryWasSlow -
commandBuilder
-
-
Constructor Details
-
Method Details
-
getInstance
-
serverPrepare
public void serverPrepare(java.lang.String sql) throws java.io.IOException- Parameters:
sql
- query string- Throws:
java.io.IOException
- if an i/o error occurs
-
statementBegins
public void statementBegins()- Specified by:
statementBegins
in interfaceQuery
- Overrides:
statementBegins
in classAbstractQuery
-
serverExecute
public <T extends Resultset> T serverExecute(int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory)- Type Parameters:
T
- extendsResultset
- Parameters:
maxRowsToRetrieve
- rows limitcreateStreamingResultSet
- should c/J create a streaming result?metadata
- use this metadata instead of the one provided on wireresultSetFactory
-ProtocolEntityFactory
- Returns:
- T instance
-
prepareExecutePacket
-
sendExecutePacket
public NativePacketPayload sendExecutePacket(NativePacketPayload packet, java.lang.String queryAsString) -
readExecuteResult
public <T extends Resultset> T readExecuteResult(NativePacketPayload resultPacket, int maxRowsToRetrieve, boolean createStreamingResultSet, ColumnDefinition metadata, ProtocolEntityFactory<T,NativePacketPayload> resultSetFactory, java.lang.String queryAsString) -
closeQuery
public void closeQuery()- Specified by:
closeQuery
in interfaceQuery
- Overrides:
closeQuery
in classAbstractPreparedQuery<ServerPreparedQueryBindings>
-
getServerStatementId
public long getServerStatementId() -
setServerStatementId
public void setServerStatementId(long serverStatementId) -
getParameterFields
-
setParameterFields
-
getResultFields
-
setResultFields
-
storeStream
public void storeStream(int parameterIndex, NativePacketPayload packet, java.io.InputStream inStream) -
storeReader
-
clearParameters
public void clearParameters(boolean clearServerParameters)- Parameters:
clearServerParameters
- flag indicating whether we need an additional clean up
-
serverResetStatement
public void serverResetStatement() -
computeMaxParameterSetSizeAndBatchSize
protected long[] computeMaxParameterSetSizeAndBatchSize(int numBatchedArgs)Computes the maximum parameter set size and the size of the entire batch given the number of arguments in the batch.- Specified by:
computeMaxParameterSetSizeAndBatchSize
in classAbstractPreparedQuery<ServerPreparedQueryBindings>
-
fillSendPacket
Description copied from class:AbstractPreparedQuery
Creates the packet that contains the query to be sent to the server.- Specified by:
fillSendPacket
in interfacePreparedQuery<ServerPreparedQueryBindings>
- Overrides:
fillSendPacket
in classAbstractPreparedQuery<ServerPreparedQueryBindings>
- Returns:
- A Buffer filled with the query representing the PreparedStatement.
-
fillSendPacket
Description copied from class:AbstractPreparedQuery
Creates the packet that contains the query to be sent to the server.- Specified by:
fillSendPacket
in interfacePreparedQuery<ServerPreparedQueryBindings>
- Overrides:
fillSendPacket
in classAbstractPreparedQuery<ServerPreparedQueryBindings>
- Parameters:
bindings
- values- Returns:
- a Buffer filled with the query that represents this statement
-