Postgres: Apply ONLY keyword per table in TRUNCATE stmt (#1872)

This commit is contained in:
Mohamed Abdeen 2025-06-06 08:10:03 +01:00 committed by GitHub
parent de2cc7b502
commit 4cf5e571d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 44 additions and 14 deletions

View file

@ -960,12 +960,13 @@ impl<'a> Parser<'a> {
pub fn parse_truncate(&mut self) -> Result<Statement, ParserError> {
let table = self.parse_keyword(Keyword::TABLE);
let only = self.parse_keyword(Keyword::ONLY);
let table_names = self
.parse_comma_separated(|p| p.parse_object_name(false))?
.parse_comma_separated(|p| {
Ok((p.parse_keyword(Keyword::ONLY), p.parse_object_name(false)?))
})?
.into_iter()
.map(|n| TruncateTableTarget { name: n })
.map(|(only, name)| TruncateTableTarget { name, only })
.collect();
let mut partitions = None;
@ -996,7 +997,6 @@ impl<'a> Parser<'a> {
table_names,
partitions,
table,
only,
identity,
cascade,
on_cluster,