Interface ClientMessage

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.regex.Pattern LOAD_LOCAL_INFILE_PREFIX
      LOAD DATA/XML LOCAL INFILE statement prefix, matched at a statement start only
    • Field Detail

      • LOAD_LOCAL_INFILE_PREFIX

        static final java.util.regex.Pattern LOAD_LOCAL_INFILE_PREFIX
        LOAD DATA/XML LOCAL INFILE statement prefix, matched at a statement start only
    • 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 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​(java.lang.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​(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 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 java.io.IOException,
                   java.sql.SQLException
        Encode client message to socket.
        Parameters:
        writer - socket writer
        context - connection context
        Returns:
        number of client message written
        Throws:
        java.io.IOException - if socket error occur
        java.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 - 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:
        java.io.IOException - if any socket error occurs
        java.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 path
        context - current connection context
        Returns:
        true if file name correspond to demand and query is a load local infile