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 Details

    • LOAD_LOCAL_INFILE_PREFIX

      static final Pattern 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 sql
      parameters - current command parameter
      fileName - file path request
      context - current connection context
      Returns:
      true if file name correspond to demand and query is a load local infile
    • skipToEndOfLine

      static int skipToEndOfLine(String sql, int pos)
      Skip to the end of the current line.
      Parameters:
      sql - sql text
      pos - current position
      Returns:
      position of the line terminator, or sql length when there is none
    • skipStringLiteral

      static int skipStringLiteral(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 text
      pos - position of the opening quote
      backslashEscapes - 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 IOException, SQLException
      Encode client message to socket.
      Parameters:
      writer - socket writer
      context - connection context
      Returns:
      number of client message written
      Throws:
      IOException - if socket error occur
      SQLException - if any issue occurs
    • batchUpdateLength

      default int batchUpdateLength()
      Number of parameter rows, and so expected return length
      Returns:
      batch update length
    • description

      default 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, Consumer<String> redirectFct) throws IOException, SQLException
      default packet resultset parser
      Parameters:
      stmt - caller
      fetchSize - fetch size
      maxRows - maximum number of rows
      resultSetConcurrency - resultset concurrency
      resultSetType - resultset type
      closeOnCompletion - must close caller on result parsing end
      reader - packet reader
      writer - packet writer
      context - connection context
      exceptionFactory - connection exception factory
      lock - thread safe locks
      traceEnable - is logging trace enable
      message - client message
      redirectFct - redirect consumer
      Returns:
      results
      Throws:
      IOException - if any socket error occurs
      SQLException - for other kind of errors
    • getLocalInfileInputStream

      default 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(String fileName, Context context)
      Request for local file to be validated from current query.
      Parameters:
      fileName - server file request path
      context - current connection context
      Returns:
      true if file name correspond to demand and query is a load local infile