-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtemp_drop_table.txt
More file actions
36 lines (29 loc) · 1.05 KB
/
temp_drop_table.txt
File metadata and controls
36 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
private void ExecuteDropTableInternal(string sql)
{
var regex = new Regex(
@"DROP\s+TABLE\s+(?:IF\s+EXISTS\s+)?(\w+)",
RegexOptions.IgnoreCase);
var match = regex.Match(sql);
if (!match.Success)
{
throw new InvalidOperationException($"Invalid DROP TABLE syntax: {sql}");
}
var tableName = match.Groups[1].Value.Trim();
if (!_tables.TryGetValue(tableName, out var table))
{
// If IF EXISTS, silently ignore
if (sql.ToUpperInvariant().Contains("IF EXISTS"))
return;
throw new InvalidOperationException($"Table '{tableName}' not found");
}
// Remove from tables dictionary
_tables.Remove(tableName);
// Remove from storage provider metadata
_tableDirectoryManager.RemoveTable(tableName);
_tableDirectoryManager.Flush();
// Dispose table if needed
if (table is IDisposable disposable)
{
disposable.Dispose();
}
}