From 35e23e451e78b0cf82eeafedf2813c017336ada9 Mon Sep 17 00:00:00 2001 From: teooooozhang Date: Tue, 20 Jun 2023 15:06:11 +0800 Subject: [PATCH] =?UTF-8?q?gs=5Fget=5Fsession=5Fmemctx=5Fdetail=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=A9=BA=E5=80=BC=E8=BE=93=E5=85=A5=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/adt/memory_func.cpp | 18 ++++++++++++++++++ src/test/regress/expected/wlm_memory_trace.out | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/common/backend/utils/adt/memory_func.cpp b/src/common/backend/utils/adt/memory_func.cpp index 9fba99703..bbc917e82 100644 --- a/src/common/backend/utils/adt/memory_func.cpp +++ b/src/common/backend/utils/adt/memory_func.cpp @@ -310,6 +310,12 @@ Datum gs_get_thread_memctx_detail(PG_FUNCTION_ARGS) aclcheck_error(ACLCHECK_NO_PRIV, ACL_KIND_PROC, "gs_get_thread_memctx_detail"); } + if (PG_ARGISNULL(1)) { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("second parameter should not be empty"))); + } + const ThreadId tid = PG_GETARG_INT64(0); char* ctx_name = TextDatumGetCString(PG_GETARG_TEXT_PP(1)); @@ -411,6 +417,12 @@ Datum gs_get_session_memctx_detail(PG_FUNCTION_ARGS) aclcheck_error(ACLCHECK_NO_PRIV, ACL_KIND_PROC, "gs_get_session_memctx_detail"); } + if (PG_ARGISNULL(0)) { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("input parameter should not be empty"))); + } + char* ctx_name = TextDatumGetCString(PG_GETARG_TEXT_PP(0)); gs_check_context_name_valid(ctx_name); @@ -476,6 +488,12 @@ Datum gs_get_shared_memctx_detail(PG_FUNCTION_ARGS) aclcheck_error(ACLCHECK_NO_PRIV, ACL_KIND_PROC, "gs_get_shared_memctx_detail"); } + if (PG_ARGISNULL(0)) { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("input parameter should not be empty"))); + } + char* ctx_name = TextDatumGetCString(PG_GETARG_TEXT_PP(0)); gs_check_context_name_valid(ctx_name); diff --git a/src/test/regress/expected/wlm_memory_trace.out b/src/test/regress/expected/wlm_memory_trace.out index d8c03049e..5788e8c4e 100644 --- a/src/test/regress/expected/wlm_memory_trace.out +++ b/src/test/regress/expected/wlm_memory_trace.out @@ -11,7 +11,7 @@ select * from gs_get_shared_memctx_detail('AbnormalContext'); (0 rows) select * from gs_get_shared_memctx_detail(NULL); -ERROR: NULL input for detoast datum packed +ERROR: input parameter should not be empty select * from gs_get_session_memctx_detail('CBBTopMemoryContext') limit 1; --?.* --?.* @@ -24,12 +24,12 @@ select * from gs_get_session_memctx_detail('AbnormalContext'); (0 rows) select * from gs_get_session_memctx_detail(NULL); -ERROR: NULL input for detoast datum packed +ERROR: input parameter should not be empty select * from gs_get_thread_memctx_detail(100, 'CBBTopMemoryContext'); ERROR: can not find pid 100 select * from gs_get_thread_memctx_detail(100, NULL); -ERROR: NULL input for detoast datum packed +ERROR: second parameter should not be empty select gs_get_thread_memctx_detail(tid, 'CBBTopMemoryContext') from pv_thread_memory_context where contextname = 'CBBTopMemoryContext' limit 1; --?.* --?.*