From 3842a723997130d97b5e001108d38bb8a5ed9482 Mon Sep 17 00:00:00 2001 From: Lamaric Date: Tue, 6 Jun 2023 19:23:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[bugfix]=20pg=5Ffree=5Fremain=5Fsegment=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=9C=AA=E5=A4=84=E7=90=86=E8=B4=9F=E6=95=B0?= =?UTF-8?q?=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/adt/pgstatfuncs.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/backend/utils/adt/pgstatfuncs.cpp b/src/common/backend/utils/adt/pgstatfuncs.cpp index ad68260ce..7fcf17ee2 100644 --- a/src/common/backend/utils/adt/pgstatfuncs.cpp +++ b/src/common/backend/utils/adt/pgstatfuncs.cpp @@ -1818,9 +1818,9 @@ static void pgOutputRemainInfoToFile(RemainSegsCtx* remainSegsCtx) Datum pg_free_remain_segment(PG_FUNCTION_ARGS) { - Oid spaceId = PG_GETARG_OID(0); - Oid dbId = PG_GETARG_OID(1); - Oid segmentId = PG_GETARG_OID(2); + int32 spaceId = PG_GETARG_INT32(0); + int32 dbId = PG_GETARG_INT32(1); + int32 segmentId = PG_GETARG_INT32(2); RemainSegsCtx* remainSegsCtx = (RemainSegsCtx *)palloc(sizeof(RemainSegsCtx)); remainSegsCtx->remainSegsBuf = NULL; @@ -1828,7 +1828,7 @@ Datum pg_free_remain_segment(PG_FUNCTION_ARGS) ReadRemainSegsFileForFunc(remainSegsCtx); - int segIdx = pgCheckRemainSegment(remainSegsCtx, spaceId, dbId, segmentId); + int segIdx = pgCheckRemainSegment(remainSegsCtx, (Oid)spaceId, (Oid)dbId, (Oid)segmentId); if (segIdx >= 0 && (uint32)segIdx < remainSegsCtx->remainSegsNum) { pgDoFreeRemainSegment(remainSegsCtx, segIdx); @@ -1836,7 +1836,7 @@ Datum pg_free_remain_segment(PG_FUNCTION_ARGS) pgOutputRemainInfoToFile(remainSegsCtx); } else { - ereport(ERROR, (errmsg("Input segment [%u, %u, %u] is not remained segment!", spaceId, dbId, segmentId))); + ereport(ERROR, (errmsg("Input segment [%d, %d, %d] is not remained segment!", spaceId, dbId, segmentId))); } if (remainSegsCtx->remainSegsBuf != NULL) { From 7960232ba0e4b5dda4cb97edafee796164da3176 Mon Sep 17 00:00:00 2001 From: Lamaric Date: Tue, 18 Jul 2023 15:07:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=90=88=E6=B3=95=E6=80=A7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/adt/pgstatfuncs.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/backend/utils/adt/pgstatfuncs.cpp b/src/common/backend/utils/adt/pgstatfuncs.cpp index 7fcf17ee2..dcd9e61e2 100644 --- a/src/common/backend/utils/adt/pgstatfuncs.cpp +++ b/src/common/backend/utils/adt/pgstatfuncs.cpp @@ -1822,6 +1822,11 @@ Datum pg_free_remain_segment(PG_FUNCTION_ARGS) int32 dbId = PG_GETARG_INT32(1); int32 segmentId = PG_GETARG_INT32(2); + if (spaceId < 0 || dbId < 0 || segmentId < 0) { + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("Input segment [%d, %d, %d] is not valid segment!", spaceId, dbId, segmentId))); + } + RemainSegsCtx* remainSegsCtx = (RemainSegsCtx *)palloc(sizeof(RemainSegsCtx)); remainSegsCtx->remainSegsBuf = NULL; remainSegsCtx->remainSegsNum = 0;