summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2022-11-21 14:13:49 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-21 03:46:22 +0000
commit6ecd06b4d8c49bff25a997eb0935731daef47bf7 (patch)
tree7c32c5972d1c5db4e5f47508ba512dfe9c7d9f2b /src
parent44d6f998612ecde862bc298c7e9bbce512df156b (diff)
downloadmongo-6ecd06b4d8c49bff25a997eb0935731daef47bf7.tar.gz
Import wiredtiger: de945280b9fe413f00134ab1f1eeea9c15a05383 from branch mongodb-master
ref: b412563e92..de945280b9 for: 6.3.0-rc0 WT-10140 Add a new API to retrieve record count of a table
Diffstat (limited to 'src')
-rw-r--r--src/third_party/wiredtiger/dist/api_data.py2
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/lang/python/wiredtiger.i6
-rw-r--r--src/third_party/wiredtiger/src/config/config_def.c1
-rw-r--r--src/third_party/wiredtiger/src/include/config.h69
-rw-r--r--src/third_party/wiredtiger/src/include/extern.h2
-rw-r--r--src/third_party/wiredtiger/src/include/wiredtiger.in10
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c48
-rw-r--r--src/third_party/wiredtiger/test/suite/test_count01.py49
9 files changed, 150 insertions, 39 deletions
diff --git a/src/third_party/wiredtiger/dist/api_data.py b/src/third_party/wiredtiger/dist/api_data.py
index 9f1f1675cc3..3cb49dfdfd1 100644
--- a/src/third_party/wiredtiger/dist/api_data.py
+++ b/src/third_party/wiredtiger/dist/api_data.py
@@ -1286,6 +1286,8 @@ methods = {
type='int'),
]),
+'WT_SESSION.count' : Method([]),
+
'WT_SESSION.create' : Method(file_config + lsm_config + tiered_config +
source_meta + index_only_config + table_only_config + [
Config('exclusive', 'false', r'''
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index be301744750..a82a92e73ad 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-master",
- "commit": "b412563e92786caa4e9a36b7430468c2e8d3e649"
+ "commit": "de945280b9fe413f00134ab1f1eeea9c15a05383"
}
diff --git a/src/third_party/wiredtiger/lang/python/wiredtiger.i b/src/third_party/wiredtiger/lang/python/wiredtiger.i
index 40322728c5f..c0bfa5a5ecc 100644
--- a/src/third_party/wiredtiger/lang/python/wiredtiger.i
+++ b/src/third_party/wiredtiger/lang/python/wiredtiger.i
@@ -30,6 +30,7 @@
* wiredtiger.i
* The SWIG interface file defining the wiredtiger python API.
*/
+%include <cpointer.i>
%include <pybuffer.i>
%define DOCSTRING
@@ -321,6 +322,11 @@ from packing import pack, unpack
%typemap(out) uint64_t {
$result = PyLong_FromUnsignedLongLong($1);
}
+%typemap(out) int64_t {
+ $result = PyLong_FromLongLong($1);
+}
+
+%pointer_class(int64_t, int64_t_ptr);
/* Internal _set_key, _set_value methods take a 'bytes' object as parameter. */
%pybuffer_binary(unsigned char *data, int);
diff --git a/src/third_party/wiredtiger/src/config/config_def.c b/src/third_party/wiredtiger/src/config/config_def.c
index 4ec87cf3254..85cbe50436c 100644
--- a/src/third_party/wiredtiger/src/config/config_def.c
+++ b/src/third_party/wiredtiger/src/config/config_def.c
@@ -1262,6 +1262,7 @@ static const WT_CONFIG_ENTRY config_entries[] = {{"WT_CONNECTION.add_collator",
"sync=",
confchk_WT_SESSION_commit_transaction, 4},
{"WT_SESSION.compact", "timeout=1200", confchk_WT_SESSION_compact, 1},
+ {"WT_SESSION.count", "", NULL, 0},
{"WT_SESSION.create",
"access_pattern_hint=none,allocation_size=4KB,app_metadata=,"
"assert=(commit_timestamp=none,durable_timestamp=none,"
diff --git a/src/third_party/wiredtiger/src/include/config.h b/src/third_party/wiredtiger/src/include/config.h
index a876e858bba..eb70ad92195 100644
--- a/src/third_party/wiredtiger/src/include/config.h
+++ b/src/third_party/wiredtiger/src/include/config.h
@@ -90,40 +90,41 @@ struct __wt_config_parser_impl {
#define WT_CONFIG_ENTRY_WT_SESSION_close 21
#define WT_CONFIG_ENTRY_WT_SESSION_commit_transaction 22
#define WT_CONFIG_ENTRY_WT_SESSION_compact 23
-#define WT_CONFIG_ENTRY_WT_SESSION_create 24
-#define WT_CONFIG_ENTRY_WT_SESSION_drop 25
-#define WT_CONFIG_ENTRY_WT_SESSION_flush_tier 26
-#define WT_CONFIG_ENTRY_WT_SESSION_join 27
-#define WT_CONFIG_ENTRY_WT_SESSION_log_flush 28
-#define WT_CONFIG_ENTRY_WT_SESSION_log_printf 29
-#define WT_CONFIG_ENTRY_WT_SESSION_open_cursor 30
-#define WT_CONFIG_ENTRY_WT_SESSION_prepare_transaction 31
-#define WT_CONFIG_ENTRY_WT_SESSION_query_timestamp 32
-#define WT_CONFIG_ENTRY_WT_SESSION_reconfigure 33
-#define WT_CONFIG_ENTRY_WT_SESSION_rename 34
-#define WT_CONFIG_ENTRY_WT_SESSION_reset 35
-#define WT_CONFIG_ENTRY_WT_SESSION_reset_snapshot 36
-#define WT_CONFIG_ENTRY_WT_SESSION_rollback_transaction 37
-#define WT_CONFIG_ENTRY_WT_SESSION_salvage 38
-#define WT_CONFIG_ENTRY_WT_SESSION_strerror 39
-#define WT_CONFIG_ENTRY_WT_SESSION_timestamp_transaction 40
-#define WT_CONFIG_ENTRY_WT_SESSION_timestamp_transaction_uint 41
-#define WT_CONFIG_ENTRY_WT_SESSION_truncate 42
-#define WT_CONFIG_ENTRY_WT_SESSION_upgrade 43
-#define WT_CONFIG_ENTRY_WT_SESSION_verify 44
-#define WT_CONFIG_ENTRY_colgroup_meta 45
-#define WT_CONFIG_ENTRY_file_config 46
-#define WT_CONFIG_ENTRY_file_meta 47
-#define WT_CONFIG_ENTRY_index_meta 48
-#define WT_CONFIG_ENTRY_lsm_meta 49
-#define WT_CONFIG_ENTRY_object_meta 50
-#define WT_CONFIG_ENTRY_table_meta 51
-#define WT_CONFIG_ENTRY_tier_meta 52
-#define WT_CONFIG_ENTRY_tiered_meta 53
-#define WT_CONFIG_ENTRY_wiredtiger_open 54
-#define WT_CONFIG_ENTRY_wiredtiger_open_all 55
-#define WT_CONFIG_ENTRY_wiredtiger_open_basecfg 56
-#define WT_CONFIG_ENTRY_wiredtiger_open_usercfg 57
+#define WT_CONFIG_ENTRY_WT_SESSION_count 24
+#define WT_CONFIG_ENTRY_WT_SESSION_create 25
+#define WT_CONFIG_ENTRY_WT_SESSION_drop 26
+#define WT_CONFIG_ENTRY_WT_SESSION_flush_tier 27
+#define WT_CONFIG_ENTRY_WT_SESSION_join 28
+#define WT_CONFIG_ENTRY_WT_SESSION_log_flush 29
+#define WT_CONFIG_ENTRY_WT_SESSION_log_printf 30
+#define WT_CONFIG_ENTRY_WT_SESSION_open_cursor 31
+#define WT_CONFIG_ENTRY_WT_SESSION_prepare_transaction 32
+#define WT_CONFIG_ENTRY_WT_SESSION_query_timestamp 33
+#define WT_CONFIG_ENTRY_WT_SESSION_reconfigure 34
+#define WT_CONFIG_ENTRY_WT_SESSION_rename 35
+#define WT_CONFIG_ENTRY_WT_SESSION_reset 36
+#define WT_CONFIG_ENTRY_WT_SESSION_reset_snapshot 37
+#define WT_CONFIG_ENTRY_WT_SESSION_rollback_transaction 38
+#define WT_CONFIG_ENTRY_WT_SESSION_salvage 39
+#define WT_CONFIG_ENTRY_WT_SESSION_strerror 40
+#define WT_CONFIG_ENTRY_WT_SESSION_timestamp_transaction 41
+#define WT_CONFIG_ENTRY_WT_SESSION_timestamp_transaction_uint 42
+#define WT_CONFIG_ENTRY_WT_SESSION_truncate 43
+#define WT_CONFIG_ENTRY_WT_SESSION_upgrade 44
+#define WT_CONFIG_ENTRY_WT_SESSION_verify 45
+#define WT_CONFIG_ENTRY_colgroup_meta 46
+#define WT_CONFIG_ENTRY_file_config 47
+#define WT_CONFIG_ENTRY_file_meta 48
+#define WT_CONFIG_ENTRY_index_meta 49
+#define WT_CONFIG_ENTRY_lsm_meta 50
+#define WT_CONFIG_ENTRY_object_meta 51
+#define WT_CONFIG_ENTRY_table_meta 52
+#define WT_CONFIG_ENTRY_tier_meta 53
+#define WT_CONFIG_ENTRY_tiered_meta 54
+#define WT_CONFIG_ENTRY_wiredtiger_open 55
+#define WT_CONFIG_ENTRY_wiredtiger_open_all 56
+#define WT_CONFIG_ENTRY_wiredtiger_open_basecfg 57
+#define WT_CONFIG_ENTRY_wiredtiger_open_usercfg 58
/*
* configuration section: END
* DO NOT EDIT: automatically built by dist/flags.py.
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h
index 78803749b51..20b34d5347d 100644
--- a/src/third_party/wiredtiger/src/include/extern.h
+++ b/src/third_party/wiredtiger/src/include/extern.h
@@ -1407,6 +1407,8 @@ extern int __wt_session_compact_readonly(WT_SESSION *wt_session, const char *uri
const char *config) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_session_copy_values(WT_SESSION_IMPL *session)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
+extern int __wt_session_count(WT_SESSION *wt_session, const char *uri, int64_t *count)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_session_create(WT_SESSION_IMPL *session, const char *uri, const char *config)
WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_session_cursor_cache_sweep(WT_SESSION_IMPL *session)
diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in
index ce65c64f6ce..f555db61287 100644
--- a/src/third_party/wiredtiger/src/include/wiredtiger.in
+++ b/src/third_party/wiredtiger/src/include/wiredtiger.in
@@ -1949,6 +1949,16 @@ struct __wt_session {
*/
int __F(timestamp_transaction_uint)(WT_SESSION *session, WT_TS_TXN_TYPE which,
uint64_t ts);
+
+ /*!
+ * Returns the number of records in the table.
+ *
+ * @param session the session handle
+ * @param uri the URI of the table, such as \c "table:old"
+ * @param count the number of records in the table
+ * @errors
+ */
+ int __F(count)(WT_SESSION *session, const char *uri, int64_t *count);
/*! @} */
/*!
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index ac603c60645..16e475bff58 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -827,6 +827,45 @@ err:
}
/*
+ * __wt_session_count --
+ * WT_SESSION->count method.
+ */
+int
+__wt_session_count(WT_SESSION *wt_session, const char *uri, int64_t *count)
+{
+ WT_DECL_RET;
+
+ WT_UNUSED(uri);
+ WT_UNUSED(wt_session);
+
+ *count = -1;
+ if (*count == -1)
+ ret = WT_NOTFOUND;
+
+ return (ret);
+}
+
+/*
+ * __wt_session_count_notsup --
+ * WT_SESSION->count method; not supported version.
+ */
+static int
+__wt_session_count_notsup(WT_SESSION *wt_session, const char *uri, int64_t *count)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ WT_UNUSED(uri);
+ WT_UNUSED(count);
+
+ session = (WT_SESSION_IMPL *)wt_session;
+ SESSION_API_CALL_NOCONF(session, count);
+ ret = __wt_session_notsup(session);
+err:
+ API_END_RET(session, ret);
+}
+
+/*
* __wt_session_create --
* Internal version of WT_SESSION::create.
*/
@@ -2318,8 +2357,9 @@ __open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const
__session_truncate, __session_upgrade, __session_verify, __session_begin_transaction,
__session_commit_transaction, __session_prepare_transaction, __session_rollback_transaction,
__session_query_timestamp, __session_timestamp_transaction,
- __session_timestamp_transaction_uint, __session_checkpoint, __session_reset_snapshot,
- __session_transaction_pinned_range, __session_get_rollback_reason, __wt_session_breakpoint},
+ __session_timestamp_transaction_uint, __wt_session_count, __session_checkpoint,
+ __session_reset_snapshot, __session_transaction_pinned_range, __session_get_rollback_reason,
+ __wt_session_breakpoint},
stds_min = {NULL, NULL, __session_close, __session_reconfigure_notsup,
__session_flush_tier_readonly, __wt_session_strerror, __session_open_cursor,
__session_alter_readonly, __session_create_readonly, __wt_session_compact_readonly,
@@ -2330,7 +2370,7 @@ __open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const
__session_commit_transaction_notsup, __session_prepare_transaction_readonly,
__session_rollback_transaction_notsup, __session_query_timestamp_notsup,
__session_timestamp_transaction_notsup, __session_timestamp_transaction_uint_notsup,
- __session_checkpoint_readonly, __session_reset_snapshot_notsup,
+ __wt_session_count_notsup, __session_checkpoint_readonly, __session_reset_snapshot_notsup,
__session_transaction_pinned_range_notsup, __session_get_rollback_reason,
__wt_session_breakpoint},
stds_readonly = {NULL, NULL, __session_close, __session_reconfigure,
@@ -2342,7 +2382,7 @@ __open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const
__session_verify, __session_begin_transaction, __session_commit_transaction,
__session_prepare_transaction_readonly, __session_rollback_transaction,
__session_query_timestamp, __session_timestamp_transaction,
- __session_timestamp_transaction_uint, __session_checkpoint_readonly,
+ __session_timestamp_transaction_uint, __wt_session_count, __session_checkpoint_readonly,
__session_reset_snapshot, __session_transaction_pinned_range, __session_get_rollback_reason,
__wt_session_breakpoint};
WT_DECL_RET;
diff --git a/src/third_party/wiredtiger/test/suite/test_count01.py b/src/third_party/wiredtiger/test/suite/test_count01.py
new file mode 100644
index 00000000000..3ddd127d162
--- /dev/null
+++ b/src/third_party/wiredtiger/test/suite/test_count01.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Public Domain 2014-present MongoDB, Inc.
+# Public Domain 2008-2014 WiredTiger, Inc.
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# test_count01.py
+# Tests WT_SESSION->count
+#
+
+import wiredtiger, wttest
+
+class test_count01(wttest.WiredTigerTestCase):
+ tablename = 'test_count01'
+ uri = 'table:' + tablename
+
+ def test_count_api(self):
+ self.session.create(self.uri, 'key_format=i,value_format=i')
+
+ count = wiredtiger.int64_t_ptr()
+ self.assertRaisesException(
+ wiredtiger.WiredTigerError, lambda: self.session.count(self.uri, count))
+ self.assertEqual(count.value(), -1)
+
+
+if __name__ == '__main__':
+ wttest.run()