From 6c87699fa979c17e0f3f23f5ef1ea7393ea74be7 Mon Sep 17 00:00:00 2001 From: Vinoth Veeraraghavan Date: Wed, 14 Dec 2022 10:12:10 +0800 Subject: [PATCH] Minor bug fix to setup/restore jit_context in MOT JIT --- src/gausskernel/storage/mot/core/Makefile.local | 14 ++++++-------- .../storage/mot/fdw_adapter/mot_internal.cpp | 4 ++-- src/gausskernel/storage/mot/jit_exec/jit_exec.cpp | 8 ++++---- .../regress/expected/mot/single_new_indexes.out | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/gausskernel/storage/mot/core/Makefile.local b/src/gausskernel/storage/mot/core/Makefile.local index 47c314bee..8bb0709cf 100644 --- a/src/gausskernel/storage/mot/core/Makefile.local +++ b/src/gausskernel/storage/mot/core/Makefile.local @@ -17,14 +17,13 @@ # Makefile for the MOT storage engine core components # # IDENTIFICATION -# src/gausskernel/storage/mot/core/Makefile.local +# src/gausskernel/storage/mot/core/Makefile.local # # --------------------------------------------------------------------------------------- -UNDERPG ?= yes +UNDER_ENVELOPE ?= yes SECURE ?= yes DEBUG ?= no -MODE ?= PG REPLICA ?= no ISOLATION ?= no CC=g++ @@ -33,7 +32,7 @@ CFLAGS ?= subdir=src/gausskernel/storage/mot/core top_builddir ?= ../../../../../ -ifeq ($(UNDERPG),yes) +ifeq ($(UNDER_ENVELOPE),yes) include $(top_builddir)/src/Makefile.global include $(top_srcdir)/src/gausskernel/common.mk endif @@ -89,7 +88,7 @@ ifeq ($(HUGE_PAGES_ON), yes) CFLAGS += -DHUGE_PAGES_ON=1 endif #Debug and release flag definition -ifeq ($(UNDERPG), no) +ifeq ($(UNDER_ENVELOPE), no) ifeq ($(BUILD),Release) ifeq ($(PLATFORM_ARCH),aarch64) CFLAGS += -O2 -DNDEBUG -D_FORTIFY_SOURCE=2 @@ -119,7 +118,6 @@ CFLAGS += -L$(MASSTREE_HOME)/lib -lmasstree # For Masstree index tests CFLAGS += -DMASSTREE -CFLAGS += -D$(MODE) # disable exceptions CFLAGS += -fno-exceptions # disable RTTI usage @@ -158,7 +156,7 @@ OBJS := $(CPPS) OBJS := $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(OBJS)) DEPS := $(OBJS:.o=.d) -ifeq ($(UNDERPG), yes) +ifeq ($(UNDER_ENVELOPE), yes) ifeq ($(SECURE), yes) CFLAGS += -DMOT_SECURE LDFLAGS += -L$(LIBOBS_LIB_PATH) -l$(SECURE_C_CHECK) @@ -196,7 +194,7 @@ buildrepo: .PHONY: show show: - @echo "UNDERPG=${UNDERPG}" + @echo "UNDER_ENVELOPE=${UNDER_ENVELOPE}" @echo "enable_cassert=${enable_cassert}" @echo "CC_VERSION=${CC_VERSION}" @echo "CC=${CC}" diff --git a/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp b/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp index c1ae61c18..2ffad8b0a 100644 --- a/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp +++ b/src/gausskernel/storage/mot/fdw_adapter/mot_internal.cpp @@ -888,7 +888,7 @@ static void ValidateCreateIndex(IndexStmt* stmt, MOT::Table* table, MOT::TxnMana ereport(ERROR, (errmodule(MOD_MOT), errcode(ERRCODE_FDW_TOO_MANY_INDEXES), - errmsg("Can not create index, max number of indexes %u reached", MAX_NUM_INDEXES))); + errmsg("Cannot create index, max number of indexes %u reached", MAX_NUM_INDEXES))); } if (strcmp(stmt->accessMethod, "btree") != 0) { @@ -1061,7 +1061,7 @@ MOT::RC MOTAdaptor::CreateIndex(IndexStmt* stmt, ::TransactionId tid) ereport(ERROR, (errmodule(MOD_MOT), errcode(ERRCODE_FDW_TOO_MANY_INDEXES), - errmsg("Can not create index, max number of indexes %u reached", MAX_NUM_INDEXES))); + errmsg("Cannot create index, max number of indexes %u reached", MAX_NUM_INDEXES))); return MOT::RC_TABLE_EXCEEDS_MAX_INDEXES; } report_pg_error(txn->m_err, stmt->idxname, txn->m_errMsgBuf); diff --git a/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp b/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp index e9f00d7c7..33e7f60a5 100644 --- a/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp +++ b/src/gausskernel/storage/mot/jit_exec/jit_exec.cpp @@ -1613,10 +1613,6 @@ extern int JitExecFunction( return result; } - // setup current JIT context - volatile MotJitContext* prevContext = u_sess->mot_cxt.jit_context; - u_sess->mot_cxt.jit_context = jitContext; - // we avoid weird stuff by putting null in case of internal error bool isFunctionContext = (jitContext->m_contextType == JitContextType::JIT_CONTEXT_TYPE_FUNCTION); volatile JitFunctionExecState* execState = @@ -1662,6 +1658,10 @@ extern int JitExecFunction( jitContext->m_queryString))); } + // setup current JIT context + volatile MotJitContext* prevContext = u_sess->mot_cxt.jit_context; + u_sess->mot_cxt.jit_context = jitContext; + // invoke the jitted function volatile MemoryContext origCxt = CurrentMemoryContext; // since we use parts of the PG function in query invocation, we need to make sure it does not get deleted diff --git a/src/test/regress/expected/mot/single_new_indexes.out b/src/test/regress/expected/mot/single_new_indexes.out index 89524c8e3..205dbb130 100644 --- a/src/test/regress/expected/mot/single_new_indexes.out +++ b/src/test/regress/expected/mot/single_new_indexes.out @@ -46,7 +46,7 @@ create index idx7 on test_new_index (c,v); create index idx8 on test_new_index (d,t,ts); create index idx9 on test_new_index (intrvl); create index idx10 on test_new_index (b); -ERROR: Can not create index, max number of indexes 10 reached +ERROR: Cannot create index, max number of indexes 10 reached insert into test_new_index (i, i2, i4) values (generate_series(1,100), generate_series(1,100), generate_series(1,100)); ERROR: null value in column "i8" violates not-null constraint DETAIL: Failing row contains (1, 1, 1, null, null, null, null, 1, null, null, null, null, null, null, null, null).