From 58e98149a77ae23548c8d0fb3f3d229496ea1d9e Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Thu, 19 Jan 2023 23:49:33 +0900 Subject: [PATCH v20 08/13] Fix bug in RT_CHUNK_VALUES_ARRAY_SHIFT(). --- src/include/lib/radixtree.h | 2 +- src/test/modules/test_radixtree/test_radixtree.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/include/lib/radixtree.h b/src/include/lib/radixtree.h index b9e09f5761..4ed463ba51 100644 --- a/src/include/lib/radixtree.h +++ b/src/include/lib/radixtree.h @@ -830,7 +830,7 @@ static inline void RT_CHUNK_VALUES_ARRAY_SHIFT(uint8 *chunks, uint64 *values, int count, int idx) { memmove(&(chunks[idx + 1]), &(chunks[idx]), sizeof(uint8) * (count - idx)); - memmove(&(values[idx + 1]), &(values[idx]), sizeof(uint64 *) * (count - idx)); + memmove(&(values[idx + 1]), &(values[idx]), sizeof(uint64) * (count - idx)); } /* Delete the element at 'idx' */ diff --git a/src/test/modules/test_radixtree/test_radixtree.c b/src/test/modules/test_radixtree/test_radixtree.c index f01d4dd733..4b250be3f9 100644 --- a/src/test/modules/test_radixtree/test_radixtree.c +++ b/src/test/modules/test_radixtree/test_radixtree.c @@ -206,6 +206,18 @@ test_basic(int children, bool test_inner) elog(ERROR, "new inserted key 0x" UINT64_HEX_FORMAT " is found ", keys[i]); } + /* look up keys */ + for (int i = 0; i < children; i++) + { + uint64 value; + + if (!rt_search(radixtree, keys[i], &value)) + elog(ERROR, "could not find key 0x" UINT64_HEX_FORMAT, keys[i]); + if (value != keys[i]) + elog(ERROR, "rt_search returned 0x" UINT64_HEX_FORMAT ", expected " UINT64_HEX_FORMAT, + value, keys[i]); + } + /* update keys */ for (int i = 0; i < children; i++) { -- 2.31.1