v19-0007-Make-RT_DELETE-optional.patch
text/x-patch
Filename: v19-0007-Make-RT_DELETE-optional.patch
Type: text/x-patch
Part: 7
Patch
Format: format-patch
Series: patch v19-0007
Subject: Make RT_DELETE optional
| File | + | − |
|---|---|---|
| src/include/lib/radixtree.h | 15 | 1 |
| src/test/modules/test_radixtree/test_radixtree.c | 1 | 0 |
From 88e0f6202959fa1a872eacb01c0e24cb27ae66d4 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Tue, 17 Jan 2023 17:34:28 +0700
Subject: [PATCH v19 7/9] Make RT_DELETE optional
To prevent compiler warnings in TIDStore
---
src/include/lib/radixtree.h | 16 +++++++++++++++-
src/test/modules/test_radixtree/test_radixtree.c | 1 +
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/include/lib/radixtree.h b/src/include/lib/radixtree.h
index 7c7b126b98..c2df8e882e 100644
--- a/src/include/lib/radixtree.h
+++ b/src/include/lib/radixtree.h
@@ -58,7 +58,6 @@
* RT_GET_HANDLE - Return the handle of the radix tree
* RT_SEARCH - Search a key-value pair
* RT_SET - Set a key-value pair
- * RT_DELETE - Delete a key-value pair
* RT_BEGIN_ITERATE - Begin iterating through all key-value pairs
* RT_ITERATE_NEXT - Return next key-value pair, if any
* RT_END_ITER - End iteration
@@ -70,6 +69,12 @@
* RT_ITERATE_NEXT() ensures returning key-value pairs in the ascending
* order of the key.
*
+ * Optional Interface
+ * ---------
+ *
+ * RT_DELETE - Delete a key-value pair. Declared/define if RT_USE_DELETE is defined
+ *
+ *
* Copyright (c) 2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
@@ -106,7 +111,9 @@
#define RT_BEGIN_ITERATE RT_MAKE_NAME(begin_iterate)
#define RT_ITERATE_NEXT RT_MAKE_NAME(iterate_next)
#define RT_END_ITERATE RT_MAKE_NAME(end_iterate)
+#ifdef RT_USE_DELETE
#define RT_DELETE RT_MAKE_NAME(delete)
+#endif
#define RT_MEMORY_USAGE RT_MAKE_NAME(memory_usage)
#define RT_DUMP RT_MAKE_NAME(dump)
#define RT_DUMP_SEARCH RT_MAKE_NAME(dump_search)
@@ -213,7 +220,9 @@ RT_SCOPE void RT_FREE(RT_RADIX_TREE *tree);
RT_SCOPE bool RT_SEARCH(RT_RADIX_TREE *tree, uint64 key, uint64 *val_p);
RT_SCOPE bool RT_SET(RT_RADIX_TREE *tree, uint64 key, uint64 val);
+#ifdef RT_USE_DELETE
RT_SCOPE bool RT_DELETE(RT_RADIX_TREE *tree, uint64 key);
+#endif
RT_SCOPE RT_ITER * RT_BEGIN_ITERATE(RT_RADIX_TREE *tree);
RT_SCOPE bool RT_ITERATE_NEXT(RT_ITER *iter, uint64 *key_p, uint64 *value_p);
@@ -1264,6 +1273,7 @@ RT_NODE_SEARCH_LEAF(RT_PTR_LOCAL node, uint64 key, uint64 *value_p)
#undef RT_NODE_LEVEL_LEAF
}
+#ifdef RT_USE_DELETE
/*
* Search for the child pointer corresponding to 'key' in the given node.
*
@@ -1289,6 +1299,7 @@ RT_NODE_DELETE_LEAF(RT_PTR_LOCAL node, uint64 key)
#include "lib/radixtree_delete_impl.h"
#undef RT_NODE_LEVEL_LEAF
}
+#endif
/* Insert the child to the inner node */
static bool
@@ -1523,6 +1534,7 @@ RT_SEARCH(RT_RADIX_TREE *tree, uint64 key, uint64 *value_p)
return RT_NODE_SEARCH_LEAF(node, key, value_p);
}
+#ifdef RT_USE_DELETE
/*
* Delete the given key from the radix tree. Return true if the key is found (and
* deleted), otherwise do nothing and return false.
@@ -1609,6 +1621,7 @@ RT_DELETE(RT_RADIX_TREE *tree, uint64 key)
return true;
}
+#endif
static inline void
RT_ITER_UPDATE_KEY(RT_ITER *iter, uint8 chunk, uint8 shift)
@@ -2166,6 +2179,7 @@ rt_dump(RT_RADIX_TREE *tree)
#undef RT_BEGIN_ITERATE
#undef RT_ITERATE_NEXT
#undef RT_END_ITERATE
+#undef RT_USE_DELETE
#undef RT_DELETE
#undef RT_MEMORY_USAGE
#undef RT_DUMP
diff --git a/src/test/modules/test_radixtree/test_radixtree.c b/src/test/modules/test_radixtree/test_radixtree.c
index 076173f628..f01d4dd733 100644
--- a/src/test/modules/test_radixtree/test_radixtree.c
+++ b/src/test/modules/test_radixtree/test_radixtree.c
@@ -104,6 +104,7 @@ static const test_spec test_specs[] = {
#define RT_SCOPE static
#define RT_DECLARE
#define RT_DEFINE
+#define RT_USE_DELETE
// WIP: compiles with warnings because rt_attach is defined but not used
// #define RT_SHMEM
#include "lib/radixtree.h"
--
2.39.0