org.mariadb.jdbc.internal.util.dao
Class ClientPrepareResult

java.lang.Object
  extended by org.mariadb.jdbc.internal.util.dao.ClientPrepareResult
All Implemented Interfaces:
PrepareResult

public class ClientPrepareResult
extends Object
implements PrepareResult


Method Summary
 int getParamCount()
           
 List<byte[]> getQueryParts()
           
 String getSql()
           
 boolean isQueryMultipleRewritable()
           
 boolean isQueryMultiValuesRewritable()
           
static boolean isRewritableBatch(String queryString, boolean noBackslashEscapes)
          Valid that query is valid (no ending semi colon, or end-of line comment ).
 boolean isRewriteType()
           
static ClientPrepareResult parameterParts(String queryString, boolean noBackslashEscapes)
          Separate query in a String list and set flag isQueryMultipleRewritable.
static ClientPrepareResult rewritableParts(String queryString, boolean noBackslashEscapes)
          Separate query in a String list and set flag isQueryMultiValuesRewritable The parameters "?"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parameterParts

public static ClientPrepareResult parameterParts(String queryString,
                                                 boolean noBackslashEscapes)
Separate query in a String list and set flag isQueryMultipleRewritable. The resulting string list is separed by ? that are not in comments. isQueryMultipleRewritable flag is set if query can be rewrite in one query (all case but if using "-- comment"). example for query : "INSERT INTO tableName(id, name) VALUES (?, ?)" result list will be : {"INSERT INTO tableName(id, name) VALUES (", ", ", ")"}

Parameters:
queryString - query
noBackslashEscapes - escape mode
Returns:
ClientPrepareResult

isRewritableBatch

public static boolean isRewritableBatch(String queryString,
                                        boolean noBackslashEscapes)
Valid that query is valid (no ending semi colon, or end-of line comment ).

Parameters:
queryString - query
noBackslashEscapes - escape
Returns:
valid flag

rewritableParts

public static ClientPrepareResult rewritableParts(String queryString,
                                                  boolean noBackslashEscapes)

Separate query in a String list and set flag isQueryMultiValuesRewritable The parameters "?" (not in comments) emplacements are to be known.

The only rewritten queries follow these notation: INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_list)] [(col,...)] {VALUES | VALUE} (...) [ ON DUPLICATE KEY UPDATE col=expr [, col=expr] ... ] With expr without parameter.

Query with LAST_INSERT_ID() will not be rewritten

INSERT ... SELECT will not be rewritten.

String list :

example : INSERT INTO TABLE(col1,col2,col3,col4, col5) VALUES (9, ?, 5, ?, 8) ON DUPLICATE KEY UPDATE col2=col2+10

- pre value part : INSERT INTO TABLE(col1,col2,col3,col4, col5) VALUES - after value part : " (9 " - part after parameter 1: ", 5," - ", 5," - ",8)" - last part : ON DUPLICATE KEY UPDATE col2=col2+10

With 2 series of parameters, this query will be rewritten like [INSERT INTO TABLE(col1,col2,col3,col4, col5) VALUES][ (9, param0_1, 5, param0_2, 8)][, (9, param1_1, 5, param1_2, 8)][ ON DUPLICATE KEY UPDATE col2=col2+10]

Parameters:
queryString - query String
noBackslashEscapes - must backslash be escaped.
Returns:
List of query part.

getSql

public String getSql()
Specified by:
getSql in interface PrepareResult

getQueryParts

public List<byte[]> getQueryParts()

isQueryMultiValuesRewritable

public boolean isQueryMultiValuesRewritable()

isQueryMultipleRewritable

public boolean isQueryMultipleRewritable()

isRewriteType

public boolean isRewriteType()

getParamCount

public int getParamCount()
Specified by:
getParamCount in interface PrepareResult


Copyright © 2017. All rights reserved.