Interface ClientMessage
- All Known Subinterfaces:
RedoableClientMessage, RedoableWithPrepareClientMessage
- All Known Implementing Classes:
AuthMoreRawPacket, BulkExecutePacket, ChangeDbPacket, ClosePreparePacket, ExecutePacket, HandshakeResponse, LongDataPacket, PingPacket, PrepareExecutePacket, PreparePacket, QueryPacket, QueryWithParametersPacket, QueryWithParametersRewritePacket, QuitPacket, ResetPacket, SslRequestPacket
public interface ClientMessage
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternLOAD DATA/XML LOCAL INFILE statement prefix, matched at a statement start only -
Method Summary
Modifier and TypeMethodDescriptiondefault intNumber of parameter rows, and so expected return lengthdefault booleanAre return value encoded in binary protocoldefault booleanCan skip metadatadefault StringMessage descriptionintEncode client message to socket.default InputStreamGet current local infile input stream.default booleanIndicating if result might be a COM_STMT_BULK resultdefault CompletionreadPacket(Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion, Reader reader, Writer writer, Context context, ExceptionFactory exceptionFactory, ClosableLock lock, boolean traceEnable, ClientMessage message, Consumer<String> redirectFct) default packet resultset parserstatic intskipStringLiteral(String sql, int pos, boolean backslashEscapes) Skip a string literal starting at pos (a quote character), handling backslash escapes when enabled and doubled quotes.static intskipToEndOfLine(String sql, int pos) Skip to the end of the current line.default booleanvalidateLocalFileName(String fileName, Context context) Request for local file to be validated from current query.static booleanvalidateLocalFileName(String sql, Parameters parameters, String fileName, Context context) Check that the file requested by the server corresponds to a LOAD DATA LOCAL INFILE statement of the current command.
-
Field Details
-
LOAD_LOCAL_INFILE_PREFIX
LOAD DATA/XML LOCAL INFILE statement prefix, matched at a statement start only
-
-
Method Details
-
validateLocalFileName
static boolean validateLocalFileName(String sql, Parameters parameters, String fileName, Context context) Check that the file requested by the server corresponds to a LOAD DATA LOCAL INFILE statement of the current command.The command is tokenized: string literals, quoted identifiers and comments are skipped, and only a LOAD [DATA|XML] LOCAL INFILE found at the start of a statement is considered. Text that merely appears inside a quoted identifier or a literal, e.g. a database or table name returned by a malicious server and re-used by the driver or the application in a later query, can therefore never satisfy a local file request.
- Parameters:
sql- current command sqlparameters- current command parameterfileName- file path requestcontext- current connection context- Returns:
- true if file name correspond to demand and query is a load local infile
-
skipToEndOfLine
Skip to the end of the current line.- Parameters:
sql- sql textpos- current position- Returns:
- position of the line terminator, or sql length when there is none
-
skipStringLiteral
Skip a string literal starting at pos (a quote character), handling backslash escapes when enabled and doubled quotes.- Parameters:
sql- sql textpos- position of the opening quotebackslashEscapes- whether backslash escapes the next character- Returns:
- position after the closing quote, or sql length when the literal is unterminated
-
encode
Encode client message to socket.- Parameters:
writer- socket writercontext- connection context- Returns:
- number of client message written
- Throws:
IOException- if socket error occurSQLException- if any issue occurs
-
batchUpdateLength
default int batchUpdateLength()Number of parameter rows, and so expected return length- Returns:
- batch update length
-
description
-
binaryProtocol
default boolean binaryProtocol()Are return value encoded in binary protocol- Returns:
- use binary protocol
-
canSkipMeta
default boolean canSkipMeta()Can skip metadata- Returns:
- can skip metadata
-
readPacket
default Completion readPacket(Statement stmt, int fetchSize, long maxRows, int resultSetConcurrency, int resultSetType, boolean closeOnCompletion, Reader reader, Writer writer, Context context, ExceptionFactory exceptionFactory, ClosableLock lock, boolean traceEnable, ClientMessage message, Consumer<String> redirectFct) throws IOException, SQLException default packet resultset parser- Parameters:
stmt- callerfetchSize- fetch sizemaxRows- maximum number of rowsresultSetConcurrency- resultset concurrencyresultSetType- resultset typecloseOnCompletion- must close caller on result parsing endreader- packet readerwriter- packet writercontext- connection contextexceptionFactory- connection exception factorylock- thread safe lockstraceEnable- is logging trace enablemessage- client messageredirectFct- redirect consumer- Returns:
- results
- Throws:
IOException- if any socket error occursSQLException- for other kind of errors
-
getLocalInfileInputStream
Get current local infile input stream.- Returns:
- default to null
-
mightBeBulkResult
default boolean mightBeBulkResult()Indicating if result might be a COM_STMT_BULK result- Returns:
- true if so.
-
validateLocalFileName
-