Struct mz_sql_parser::parser::Parser

source ·
struct Parser<'a> {
    sql: &'a str,
    tokens: Vec<PosToken>,
    index: usize,
    recursion_guard: RecursionGuard,
}
Expand description

SQL Parser

Fields§

§sql: &'a str§tokens: Vec<PosToken>§index: usize

The index of the first unprocessed token in self.tokens

§recursion_guard: RecursionGuard

Implementations§

source§

impl<'a> Parser<'a>

source

fn new(sql: &'a str, tokens: Vec<PosToken>) -> Self

Parse the specified tokens

source

fn error(&self, pos: usize, message: String) -> ParserError

source

fn parse_statements( &mut self, ) -> Result<Vec<StatementParseResult<'a>>, ParserStatementError>

source

fn parse_statement( &mut self, ) -> Result<StatementParseResult<'a>, ParserStatementError>

Parse a single top-level statement (such as SELECT, INSERT, CREATE, etc.), stopping before the statement separator, if any. Returns the parsed statement and the SQL fragment corresponding to it.

source

fn parse_statement_inner( &mut self, ) -> Result<Statement<Raw>, ParserStatementError>

Parse a single top-level statement (such as SELECT, INSERT, CREATE, etc.), stopping before the statement separator, if any.

source

fn parse_expr(&mut self) -> Result<Expr<Raw>, ParserError>

Parse a new expression

source

fn parse_subexpr( &mut self, precedence: Precedence, ) -> Result<Expr<Raw>, ParserError>

Parse tokens until the precedence decreases

source

fn parse_subexpr_seeded( &mut self, precedence: Precedence, expr: Expr<Raw>, ) -> Result<Expr<Raw>, ParserError>

source

fn parse_prefix(&mut self) -> Result<Expr<Raw>, ParserError>

Parse an expression prefix

source

fn parse_parenthesized_fragment( &mut self, ) -> Result<ParenthesizedFragment, ParserError>

Parses an expression list that appears in parentheses, like (1 + 1), (SELECT 1), or (1, 2). Assumes that the opening parenthesis has already been parsed. Parses up to the closing parenthesis without consuming it.

source

fn parse_function( &mut self, name: RawItemName, ) -> Result<Function<Raw>, ParserError>

source

fn parse_window_frame(&mut self) -> Result<WindowFrame, ParserError>

source

fn parse_window_frame_bound(&mut self) -> Result<WindowFrameBound, ParserError>

Parse CURRENT ROW or { <positive number> | UNBOUNDED } { PRECEDING | FOLLOWING }

source

fn parse_case_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_cast_expr(&mut self) -> Result<Expr<Raw>, ParserError>

Parse a SQL CAST function e.g. CAST(expr AS FLOAT)

source

fn parse_exists_expr(&mut self) -> Result<Expr<Raw>, ParserError>

Parse a SQL EXISTS expression e.g. WHERE EXISTS(SELECT ...).

source

fn parse_homogenizing_function( &mut self, function: HomogenizingFunction, ) -> Result<Expr<Raw>, ParserError>

source

fn parse_nullif_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_extract_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_row_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_composite_type_definition( &mut self, ) -> Result<Vec<ColumnDef<Raw>>, ParserError>

source

fn parse_trim_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_position_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_interval_value(&mut self) -> Result<IntervalValue, ParserError>

Parse an INTERVAL literal.

Some syntactically valid intervals:

  • INTERVAL '1' DAY
  • INTERVAL '1-1' YEAR TO MONTH
  • INTERVAL '1' SECOND
  • `INTERVAL ‘1:1’ MINUTE TO SECOND
  • INTERVAL '1:1:1.1' HOUR TO SECOND (5)
  • INTERVAL '1.111' SECOND (2)
source

fn parse_infix( &mut self, expr: Expr<Raw>, precedence: Precedence, ) -> Result<Expr<Raw>, ParserError>

Parse an operator following an expression

source

fn parse_subscript(&mut self, expr: Expr<Raw>) -> Result<Expr<Raw>, ParserError>

Parse subscript expression, i.e. either an index value or slice range.

source

fn parse_substring_expr(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_operator(&mut self) -> Result<Op, ParserError>

Parse an operator reference.

Examples:

  • +
  • OPERATOR(schema.+)
  • OPERATOR("foo"."bar"."baz".@>)
source

fn parse_any_all( &mut self, left: Expr<Raw>, op: Op, kw: Keyword, ) -> Result<Expr<Raw>, ParserError>

Parses an ANY, ALL, or SOME operation, starting after the ANY, ALL, or SOME keyword.

source

fn parse_in( &mut self, expr: Expr<Raw>, negated: bool, ) -> Result<Expr<Raw>, ParserError>

Parses the parens following the [ NOT ] IN operator

source

fn parse_between( &mut self, expr: Expr<Raw>, negated: bool, ) -> Result<Expr<Raw>, ParserError>

Parses BETWEEN <low> AND <high>, assuming the BETWEEN keyword was already consumed

source

fn parse_like( &mut self, expr: Expr<Raw>, case_insensitive: bool, negated: bool, ) -> Result<Expr<Raw>, ParserError>

Parses LIKE <pattern> [ ESCAPE <char> ], assuming the LIKE keyword was already consumed

source

fn parse_pg_cast(&mut self, expr: Expr<Raw>) -> Result<Expr<Raw>, ParserError>

Parse a postgresql casting style which is in the form of expr::datatype

source

fn get_next_precedence(&self) -> Precedence

Get the precedence of the next token

source

fn peek_token(&self) -> Option<Token>

Return the first non-whitespace token that has not yet been processed (or None if reached end-of-file)

source

fn peek_keyword(&self, kw: Keyword) -> bool

source

fn peek_keywords(&self, keywords: &[Keyword]) -> bool

source

fn peek_keywords_from(&self, start: usize, keywords: &[Keyword]) -> bool

source

fn peek_one_of_keywords(&self, kws: &[Keyword]) -> bool

source

fn peek_keywords_lookahead(&self, keywords: &[Keyword]) -> bool

Returns whether the sequence of keywords is found at any point before the end of the unprocessed tokens.

source

fn peek_nth_token(&self, n: usize) -> Option<Token>

Return the nth token that has not yet been processed.

source

fn next_token(&mut self) -> Option<Token>

Return the next token that has not yet been processed, or None if reached end-of-file, and mark it as processed. OK to call repeatedly after reaching EOF.

source

fn prev_token(&mut self)

Push back the last one non-whitespace token. Must be called after next_token(), otherwise might panic. OK to call after next_token() indicates an EOF.

source

fn peek_pos(&self) -> usize

Return the byte position within the query string at which the next token starts.

source

fn peek_prev_pos(&self) -> usize

Return the byte position within the query string at which the previous token starts.

Must be called after next_token(), otherwise might panic. OK to call after next_token() indicates an EOF.

source

fn expected<D, T>( &self, pos: usize, expected: D, found: Option<Token>, ) -> Result<T, ParserError>
where D: Display,

Report unexpected token

source

fn parse_keyword(&mut self, kw: Keyword) -> bool

Look for an expected keyword and consume it if it exists

source

fn parse_keywords(&mut self, keywords: &[Keyword]) -> bool

Look for an expected sequence of keywords and consume them if they exist

source

fn parse_at_most_one_keyword( &mut self, keywords: &[Keyword], location: &str, ) -> Result<Option<Keyword>, ParserError>

source

fn parse_one_of_keywords(&mut self, kws: &[Keyword]) -> Option<Keyword>

Look for one of the given keywords and return the one that matches.

source

fn expect_one_of_keywords( &mut self, keywords: &[Keyword], ) -> Result<Keyword, ParserError>

Bail out if the current token is not one of the expected keywords, or consume it if it is

source

fn expect_keyword(&mut self, expected: Keyword) -> Result<(), ParserError>

Bail out if the current token is not an expected keyword, or consume it if it is

source

fn expect_keywords(&mut self, expected: &[Keyword]) -> Result<(), ParserError>

Bail out if the following tokens are not the expected sequence of keywords, or consume them if they are.

source

fn consume_token(&mut self, expected: &Token) -> bool

Consume the next token if it matches the expected token, otherwise return false

source

fn expect_token(&mut self, expected: &Token) -> Result<(), ParserError>

Bail out if the current token is not an expected token, or consume it if it is

source

fn expect_one_of_tokens( &mut self, tokens: &[Token], ) -> Result<Token, ParserError>

Bail out if the current token is not one of the expected tokens, or consume it if it is

source

fn expect_keyword_or_token( &mut self, expected_keyword: Keyword, expected_token: &Token, ) -> Result<(), ParserError>

Bail out if the current token is not an expected keyword or token, or consume it if it is

source

fn parse_comma_separated<T, F>(&mut self, f: F) -> Result<Vec<T>, ParserError>
where F: FnMut(&mut Self) -> Result<T, ParserError>,

Parse a comma-separated list of 1+ items accepted by F

source

fn maybe_parse<T, F>(&mut self, f: F) -> Option<T>
where F: FnMut(&mut Self) -> Result<T, ParserError>,

source

fn parse_create(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse a SQL CREATE statement

source

fn parse_create_database(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_schema(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_format(&mut self) -> Result<Format<Raw>, ParserError>

source

fn parse_avro_schema(&mut self) -> Result<AvroSchema<Raw>, ParserError>

source

fn parse_avro_schema_option( &mut self, ) -> Result<AvroSchemaOption<Raw>, ParserError>

source

fn parse_protobuf_schema(&mut self) -> Result<ProtobufSchema<Raw>, ParserError>

source

fn parse_csr_connection_reference( &mut self, ) -> Result<CsrConnection<Raw>, ParserError>

source

fn parse_csr_config_option( &mut self, ) -> Result<CsrConfigOption<Raw>, ParserError>

source

fn parse_avro_doc_on_option_name( &mut self, ) -> Result<DocOnIdentifier<Raw>, ParserError>

source

fn parse_csr_connection_avro( &mut self, ) -> Result<CsrConnectionAvro<Raw>, ParserError>

source

fn parse_csr_connection_proto( &mut self, ) -> Result<CsrConnectionProtobuf<Raw>, ParserError>

source

fn parse_source_error_policy_option( &mut self, ) -> Result<SourceErrorPolicy, ParserError>

source

fn parse_source_envelope(&mut self) -> Result<SourceEnvelope, ParserError>

source

fn parse_sink_envelope(&mut self) -> Result<SinkEnvelope, ParserError>

source

fn parse_validate(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a VALIDATE statement

source

fn parse_create_connection(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_connection_option_name( &mut self, ) -> Result<CreateConnectionOptionName, ParserError>

source

fn parse_create_connection_option( &mut self, ) -> Result<CreateConnectionOption<Raw>, ParserError>

Parses a single valid option in the WITH block of a create source

source

fn parse_kafka_broker(&mut self) -> Result<WithOptionValue<Raw>, ParserError>

source

fn parse_kafka_source_config_option( &mut self, ) -> Result<KafkaSourceConfigOption<Raw>, ParserError>

source

fn parse_kafka_sink_config_option( &mut self, ) -> Result<KafkaSinkConfigOption<Raw>, ParserError>

source

fn parse_connection_option_name( &mut self, ) -> Result<ConnectionOptionName, ParserError>

source

fn parse_connection_option_unified( &mut self, ) -> Result<ConnectionOption<Raw>, ParserError>

source

fn parse_create_subsource(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_subsource_option( &mut self, ) -> Result<CreateSubsourceOption<Raw>, ParserError>

source

fn parse_create_source(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_subsource_references( &mut self, ) -> Result<ExternalReferenceExport, ParserError>

source

fn parse_source_columns( &mut self, ) -> Result<(Vec<Ident>, Option<KeyConstraint>), ParserError>

Parses the column section of a CREATE SOURCE statement which can be empty or a comma-separated list of column identifiers and a single key constraint, e.g.

(col_0, col_i, …, col_n, key_constraint)

source

fn parse_key_constraint(&mut self) -> Result<Option<KeyConstraint>, ParserError>

Parses a key constraint.

source

fn parse_source_option_name( &mut self, ) -> Result<CreateSourceOptionName, ParserError>

source

fn parse_source_option( &mut self, ) -> Result<CreateSourceOption<Raw>, ParserError>

Parses a single valid option in the WITH block of a create source

source

fn parse_create_webhook_source( &mut self, name: UnresolvedItemName, if_not_exists: bool, in_cluster: Option<RawClusterName>, is_table: bool, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_webhook_check_options( &mut self, ) -> Result<CreateWebhookSourceCheckOptions<Raw>, ParserError>

source

fn parse_create_sink(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_sink_option_name( &mut self, ) -> Result<CreateSinkOptionName, ParserError>

Parse the name of a CREATE SINK optional parameter

source

fn parse_create_sink_option( &mut self, ) -> Result<CreateSinkOption<Raw>, ParserError>

Parse a NAME = VALUE parameter for CREATE SINK

source

fn parse_create_source_connection( &mut self, ) -> Result<CreateSourceConnection<Raw>, ParserError>

source

fn parse_pg_connection_option( &mut self, ) -> Result<PgConfigOption<Raw>, ParserError>

source

fn parse_mysql_connection_option( &mut self, ) -> Result<MySqlConfigOption<Raw>, ParserError>

source

fn parse_load_generator_option( &mut self, ) -> Result<LoadGeneratorOption<Raw>, ParserError>

source

fn parse_create_sink_connection( &mut self, ) -> Result<CreateSinkConnection<Raw>, ParserError>

source

fn parse_create_view(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_view_definition(&mut self) -> Result<ViewDefinition<Raw>, ParserError>

source

fn parse_create_materialized_view( &mut self, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_continual_task(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_continual_task_from_transform( &mut self, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_continual_task_from_retain( &mut self, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_materialized_view_option_name( &mut self, ) -> Result<MaterializedViewOptionName, ParserError>

source

fn parse_materialized_view_option( &mut self, ) -> Result<MaterializedViewOption<Raw>, ParserError>

source

fn parse_option_retain_history( &mut self, ) -> Result<Option<WithOptionValue<Raw>>, ParserError>

source

fn parse_retain_history(&mut self) -> Result<WithOptionValue<Raw>, ParserError>

source

fn parse_materialized_view_refresh_option_value( &mut self, ) -> Result<WithOptionValue<Raw>, ParserError>

source

fn parse_create_continual_task_with_options( &mut self, ) -> Result<Vec<ContinualTaskOption<Raw>>, ParserError>

source

fn parse_continual_task_option_name( &mut self, ) -> Result<ContinualTaskOptionName, ParserError>

source

fn parse_continual_task_option( &mut self, ) -> Result<ContinualTaskOption<Raw>, ParserError>

source

fn parse_create_index(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_table_option_name(&mut self) -> Result<TableOptionName, ParserError>

source

fn parse_table_option(&mut self) -> Result<TableOption<Raw>, ParserError>

source

fn parse_index_option_name(&mut self) -> Result<IndexOptionName, ParserError>

source

fn parse_index_option(&mut self) -> Result<IndexOption<Raw>, ParserError>

source

fn parse_raw_ident(&mut self) -> Result<RawClusterName, ParserError>

source

fn parse_raw_network_policy_name( &mut self, ) -> Result<RawNetworkPolicyName, ParserError>

source

fn parse_raw_ident_str(&mut self) -> Result<String, ParserError>

source

fn parse_optional_in_cluster( &mut self, ) -> Result<Option<RawClusterName>, ParserError>

source

fn parse_create_role(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_role_attributes(&mut self) -> Vec<RoleAttribute>

source

fn parse_create_secret(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_type(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_type_list_option( &mut self, ) -> Result<CreateTypeListOption<Raw>, ParserError>

source

fn parse_create_type_map_option( &mut self, ) -> Result<CreateTypeMapOption<Raw>, ParserError>

source

fn parse_create_cluster(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_cluster_option_name( &mut self, ) -> Result<ClusterOptionName, ParserError>

source

fn parse_cluster_option(&mut self) -> Result<ClusterOption<Raw>, ParserError>

source

fn parse_alter_cluster_option( &mut self, ) -> Result<ClusterAlterOption<Raw>, ParserError>

source

fn parse_cluster_alter_until_ready_option( &mut self, ) -> Result<ClusterAlterUntilReadyOption<Raw>, ParserError>

source

fn parse_cluster_option_replicas( &mut self, ) -> Result<ClusterOption<Raw>, ParserError>

source

fn parse_cluster_option_schedule( &mut self, ) -> Result<ClusterOption<Raw>, ParserError>

source

fn parse_replica_option(&mut self) -> Result<ReplicaOption<Raw>, ParserError>

source

fn parse_cluster_feature(&mut self) -> Result<ClusterFeature<Raw>, ParserError>

source

fn parse_create_cluster_replica( &mut self, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_if_exists(&mut self) -> Result<bool, ParserError>

source

fn parse_if_not_exists(&mut self) -> Result<bool, ParserError>

source

fn parse_alias(&mut self) -> Result<Option<Ident>, ParserError>

source

fn parse_source_include_metadata( &mut self, ) -> Result<Vec<SourceIncludeMetadata>, ParserError>

source

fn parse_discard(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_drop(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_drop_objects(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_drop_clusters( &mut self, if_exists: bool, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_drop_cluster_replicas( &mut self, if_exists: bool, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_drop_owned(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_cluster_replica_name( &mut self, ) -> Result<QualifiedReplica, ParserError>

source

fn parse_alter_network_policy(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_network_policy(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_network_policy_option( &mut self, ) -> Result<NetworkPolicyOption<Raw>, ParserError>

source

fn parse_network_policy_option_rules( &mut self, ) -> Result<NetworkPolicyOption<Raw>, ParserError>

source

fn parse_network_policy_rule_option( &mut self, ) -> Result<NetworkPolicyRuleOption<Raw>, ParserError>

source

fn parse_create_table(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_create_table_from_source( &mut self, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_table_from_source_option( &mut self, ) -> Result<TableFromSourceOption<Raw>, ParserError>

source

fn parse_table_from_source_columns( &mut self, ) -> Result<(TableFromSourceColumns<Raw>, Vec<TableConstraint<Raw>>), ParserError>

source

fn parse_columns( &mut self, optional: IsOptional, ) -> Result<(Vec<ColumnDef<Raw>>, Vec<TableConstraint<Raw>>), ParserError>

source

fn parse_column_option_def( &mut self, ) -> Result<ColumnOptionDef<Raw>, ParserError>

source

fn parse_optional_table_constraint( &mut self, ) -> Result<Option<TableConstraint<Raw>>, ParserError>

source

fn parse_object_option_value( &mut self, ) -> Result<WithOptionValue<Raw>, ParserError>

source

fn parse_optional_option_value( &mut self, ) -> Result<Option<WithOptionValue<Raw>>, ParserError>

source

fn parse_option_sequence<T, F>( &mut self, f: F, ) -> Result<Option<Vec<T>>, ParserError>
where F: FnMut(&mut Self) -> Result<T, ParserError>,

source

fn parse_option_map( &mut self, ) -> Result<Option<BTreeMap<String, WithOptionValue<Raw>>>, ParserError>

source

fn parse_option_value(&mut self) -> Result<WithOptionValue<Raw>, ParserError>

source

fn parse_data_type_option_value( &mut self, ) -> Result<WithOptionValue<Raw>, ParserError>

source

fn parse_alter(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_object(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_cluster( &mut self, object_type: ObjectType, ) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_source(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_source_add_subsource_option( &mut self, ) -> Result<AlterSourceAddSubsourceOption<Raw>, ParserError>

source

fn parse_alter_index(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_secret(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_sink(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse an ALTER SINK statement.

source

fn parse_alter_system(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse an ALTER SYSTEM statement.

source

fn parse_alter_connection( &mut self, ) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_connection_action( &mut self, ) -> Result<AlterConnectionAction<Raw>, ParserError>

source

fn parse_alter_connection_option( &mut self, ) -> Result<AlterConnectionOption<Raw>, ParserError>

Parses a single valid option in the WITH block of a create source

source

fn parse_alter_role(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_alter_default_privileges( &mut self, ) -> Result<Statement<Raw>, ParserError>

source

fn parse_alter_views( &mut self, object_type: ObjectType, ) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_alter_schema( &mut self, object_type: ObjectType, ) -> Result<Statement<Raw>, ParserStatementError>

source

fn maybe_parse_alter_set_cluster( &mut self, if_exists: bool, name: &UnresolvedItemName, object_type: ObjectType, ) -> Option<Result<Statement<Raw>, ParserStatementError>>

Parses CLUSTER name fragments into a AlterSetClusterStatement if CLUSTER is found.

source

fn parse_alter_set_cluster( &mut self, if_exists: bool, name: UnresolvedItemName, object_type: ObjectType, ) -> Result<Statement<Raw>, ParserStatementError>

Parses IN CLUSTER name fragments into a AlterSetClusterStatement.

source

fn parse_copy(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse a copy statement

source

fn parse_copy_option(&mut self) -> Result<CopyOption<Raw>, ParserError>

source

fn parse_value(&mut self) -> Result<Value, ParserError>

Parse a literal value (numbers, strings, date/time, booleans)

source

fn parse_array(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_list(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_map(&mut self) -> Result<Expr<Raw>, ParserError>

source

fn parse_sequence<F>(&mut self, f: F) -> Result<Vec<Expr<Raw>>, ParserError>

source

fn parse_number_value(&mut self) -> Result<Value, ParserError>

source

fn parse_version(&mut self) -> Result<Version, ParserError>

source

fn parse_literal_int(&mut self) -> Result<i64, ParserError>

Parse a signed literal integer.

source

fn parse_literal_uint(&mut self) -> Result<u64, ParserError>

Parse an unsigned literal integer.

source

fn parse_literal_string(&mut self) -> Result<String, ParserError>

Parse a literal string

source

fn parse_data_type(&mut self) -> Result<RawDataType, ParserError>

Parse a SQL datatype (in the context of a CREATE TABLE statement for example)

source

fn parse_typ_mod(&mut self) -> Result<Vec<i64>, ParserError>

source

fn parse_timestamp_precision(&mut self) -> Result<Vec<i64>, ParserError>

source

fn parse_optional_alias<F>( &mut self, is_reserved: F, ) -> Result<Option<Ident>, ParserError>
where F: FnOnce(Keyword) -> bool,

Parse AS identifier (or simply identifier if it’s not a reserved keyword) Some examples with aliases: SELECT 1 foo, SELECT COUNT(*) AS cnt, SELECT ... FROM t1 foo, t2 bar, SELECT ... FROM (...) AS bar

source

fn parse_optional_table_alias( &mut self, ) -> Result<Option<TableAlias>, ParserError>

Parse AS identifier when the AS is describing a table-valued object, like in ... FROM generate_series(1, 10) AS t (col). In this case the alias is allowed to optionally name the columns in the table, in addition to the table itself.

source

fn parse_deferred_item_name( &mut self, ) -> Result<DeferredItemName<Raw>, ParserError>

source

fn parse_raw_name(&mut self) -> Result<RawItemName, ParserError>

source

fn parse_column_name(&mut self) -> Result<ColumnName<Raw>, ParserError>

source

fn parse_database_name(&mut self) -> Result<UnresolvedDatabaseName, ParserError>

Parse a possibly quoted database identifier, e.g. foo or "mydatabase"

source

fn parse_schema_name(&mut self) -> Result<UnresolvedSchemaName, ParserError>

Parse a possibly qualified, possibly quoted schema identifier, e.g. foo or mydatabase."schema"

source

fn parse_item_name(&mut self) -> Result<UnresolvedItemName, ParserError>

Parse a possibly qualified, possibly quoted object identifier, e.g. foo or myschema."table"

source

fn parse_object_name( &mut self, object_type: ObjectType, ) -> Result<UnresolvedObjectName, ParserError>

Parse an object name.

source

fn parse_identifiers(&mut self) -> Result<Vec<Ident>, ParserError>

Parse one or more simple one-word identifiers separated by a ‘.’

source

fn parse_identifier(&mut self) -> Result<Ident, ParserError>

Parse a simple one-word identifier (possibly quoted, possibly a keyword)

source

fn consume_identifier(&mut self) -> Result<Option<Ident>, ParserError>

source

fn parse_qualified_identifier( &mut self, id: Ident, ) -> Result<Expr<Raw>, ParserError>

source

fn parse_parenthesized_column_list( &mut self, optional: IsOptional, ) -> Result<Vec<Ident>, ParserError>

Parse a parenthesized comma-separated list of unqualified, possibly quoted identifiers

source

fn parse_optional_precision(&mut self) -> Result<Option<u64>, ParserError>

source

fn parse_map_type(&mut self) -> Result<RawDataType, ParserError>

source

fn parse_delete(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_select_statement( &mut self, ) -> Result<SelectStatement<Raw>, ParserError>

Parses a SELECT (or WITH, VALUES, TABLE) statement with optional AS OF.

source

fn parse_query(&mut self) -> Result<Query<Raw>, ParserError>

Parse a query expression, i.e. a SELECT statement optionally preceded with some WITH CTE declarations and optionally followed by ORDER BY. Unlike some other parse_… methods, this one doesn’t expect the initial keyword to be already consumed

source

fn parse_mut_rec_block_option( &mut self, ) -> Result<MutRecBlockOption<Raw>, ParserError>

source

fn parse_query_tail( &mut self, ctes: CteBlock<Raw>, body: SetExpr<Raw>, ) -> Result<Query<Raw>, ParserError>

source

fn parse_cte(&mut self) -> Result<Cte<Raw>, ParserError>

Parse a CTE (alias [( col1, col2, ... )] AS (subquery))

source

fn parse_cte_mut_rec(&mut self) -> Result<CteMutRec<Raw>, ParserError>

Parse a mutually recursive CTE (alias ( col1: typ1, col2: typ2, ... ) AS (subquery)).

The main distinction from parse_cte is that the column names and types are mandatory. This is not how SQL works for WITH RECURSIVE, but we are doing it for now to make the query interpretation that much easier.

source

fn parse_query_body( &mut self, precedence: SetPrecedence, ) -> Result<SetExpr<Raw>, ParserError>

Parse a “query body”, which is an expression with roughly the following grammar:

  query_body ::= restricted_select | '(' subquery ')' | set_operation
  restricted_select ::= 'SELECT' [expr_list] [ from ] [ where ] [ groupby_having ]
  subquery ::= query_body [ order_by_limit ]
  set_operation ::= query_body { 'UNION' | 'EXCEPT' | 'INTERSECT' } [ 'ALL' ] query_body
source

fn parse_query_body_seeded( &mut self, precedence: SetPrecedence, expr: SetExpr<Raw>, ) -> Result<SetExpr<Raw>, ParserError>

source

fn parse_set_operator(&self, token: &Option<Token>) -> Option<SetOperator>

source

fn parse_select(&mut self) -> Result<Select<Raw>, ParserError>

Parse a restricted SELECT statement (no CTEs / UNION / ORDER BY), assuming the initial SELECT was already consumed

source

fn parse_select_option(&mut self) -> Result<SelectOption<Raw>, ParserError>

source

fn parse_set(&mut self) -> Result<Statement<Raw>, ParserStatementError>

source

fn parse_set_schema_to(&mut self) -> Result<SetVariableTo, ParserError>

source

fn parse_set_variable_to(&mut self) -> Result<SetVariableTo, ParserError>

source

fn parse_set_variable_value(&mut self) -> Result<SetVariableValue, ParserError>

source

fn parse_reset(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_show(&mut self) -> Result<ShowStatement<Raw>, ParserError>

source

fn parse_show_columns(&mut self) -> Result<ShowStatement<Raw>, ParserError>

source

fn parse_show_statement_filter( &mut self, ) -> Result<Option<ShowStatementFilter<Raw>>, ParserError>

source

fn parse_show_privileges(&mut self) -> Result<ShowStatement<Raw>, ParserError>

source

fn parse_show_default_privileges( &mut self, ) -> Result<ShowStatement<Raw>, ParserError>

source

fn parse_inspect(&mut self) -> Result<ShowStatement<Raw>, ParserError>

source

fn parse_table_and_joins(&mut self) -> Result<TableWithJoins<Raw>, ParserError>

source

fn parse_table_factor(&mut self) -> Result<TableFactor<Raw>, ParserError>

A table name or a parenthesized subquery, followed by optional [AS] alias

source

fn parse_rows_from(&mut self) -> Result<TableFactor<Raw>, ParserError>

source

fn parse_named_function(&mut self) -> Result<Function<Raw>, ParserError>

source

fn parse_derived_table_factor( &mut self, lateral: IsLateral, ) -> Result<TableFactor<Raw>, ParserError>

source

fn parse_join_constraint( &mut self, natural: bool, ) -> Result<JoinConstraint<Raw>, ParserError>

source

fn parse_insert(&mut self) -> Result<Statement<Raw>, ParserError>

Parse an INSERT statement

source

fn parse_returning(&mut self) -> Result<Vec<SelectItem<Raw>>, ParserError>

source

fn parse_update(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_assignment(&mut self) -> Result<Assignment<Raw>, ParserError>

Parse a var = expr assignment, used in an UPDATE statement

source

fn parse_optional_args( &mut self, allow_order_by: bool, ) -> Result<FunctionArgs<Raw>, ParserError>

source

fn parse_optional_as_of(&mut self) -> Result<Option<AsOf<Raw>>, ParserError>

Parse AS OF, if present.

source

fn parse_optional_up_to(&mut self) -> Result<Option<Expr<Raw>>, ParserError>

Parse UP TO, if present

source

fn parse_optional_internal_as_of(&mut self) -> Result<Option<u64>, ParserError>

Parse AS OF, if present.

In contrast to parse_optional_as_of, this parser only supports AS OF <time> syntax and directly returns an u64. It is only meant to be used for internal SQL syntax.

source

fn parse_select_item(&mut self) -> Result<SelectItem<Raw>, ParserError>

Parse a comma-delimited list of projections after SELECT

source

fn parse_order_by_expr(&mut self) -> Result<OrderByExpr<Raw>, ParserError>

Parse an expression, optionally followed by ASC or DESC, and then [NULLS { FIRST | LAST }] (used in ORDER BY)

source

fn parse_values(&mut self) -> Result<Values<Raw>, ParserError>

source

fn parse_start_transaction(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_begin(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_transaction_modes( &mut self, required: bool, ) -> Result<Vec<TransactionMode>, ParserError>

source

fn parse_commit(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_rollback(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_commit_rollback_chain(&mut self) -> Result<bool, ParserError>

source

fn parse_tail(&self) -> Result<Statement<Raw>, ParserError>

source

fn parse_subscribe(&mut self) -> Result<Statement<Raw>, ParserError>

source

fn parse_subscribe_option( &mut self, ) -> Result<SubscribeOption<Raw>, ParserError>

source

fn parse_subscribe_output( &mut self, ) -> Result<SubscribeOutput<Raw>, ParserError>

source

fn parse_explain(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse an EXPLAIN statement, assuming that the EXPLAIN token has already been consumed.

source

fn parse_explainee(&mut self) -> Result<Explainee<Raw>, ParserError>

source

fn parse_explain_plan(&mut self) -> Result<Statement<Raw>, ParserError>

Parse an EXPLAIN ... PLAN statement, assuming that the EXPLAIN token has already been consumed.

source

fn parse_explain_plan_option( &mut self, ) -> Result<ExplainPlanOption<Raw>, ParserError>

source

fn parse_explain_pushdown(&mut self) -> Result<Statement<Raw>, ParserError>

Parse an EXPLAIN FILTER PUSHDOWN statement, assuming that the EXPLAIN PUSHDOWN tokens have already been consumed.

source

fn parse_explain_timestamp(&mut self) -> Result<Statement<Raw>, ParserError>

Parse an EXPLAIN TIMESTAMP statement, assuming that the EXPLAIN TIMESTAMP tokens have already been consumed.

source

fn parse_explain_schema(&mut self) -> Result<Statement<Raw>, ParserError>

Parse an EXPLAIN [KEY|VALUE] SCHEMA statement assuming that the EXPLAIN token have already been consumed

source

fn parse_declare(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse a DECLARE statement, assuming that the DECLARE token has already been consumed.

source

fn parse_close(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a CLOSE statement, assuming that the CLOSE token has already been consumed.

source

fn parse_prepare(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse a PREPARE statement, assuming that the PREPARE token has already been consumed.

source

fn parse_execute(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a EXECUTE statement, assuming that the EXECUTE token has already been consumed.

source

fn parse_deallocate(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a DEALLOCATE statement, assuming that the DEALLOCATE token has already been consumed.

source

fn parse_fetch(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a FETCH statement, assuming that the FETCH token has already been consumed.

source

fn parse_fetch_option(&mut self) -> Result<FetchOption<Raw>, ParserError>

source

fn parse_raise(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a RAISE statement, assuming that the RAISE token has already been consumed.

source

fn parse_grant(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse a GRANT statement, assuming that the GRANT token has already been consumed.

source

fn parse_grant_privilege( &mut self, privileges: PrivilegeSpecification, ) -> Result<Statement<Raw>, ParserError>

Parse a GRANT PRIVILEGE statement, assuming that the GRANT token and all privileges have already been consumed.

source

fn parse_grant_role(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a GRANT ROLE statement, assuming that the GRANT token has already been consumed.

source

fn parse_revoke(&mut self) -> Result<Statement<Raw>, ParserStatementError>

Parse a REVOKE statement, assuming that the REVOKE token has already been consumed.

source

fn parse_revoke_privilege( &mut self, privileges: PrivilegeSpecification, ) -> Result<Statement<Raw>, ParserError>

Parse a REVOKE PRIVILEGE statement, assuming that the REVOKE token and all privileges have already been consumed.

source

fn parse_revoke_role(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a REVOKE ROLE statement, assuming that the REVOKE token has already been consumed.

source

fn expect_grant_target_specification( &mut self, statement_type: &str, ) -> Result<GrantTargetSpecification<Raw>, ParserError>

source

fn expect_grant_revoke_object_type( &mut self, statement_type: &str, ) -> Result<ObjectType, ParserError>

Bail out if the current token is not an object type suitable for a GRANT/REVOKE, or consume and return it if it is.

source

fn expect_grant_revoke_plural_object_type( &mut self, statement_type: &str, ) -> Result<ObjectType, ParserError>

Bail out if the current token is not a plural object type suitable for a GRANT/REVOKE, or consume and return it if it is.

source

fn expect_grant_revoke_object_type_inner( &self, statement_type: &str, object_type: ObjectType, ) -> Result<ObjectType, ParserError>

source

fn expect_object_type(&mut self) -> Result<ObjectType, ParserError>

Bail out if the current token is not an object type, or consume and return it if it is.

source

fn parse_object_type(&mut self) -> Option<ObjectType>

Look for an object type and return it if it matches.

source

fn expect_plural_object_type(&mut self) -> Result<ObjectType, ParserError>

Bail out if the current token is not an object type in the plural form, or consume and return it if it is.

source

fn parse_plural_object_type(&mut self) -> Option<ObjectType>

Look for an object type in the plural form and return it if it matches.

source

fn expect_plural_object_type_for_privileges( &mut self, ) -> Result<ObjectType, ParserError>

Bail out if the current token is not a privilege object type, or consume and return it if it is.

source

fn expect_plural_system_object_type_for_privileges( &mut self, ) -> Result<SystemObjectType, ParserError>

Bail out if the current token is not a privilege object type in the plural form, or consume and return it if it is.

source

fn parse_privilege(&mut self) -> Option<Privilege>

Look for a privilege and return it if it matches.

source

fn parse_privilege_specification(&mut self) -> Option<PrivilegeSpecification>

Parse one or more privileges separated by a ‘,’.

source

fn expect_role_specification(&mut self) -> Result<Ident, ParserError>

Bail out if the current token is not a role specification, or consume and return it if it is.

source

fn parse_reassign_owned(&mut self) -> Result<Statement<Raw>, ParserError>

Parse a REASSIGN OWNED statement, assuming that the REASSIGN token has already been consumed.

source

fn parse_comment(&mut self) -> Result<Statement<Raw>, ParserError>

source

pub fn new_identifier<S>(&self, s: S) -> Result<Ident, ParserError>

§

impl<'a> Parser<'a>

Trait Implementations§

source§

impl CheckedRecursion for Parser<'_>

source§

fn recursion_guard(&self) -> &RecursionGuard

Extracts a reference to the recursion guard embedded within the type.
source§

fn checked_recur<F, T, E>(&self, f: F) -> Result<T, E>
where F: FnOnce(&Self) -> Result<T, E>, E: From<RecursionLimitError>,

Checks whether it is safe to recur and calls f if so. Read more
source§

fn checked_recur_mut<F, T, E>(&mut self, f: F) -> Result<T, E>

Like CheckedRecursion::checked_recur, but operates on a mutable reference to Self.

Auto Trait Implementations§

§

impl<'a> !Freeze for Parser<'a>

§

impl<'a> !RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> !Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

fn cast_into(self) -> U

Performs the cast.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more