diff --git a/src/keywords.rs b/src/keywords.rs index 771e8670..ec9d4251 100644 --- a/src/keywords.rs +++ b/src/keywords.rs @@ -810,6 +810,7 @@ pub const RESERVED_FOR_COLUMN_ALIAS: &[Keyword] = &[ Keyword::INTERSECT, Keyword::CLUSTER, Keyword::DISTRIBUTE, + Keyword::RETURNING, // Reserved only as a column alias in the `SELECT` clause Keyword::FROM, Keyword::INTO, diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs index 21cbcc99..bd95e316 100644 --- a/tests/sqlparser_common.rs +++ b/tests/sqlparser_common.rs @@ -225,6 +225,25 @@ fn parse_insert_default_values() { ); } +#[test] +fn parse_insert_select_returning() { + verified_stmt("INSERT INTO t SELECT 1 RETURNING 2"); + let stmt = verified_stmt("INSERT INTO t SELECT x RETURNING x AS y"); + match stmt { + Statement::Insert { + returning: Some(ret), + source: Some(_), + .. + } => assert_eq!(ret.len(), 1), + _ => unreachable!(), + } +} + +#[test] +fn parse_returning_as_column_alias() { + verified_stmt("SELECT 1 AS RETURNING"); +} + #[test] fn parse_insert_sqlite() { let dialect = SQLiteDialect {};