added user module
This commit is contained in:
+2
-1
@@ -659,7 +659,8 @@ class load(ast_node):
|
||||
self.context.module_map[fname] = cpp_stub
|
||||
#registration for parser
|
||||
self.functions[fname] = user_module_function(fname, nargs, ret_type, self.context)
|
||||
|
||||
self.context.module_init_loc = len(self.context.queries)
|
||||
|
||||
def produce_aq(self, node):
|
||||
node = node['load']
|
||||
s1 = 'LOAD DATA INFILE '
|
||||
|
||||
@@ -95,6 +95,7 @@ class Context:
|
||||
self.scans = []
|
||||
self.procs = []
|
||||
self.queries = []
|
||||
self.module_init_loc = 0
|
||||
|
||||
def __init__(self):
|
||||
self.tables_byname = dict()
|
||||
@@ -143,14 +144,18 @@ class Context:
|
||||
ret = '__AQEXPORT__(void) __builtin_init_user_module(Context* cxt){\n'
|
||||
for fname in self.module_map.keys():
|
||||
ret += f'{fname} = (decltype({fname}))(cxt->get_module_function("{fname}"));\n'
|
||||
self.queries.insert(0, f'P__builtin_init_user_module')
|
||||
self.queries.insert(self.module_init_loc, 'P__builtin_init_user_module')
|
||||
return ret + '}\n'
|
||||
|
||||
def sql_begin(self):
|
||||
self.sql = ''
|
||||
|
||||
def sql_end(self):
|
||||
if self.sql.strip():
|
||||
# eliminate empty queries
|
||||
s = self.sql.strip()
|
||||
while(s and s[-1] == ';'):
|
||||
s = s[:-1].strip()
|
||||
if s and s.lower() != 'select':
|
||||
self.queries.append('Q' + self.sql)
|
||||
self.sql = ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user