From 4333af07f27b7352037d06cb395e1257c1aa13c3 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 24 Feb 2023 08:19:50 +0800 Subject: [PATCH] trigger type 2 --- build.py | 2 +- server/monetdb_conn.h | 4 ++-- server/monetdb_ext.c | 6 ++++++ server/server.cpp | 2 +- server/vector_type.hpp | 2 +- tests/triggers.aquery | 5 ++++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index e8c5255..a0de64b 100644 --- a/build.py +++ b/build.py @@ -75,7 +75,7 @@ class build_manager: 'build.py', 'Makefile', 'server/server.cpp', 'server/libaquery.cpp', 'server/monetdb_conn.cpp', 'server/threading.cpp', - 'server/winhelper.cpp' + 'server/winhelper.cpp', 'server/monetdb_ext.c' ] headerfiles = ['server/aggregations.h', 'server/hasher.h', 'server/io.h', 'server/libaquery.h', 'server/monetdb_conn.h', 'server/pch.hpp', diff --git a/server/monetdb_conn.h b/server/monetdb_conn.h index 614e3d4..4fe55f6 100644 --- a/server/monetdb_conn.h +++ b/server/monetdb_conn.h @@ -35,9 +35,9 @@ struct monetdbe_table_data{ void* cols; }; -size_t +extern "C" size_t monetdbe_get_size(void* dbhdl, const char *table_name); -void* +extern "C" void* monetdbe_get_col(void* dbhdl, const char *table_name, uint32_t col_id); #endif diff --git a/server/monetdb_ext.c b/server/monetdb_ext.c index fe0e144..06960c1 100644 --- a/server/monetdb_ext.c +++ b/server/monetdb_ext.c @@ -69,10 +69,13 @@ monetdbe_get_size(monetdbe_database dbhdl, const char *table_name) monetdbe_database_internal* hdl = (monetdbe_database_internal*)dbhdl; backend* be = ((backend *)(((monetdbe_database_internal*)dbhdl)->c->sqlcontext)); mvc *m = be->mvc; + //mvc_trans(m); sql_table *t = find_table_or_view_on_scope(m, NULL, "sys", table_name, "CATALOG", false); + if (!t) return 0; sql_column *col = ol_first_node(t->columns)->data; sqlstore* store = m->store; size_t sz = store->storage_api.count_col(m->session->tr, col, QUICK); + //mvc_cancel_session(m); return sz; } @@ -81,10 +84,13 @@ monetdbe_get_col(monetdbe_database dbhdl, const char *table_name, uint32_t col_i monetdbe_database_internal* hdl = (monetdbe_database_internal*)dbhdl; backend* be = ((backend *)(((monetdbe_database_internal*)dbhdl)->c->sqlcontext)); mvc *m = be->mvc; + //mvc_trans(m); sql_table *t = find_table_or_view_on_scope(m, NULL, "sys", table_name, "CATALOG", false); + if (!t) return 0; sql_column *col = ol_fetch(t->columns, col_id); sqlstore* store = m->store; BAT *b = store->storage_api.bind_col(m->session->tr, col, QUICK); BATiter iter = bat_iterator(b); + //mvc_cancel_session(m); return iter.base; } diff --git a/server/server.cpp b/server/server.cpp index a015422..62da014 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -472,7 +472,7 @@ start: auto fp = fopen(config_name.c_str(), "rb"); if(fp == nullptr){ puts("ERROR: Procedure not found on disk."); - return false; + return true; } fread(&p.cnt, sizeof(p.cnt), 1, fp); fread(&p.postproc_modules, sizeof(p.postproc_modules), 1, fp); diff --git a/server/vector_type.hpp b/server/vector_type.hpp index 2581c82..7722a64 100644 --- a/server/vector_type.hpp +++ b/server/vector_type.hpp @@ -211,7 +211,7 @@ public: iterator_t erase(iterator_t _it) { #ifdef DEBUG // Do bound checks - if (!(size && capicity && container && + if (!(size && capacity && container && _it >= container && (_it - container) < size)) return 0; #endif diff --git a/tests/triggers.aquery b/tests/triggers.aquery index eb54269..0636414 100644 --- a/tests/triggers.aquery +++ b/tests/triggers.aquery @@ -1,3 +1,5 @@ +#!aquery + procedure one run procedure two run @@ -5,4 +7,5 @@ create table t(a int); exec create trigger a on t action one when two; exec -insert into t(a) values (1); \ No newline at end of file +insert into t(a) values (1); +exec \ No newline at end of file