Package org.mariadb.jdbc.message
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
Fields Modifier and Type Field Description static java.util.regex.PatternLOAD_LOCAL_INFILE_PREFIXLOAD DATA/XML LOCAL INFILE statement prefix, matched at a statement start only
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intbatchUpdateLength()Number of parameter rows, and so expected return lengthdefault booleanbinaryProtocol()Are return value encoded in binary protocoldefault booleancanSkipMeta()Can skip metadatadefault java.lang.Stringdescription()Message descriptionintencode(Writer writer, Context context)Encode client message to socket.default java.io.InputStreamgetLocalInfileInputStream()Get current local infile input stream.default booleanmightBeBulkResult()Indicating 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, java.util.function.Consumer<java.lang.String> redirectFct)default packet resultset parserstatic intskipStringLiteral(java.lang.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(java.lang.String sql, int pos)Skip to the end of the current line.default booleanvalidateLocalFileName(java.lang.String fileName, Context context)Request for local file to be validated from current query.static booleanvalidateLocalFileName(java.lang.String sql, Parameters parameters, java.lang.String fileName, Context context)Check that the file requested by the server corresponds to a LOAD DATA LOCAL INFILE statement of the current command.
-
-
-
Method Detail
-
validateLocalFileName
static boolean validateLocalFileName(java.lang.String sql, Parameters parameters, java.lang.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
static int skipToEndOfLine(java.lang.String sql, int pos)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
static int skipStringLiteral(java.lang.String sql, int pos, boolean backslashEscapes)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
int encode(Writer writer, Context context) throws java.io.IOException, java.sql.SQLException
Encode client message to socket.- Parameters:
writer- socket writercontext- connection context- Returns:
- number of client message written
- Throws:
java.io.IOException- if socket error occurjava.sql.SQLException- if any issue occurs
-
batchUpdateLength
default int batchUpdateLength()
Number of parameter rows, and so expected return length- Returns:
- batch update length
-
description
default java.lang.String description()
Message description- Returns:
- 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, java.util.function.Consumer<java.lang.String> redirectFct) throws java.io.IOException, java.sql.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:
java.io.IOException- if any socket error occursjava.sql.SQLException- for other kind of errors
-
getLocalInfileInputStream
default java.io.InputStream 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
default boolean validateLocalFileName(java.lang.String fileName, Context context)Request for local file to be validated from current query.- Parameters:
fileName- server file request pathcontext- current connection context- Returns:
- true if file name correspond to demand and query is a load local infile
-
-