-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_views_fromless.py
More file actions
executable file
·40 lines (33 loc) · 1.31 KB
/
Copy pathfix_views_fromless.py
File metadata and controls
executable file
·40 lines (33 loc) · 1.31 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
37
38
39
40
#!/usr/bin/env python3
"""Fix Views and Procedures to handle FROM-less SELECT queries."""
DISPATCH = '/opt/milansql/src/dispatch.hpp'
with open(DISPATCH, 'r') as f:
content = f.read()
changes = 0
# Fix materializeView — handle empty tableName (FROM-less SELECT)
old_materialize = ''' milansql::Table base;
if (!vc.whereConds.empty()) {
auto qr = engine.selectWhere(vc.tableName, vc.whereConds, vc.whereLogic);
base = std::move(qr.table);
} else {
base = engine.selectAll(vc.tableName).clone();
}'''
new_materialize = ''' milansql::Table base;
if (vc.tableName.empty()) {
// Phase 173: FROM-less SELECT (e.g., SELECT 1 AS val, SELECT expression)
base = dispatch_executeSelectToTable(engine, parser, vc);
} else if (!vc.whereConds.empty()) {
auto qr = engine.selectWhere(vc.tableName, vc.whereConds, vc.whereLogic);
base = std::move(qr.table);
} else {
base = engine.selectAll(vc.tableName).clone();
}'''
if old_materialize in content:
content = content.replace(old_materialize, new_materialize)
changes += 1
print("OK: materializeView FROM-less SELECT fixed")
else:
print("WARN: materializeView pattern not found")
with open(DISPATCH, 'w') as f:
f.write(content)
print(f"DONE: {changes} view fixes applied")