Add support for ATTACH DATABASE (#989)

This commit is contained in:
Ophir LOJKINE 2023-10-02 13:10:56 +02:00 committed by GitHub
parent 7723ea56c5
commit 495d0a02d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 0 deletions

View file

@ -456,6 +456,7 @@ impl<'a> Parser<'a> {
Ok(Statement::Query(Box::new(self.parse_query()?)))
}
Keyword::TRUNCATE => Ok(self.parse_truncate()?),
Keyword::ATTACH => Ok(self.parse_attach_database()?),
Keyword::MSCK => Ok(self.parse_msck()?),
Keyword::CREATE => Ok(self.parse_create()?),
Keyword::CACHE => Ok(self.parse_cache_table()?),
@ -543,6 +544,18 @@ impl<'a> Parser<'a> {
})
}
pub fn parse_attach_database(&mut self) -> Result<Statement, ParserError> {
let database = self.parse_keyword(Keyword::DATABASE);
let database_file_name = self.parse_expr()?;
self.expect_keyword(Keyword::AS)?;
let schema_name = self.parse_identifier()?;
Ok(Statement::AttachDatabase {
database,
schema_name,
database_file_name,
})
}
pub fn parse_analyze(&mut self) -> Result<Statement, ParserError> {
self.expect_keyword(Keyword::TABLE)?;
let table_name = self.parse_object_name()?;