This repository was archived by the owner on Oct 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -62,20 +62,34 @@ impl StmtKind {
62
62
| Stmt :: CreateIndex { .. } ,
63
63
) => Some ( Self :: Write ) ,
64
64
Cmd :: Stmt ( Stmt :: Select { .. } ) => Some ( Self :: Read ) ,
65
- Cmd :: Stmt ( Stmt :: Pragma ( name, body) ) if is_pragma_allowed ( name, body. as_ref ( ) ) => {
66
- Some ( Self :: Write )
65
+ Cmd :: Stmt ( Stmt :: Pragma ( name, body) ) => {
66
+ if is_ro_pragma ( name, body. as_ref ( ) ) {
67
+ Some ( Self :: Read )
68
+ } else if is_pragma_allowed ( name, body. as_ref ( ) ) {
69
+ Some ( Self :: Write )
70
+ } else {
71
+ None
72
+ }
67
73
}
68
74
_ => None ,
69
75
}
70
76
}
71
77
}
72
78
79
+ fn is_ro_pragma ( name : & QualifiedName , _body : Option < & PragmaBody > ) -> bool {
80
+ matches ! ( name, QualifiedName {
81
+ db_name: None ,
82
+ name,
83
+ alias: None ,
84
+ } if name. 0 . starts_with( "index_" ) || name. 0 == "encoding" || name. 0 == "function_list" || name. 0 == "module_list" || name. 0 . starts_with( "table_" ) )
85
+ }
86
+
73
87
fn is_pragma_allowed ( name : & QualifiedName , _body : Option < & PragmaBody > ) -> bool {
74
88
matches ! ( name, QualifiedName {
75
89
db_name: None ,
76
90
name,
77
91
alias: None ,
78
- } if name. 0 == "writable_schema" || name. 0 == "foreign_keys" )
92
+ } if name. 0 == "writable_schema" || name. 0 . starts_with ( "foreign_key" ) )
79
93
}
80
94
81
95
/// The state of a transaction for a series of statement
You can’t perform that action at this time.
0 commit comments