|
28 | 28 | // limitations under the License.
|
29 | 29 | use log::debug;
|
30 | 30 |
|
31 |
| -use crate::ast::{ObjectName, Statement, UserDefinedTypeRepresentation}; |
32 | 31 | use crate::dialect::{Dialect, Precedence};
|
33 | 32 | use crate::keywords::Keyword;
|
34 | 33 | use crate::parser::{Parser, ParserError};
|
@@ -135,15 +134,6 @@ impl Dialect for PostgreSqlDialect {
|
135 | 134 | }
|
136 | 135 | }
|
137 | 136 |
|
138 |
| - fn parse_statement(&self, parser: &mut Parser) -> Option<Result<Statement, ParserError>> { |
139 |
| - if parser.parse_keyword(Keyword::CREATE) { |
140 |
| - parser.prev_token(); // unconsume the CREATE in case we don't end up parsing anything |
141 |
| - parse_create(parser) |
142 |
| - } else { |
143 |
| - None |
144 |
| - } |
145 |
| - } |
146 |
| - |
147 | 137 | fn supports_filter_during_aggregation(&self) -> bool {
|
148 | 138 | true
|
149 | 139 | }
|
@@ -259,41 +249,11 @@ impl Dialect for PostgreSqlDialect {
|
259 | 249 | true
|
260 | 250 | }
|
261 | 251 |
|
262 |
| - fn supports_alter_type(&self) -> bool { |
| 252 | + fn supports_create_type_as_enum(&self) -> bool { |
263 | 253 | true
|
264 | 254 | }
|
265 |
| -} |
266 |
| - |
267 |
| -pub fn parse_create(parser: &mut Parser) -> Option<Result<Statement, ParserError>> { |
268 |
| - let name = parser.maybe_parse(|parser| -> Result<ObjectName, ParserError> { |
269 |
| - parser.expect_keyword_is(Keyword::CREATE)?; |
270 |
| - parser.expect_keyword_is(Keyword::TYPE)?; |
271 |
| - let name = parser.parse_object_name(false)?; |
272 |
| - parser.expect_keyword_is(Keyword::AS)?; |
273 |
| - parser.expect_keyword_is(Keyword::ENUM)?; |
274 |
| - Ok(name) |
275 |
| - }); |
276 |
| - |
277 |
| - match name { |
278 |
| - Ok(name) => name.map(|name| parse_create_type_as_enum(parser, name)), |
279 |
| - Err(e) => Some(Err(e)), |
280 |
| - } |
281 |
| -} |
282 | 255 |
|
283 |
| -// https://www.postgresql.org/docs/current/sql-createtype.html |
284 |
| -pub fn parse_create_type_as_enum( |
285 |
| - parser: &mut Parser, |
286 |
| - name: ObjectName, |
287 |
| -) -> Result<Statement, ParserError> { |
288 |
| - if !parser.consume_token(&Token::LParen) { |
289 |
| - return parser.expected("'(' after CREATE TYPE AS ENUM", parser.peek_token()); |
| 256 | + fn supports_alter_type(&self) -> bool { |
| 257 | + true |
290 | 258 | }
|
291 |
| - |
292 |
| - let labels = parser.parse_comma_separated0(|p| p.parse_identifier(), Token::RParen)?; |
293 |
| - parser.expect_token(&Token::RParen)?; |
294 |
| - |
295 |
| - Ok(Statement::CreateType { |
296 |
| - name, |
297 |
| - representation: UserDefinedTypeRepresentation::Enum { labels }, |
298 |
| - }) |
299 | 259 | }
|
0 commit comments