Class ClientPrepareResult
- java.lang.Object
-
- org.mariadb.jdbc.internal.util.dao.ClientPrepareResult
-
- All Implemented Interfaces:
PrepareResult
public class ClientPrepareResult extends Object implements PrepareResult
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancanAggregateSemiColon(String queryString, boolean noBackslashEscapes)Valid that query is valid (no ending semi colon, or end-of line comment ).intgetParamCount()List<byte[]>getQueryParts()StringgetSql()booleanisQueryMultipleRewritable()booleanisQueryMultiValuesRewritable()booleanisRewriteType()static ClientPrepareResultparameterParts(String queryString, boolean noBackslashEscapes)Separate query in a String list and set flag isQueryMultipleRewritable.static ClientPrepareResultrewritableParts(String queryString, boolean noBackslashEscapes)Separate query in a String list and set flag isQueryMultiValuesRewritable The parameters "?" (not in comments) emplacements are to be known.
-
-
-
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- querynoBackslashEscapes- escape mode- Returns:
- ClientPrepareResult
-
canAggregateSemiColon
public static boolean canAggregateSemiColon(String queryString, boolean noBackslashEscapes)
Valid that query is valid (no ending semi colon, or end-of line comment ).- Parameters:
queryString- querynoBackslashEscapes- 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 :
- pre value part
- After value and first parameter part
- for each parameters :
- part after parameter and before last parenthesis
- Last query part
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 StringnoBackslashEscapes- must backslash be escaped.- Returns:
- List of query part.
-
getSql
public String getSql()
- Specified by:
getSqlin interfacePrepareResult
-
getQueryParts
public List<byte[]> getQueryParts()
-
isQueryMultiValuesRewritable
public boolean isQueryMultiValuesRewritable()
-
isQueryMultipleRewritable
public boolean isQueryMultipleRewritable()
-
isRewriteType
public boolean isRewriteType()
-
getParamCount
public int getParamCount()
- Specified by:
getParamCountin interfacePrepareResult
-
-