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; --?.* --?.*