File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,18 @@ pub enum AlterTableOperation {
45
45
/// <column_def>.
46
46
column_def : ColumnDef ,
47
47
} ,
48
+ /// DISABLE TRIGGER [ trigger_name | ALL | USER ]
49
+ /// DISABLE RULE rewrite_rule_name
50
+ /// DISABLE ROW LEVEL SECURITY
51
+ ///
52
+ /// Note: this is a PostgreSQL-specific operation.
53
+ DisableTrigger {
54
+ name : Ident ,
55
+ } ,
56
+ DisableRule {
57
+ name : Ident ,
58
+ } ,
59
+ DisableRowLevelSecurity ,
48
60
/// `DROP CONSTRAINT [ IF EXISTS ] <name>`
49
61
DropConstraint {
50
62
if_exists : bool ,
@@ -143,6 +155,15 @@ impl fmt::Display for AlterTableOperation {
143
155
AlterTableOperation :: AlterColumn { column_name, op } => {
144
156
write ! ( f, "ALTER COLUMN {column_name} {op}" )
145
157
}
158
+ AlterTableOperation :: DisableTrigger { name } => {
159
+ write ! ( f, "DISABLE TRIGGER {name}" )
160
+ }
161
+ AlterTableOperation :: DisableRule { name } => {
162
+ write ! ( f, "DISABLE RULE {name}" )
163
+ }
164
+ AlterTableOperation :: DisableRowLevelSecurity => {
165
+ write ! ( f, "DISABLE ROW LEVEL SECURITY" )
166
+ }
146
167
AlterTableOperation :: DropPartitions {
147
168
partitions,
148
169
if_exists,
Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ define_keywords!(
222
222
DETAIL ,
223
223
DETERMINISTIC ,
224
224
DIRECTORY ,
225
+ DISABLE ,
225
226
DISCARD ,
226
227
DISCONNECT ,
227
228
DISTINCT ,
@@ -557,6 +558,7 @@ define_keywords!(
557
558
ROWID ,
558
559
ROWS ,
559
560
ROW_NUMBER ,
561
+ RULE ,
560
562
RUN ,
561
563
SAFE_CAST ,
562
564
SAVEPOINT ,
Original file line number Diff line number Diff line change @@ -4636,6 +4636,26 @@ impl<'a> Parser<'a> {
4636
4636
new_column_name,
4637
4637
}
4638
4638
}
4639
+ } else if self . parse_keyword ( Keyword :: DISABLE ) {
4640
+ if self . parse_keyword ( Keyword :: TRIGGER ) {
4641
+ // let all = self.parse_keyword(Keyword::ALL);
4642
+ // let user = self.parse_keyword(Keyword::ALL);
4643
+ let name = self . parse_identifier ( ) ?;
4644
+
4645
+ // println!("parse all: {}", all);
4646
+
4647
+ AlterTableOperation :: DisableTrigger { name }
4648
+ } else if self . parse_keyword ( Keyword :: RULE ) {
4649
+ let name = self . parse_identifier ( ) ?;
4650
+ AlterTableOperation :: DisableRule { name }
4651
+ } else if self . parse_keyword ( Keyword :: ROW ) {
4652
+ AlterTableOperation :: DisableRowLevelSecurity { }
4653
+ } else {
4654
+ return self . expected (
4655
+ "TRIGGER, RULE or ROW LEVEL SECURITY after DISABLE" ,
4656
+ self . peek_token ( ) ,
4657
+ ) ;
4658
+ }
4639
4659
} else if self . parse_keyword ( Keyword :: DROP ) {
4640
4660
if self . parse_keywords ( & [ Keyword :: IF , Keyword :: EXISTS , Keyword :: PARTITION ] ) {
4641
4661
self . expect_token ( & Token :: LParen ) ?;
Original file line number Diff line number Diff line change @@ -563,6 +563,13 @@ fn parse_alter_table_constraints_rename() {
563
563
}
564
564
}
565
565
566
+ #[ test]
567
+ fn parse_alter_table_disable_trigger ( ) {
568
+ pg_and_generic ( ) . verified_stmt ( "ALTER TABLE tab DISABLE TRIGGER ALL" ) ;
569
+ pg_and_generic ( ) . verified_stmt ( "ALTER TABLE tab DISABLE TRIGGER USER" ) ;
570
+ pg_and_generic ( ) . verified_stmt ( "ALTER TABLE tab DISABLE TRIGGER trigger_name" ) ;
571
+ }
572
+
566
573
#[ test]
567
574
fn parse_alter_table_alter_column ( ) {
568
575
pg ( ) . one_statement_parses_to (
You can’t perform that action at this time.
0 commit comments