Class ClientPrepareResult
- java.lang.Object
-
- org.mariadb.jdbc.internal.util.dao.ClientPrepareResult
-
- All Implemented Interfaces:
PrepareResult
public class ClientPrepareResult extends java.lang.Object implements PrepareResult
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classClientPrepareResult.LexState
-
Field Summary
Fields Modifier and Type Field Description private booleanisQueryMultipleRewritableprivate booleanisQueryMultiValuesRewritableprivate intparamCountprivate java.util.List<byte[]>queryPartsprivate booleanrewriteTypeprivate java.lang.Stringsql
-
Constructor Summary
Constructors Modifier Constructor Description privateClientPrepareResult(java.lang.String sql, java.util.List<byte[]> queryParts, boolean isQueryMultiValuesRewritable, boolean isQueryMultipleRewritable, boolean rewriteType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancanAggregateSemiColon(java.lang.String queryString, boolean noBackslashEscapes)Valid that query is valid (no ending semi colon, or end-of line comment ).intgetParamCount()java.util.List<byte[]>getQueryParts()java.lang.StringgetSql()booleanisQueryMultipleRewritable()booleanisQueryMultiValuesRewritable()booleanisRewriteType()static ClientPrepareResultparameterParts(java.lang.String queryString, boolean noBackslashEscapes)Separate query in a String list and set flag isQueryMultipleRewritable.static ClientPrepareResultrewritableParts(java.lang.String queryString, boolean noBackslashEscapes)Separate query in a String list and set flag isQueryMultiValuesRewritable The parameters "?" (not in comments) emplacements are to be known.
-
-
-
Field Detail
-
sql
private final java.lang.String sql
-
queryParts
private final java.util.List<byte[]> queryParts
-
rewriteType
private final boolean rewriteType
-
paramCount
private final int paramCount
-
isQueryMultiValuesRewritable
private boolean isQueryMultiValuesRewritable
-
isQueryMultipleRewritable
private boolean isQueryMultipleRewritable
-
-
Method Detail
-
parameterParts
public static ClientPrepareResult parameterParts(java.lang.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(java.lang.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(java.lang.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 java.lang.String getSql()
- Specified by:
getSqlin interfacePrepareResult
-
getQueryParts
public java.util.List<byte[]> getQueryParts()
-
isQueryMultiValuesRewritable
public boolean isQueryMultiValuesRewritable()
-
isQueryMultipleRewritable
public boolean isQueryMultipleRewritable()
-
isRewriteType
public boolean isRewriteType()
-
getParamCount
public int getParamCount()
- Specified by:
getParamCountin interfacePrepareResult
-
-