From 4942dc1f5044bdd79b72d554f1b04cb0c6587762 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 6 Dec 2022 11:34:39 +0800 Subject: [PATCH] fixes on stored proc --- Makefile | 4 ++-- aquery_config.py | 2 +- build.py | 4 ++-- server/server.cpp | 26 ++++++++++++++++++-------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index c438529..4240bf6 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ MonetDB_INC = Defines = CXXFLAGS = --std=c++2a ifeq ($(AQ_DEBUG), 1) - OPTFLAGS = -g3 -fsanitize=address -fsanitize=leak + OPTFLAGS = -g3 #-fsanitize=address LINKFLAGS = else - OPTFLAGS = -O3 -DNDEBUG -fno-stack-protector + OPTFLAGS = -Ofast -DNDEBUG -fno-stack-protector LINKFLAGS = -flto -s endif SHAREDFLAGS = -shared diff --git a/aquery_config.py b/aquery_config.py index 094bc47..df2511a 100644 --- a/aquery_config.py +++ b/aquery_config.py @@ -2,7 +2,7 @@ ## GLOBAL CONFIGURATION FLAGS -version_string = '0.5.4a' +version_string = '0.6.0a' add_path_to_ldpath = True rebuild_backend = False run_backend = True diff --git a/build.py b/build.py index ec59122..e8c5255 100644 --- a/build.py +++ b/build.py @@ -117,7 +117,7 @@ class build_manager: else: mgr.cxx = os.environ['CXX'] if 'AQ_DEBUG' not in os.environ: - os.environ['AQ_DEBUG'] = '0' if mgr.OptimizationLv else '1' + os.environ['AQ_DEBUG'] = ('0' if mgr.OptimizationLv != '0' else '1') def libaquery_a(self): self.build_cmd = [['rm', 'libaquery.a'],['make', 'libaquery']] @@ -184,7 +184,7 @@ class build_manager: def __init__(self) -> None: self.method = 'make' self.cxx = '' - self.OptimizationLv = '0' # [O0, O1, O2, O3, Ofast] + self.OptimizationLv = '4' # [O0, O1, O2, O3, Ofast] self.Platform = 'amd64' self.PCH = os.environ['PCH'] if 'PCH' in os.environ else 1 self.StaticLib = 1 diff --git a/server/server.cpp b/server/server.cpp index 64f6544..f2e8c77 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -503,6 +503,7 @@ start: }; const auto& load_proc_fromfile = [&](StoredProcedure& p) { auto config_name = procedure_root + p.name + ".aqp"; + puts(p.name); auto fp = fopen(config_name.c_str(), "rb"); if(fp == nullptr){ puts("ERROR: Procedure not found on disk."); @@ -517,12 +518,14 @@ start: p.queries = static_cast(malloc(sizeof(char*) * p.cnt)); p.queries[0] = static_cast(malloc(sizeof(char) * queries_size)); - fread(&p.queries[0], queries_size, 1, fp); + fread(p.queries[0], 1, queries_size, fp); for(uint32_t j = 1; j < p.cnt; ++j){ p.queries[j] = p.queries[j-1]; - while(*p.queries[j] != '\0') + while(*(p.queries[j]) != '\0') ++p.queries[j]; + ++p.queries[j]; + puts(p.queries[j-1]); } fclose(fp); return load_modules(p); @@ -553,18 +556,22 @@ start: auto _proc = cxt->stored_proc.find(proc_name); if (_proc == cxt->stored_proc.end()){ printf("Procedure %s not found. Trying load from disk.\n", proc_name); - if (load_proc_fromfile(current_procedure)){ + current_procedure.name = copy_lpstr(proc_name); + if (!load_proc_fromfile(current_procedure)){ cxt->stored_proc.insert_or_assign(proc_name, current_procedure); } + else { + continue; + } } else{ current_procedure = _proc->second; - n_recv = current_procedure.cnt; - n_recvd = current_procedure.queries; - load_modules(current_procedure); - procedure_replaying = true; - goto start; // yes, I know, refactor later!! } + n_recv = current_procedure.cnt; + n_recvd = current_procedure.queries; + load_modules(current_procedure); + procedure_replaying = true; + goto start; // yes, I know, refactor later!! } break; case 'D': // delete procedure @@ -572,6 +579,9 @@ start: case 'S': //save procedure break; case 'L': //load procedure + if (!load_proc_fromfile(current_procedure)) { + cxt->stored_proc.insert_or_assign(proc_name, current_procedure); + } break; case 'd': // display all procedures for(const auto& p : cxt->stored_proc){