Struct sqlparser::parser::Parser

source ·
pub struct Parser<'a> { /* private fields */ }

Implementations§

source§

impl<'a> Parser<'a>

source§

impl<'a> Parser<'a>

source

pub fn new(dialect: &'a dyn Dialect) -> Self

Create a parser for a Dialect

See also Parser::parse_sql

Example:

let dialect = GenericDialect{};
let statements = Parser::new(&dialect)
  .try_with_sql("SELECT * FROM foo")?
  .parse_statements()?;
source

pub fn with_recursion_limit(self, recursion_limit: usize) -> Self

Specify the maximum recursion limit while parsing.

Parser prevents stack overflows by returning ParserError::RecursionLimitExceeded if the parser exceeds this depth while processing the query.

Example:

let dialect = GenericDialect{};
let result = Parser::new(&dialect)
  .with_recursion_limit(1)
  .try_with_sql("SELECT * FROM foo WHERE (a OR (b OR (c OR d)))")?
  .parse_statements();
  assert_eq!(result, Err(ParserError::RecursionLimitExceeded));
source

pub fn with_options(self, options: ParserOptions) -> Self

Specify additional parser options

Parser supports additional options (ParserOptions) that allow you to mix & match behavior otherwise constrained to certain dialects (e.g. trailing commas).

Example:

let dialect = GenericDialect{};
let options = ParserOptions::new()
   .with_trailing_commas(true)
   .with_unescape(false);
let result = Parser::new(&dialect)
  .with_options(options)
  .try_with_sql("SELECT a, b, COUNT(*), FROM foo GROUP BY a, b,")?
  .parse_statements();
  assert!(matches!(result, Ok(_)));
source

pub fn with_tokens_with_locations(self, tokens: Vec<TokenWithLocation>) -> Self

Reset this parser to parse the specified token stream

source

pub fn with_tokens(self, tokens: Vec<Token>) -> Self

Reset this parser state to parse the specified tokens

source

pub fn try_with_sql(self, sql: &str) -> Result<Self, ParserError>

Tokenize the sql string and sets this Parser’s state to parse the resulting tokens

Returns an error if there was an error tokenizing the SQL string.

See example on Parser::new() for an example

source

pub fn parse_statements(&mut self) -> Result<Vec<Statement>, ParserError>

Parse potentially multiple statements

Example

let dialect = GenericDialect{};
let statements = Parser::new(&dialect)
  // Parse a SQL string with 2 separate statements
  .try_with_sql("SELECT * FROM foo; SELECT * FROM bar;")?
  .parse_statements()?;
assert_eq!(statements.len(), 2);
source

pub fn parse_sql( dialect: &dyn Dialect, sql: &str ) -> Result<Vec<Statement>, ParserError>

Convenience method to parse a string with one or more SQL statements into produce an Abstract Syntax Tree (AST).

Example

let dialect = GenericDialect{};
let statements = Parser::parse_sql(
  &dialect, "SELECT * FROM foo"
)?;
assert_eq!(statements.len(), 1);
source

pub fn parse_statement(&mut self) -> Result<Statement, ParserError>

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

source

pub fn parse_msck(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_truncate(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_analyze(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_wildcard_expr(&mut self) -> Result<WildcardExpr, ParserError>

Parse a new expression including wildcard & qualified wildcard

source

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

Parse a new expression

source

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

Parse tokens until the precedence changes

source

pub fn parse_interval_expr(&mut self) -> Result<Expr, ParserError>

source

pub fn get_next_interval_precedence(&self) -> Result<u8, ParserError>

Get the precedence of the next token With AND, OR, and XOR

source

pub fn parse_assert(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_savepoint(&mut self) -> Result<Statement, ParserError>

source

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

Parse an expression prefix

source

pub fn parse_function(&mut self, name: ObjectName) -> Result<Expr, ParserError>

source

pub fn parse_time_functions( &mut self, name: ObjectName ) -> Result<Expr, ParserError>

source

pub fn parse_window_frame_units( &mut self ) -> Result<WindowFrameUnits, ParserError>

source

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

source

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

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

source

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

source

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

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

source

pub fn parse_try_cast_expr(&mut self) -> Result<Expr, ParserError>

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

source

pub fn parse_safe_cast_expr(&mut self) -> Result<Expr, ParserError>

Parse a BigQuery SAFE_CAST function e.g. SAFE_CAST(expr AS FLOAT64)

source

pub fn parse_exists_expr(&mut self, negated: bool) -> Result<Expr, ParserError>

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

source

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

source

pub fn parse_ceil_floor_expr( &mut self, is_ceil: bool ) -> Result<Expr, ParserError>

source

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

source

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

source

pub fn parse_overlay_expr(&mut self) -> Result<Expr, ParserError>

source

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

TRIM ([WHERE] ['text' FROM] 'text')
TRIM ('text')
source

pub fn parse_trim_where(&mut self) -> Result<TrimWhereField, ParserError>

source

pub fn parse_array_expr(&mut self, named: bool) -> Result<Expr, ParserError>

Parses an array expression [ex1, ex2, ..] if named is true, came from an expression like ARRAY[ex1, ex2]

source

pub fn parse_array_subquery(&mut self) -> Result<Expr, ParserError>

source

pub fn parse_listagg_expr(&mut self) -> Result<Expr, ParserError>

Parse a SQL LISTAGG expression, e.g. LISTAGG(...) WITHIN GROUP (ORDER BY ...).

source

pub fn parse_array_agg_expr(&mut self) -> Result<Expr, ParserError>

source

pub fn parse_date_time_field(&mut self) -> Result<DateTimeField, ParserError>

source

pub fn parse_not(&mut self) -> Result<Expr, ParserError>

source

pub fn parse_match_against(&mut self) -> Result<Expr, ParserError>

Parses fulltext expressions (1)

Errors

This method will raise an error if the column list is empty or with invalid identifiers, the match expression is not a literal string, or if the search modifier is not valid.

source

pub fn parse_interval(&mut self) -> Result<Expr, ParserError>

Parse an INTERVAL expression.

Some syntactically valid intervals:

  1. INTERVAL '1' DAY
  2. INTERVAL '1-1' YEAR TO MONTH
  3. INTERVAL '1' SECOND
  4. INTERVAL '1:1:1.1' HOUR (5) TO SECOND (5)
  5. INTERVAL '1.1' SECOND (2, 2)
  6. INTERVAL '1:1' HOUR (5) TO MINUTE (5)
  7. (MySql and BigQuey only):INTERVAL 1 DAY

Note that we do not currently attempt to parse the quoted value.

source

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

Parse an operator following an expression

source

pub fn parse_escape_char(&mut self) -> Result<Option<char>, ParserError>

parse the ESCAPE CHAR portion of LIKE, ILIKE, and SIMILAR TO

source

pub fn parse_array_index(&mut self, expr: Expr) -> Result<Expr, ParserError>

source

pub fn parse_map_access(&mut self, expr: Expr) -> Result<Expr, ParserError>

source

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

Parses the parens following the [ NOT ] IN operator

source

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

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

source

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

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

source

pub fn get_next_precedence(&self) -> Result<u8, ParserError>

Get the precedence of the next token

source

pub fn peek_token(&self) -> TokenWithLocation

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

source

pub fn peek_nth_token(&self, n: usize) -> TokenWithLocation

Return nth non-whitespace token that has not yet been processed

source

pub fn next_token(&mut self) -> TokenWithLocation

Return the first non-whitespace 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

pub fn next_token_no_skip(&mut self) -> Option<&TokenWithLocation>

Return the first unprocessed token, possibly whitespace.

source

pub 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

pub fn expected<T>( &self, expected: &str, found: TokenWithLocation ) -> Result<T, ParserError>

Report unexpected token

source

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

Look for an expected keyword and consume it if it exists

source

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

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

source

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

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

source

pub 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

pub 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

pub 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

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

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

source

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

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

source

pub fn parse_projection(&mut self) -> Result<Vec<SelectItem>, ParserError>

Parse a comma-separated list of 1+ SelectItem

source

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

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

source

pub fn parse_all_or_distinct(&mut self) -> Result<Option<Distinct>, ParserError>

Parse either ALL, DISTINCT or DISTINCT ON (...). Returns None if ALL is parsed and results in a ParserError if both ALL and DISTINCT are found.

source

pub fn parse_create(&mut self) -> Result<Statement, ParserError>

Parse a SQL CREATE statement

source

pub fn parse_cache_table(&mut self) -> Result<Statement, ParserError>

Parse a CACHE TABLE statement

source

pub fn parse_as_query(&mut self) -> Result<(bool, Query), ParserError>

Parse ‘AS’ before as query,such as WITH XXX AS SELECT XXX oer CACHE TABLE AS SELECT XXX

source

pub fn parse_uncache_table(&mut self) -> Result<Statement, ParserError>

Parse a UNCACHE TABLE statement

source

pub fn parse_create_virtual_table(&mut self) -> Result<Statement, ParserError>

SQLite-specific CREATE VIRTUAL TABLE

source

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

source

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

source

pub fn parse_optional_create_function_using( &mut self ) -> Result<Option<CreateFunctionUsing>, ParserError>

source

pub fn parse_create_function( &mut self, or_replace: bool, temporary: bool ) -> Result<Statement, ParserError>

source

pub fn parse_create_macro( &mut self, or_replace: bool, temporary: bool ) -> Result<Statement, ParserError>

source

pub fn parse_create_external_table( &mut self, or_replace: bool ) -> Result<Statement, ParserError>

source

pub fn parse_file_format(&mut self) -> Result<FileFormat, ParserError>

source

pub fn parse_analyze_format(&mut self) -> Result<AnalyzeFormat, ParserError>

source

pub fn parse_create_view( &mut self, or_replace: bool ) -> Result<Statement, ParserError>

source

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

source

pub fn parse_drop(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_declare(&mut self) -> Result<Statement, ParserError>

DECLARE name [ BINARY ] [ ASENSITIVE | INSENSITIVE ] [ [ NO ] SCROLL ]
    CURSOR [ { WITH | WITHOUT } HOLD ] FOR query
source

pub fn parse_fetch_statement(&mut self) -> Result<Statement, ParserError>

source

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

source

pub fn parse_create_index( &mut self, unique: bool ) -> Result<Statement, ParserError>

source

pub fn parse_hive_distribution( &mut self ) -> Result<HiveDistributionStyle, ParserError>

source

pub fn parse_hive_formats(&mut self) -> Result<HiveFormat, ParserError>

source

pub fn parse_row_format(&mut self) -> Result<HiveRowFormat, ParserError>

source

pub fn parse_create_table( &mut self, or_replace: bool, temporary: bool, global: Option<bool>, transient: bool ) -> Result<Statement, ParserError>

source

pub fn parse_optional_procedure_parameters( &mut self ) -> Result<Option<Vec<ProcedureParam>>, ParserError>

source

pub fn parse_columns( &mut self ) -> Result<(Vec<ColumnDef>, Vec<TableConstraint>), ParserError>

source

pub fn parse_procedure_param(&mut self) -> Result<ProcedureParam, ParserError>

source

pub fn parse_column_def(&mut self) -> Result<ColumnDef, ParserError>

source

pub fn parse_optional_column_option( &mut self ) -> Result<Option<ColumnOption>, ParserError>

source

pub fn parse_referential_action( &mut self ) -> Result<ReferentialAction, ParserError>

source

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

source

pub fn parse_options( &mut self, keyword: Keyword ) -> Result<Vec<SqlOption>, ParserError>

source

pub fn parse_index_type(&mut self) -> Result<IndexType, ParserError>

source

pub fn parse_sql_option(&mut self) -> Result<SqlOption, ParserError>

source

pub fn parse_alter(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_alter_view(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_copy(&mut self) -> Result<Statement, ParserError>

Parse a copy statement

source

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

source

pub fn parse_tsv(&mut self) -> Vec<Option<String>>

Parse a tab separated values in COPY payload

source

pub fn parse_tab_value(&mut self) -> Vec<Option<String>>

source

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

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

source

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

source

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

Parse an unsigned literal integer/long

source

pub fn parse_function_definition( &mut self ) -> Result<FunctionDefinition, ParserError>

source

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

Parse a literal string

source

pub fn parse_map_key(&mut self) -> Result<Expr, ParserError>

Parse a map key string

source

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

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

source

pub fn parse_string_values(&mut self) -> Result<Vec<String>, ParserError>

source

pub fn parse_identifier_with_alias( &mut self ) -> Result<IdentWithAlias, ParserError>

Strictly parse identifier AS identifier

source

pub fn parse_optional_alias( &mut self, reserved_kwds: &[Keyword] ) -> Result<Option<Ident>, ParserError>

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

pub fn parse_optional_table_alias( &mut self, reserved_kwds: &[Keyword] ) -> 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

pub fn parse_object_name(&mut self) -> Result<ObjectName, ParserError>

Parse a possibly qualified, possibly quoted identifier, e.g. foo or `myschema.“table”

source

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

Parse identifiers

source

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

Parse identifiers of form ident1[.identN]*

Similar in functionality to parse_identifiers, with difference being this function is much more strict about parsing a valid multipart identifier, not allowing extraneous tokens to be parsed, otherwise it fails.

For example:

use sqlparser::ast::Ident;
use sqlparser::dialect::GenericDialect;
use sqlparser::parser::Parser;

let dialect = GenericDialect {};
let expected = vec![Ident::new("one"), Ident::new("two")];

// expected usage
let sql = "one.two";
let mut parser = Parser::new(&dialect).try_with_sql(sql).unwrap();
let actual = parser.parse_multipart_identifier().unwrap();
assert_eq!(&actual, &expected);

// parse_identifiers is more loose on what it allows, parsing successfully
let sql = "one + two";
let mut parser = Parser::new(&dialect).try_with_sql(sql).unwrap();
let actual = parser.parse_identifiers().unwrap();
assert_eq!(&actual, &expected);

// expected to strictly fail due to + separator
let sql = "one + two";
let mut parser = Parser::new(&dialect).try_with_sql(sql).unwrap();
let actual = parser.parse_multipart_identifier().unwrap_err();
assert_eq!(
    actual.to_string(),
    "sql parser error: Unexpected token in identifier: +"
);
source

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

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

source

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

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

source

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

source

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

source

pub fn parse_optional_character_length( &mut self ) -> Result<Option<CharacterLength>, ParserError>

source

pub fn parse_character_length(&mut self) -> Result<CharacterLength, ParserError>

source

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

source

pub fn parse_exact_number_optional_precision_scale( &mut self ) -> Result<ExactNumberInfo, ParserError>

source

pub fn parse_optional_type_modifiers( &mut self ) -> Result<Option<Vec<String>>, ParserError>

source

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

source

pub fn parse_kill(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_explain( &mut self, describe_alias: bool ) -> Result<Statement, ParserError>

source

pub fn parse_query(&mut self) -> Result<Query, 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

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

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

source

pub fn parse_query_body( &mut self, precedence: u8 ) -> Result<SetExpr, 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

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

source

pub fn parse_set_quantifier( &mut self, op: &Option<SetOperator> ) -> SetQuantifier

source

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

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

source

pub fn parse_as_table(&mut self) -> Result<Table, ParserError>

Parse CREATE TABLE x AS TABLE y

source

pub fn parse_set(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_show(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_show_create(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_show_columns( &mut self, extended: bool, full: bool ) -> Result<Statement, ParserError>

source

pub fn parse_show_tables( &mut self, extended: bool, full: bool ) -> Result<Statement, ParserError>

source

pub fn parse_show_functions(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_show_collation(&mut self) -> Result<Statement, ParserError>

source

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

source

pub fn parse_use(&mut self) -> Result<Statement, ParserError>

source

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

source

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

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

source

pub fn parse_table_version( &mut self ) -> Result<Option<TableVersion>, ParserError>

Parse a given table version specifier.

For now it only supports timestamp versioning for BigQuery and MSSQL dialects.

source

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

source

pub fn parse_pivot_table_factor( &mut self, name: ObjectName, table_alias: Option<TableAlias> ) -> Result<TableFactor, ParserError>

source

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

source

pub fn parse_grant(&mut self) -> Result<Statement, ParserError>

Parse a GRANT statement.

source

pub fn parse_grant_revoke_privileges_objects( &mut self ) -> Result<(Privileges, GrantObjects), ParserError>

source

pub fn parse_grant_permission( &mut self ) -> Result<(Keyword, Option<Vec<Ident>>), ParserError>

source

pub fn parse_revoke(&mut self) -> Result<Statement, ParserError>

Parse a REVOKE statement

source

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

Parse an INSERT statement

source

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

source

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

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

source

pub fn parse_function_args(&mut self) -> Result<FunctionArg, ParserError>

source

pub fn parse_optional_args(&mut self) -> Result<Vec<FunctionArg>, ParserError>

source

pub fn parse_optional_args_with_orderby( &mut self ) -> Result<(Vec<FunctionArg>, Vec<OrderByExpr>), ParserError>

source

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

Parse a comma-delimited list of projections after SELECT

source

pub fn parse_wildcard_additional_options( &mut self ) -> Result<WildcardAdditionalOptions, ParserError>

Parse an WildcardAdditionalOptions information for wildcard select items.

If it is not possible to parse it, will return an option.

source

pub fn parse_optional_select_item_exclude( &mut self ) -> Result<Option<ExcludeSelectItem>, ParserError>

Parse an Exclude information for wildcard select items.

If it is not possible to parse it, will return an option.

source

pub fn parse_optional_select_item_except( &mut self ) -> Result<Option<ExceptSelectItem>, ParserError>

Parse an Except information for wildcard select items.

If it is not possible to parse it, will return an option.

source

pub fn parse_optional_select_item_rename( &mut self ) -> Result<Option<RenameSelectItem>, ParserError>

Parse a Rename information for wildcard select items.

source

pub fn parse_optional_select_item_replace( &mut self ) -> Result<Option<ReplaceSelectItem>, ParserError>

Parse a Replace information for wildcard select items.

source

pub fn parse_replace_elements( &mut self ) -> Result<ReplaceSelectElement, ParserError>

source

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

Parse an expression, optionally followed by ASC or DESC (used in ORDER BY)

source

pub fn parse_top(&mut self) -> Result<Top, ParserError>

Parse a TOP clause, MSSQL equivalent of LIMIT, that follows after SELECT [DISTINCT].

source

pub fn parse_limit(&mut self) -> Result<Option<Expr>, ParserError>

Parse a LIMIT clause

source

pub fn parse_offset(&mut self) -> Result<Offset, ParserError>

Parse an OFFSET clause

source

pub fn parse_fetch(&mut self) -> Result<Fetch, ParserError>

Parse a FETCH clause

source

pub fn parse_lock(&mut self) -> Result<LockClause, ParserError>

Parse a FOR UPDATE/FOR SHARE clause

source

pub fn parse_values(&mut self, allow_empty: bool) -> Result<Values, ParserError>

source

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

source

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

source

pub fn parse_transaction_modes( &mut self ) -> Result<Vec<TransactionMode>, ParserError>

source

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

source

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

source

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

source

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

source

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

source

pub fn parse_prepare(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_merge_clauses(&mut self) -> Result<Vec<MergeClause>, ParserError>

source

pub fn parse_merge(&mut self) -> Result<Statement, ParserError>

source

pub fn parse_create_sequence( &mut self, temporary: bool ) -> Result<Statement, ParserError>

CREATE [ { TEMPORARY | TEMP } ] SEQUENCE [ IF NOT EXISTS ] <sequence_name>

See Postgres docs for more details.

source

pub fn index(&self) -> usize

The index of the first unprocessed token.

source

pub fn parse_named_window( &mut self ) -> Result<NamedWindowDefinition, ParserError>

source

pub fn parse_create_procedure( &mut self, or_alter: bool ) -> Result<Statement, ParserError>

source

pub fn parse_window_spec(&mut self) -> Result<WindowSpec, ParserError>

source

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

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.