File tree 2 files changed +21
-9
lines changed
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ pub enum DataType {
49
49
///
50
50
/// [PostgreSQL]: https://www.postgresql.org/docs/15/sql-createfunction.html
51
51
/// [MsSQL]: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql?view=sql-server-ver16#c-create-a-multi-statement-table-valued-function
52
- Table ( Vec < ColumnDef > ) ,
52
+ Table ( Option < Vec < ColumnDef > > ) ,
53
53
/// Table type with a name, e.g. CREATE FUNCTION RETURNS @result TABLE(...).
54
54
NamedTable (
55
55
/// Table name.
@@ -724,12 +724,14 @@ impl fmt::Display for DataType {
724
724
DataType :: Unspecified => Ok ( ( ) ) ,
725
725
DataType :: Trigger => write ! ( f, "TRIGGER" ) ,
726
726
DataType :: AnyType => write ! ( f, "ANY TYPE" ) ,
727
- DataType :: Table ( fields) => {
728
- if fields . is_empty ( ) {
729
- return write ! ( f, "TABLE" ) ;
727
+ DataType :: Table ( fields) => match fields {
728
+ Some ( fields ) => {
729
+ write ! ( f, "TABLE({})" , display_comma_separated ( fields ) )
730
730
}
731
- write ! ( f, "TABLE({})" , display_comma_separated( fields) )
732
- }
731
+ None => {
732
+ write ! ( f, "TABLE" )
733
+ }
734
+ } ,
733
735
DataType :: NamedTable ( name, fields) => {
734
736
write ! ( f, "{} TABLE ({})" , name, display_comma_separated( fields) )
735
737
}
Original file line number Diff line number Diff line change @@ -5220,9 +5220,19 @@ impl<'a> Parser<'a> {
5220
5220
p.peek_token().span.start
5221
5221
)?
5222
5222
};
5223
+
5224
+ if table_column_defs.is_none()
5225
+ || table_column_defs.clone().is_some_and(|tcd| tcd.is_empty())
5226
+ {
5227
+ parser_err!(
5228
+ "Expected table column definitions after TABLE keyword",
5229
+ p.peek_token().span.start
5230
+ )?
5231
+ }
5232
+
5223
5233
Ok(DataType::NamedTable(
5224
5234
ObjectName(vec![ObjectNamePart::Identifier(return_table_name)]),
5225
- table_column_defs.clone(),
5235
+ table_column_defs.clone().unwrap() ,
5226
5236
))
5227
5237
})?;
5228
5238
@@ -9817,10 +9827,10 @@ impl<'a> Parser<'a> {
9817
9827
}
9818
9828
Keyword::TABLE => {
9819
9829
if self.peek_token() != Token::LParen {
9820
- Ok(DataType::Table(Vec::<ColumnDef>::new() ))
9830
+ Ok(DataType::Table(None ))
9821
9831
} else {
9822
9832
let columns = self.parse_returns_table_columns()?;
9823
- Ok(DataType::Table(columns))
9833
+ Ok(DataType::Table(Some( columns) ))
9824
9834
}
9825
9835
}
9826
9836
Keyword::SIGNED => {
You can’t perform that action at this time.
0 commit comments