From c6d97ea0abb301feab8f6d56eaf57937a3f9e0d7 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Mon, 10 Apr 2023 16:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AA=E5=9B=9E=E6=81=A2=E5=A4=8D=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=9C=A8drop=E4=B8=A4=E6=AC=A1=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E8=A1=A8=E6=97=B6=E7=9A=84=E8=AE=BE=E8=AE=A1=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/tcap/tcap_manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gausskernel/storage/tcap/tcap_manager.cpp b/src/gausskernel/storage/tcap/tcap_manager.cpp index 23d3b0b2ea..2d2752bb18 100644 --- a/src/gausskernel/storage/tcap/tcap_manager.cpp +++ b/src/gausskernel/storage/tcap/tcap_manager.cpp @@ -298,7 +298,9 @@ static bool TrFetchOrinameImpl(Oid nspId, const char *oriname, TrObjType type, F_NAMEEQ, CStringGetDatum(oriname)); sd = systable_beginscan(rbRel, RecyclebinDbidNspOrinameIndexId, true, NULL, 3, skey); - while ((tup = systable_getnext(sd)) != NULL) { + /* restore drop/truncate use the latest version, purge use the oldest version */ + ScanDirection scan_direct = (operMode == RB_OPER_PURGE) ? ForwardScanDirection : BackwardScanDirection; + while ((tup = (HeapTuple)index_getnext(sd->iscan, scan_direct)) != NULL) { Form_pg_recyclebin rbForm = (Form_pg_recyclebin)GETSTRUCT(tup); if ((rbForm->rcytype != type && rbForm->rcytype == RB_OBJ_TABLE) || (rbForm->rcytype != type && rbForm->rcytype == RB_OBJ_INDEX) || -- Gitee