Skip to content

Commit 8e0d26a

Browse files
authored
fix for maybe_parse preventing parser from erroring on recursion limit (apache#1464)
1 parent 38f1e57 commit 8e0d26a

19 files changed

+423
-571
lines changed

src/ast/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3208,7 +3208,7 @@ pub enum Statement {
32083208
/// Table confs
32093209
options: Vec<SqlOption>,
32103210
/// Cache table as a Query
3211-
query: Option<Query>,
3211+
query: Option<Box<Query>>,
32123212
},
32133213
/// ```sql
32143214
/// UNCACHE TABLE [ IF EXISTS ] <table_name>
@@ -6883,7 +6883,7 @@ impl fmt::Display for MacroArg {
68836883
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
68846884
pub enum MacroDefinition {
68856885
Expr(Expr),
6886-
Table(Query),
6886+
Table(Box<Query>),
68876887
}
68886888

68896889
impl fmt::Display for MacroDefinition {

src/ast/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ pub enum PivotValueSource {
11031103
/// Pivot on all values returned by a subquery.
11041104
///
11051105
/// See <https://docs.snowflake.com/en/sql-reference/constructs/pivot#pivot-on-column-values-using-a-subquery-with-dynamic-pivot>.
1106-
Subquery(Query),
1106+
Subquery(Box<Query>),
11071107
}
11081108

11091109
impl fmt::Display for PivotValueSource {

src/dialect/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@ pub trait Dialect: Debug + Any {
486486
fn parse_column_option(
487487
&self,
488488
_parser: &mut Parser,
489-
) -> Option<Result<Option<ColumnOption>, ParserError>> {
489+
) -> Result<Option<Result<Option<ColumnOption>, ParserError>>, ParserError> {
490490
// return None to fall back to the default behavior
491-
None
491+
Ok(None)
492492
}
493493

494494
/// Decide the lexical Precedence of operators.

src/dialect/snowflake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl Dialect for SnowflakeDialect {
156156
fn parse_column_option(
157157
&self,
158158
parser: &mut Parser,
159-
) -> Option<Result<Option<ColumnOption>, ParserError>> {
159+
) -> Result<Option<Result<Option<ColumnOption>, ParserError>>, ParserError> {
160160
parser.maybe_parse(|parser| {
161161
let with = parser.parse_keyword(Keyword::WITH);
162162

@@ -247,7 +247,7 @@ pub fn parse_create_table(
247247
builder = builder.comment(parser.parse_optional_inline_comment()?);
248248
}
249249
Keyword::AS => {
250-
let query = parser.parse_boxed_query()?;
250+
let query = parser.parse_query()?;
251251
builder = builder.query(Some(query));
252252
break;
253253
}

src/parser/alter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a> Parser<'a> {
192192
let _ = self.parse_keyword(Keyword::WITH);
193193
// option
194194
let mut options = vec![];
195-
while let Some(opt) = self.maybe_parse(|parser| parser.parse_pg_role_option()) {
195+
while let Some(opt) = self.maybe_parse(|parser| parser.parse_pg_role_option())? {
196196
options.push(opt);
197197
}
198198
// check option

0 commit comments

Comments
 (0)