feat: Support TABLE keyword with SELECT INTO (#487)

This commit is contained in:
Alex Qyoun-ae 2022-05-09 22:29:43 +04:00 committed by GitHub
parent 6d057ef4df
commit 6b2fc8102f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -654,6 +654,7 @@ impl fmt::Display for Values {
pub struct SelectInto {
pub temporary: bool,
pub unlogged: bool,
pub table: bool,
pub name: ObjectName,
}
@ -661,7 +662,8 @@ impl fmt::Display for SelectInto {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let temporary = if self.temporary { " TEMPORARY" } else { "" };
let unlogged = if self.unlogged { " UNLOGGED" } else { "" };
let table = if self.table { " TABLE" } else { "" };
write!(f, "INTO{}{} {}", temporary, unlogged, self.name)
write!(f, "INTO{}{}{} {}", temporary, unlogged, table, self.name)
}
}

View file

@ -3138,10 +3138,12 @@ impl<'a> Parser<'a> {
.parse_one_of_keywords(&[Keyword::TEMP, Keyword::TEMPORARY])
.is_some();
let unlogged = self.parse_keyword(Keyword::UNLOGGED);
let table = self.parse_keyword(Keyword::TABLE);
let name = self.parse_object_name()?;
Some(SelectInto {
temporary,
unlogged,
table,
name,
})
} else {

View file

@ -383,13 +383,17 @@ fn parse_select_into() {
&SelectInto {
temporary: false,
unlogged: false,
table: false,
name: ObjectName(vec![Ident::new("table0")])
},
only(&select.into)
);
let sql = "SELECT * INTO TEMPORARY UNLOGGED table0 FROM table1";
one_statement_parses_to(sql, "SELECT * INTO TEMPORARY UNLOGGED table0 FROM table1");
let sql = "SELECT * INTO TEMPORARY UNLOGGED TABLE table0 FROM table1";
one_statement_parses_to(
sql,
"SELECT * INTO TEMPORARY UNLOGGED TABLE table0 FROM table1",
);
// Do not allow aliases here
let sql = "SELECT * INTO table0 asdf FROM table1";