Class ClientParser

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  ClientParser.LexState  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ClientParser​(java.lang.String sql, byte[] query, java.util.List<java.lang.Integer> paramPositions, java.util.List<java.lang.Integer> valuesBracketPositions, boolean isInsert, boolean isInsertDuplicate, boolean isMultiQuery)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean equalsIgnoreCase​(byte b, byte lower)
      Fast case-insensitive byte comparison for ASCII letters.
      int getParamCount()  
      java.util.List<java.lang.Integer> getParamPositions()  
      byte[] getQuery()  
      java.lang.String getSql()  
      java.util.List<java.lang.Integer> getValuesBracketPositions()  
      private static boolean isDelimiter​(byte b)
      Fast check if byte is a delimiter character: ();><=-+, Avoids String.indexOf() overhead
      boolean isInsert()  
      boolean isInsertDuplicate()  
      boolean isMultiQuery()  
      private static boolean isWhitespace​(byte b)
      Fast check if byte is whitespace: space, \n, \r, \t
      static ClientParser parameterParts​(java.lang.String queryString, boolean noBackslashEscapes)
      For a given queryString, get query - a byte array containing the UTF8 representation of that string paramPositions - the byte positions of any '?' positional parameters in query and set the following flags: isInsert - queryString contains 'INSERT' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following isInsertDuplicate - isInsert && queryString contains 'DUPLICATE' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following isMulti - queryString contains text after the last ';' outside of quotes
      static ClientParser rewritableParts​(java.lang.String queryString, boolean noBackslashEscapes)
      For a given queryString, get the fields and flags from parameterParts(String, boolean), and valuesBracketPositions - a two-element list containing the positions of the opening and closing parenthesis of the VALUES block
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sql

        private final java.lang.String sql
      • query

        private final byte[] query
      • paramPositions

        private final java.util.List<java.lang.Integer> paramPositions
      • valuesBracketPositions

        private final java.util.List<java.lang.Integer> valuesBracketPositions
      • paramCount

        private final int paramCount
      • isInsert

        private final boolean isInsert
      • isInsertDuplicate

        private final boolean isInsertDuplicate
      • isMultiQuery

        private final boolean isMultiQuery
    • Constructor Detail

      • ClientParser

        private ClientParser​(java.lang.String sql,
                             byte[] query,
                             java.util.List<java.lang.Integer> paramPositions,
                             java.util.List<java.lang.Integer> valuesBracketPositions,
                             boolean isInsert,
                             boolean isInsertDuplicate,
                             boolean isMultiQuery)
    • Method Detail

      • parameterParts

        public static ClientParser parameterParts​(java.lang.String queryString,
                                                  boolean noBackslashEscapes)
        For a given queryString, get
        • query - a byte array containing the UTF8 representation of that string
        • paramPositions - the byte positions of any '?' positional parameters in query
        and set the following flags:
        • isInsert - queryString contains 'INSERT' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following
        • isInsertDuplicate - isInsert && queryString contains 'DUPLICATE' outside of quotes, without one of the characters '();><=-+,' immediately preceding or following
        • isMulti - queryString contains text after the last ';' outside of quotes
        Parameters:
        queryString - query
        noBackslashEscapes - escape mode
        Returns:
        ClientParser
      • rewritableParts

        public static ClientParser rewritableParts​(java.lang.String queryString,
                                                   boolean noBackslashEscapes)
        For a given queryString, get the fields and flags from parameterParts(String, boolean), and
        • valuesBracketPositions - a two-element list containing the positions of the opening and closing parenthesis of the VALUES block
        Parameters:
        queryString - query
        noBackslashEscapes - escape mode
        Returns:
        ClientParser
      • getQuery

        public byte[] getQuery()
      • getParamPositions

        public java.util.List<java.lang.Integer> getParamPositions()
      • getValuesBracketPositions

        public java.util.List<java.lang.Integer> getValuesBracketPositions()
      • isInsert

        public boolean isInsert()
      • isInsertDuplicate

        public boolean isInsertDuplicate()
      • isMultiQuery

        public boolean isMultiQuery()
      • isDelimiter

        private static boolean isDelimiter​(byte b)
        Fast check if byte is a delimiter character: ();><=-+, Avoids String.indexOf() overhead
      • isWhitespace

        private static boolean isWhitespace​(byte b)
        Fast check if byte is whitespace: space, \n, \r, \t
      • equalsIgnoreCase

        private static boolean equalsIgnoreCase​(byte b,
                                                byte lower)
        Fast case-insensitive byte comparison for ASCII letters. Uses bitwise OR to convert to lowercase before comparison.