couchbase 3.2.0 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +24 -18
- package/binding.gyp +88 -85
- package/deps/lcb/CMakeLists.txt +1 -1
- package/deps/lcb/CONTRIBUTING.md +1 -1
- package/deps/lcb/README.markdown +2 -2
- package/deps/lcb/RELEASE_NOTES.markdown +99 -14
- package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
- package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
- package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
- package/deps/lcb/doc/Doxyfile +1 -1
- package/deps/lcb/example/CMakeLists.txt +4 -4
- package/deps/lcb/example/libuvdirect/main.c +39 -12
- package/deps/lcb/example/minimal/durability.cc +149 -0
- package/deps/lcb/example/minimal/query.c +11 -9
- package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
- package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
- package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
- package/deps/lcb/include/libcouchbase/error.h +2 -0
- package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
- package/deps/lcb/include/libcouchbase/tracing.h +2 -2
- package/deps/lcb/include/memcached/protocol_binary.h +21 -0
- package/deps/lcb/libcouchbase.gyp +347 -349
- package/deps/lcb/packaging/deb/control +1 -1
- package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
- package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
- package/deps/lcb/src/bootstrap.cc +6 -3
- package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
- package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
- package/deps/lcb/src/capi/cmd_counter.hh +23 -0
- package/deps/lcb/src/capi/cmd_exists.hh +24 -1
- package/deps/lcb/src/capi/cmd_get.hh +22 -0
- package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
- package/deps/lcb/src/capi/cmd_http.hh +7 -0
- package/deps/lcb/src/capi/cmd_query.cc +11 -1
- package/deps/lcb/src/capi/cmd_query.hh +31 -0
- package/deps/lcb/src/capi/cmd_remove.hh +23 -0
- package/deps/lcb/src/capi/cmd_search.cc +6 -0
- package/deps/lcb/src/capi/cmd_search.hh +23 -0
- package/deps/lcb/src/capi/cmd_store.hh +33 -21
- package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
- package/deps/lcb/src/capi/cmd_touch.hh +23 -0
- package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
- package/deps/lcb/src/capi/cmd_view.hh +6 -0
- package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
- package/deps/lcb/src/cntl.cc +45 -11
- package/deps/lcb/src/crypto.cc +2 -2
- package/deps/lcb/src/dns-srv.cc +5 -3
- package/deps/lcb/src/errmap.cc +5 -9
- package/deps/lcb/src/errmap.h +7 -3
- package/deps/lcb/src/handler.cc +24 -18
- package/deps/lcb/src/hostlist.h +2 -2
- package/deps/lcb/src/http/http-priv.h +2 -2
- package/deps/lcb/src/http/http.cc +5 -2
- package/deps/lcb/src/instance.cc +20 -11
- package/deps/lcb/src/internal.h +9 -0
- package/deps/lcb/src/lcbio/connect.cc +14 -2
- package/deps/lcb/src/lcbio/connect.h +2 -2
- package/deps/lcb/src/lcbio/ctx.cc +4 -2
- package/deps/lcb/src/lcbio/ioutils.cc +9 -10
- package/deps/lcb/src/lcbio/manager.cc +1 -1
- package/deps/lcb/src/mcserver/mcserver.cc +9 -6
- package/deps/lcb/src/mcserver/negotiate.cc +39 -17
- package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
- package/deps/lcb/src/n1ql/query_handle.cc +41 -19
- package/deps/lcb/src/n1ql/query_handle.hh +28 -1
- package/deps/lcb/src/operations/counter.cc +18 -5
- package/deps/lcb/src/operations/exists.cc +25 -4
- package/deps/lcb/src/operations/get.cc +39 -19
- package/deps/lcb/src/operations/get_replica.cc +28 -8
- package/deps/lcb/src/operations/observe.cc +1 -1
- package/deps/lcb/src/operations/ping.cc +8 -8
- package/deps/lcb/src/operations/pktfwd.cc +2 -1
- package/deps/lcb/src/operations/remove.cc +39 -22
- package/deps/lcb/src/operations/store.cc +18 -5
- package/deps/lcb/src/operations/subdoc.cc +18 -6
- package/deps/lcb/src/operations/touch.cc +34 -16
- package/deps/lcb/src/operations/unlock.cc +24 -5
- package/deps/lcb/src/packetutils.h +3 -2
- package/deps/lcb/src/retryq.cc +24 -5
- package/deps/lcb/src/search/search.cc +1 -0
- package/deps/lcb/src/search/search_handle.cc +30 -8
- package/deps/lcb/src/search/search_handle.hh +29 -0
- package/deps/lcb/src/settings.cc +1 -1
- package/deps/lcb/src/ssl/ssl_common.c +6 -7
- package/deps/lcb/src/tracing/span.cc +47 -14
- package/deps/lcb/src/tracing/tracer.cc +11 -2
- package/deps/lcb/src/tracing/tracing-internal.h +105 -93
- package/deps/lcb/src/utilities.cc +43 -0
- package/deps/lcb/src/utilities.h +53 -0
- package/deps/lcb/src/vbucket/vbucket.c +34 -33
- package/deps/lcb/src/views/view_handle.cc +13 -5
- package/deps/lcb/src/views/view_handle.hh +29 -0
- package/deps/lcb/tests/CMakeLists.txt +21 -0
- package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
- package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
- package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
- package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
- package/deps/lcb/tests/iotests/mock-environment.h +49 -0
- package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
- package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
- package/deps/lcb/tests/iotests/t_collections.cc +1 -1
- package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
- package/deps/lcb/tests/iotests/t_get.cc +109 -7
- package/deps/lcb/tests/iotests/t_http.cc +9 -4
- package/deps/lcb/tests/iotests/t_lock.cc +18 -0
- package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
- package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
- package/deps/lcb/tests/iotests/t_views.cc +1 -0
- package/deps/lcb/tests/iotests/testutil.cc +168 -0
- package/deps/lcb/tests/iotests/testutil.h +116 -0
- package/deps/lcb/tests/mocksupport/procutil.c +32 -28
- package/deps/lcb/tests/mocksupport/server.c +0 -1
- package/deps/lcb/tests/mocksupport/timeout.c +2 -2
- package/deps/lcb/tools/cbc.cc +7 -0
- package/dist/analyticsindexmanager.js +512 -524
- package/dist/binding.d.ts +3 -0
- package/dist/bindingutilities.js +4 -0
- package/dist/bucket.js +1 -1
- package/dist/bucketmanager.d.ts +31 -1
- package/dist/bucketmanager.js +194 -186
- package/dist/cluster.d.ts +7 -0
- package/dist/cluster.js +48 -38
- package/dist/collection.js +11 -17
- package/dist/collectionmanager.js +181 -197
- package/dist/connection.d.ts +3 -1
- package/dist/connection.js +27 -16
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +3 -13
- package/dist/datastructures.js +239 -310
- package/dist/diagnosticsexecutor.js +70 -85
- package/dist/errors.d.ts +70 -0
- package/dist/errors.js +96 -2
- package/dist/eventingfunctionmanager.d.ts +804 -0
- package/dist/eventingfunctionmanager.js +993 -0
- package/dist/httpexecutor.d.ts +2 -1
- package/dist/httpexecutor.js +30 -37
- package/dist/queryindexmanager.js +240 -266
- package/dist/scope.js +10 -4
- package/dist/sdspecs.d.ts +1 -1
- package/dist/searchexecutor.js +3 -0
- package/dist/searchindexmanager.js +240 -271
- package/dist/searchquery.d.ts +17 -0
- package/dist/searchquery.js +22 -1
- package/dist/searchtypes.d.ts +7 -2
- package/dist/searchtypes.js +2 -2
- package/dist/usermanager.js +251 -264
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +7 -2
- package/dist/viewexecutor.js +1 -1
- package/dist/viewindexmanager.js +131 -150
- package/package.json +1 -1
- package/src/addondata.cpp +58 -0
- package/src/addondata.h +40 -0
- package/src/binding.cpp +3 -1
- package/src/cas.h +2 -2
- package/src/connection.cpp +25 -178
- package/src/connection.h +8 -65
- package/src/connection_ops.cpp +57 -34
- package/src/constants.cpp +3 -0
- package/src/instance.cpp +235 -0
- package/src/instance.h +102 -0
- package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
- package/src/logger.cpp +11 -1
- package/src/logger.h +3 -0
- package/src/metrics.cpp +10 -0
- package/src/metrics.h +3 -0
- package/src/mutationtoken.h +2 -2
- package/src/opbuilder.h +13 -15
- package/src/respreader.cpp +1 -0
- package/src/respreader.h +6 -4
- package/src/tracespan.h +11 -11
- package/src/tracing.cpp +11 -0
- package/src/tracing.h +3 -0
- package/src/valueparser.h +5 -0
- package/deps/lcb/example/observe/durability.c +0 -110
@@ -671,27 +671,54 @@ TEST_F(MutateUnitTest, testSetDefault)
|
|
671
671
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
672
672
|
}
|
673
673
|
|
674
|
+
struct lookup_result {
|
675
|
+
bool called{false};
|
676
|
+
lcb_STATUS rc{LCB_ERR_GENERIC};
|
677
|
+
|
678
|
+
lcb_STATUS rc_expiry{LCB_ERR_GENERIC};
|
679
|
+
std::uint32_t expiry{0};
|
680
|
+
|
681
|
+
lcb_STATUS rc_cas{LCB_ERR_GENERIC};
|
682
|
+
std::uint64_t cas{0};
|
683
|
+
};
|
684
|
+
|
674
685
|
static void preserve_expiry_get_expiry(lcb_INSTANCE *, int, const lcb_RESPSUBDOC *resp)
|
675
686
|
{
|
676
|
-
|
677
|
-
|
678
|
-
|
687
|
+
lookup_result *cookie = nullptr;
|
688
|
+
lcb_respsubdoc_cookie(resp, reinterpret_cast<void **>(&cookie));
|
689
|
+
|
690
|
+
cookie->called = true;
|
691
|
+
cookie->rc = lcb_respsubdoc_status(resp);
|
692
|
+
ASSERT_EQ(2, lcb_respsubdoc_result_size(resp));
|
679
693
|
|
680
694
|
const char *value = nullptr;
|
681
695
|
std::size_t value_len = 0;
|
682
|
-
|
696
|
+
|
697
|
+
cookie->rc_expiry = lcb_respsubdoc_result_status(resp, 0);
|
698
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_respsubdoc_result_value(resp, 0, &value, &value_len));
|
683
699
|
ASSERT_GT(value_len, 0);
|
700
|
+
cookie->expiry = std::strtoul(value, nullptr, 10);
|
684
701
|
|
685
|
-
|
686
|
-
|
687
|
-
|
702
|
+
cookie->rc_cas = lcb_respsubdoc_result_status(resp, 1);
|
703
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_respsubdoc_result_value(resp, 1, &value, &value_len));
|
704
|
+
// CAS is encoded as string of HEX number, so the length should be at least greater than strlen("\"0x\"")
|
705
|
+
ASSERT_GT(value_len, 4);
|
706
|
+
cookie->cas = std::strtoull(value + 1, nullptr, 16);
|
688
707
|
}
|
689
708
|
|
709
|
+
struct store_result {
|
710
|
+
bool called{false};
|
711
|
+
lcb_STATUS rc{LCB_ERR_GENERIC};
|
712
|
+
std::uint64_t cas{0};
|
713
|
+
};
|
714
|
+
|
690
715
|
static void preserve_expiry_upsert(lcb_INSTANCE *, int, const lcb_RESPSTORE *resp)
|
691
716
|
{
|
692
|
-
|
693
|
-
lcb_respstore_cookie(resp, (void **)&
|
694
|
-
|
717
|
+
store_result *res = nullptr;
|
718
|
+
lcb_respstore_cookie(resp, (void **)&res);
|
719
|
+
res->called = true;
|
720
|
+
res->rc = lcb_respstore_status(resp);
|
721
|
+
lcb_respstore_cas(resp, &res->cas);
|
695
722
|
}
|
696
723
|
|
697
724
|
TEST_F(MutateUnitTest, testUpsertPreservesExpiry)
|
@@ -709,6 +736,7 @@ TEST_F(MutateUnitTest, testUpsertPreservesExpiry)
|
|
709
736
|
lcb_install_callback(instance, LCB_CALLBACK_STORE, reinterpret_cast<lcb_RESPCALLBACK>(preserve_expiry_upsert));
|
710
737
|
|
711
738
|
std::uint32_t birthday = 1878422400;
|
739
|
+
std::uint64_t cas = 0;
|
712
740
|
|
713
741
|
{
|
714
742
|
std::string value = R"({"foo": "bar"})";
|
@@ -718,64 +746,83 @@ TEST_F(MutateUnitTest, testUpsertPreservesExpiry)
|
|
718
746
|
lcb_cmdstore_key(cmd, key.c_str(), key.size());
|
719
747
|
lcb_cmdstore_value(cmd, value.c_str(), value.size());
|
720
748
|
lcb_cmdstore_expiry(cmd, birthday);
|
721
|
-
|
722
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &
|
749
|
+
store_result res{};
|
750
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &res, cmd));
|
723
751
|
lcb_cmdstore_destroy(cmd);
|
724
752
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
725
|
-
|
753
|
+
ASSERT_TRUE(res.called);
|
754
|
+
ASSERT_NE(0, res.cas);
|
755
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
756
|
+
cas = res.cas;
|
726
757
|
}
|
727
758
|
|
728
759
|
std::string expiry_path = "$document.exptime";
|
760
|
+
std::string cas_path = "$document.CAS";
|
729
761
|
|
730
762
|
{
|
731
|
-
|
763
|
+
lookup_result res{};
|
732
764
|
|
733
765
|
lcb_CMDSUBDOC *cmd;
|
734
766
|
lcb_cmdsubdoc_create(&cmd);
|
735
767
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
736
768
|
lcb_SUBDOCSPECS *ops;
|
737
|
-
lcb_subdocspecs_create(&ops,
|
769
|
+
lcb_subdocspecs_create(&ops, 2);
|
738
770
|
lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(), expiry_path.size());
|
771
|
+
lcb_subdocspecs_get(ops, 1, LCB_SUBDOCSPECS_F_XATTRPATH, cas_path.c_str(), cas_path.size());
|
739
772
|
lcb_cmdsubdoc_specs(cmd, ops);
|
740
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &
|
773
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
741
774
|
lcb_subdocspecs_destroy(ops);
|
742
775
|
lcb_cmdsubdoc_destroy(cmd);
|
743
776
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
744
777
|
|
745
|
-
|
778
|
+
ASSERT_TRUE(res.called);
|
779
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
780
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_cas);
|
781
|
+
ASSERT_EQ(cas, res.cas);
|
782
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_expiry);
|
783
|
+
ASSERT_EQ(birthday, res.expiry);
|
746
784
|
}
|
747
785
|
|
748
786
|
{
|
749
787
|
std::string value = R"({"foo": "baz"})";
|
788
|
+
store_result res{};
|
750
789
|
|
751
790
|
lcb_CMDSTORE *cmd;
|
752
791
|
lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
|
753
792
|
lcb_cmdstore_key(cmd, key.c_str(), key.size());
|
754
793
|
lcb_cmdstore_value(cmd, value.c_str(), value.size());
|
755
794
|
lcb_cmdstore_preserve_expiry(cmd, true);
|
756
|
-
|
757
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &cookie, cmd));
|
795
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &res, cmd));
|
758
796
|
lcb_cmdstore_destroy(cmd);
|
759
797
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
760
|
-
|
798
|
+
ASSERT_TRUE(res.called);
|
799
|
+
ASSERT_NE(0, res.cas);
|
800
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
801
|
+
cas = res.cas;
|
761
802
|
}
|
762
803
|
|
763
804
|
{
|
764
|
-
|
805
|
+
lookup_result res{};
|
765
806
|
|
766
807
|
lcb_CMDSUBDOC *cmd;
|
767
808
|
lcb_cmdsubdoc_create(&cmd);
|
768
809
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
769
810
|
lcb_SUBDOCSPECS *ops;
|
770
|
-
lcb_subdocspecs_create(&ops,
|
811
|
+
lcb_subdocspecs_create(&ops, 2);
|
771
812
|
lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(), expiry_path.size());
|
813
|
+
lcb_subdocspecs_get(ops, 1, LCB_SUBDOCSPECS_F_XATTRPATH, cas_path.c_str(), cas_path.size());
|
772
814
|
lcb_cmdsubdoc_specs(cmd, ops);
|
773
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &
|
815
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
774
816
|
lcb_subdocspecs_destroy(ops);
|
775
817
|
lcb_cmdsubdoc_destroy(cmd);
|
776
818
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
777
819
|
|
778
|
-
|
820
|
+
ASSERT_TRUE(res.called);
|
821
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
822
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_cas);
|
823
|
+
ASSERT_EQ(cas, res.cas);
|
824
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_expiry);
|
825
|
+
ASSERT_EQ(birthday, res.expiry);
|
779
826
|
}
|
780
827
|
|
781
828
|
{
|
@@ -785,37 +832,50 @@ TEST_F(MutateUnitTest, testUpsertPreservesExpiry)
|
|
785
832
|
lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
|
786
833
|
lcb_cmdstore_key(cmd, key.c_str(), key.size());
|
787
834
|
lcb_cmdstore_value(cmd, value.c_str(), value.size());
|
788
|
-
|
789
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &
|
835
|
+
store_result res{};
|
836
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &res, cmd));
|
790
837
|
lcb_cmdstore_destroy(cmd);
|
791
838
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
792
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS,
|
839
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
840
|
+
|
841
|
+
ASSERT_TRUE(res.called);
|
842
|
+
ASSERT_NE(0, res.cas);
|
843
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
844
|
+
cas = res.cas;
|
793
845
|
}
|
794
846
|
|
795
847
|
{
|
796
|
-
|
848
|
+
lookup_result res{};
|
797
849
|
|
798
850
|
lcb_CMDSUBDOC *cmd;
|
799
851
|
lcb_cmdsubdoc_create(&cmd);
|
800
852
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
801
853
|
lcb_SUBDOCSPECS *ops;
|
802
|
-
lcb_subdocspecs_create(&ops,
|
854
|
+
lcb_subdocspecs_create(&ops, 2);
|
803
855
|
lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(), expiry_path.size());
|
856
|
+
lcb_subdocspecs_get(ops, 1, LCB_SUBDOCSPECS_F_XATTRPATH, cas_path.c_str(), cas_path.size());
|
804
857
|
lcb_cmdsubdoc_specs(cmd, ops);
|
805
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &
|
858
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
806
859
|
lcb_subdocspecs_destroy(ops);
|
807
860
|
lcb_cmdsubdoc_destroy(cmd);
|
808
861
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
809
862
|
|
810
|
-
|
863
|
+
ASSERT_TRUE(res.called);
|
864
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
865
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_cas);
|
866
|
+
ASSERT_EQ(cas, res.cas);
|
867
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_expiry);
|
868
|
+
ASSERT_EQ(0, res.expiry);
|
811
869
|
}
|
812
870
|
}
|
813
871
|
|
814
872
|
static void preserve_expiry_subdoc(lcb_INSTANCE *, int, const lcb_RESPSUBDOC *resp)
|
815
873
|
{
|
816
|
-
|
817
|
-
lcb_respsubdoc_cookie(resp, (void **)&
|
818
|
-
|
874
|
+
store_result *res = nullptr;
|
875
|
+
lcb_respsubdoc_cookie(resp, (void **)&res);
|
876
|
+
res->called = true;
|
877
|
+
res->rc = lcb_respsubdoc_status(resp);
|
878
|
+
lcb_respsubdoc_cas(resp, &res->cas);
|
819
879
|
}
|
820
880
|
|
821
881
|
TEST_F(MutateUnitTest, testMutateInPreservesExpiry)
|
@@ -834,83 +894,108 @@ TEST_F(MutateUnitTest, testMutateInPreservesExpiry)
|
|
834
894
|
lcb_install_callback(instance, LCB_CALLBACK_STORE, reinterpret_cast<lcb_RESPCALLBACK>(preserve_expiry_upsert));
|
835
895
|
|
836
896
|
std::uint32_t birthday = 1878422400;
|
897
|
+
std::uint64_t cas = 0;
|
837
898
|
|
838
899
|
{
|
900
|
+
store_result res{};
|
839
901
|
std::string value = R"({"foo": "bar"})";
|
840
902
|
|
841
903
|
lcb_CMDSTORE *cmd;
|
842
904
|
lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
|
843
|
-
lcb_cmdstore_key(cmd, key.c_str(), key.size());
|
844
|
-
lcb_cmdstore_value(cmd, value.c_str(), value.size());
|
845
|
-
lcb_cmdstore_expiry(cmd, birthday);
|
846
|
-
|
847
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &cookie, cmd));
|
905
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_cmdstore_key(cmd, key.c_str(), key.size()));
|
906
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_cmdstore_value(cmd, value.c_str(), value.size()));
|
907
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_cmdstore_expiry(cmd, birthday));
|
908
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_store(instance, &res, cmd));
|
848
909
|
lcb_cmdstore_destroy(cmd);
|
849
910
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
850
|
-
|
911
|
+
ASSERT_TRUE(res.called);
|
912
|
+
ASSERT_NE(0, res.cas);
|
913
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
914
|
+
cas = res.cas;
|
851
915
|
}
|
852
916
|
|
853
917
|
std::string expiry_path = "$document.exptime";
|
918
|
+
std::string cas_path = "$document.CAS";
|
854
919
|
|
855
920
|
{
|
856
|
-
|
921
|
+
lookup_result res{};
|
857
922
|
|
858
923
|
lcb_CMDSUBDOC *cmd;
|
859
924
|
lcb_cmdsubdoc_create(&cmd);
|
860
925
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
861
926
|
lcb_SUBDOCSPECS *ops;
|
862
|
-
lcb_subdocspecs_create(&ops,
|
863
|
-
lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(),
|
864
|
-
|
865
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS,
|
927
|
+
lcb_subdocspecs_create(&ops, 2);
|
928
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(),
|
929
|
+
expiry_path.size()));
|
930
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS,
|
931
|
+
lcb_subdocspecs_get(ops, 1, LCB_SUBDOCSPECS_F_XATTRPATH, cas_path.c_str(), cas_path.size()));
|
932
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_cmdsubdoc_specs(cmd, ops));
|
933
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
866
934
|
lcb_subdocspecs_destroy(ops);
|
867
935
|
lcb_cmdsubdoc_destroy(cmd);
|
868
936
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
869
937
|
|
870
|
-
|
938
|
+
ASSERT_TRUE(res.called);
|
939
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
940
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_cas);
|
941
|
+
ASSERT_EQ(cas, res.cas);
|
942
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_expiry);
|
943
|
+
ASSERT_EQ(birthday, res.expiry);
|
871
944
|
}
|
872
945
|
|
873
946
|
{
|
874
947
|
std::string path = "foo";
|
875
948
|
std::string value = R"("baz")";
|
949
|
+
store_result res{};
|
876
950
|
|
877
951
|
lcb_CMDSUBDOC *cmd;
|
878
952
|
lcb_cmdsubdoc_create(&cmd);
|
879
953
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
880
954
|
lcb_SUBDOCSPECS *ops;
|
881
955
|
lcb_subdocspecs_create(&ops, 1);
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &
|
956
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS,
|
957
|
+
lcb_subdocspecs_replace(ops, 0, 0, path.c_str(), path.size(), value.c_str(), value.size()));
|
958
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_cmdsubdoc_specs(cmd, ops));
|
959
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_cmdsubdoc_preserve_expiry(cmd, true));
|
960
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
887
961
|
lcb_subdocspecs_destroy(ops);
|
888
962
|
lcb_cmdsubdoc_destroy(cmd);
|
889
963
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
890
|
-
|
964
|
+
|
965
|
+
ASSERT_TRUE(res.called);
|
966
|
+
ASSERT_NE(0, res.cas);
|
967
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
968
|
+
cas = res.cas;
|
891
969
|
}
|
892
970
|
|
893
971
|
{
|
894
|
-
|
972
|
+
lookup_result res{};
|
895
973
|
|
896
974
|
lcb_CMDSUBDOC *cmd;
|
897
975
|
lcb_cmdsubdoc_create(&cmd);
|
898
976
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
899
977
|
lcb_SUBDOCSPECS *ops;
|
900
|
-
lcb_subdocspecs_create(&ops,
|
978
|
+
lcb_subdocspecs_create(&ops, 2);
|
901
979
|
lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(), expiry_path.size());
|
980
|
+
lcb_subdocspecs_get(ops, 1, LCB_SUBDOCSPECS_F_XATTRPATH, cas_path.c_str(), cas_path.size());
|
902
981
|
lcb_cmdsubdoc_specs(cmd, ops);
|
903
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &
|
982
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
904
983
|
lcb_subdocspecs_destroy(ops);
|
905
984
|
lcb_cmdsubdoc_destroy(cmd);
|
906
985
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
907
986
|
|
908
|
-
|
987
|
+
ASSERT_TRUE(res.called);
|
988
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
989
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_cas);
|
990
|
+
ASSERT_EQ(cas, res.cas);
|
991
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_expiry);
|
992
|
+
ASSERT_EQ(birthday, res.expiry);
|
909
993
|
}
|
910
994
|
|
911
995
|
{
|
912
996
|
std::string path = "foo";
|
913
997
|
std::string value = R"("bar")";
|
998
|
+
store_result res{};
|
914
999
|
|
915
1000
|
lcb_CMDSUBDOC *cmd;
|
916
1001
|
lcb_cmdsubdoc_create(&cmd);
|
@@ -919,29 +1004,38 @@ TEST_F(MutateUnitTest, testMutateInPreservesExpiry)
|
|
919
1004
|
lcb_subdocspecs_create(&ops, 1);
|
920
1005
|
lcb_subdocspecs_replace(ops, 0, 0, path.c_str(), path.size(), value.c_str(), value.size());
|
921
1006
|
lcb_cmdsubdoc_specs(cmd, ops);
|
922
|
-
|
923
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &cookie, cmd));
|
1007
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
924
1008
|
lcb_subdocspecs_destroy(ops);
|
925
1009
|
lcb_cmdsubdoc_destroy(cmd);
|
926
1010
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
927
|
-
|
1011
|
+
|
1012
|
+
ASSERT_TRUE(res.called);
|
1013
|
+
ASSERT_NE(0, res.cas);
|
1014
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
1015
|
+
cas = res.cas;
|
928
1016
|
}
|
929
1017
|
|
930
1018
|
{
|
931
|
-
|
1019
|
+
lookup_result res{};
|
932
1020
|
|
933
1021
|
lcb_CMDSUBDOC *cmd;
|
934
1022
|
lcb_cmdsubdoc_create(&cmd);
|
935
1023
|
lcb_cmdsubdoc_key(cmd, key.data(), key.size());
|
936
1024
|
lcb_SUBDOCSPECS *ops;
|
937
|
-
lcb_subdocspecs_create(&ops,
|
1025
|
+
lcb_subdocspecs_create(&ops, 2);
|
938
1026
|
lcb_subdocspecs_get(ops, 0, LCB_SUBDOCSPECS_F_XATTRPATH, expiry_path.c_str(), expiry_path.size());
|
1027
|
+
lcb_subdocspecs_get(ops, 1, LCB_SUBDOCSPECS_F_XATTRPATH, cas_path.c_str(), cas_path.size());
|
939
1028
|
lcb_cmdsubdoc_specs(cmd, ops);
|
940
|
-
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &
|
1029
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, lcb_subdoc(instance, &res, cmd));
|
941
1030
|
lcb_subdocspecs_destroy(ops);
|
942
1031
|
lcb_cmdsubdoc_destroy(cmd);
|
943
1032
|
lcb_wait(instance, LCB_WAIT_DEFAULT);
|
944
1033
|
|
945
|
-
|
1034
|
+
ASSERT_TRUE(res.called);
|
1035
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc);
|
1036
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_cas);
|
1037
|
+
ASSERT_EQ(cas, res.cas);
|
1038
|
+
ASSERT_STATUS_EQ(LCB_SUCCESS, res.rc_expiry);
|
1039
|
+
ASSERT_EQ(0, res.expiry);
|
946
1040
|
}
|
947
1041
|
}
|