File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -196,6 +196,11 @@ impl Display for Insert {
196196pub struct Delete {
197197 /// Token for the `DELETE` keyword
198198 pub delete_token : AttachedToken ,
199+ /// A query optimizer hint
200+ ///
201+ /// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/optimizer-hints.html)
202+ /// [Oracle](https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Comments.html#GUID-D316D545-89E2-4D54-977F-FC97815CD62E)
203+ pub optimizer_hint : Option < OptimizerHint > ,
199204 /// Multi tables delete are supported in mysql
200205 pub tables : Vec < ObjectName > ,
201206 /// FROM
@@ -215,6 +220,10 @@ pub struct Delete {
215220impl Display for Delete {
216221 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
217222 f. write_str ( "DELETE" ) ?;
223+ if let Some ( hint) = self . optimizer_hint . as_ref ( ) {
224+ f. write_str ( " " ) ?;
225+ hint. fmt ( f) ?;
226+ }
218227 if !self . tables . is_empty ( ) {
219228 indented_list ( f, & self . tables ) ?;
220229 }
Original file line number Diff line number Diff line change @@ -894,6 +894,7 @@ impl Spanned for Delete {
894894 fn span ( & self ) -> Span {
895895 let Delete {
896896 delete_token,
897+ optimizer_hint : _,
897898 tables,
898899 from,
899900 using,
Original file line number Diff line number Diff line change @@ -12985,6 +12985,7 @@ impl<'a> Parser<'a> {
1298512985
1298612986 /// Parse a `DELETE` statement and return `Statement::Delete`.
1298712987 pub fn parse_delete(&mut self, delete_token: TokenWithSpan) -> Result<Statement, ParserError> {
12988+ let optimizer_hint = self.parse_optional_optimizer_hint()?;
1298812989 let (tables, with_from_keyword) = if !self.parse_keyword(Keyword::FROM) {
1298912990 // `FROM` keyword is optional in BigQuery SQL.
1299012991 // https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#delete_statement
@@ -13028,6 +13029,7 @@ impl<'a> Parser<'a> {
1302813029
1302913030 Ok(Statement::Delete(Delete {
1303013031 delete_token: delete_token.into(),
13032+ optimizer_hint,
1303113033 tables,
1303213034 from: if with_from_keyword {
1303313035 FromTable::WithFromKeyword(from)
Original file line number Diff line number Diff line change @@ -4392,4 +4392,8 @@ fn test_optimizer_hints() {
43924392 UPDATE /*+ quux */ table_name \
43934393 SET column1 = 1 \
43944394 WHERE 1 = 1") ;
4395+
4396+ // ~ deletes
4397+ mysql_dialect. verified_stmt ( "\
4398+ DELETE /*+ foobar */ FROM table_name") ;
43954399}
Original file line number Diff line number Diff line change @@ -376,4 +376,8 @@ fn test_optimizer_hints() {
376376 // ~ updates
377377 oracle_dialect. verified_stmt (
378378 "UPDATE /*+ DISABLE_PARALLEL_DML */ table_name SET column1 = 1" ) ;
379+
380+ // ~ deletes
381+ oracle_dialect. verified_stmt (
382+ "DELETE --+ ENABLE_PARALLEL_DML\n FROM table_name" ) ;
379383}
You can’t perform that action at this time.
0 commit comments