@@ -4,7 +4,9 @@ use crate::translate::expr::{sanitize_string, translate_expr};
44use crate :: translate:: { ProgramBuilder , ProgramBuilderOpts } ;
55use crate :: util:: normalize_ident;
66use crate :: vdbe:: insn:: Insn ;
7+ use crate :: Connection ;
78use crate :: Result ;
9+ use std:: sync:: Arc ;
810use turso_parser:: ast:: { Expr , Literal } ;
911
1012/// Translate ATTACH statement
@@ -15,7 +17,13 @@ pub fn translate_attach(
1517 db_name : & Expr ,
1618 key : & Option < Box < Expr > > ,
1719 mut program : ProgramBuilder ,
20+ connection : Arc < Connection > ,
1821) -> Result < ProgramBuilder > {
22+ if !connection. experimental_attach_enabled ( ) {
23+ return Err ( crate :: LimboError :: ParseError (
24+ "ATTACH is an experimental feature. Enable with --experimental-attach flag" . to_string ( ) ,
25+ ) ) ;
26+ }
1927 // SQLite treats ATTACH as a function call to sqlite_attach(filename, dbname, key)
2028 // We'll allocate registers for the arguments and call the function
2129
@@ -119,7 +127,13 @@ pub fn translate_detach(
119127 expr : & Expr ,
120128 resolver : & Resolver ,
121129 mut program : ProgramBuilder ,
130+ connection : Arc < Connection > ,
122131) -> Result < ProgramBuilder > {
132+ if !connection. experimental_attach_enabled ( ) {
133+ return Err ( crate :: LimboError :: ParseError (
134+ "DETACH is an experimental feature. Enable with --experimental-attach flag" . to_string ( ) ,
135+ ) ) ;
136+ }
123137 // SQLite treats DETACH as a function call to sqlite_detach(dbname)
124138
125139 program. extend ( & ProgramBuilderOpts {
0 commit comments