@InternalApi public abstract class AbstractStatementParser extends Object
Parses ClientSideStatement
s and normal SQL statements. The parser is able to recognize
the type of statement, allowing the connection API to know which method on Spanner should be
called. The parser does not validate the validity of statements, except for ClientSideStatement
s. This means that an invalid DML statement could be accepted by the AbstractStatementParser
and sent to Spanner, and Spanner will then reject it with some error
message.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractStatementParser.ParametersInfo
Parameter information with positional parameters translated to named parameters.
|
static class |
AbstractStatementParser.ParsedStatement
A statement that has been parsed
|
static class |
AbstractStatementParser.StatementType
The type of statement that has been recognized by the parser.
|
Modifier and Type | Method and Description |
---|---|
AbstractStatementParser.ParametersInfo |
convertPositionalParametersToNamedParameters(char paramChar,
String sql) |
static AbstractStatementParser |
getInstance(Dialect dialect)
Get an instance of
AbstractStatementParser for the specified dialect. |
boolean |
isDdlStatement(String sql)
Checks whether the given statement is (probably) a DDL statement.
|
boolean |
isQuery(String sql)
Checks whether the given statement is (probably) a SELECT query.
|
boolean |
isUpdateStatement(String sql)
Checks whether the given statement is (probably) an update statement.
|
AbstractStatementParser.ParsedStatement |
parse(Statement statement)
Parses the given statement and categorizes it as one of the possible
AbstractStatementParser.StatementType s. |
String |
removeCommentsAndTrim(String sql) |
protected abstract boolean |
supportsExplain() |
public static AbstractStatementParser getInstance(Dialect dialect)
AbstractStatementParser
for the specified dialect.@InternalApi public AbstractStatementParser.ParsedStatement parse(Statement statement)
AbstractStatementParser.StatementType
s.
The validity of the statement is not checked, unless it is a client-side statement.statement
- The statement to parse.@InternalApi public boolean isDdlStatement(String sql)
sql
- The statement to check (without any comments).true
if the statement is a DDL statement (i.e. starts with 'CREATE',
'ALTER' or 'DROP').@InternalApi public boolean isQuery(String sql)
sql
- The statement to check (without any comments).true
if the statement is a SELECT statement (i.e. starts with 'SELECT').@InternalApi public boolean isUpdateStatement(String sql)
sql
- The statement to check (without any comments).true
if the statement is a DML update statement (i.e. starts with
'INSERT', 'UPDATE' or 'DELETE').protected abstract boolean supportsExplain()
@InternalApi public AbstractStatementParser.ParametersInfo convertPositionalParametersToNamedParameters(char paramChar, String sql)
Copyright © 2022 Google LLC. All rights reserved.