couchbase 3.0.3-universal-darwin-20 → 3.1.1-universal-darwin-20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/ext/CMakeLists.txt +4 -2
  4. data/ext/build_config.hxx.in +1 -1
  5. data/ext/build_version.hxx.in +2 -2
  6. data/ext/couchbase/bucket.hxx +1 -1
  7. data/ext/couchbase/capabilities.hxx +1 -1
  8. data/ext/couchbase/cluster.hxx +1 -1
  9. data/ext/couchbase/cluster_options.hxx +4 -1
  10. data/ext/couchbase/collections_manifest.hxx +1 -1
  11. data/ext/couchbase/configuration.hxx +1 -1
  12. data/ext/couchbase/couchbase.cxx +743 -927
  13. data/ext/couchbase/diagnostics.hxx +3 -3
  14. data/ext/couchbase/document_id.hxx +1 -1
  15. data/ext/couchbase/error_context/analytics.hxx +1 -1
  16. data/ext/couchbase/error_context/http.hxx +1 -1
  17. data/ext/couchbase/error_context/key_value.hxx +1 -1
  18. data/ext/couchbase/error_context/query.hxx +1 -1
  19. data/ext/couchbase/error_context/search.hxx +1 -1
  20. data/ext/couchbase/error_context/view.hxx +1 -1
  21. data/ext/couchbase/error_map.hxx +1 -1
  22. data/ext/couchbase/errors.hxx +1 -1
  23. data/ext/couchbase/io/dns_client.hxx +1 -1
  24. data/ext/couchbase/io/dns_codec.hxx +1 -1
  25. data/ext/couchbase/io/dns_config.hxx +1 -1
  26. data/ext/couchbase/io/dns_message.hxx +1 -1
  27. data/ext/couchbase/io/http_command.hxx +1 -1
  28. data/ext/couchbase/io/http_context.hxx +1 -1
  29. data/ext/couchbase/io/http_message.hxx +1 -1
  30. data/ext/couchbase/io/http_parser.hxx +1 -1
  31. data/ext/couchbase/io/http_session.hxx +1 -1
  32. data/ext/couchbase/io/http_session_manager.hxx +1 -1
  33. data/ext/couchbase/io/mcbp_command.hxx +1 -1
  34. data/ext/couchbase/io/mcbp_context.hxx +1 -1
  35. data/ext/couchbase/io/mcbp_message.hxx +1 -1
  36. data/ext/couchbase/io/mcbp_parser.hxx +1 -1
  37. data/ext/couchbase/io/mcbp_session.hxx +10 -1
  38. data/ext/couchbase/io/query_cache.hxx +1 -1
  39. data/ext/couchbase/io/retry_action.hxx +1 -1
  40. data/ext/couchbase/io/retry_context.hxx +1 -1
  41. data/ext/couchbase/io/retry_orchestrator.hxx +1 -1
  42. data/ext/couchbase/io/retry_reason.hxx +1 -1
  43. data/ext/couchbase/io/retry_strategy.hxx +1 -1
  44. data/ext/couchbase/io/streams.hxx +1 -1
  45. data/ext/couchbase/mutation_token.hxx +1 -1
  46. data/ext/couchbase/operations.hxx +1 -1
  47. data/ext/couchbase/operations/analytics_dataset_create.hxx +1 -1
  48. data/ext/couchbase/operations/analytics_dataset_drop.hxx +1 -1
  49. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +1 -1
  50. data/ext/couchbase/operations/analytics_dataverse_create.hxx +1 -1
  51. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +1 -1
  52. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +1 -1
  53. data/ext/couchbase/operations/analytics_index_create.hxx +1 -1
  54. data/ext/couchbase/operations/analytics_index_drop.hxx +1 -1
  55. data/ext/couchbase/operations/analytics_index_get_all.hxx +1 -1
  56. data/ext/couchbase/operations/analytics_link_connect.hxx +1 -1
  57. data/ext/couchbase/operations/analytics_link_disconnect.hxx +1 -1
  58. data/ext/couchbase/operations/bucket_create.hxx +1 -1
  59. data/ext/couchbase/operations/bucket_drop.hxx +1 -1
  60. data/ext/couchbase/operations/bucket_flush.hxx +1 -1
  61. data/ext/couchbase/operations/bucket_get.hxx +1 -1
  62. data/ext/couchbase/operations/bucket_get_all.hxx +1 -1
  63. data/ext/couchbase/operations/bucket_update.hxx +1 -1
  64. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +1 -1
  65. data/ext/couchbase/operations/collection_create.hxx +13 -9
  66. data/ext/couchbase/operations/collection_drop.hxx +11 -7
  67. data/ext/couchbase/operations/collections_manifest_get.hxx +1 -1
  68. data/ext/couchbase/operations/design_document.hxx +1 -1
  69. data/ext/couchbase/operations/document_analytics.hxx +1 -1
  70. data/ext/couchbase/operations/document_append.hxx +1 -1
  71. data/ext/couchbase/operations/document_decrement.hxx +5 -1
  72. data/ext/couchbase/operations/document_exists.hxx +1 -1
  73. data/ext/couchbase/operations/document_get.hxx +1 -1
  74. data/ext/couchbase/operations/document_get_and_lock.hxx +1 -1
  75. data/ext/couchbase/operations/document_get_and_touch.hxx +1 -1
  76. data/ext/couchbase/operations/document_get_projected.hxx +1 -1
  77. data/ext/couchbase/operations/document_increment.hxx +5 -1
  78. data/ext/couchbase/operations/document_insert.hxx +1 -1
  79. data/ext/couchbase/operations/document_lookup_in.hxx +1 -1
  80. data/ext/couchbase/operations/document_mutate_in.hxx +5 -1
  81. data/ext/couchbase/operations/document_prepend.hxx +1 -1
  82. data/ext/couchbase/operations/document_query.hxx +9 -1
  83. data/ext/couchbase/operations/document_remove.hxx +1 -1
  84. data/ext/couchbase/operations/document_replace.hxx +5 -1
  85. data/ext/couchbase/operations/document_search.hxx +1 -1
  86. data/ext/couchbase/operations/document_touch.hxx +1 -1
  87. data/ext/couchbase/operations/document_unlock.hxx +1 -1
  88. data/ext/couchbase/operations/document_upsert.hxx +5 -1
  89. data/ext/couchbase/operations/document_view.hxx +1 -1
  90. data/ext/couchbase/operations/group_drop.hxx +1 -1
  91. data/ext/couchbase/operations/group_get.hxx +1 -1
  92. data/ext/couchbase/operations/group_get_all.hxx +1 -1
  93. data/ext/couchbase/operations/group_upsert.hxx +1 -1
  94. data/ext/couchbase/operations/http_noop.hxx +1 -1
  95. data/ext/couchbase/operations/mcbp_noop.hxx +1 -1
  96. data/ext/couchbase/operations/query_index_build_deferred.hxx +1 -1
  97. data/ext/couchbase/operations/query_index_create.hxx +1 -1
  98. data/ext/couchbase/operations/query_index_drop.hxx +1 -1
  99. data/ext/couchbase/operations/query_index_get_all.hxx +1 -1
  100. data/ext/couchbase/operations/rbac.hxx +1 -1
  101. data/ext/couchbase/operations/role_get_all.hxx +1 -1
  102. data/ext/couchbase/operations/scope_create.hxx +9 -8
  103. data/ext/couchbase/operations/scope_drop.hxx +9 -6
  104. data/ext/couchbase/operations/scope_get_all.hxx +2 -2
  105. data/ext/couchbase/operations/search_get_stats.hxx +1 -1
  106. data/ext/couchbase/operations/search_index.hxx +1 -1
  107. data/ext/couchbase/operations/search_index_analyze_document.hxx +1 -1
  108. data/ext/couchbase/operations/search_index_control_ingest.hxx +1 -1
  109. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +1 -1
  110. data/ext/couchbase/operations/search_index_control_query.hxx +1 -1
  111. data/ext/couchbase/operations/search_index_drop.hxx +1 -1
  112. data/ext/couchbase/operations/search_index_get.hxx +1 -1
  113. data/ext/couchbase/operations/search_index_get_all.hxx +1 -1
  114. data/ext/couchbase/operations/search_index_get_documents_count.hxx +1 -1
  115. data/ext/couchbase/operations/search_index_get_stats.hxx +1 -1
  116. data/ext/couchbase/operations/search_index_upsert.hxx +1 -1
  117. data/ext/couchbase/operations/user_drop.hxx +1 -1
  118. data/ext/couchbase/operations/user_get.hxx +1 -1
  119. data/ext/couchbase/operations/user_get_all.hxx +1 -1
  120. data/ext/couchbase/operations/user_upsert.hxx +1 -1
  121. data/ext/couchbase/operations/view_index_drop.hxx +1 -1
  122. data/ext/couchbase/operations/view_index_get.hxx +1 -1
  123. data/ext/couchbase/operations/view_index_get_all.hxx +1 -1
  124. data/ext/couchbase/operations/view_index_upsert.hxx +1 -1
  125. data/ext/couchbase/origin.hxx +1 -1
  126. data/ext/couchbase/protocol/client_opcode.hxx +6 -1
  127. data/ext/couchbase/protocol/client_request.hxx +1 -1
  128. data/ext/couchbase/protocol/client_response.hxx +1 -1
  129. data/ext/couchbase/protocol/cmd_append.hxx +1 -1
  130. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +1 -1
  131. data/ext/couchbase/protocol/cmd_decrement.hxx +19 -9
  132. data/ext/couchbase/protocol/cmd_exists.hxx +1 -1
  133. data/ext/couchbase/protocol/cmd_get.hxx +1 -1
  134. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +1 -1
  135. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +1 -1
  136. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +1 -1
  137. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +7 -7
  138. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +1 -1
  139. data/ext/couchbase/protocol/cmd_get_error_map.hxx +1 -1
  140. data/ext/couchbase/protocol/cmd_hello.hxx +17 -4
  141. data/ext/couchbase/protocol/cmd_increment.hxx +19 -9
  142. data/ext/couchbase/protocol/cmd_info.hxx +1 -1
  143. data/ext/couchbase/protocol/cmd_insert.hxx +1 -1
  144. data/ext/couchbase/protocol/cmd_lookup_in.hxx +1 -1
  145. data/ext/couchbase/protocol/cmd_mutate_in.hxx +18 -9
  146. data/ext/couchbase/protocol/cmd_noop.hxx +1 -1
  147. data/ext/couchbase/protocol/cmd_prepend.hxx +1 -1
  148. data/ext/couchbase/protocol/cmd_remove.hxx +1 -1
  149. data/ext/couchbase/protocol/cmd_replace.hxx +17 -8
  150. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +1 -1
  151. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +1 -1
  152. data/ext/couchbase/protocol/cmd_sasl_step.hxx +1 -1
  153. data/ext/couchbase/protocol/cmd_select_bucket.hxx +1 -1
  154. data/ext/couchbase/protocol/cmd_touch.hxx +1 -1
  155. data/ext/couchbase/protocol/cmd_unlock.hxx +1 -1
  156. data/ext/couchbase/protocol/cmd_upsert.hxx +17 -8
  157. data/ext/couchbase/protocol/datatype.hxx +1 -1
  158. data/ext/couchbase/protocol/durability_level.hxx +1 -1
  159. data/ext/couchbase/protocol/enhanced_error_info.hxx +1 -1
  160. data/ext/couchbase/protocol/frame_info_id.hxx +2 -2
  161. data/ext/couchbase/protocol/hello_feature.hxx +1 -1
  162. data/ext/couchbase/protocol/magic.hxx +1 -1
  163. data/ext/couchbase/protocol/server_opcode.hxx +1 -1
  164. data/ext/couchbase/protocol/server_request.hxx +1 -1
  165. data/ext/couchbase/protocol/status.hxx +1 -1
  166. data/ext/couchbase/service_type.hxx +1 -1
  167. data/ext/couchbase/timeout_defaults.hxx +1 -1
  168. data/ext/couchbase/utils/byteswap.hxx +1 -1
  169. data/ext/couchbase/utils/connection_string.hxx +28 -1
  170. data/ext/couchbase/version.hxx +2 -2
  171. data/ext/extconf.rb +1 -1
  172. data/ext/test/test_helper.hxx +1 -1
  173. data/ext/test/test_helper_native.hxx +1 -1
  174. data/ext/test/test_helper_ruby.hxx +1 -1
  175. data/ext/test/test_native_binary_operations.cxx +1 -1
  176. data/ext/test/test_native_diagnostics.cxx +1 -1
  177. data/ext/test/test_native_trivial_crud.cxx +1 -1
  178. data/ext/test/test_ruby_trivial_crud.cxx +1 -1
  179. data/ext/test/test_ruby_trivial_query.cxx +1 -1
  180. data/lib/active_support/cache/couchbase_store.rb +2 -1
  181. data/lib/couchbase.rb +1 -1
  182. data/lib/couchbase/analytics_options.rb +1 -1
  183. data/lib/couchbase/authenticator.rb +1 -1
  184. data/lib/couchbase/binary_collection.rb +1 -1
  185. data/lib/couchbase/binary_collection_options.rb +1 -1
  186. data/lib/couchbase/bucket.rb +1 -1
  187. data/lib/couchbase/cluster.rb +2 -2
  188. data/lib/couchbase/collection.rb +1 -1
  189. data/lib/couchbase/collection_options.rb +25 -19
  190. data/lib/couchbase/configuration.rb +1 -1
  191. data/lib/couchbase/datastructures.rb +1 -1
  192. data/lib/couchbase/datastructures/couchbase_list.rb +1 -1
  193. data/lib/couchbase/datastructures/couchbase_map.rb +1 -1
  194. data/lib/couchbase/datastructures/couchbase_queue.rb +1 -1
  195. data/lib/couchbase/datastructures/couchbase_set.rb +1 -1
  196. data/lib/couchbase/diagnostics.rb +1 -1
  197. data/lib/couchbase/errors.rb +1 -1
  198. data/lib/couchbase/json_transcoder.rb +1 -1
  199. data/lib/couchbase/libcouchbase.bundle +0 -0
  200. data/lib/couchbase/logger.rb +1 -1
  201. data/lib/couchbase/management.rb +1 -1
  202. data/lib/couchbase/management/analytics_index_manager.rb +1 -1
  203. data/lib/couchbase/management/bucket_manager.rb +1 -1
  204. data/lib/couchbase/management/collection_manager.rb +8 -1
  205. data/lib/couchbase/management/query_index_manager.rb +1 -1
  206. data/lib/couchbase/management/search_index_manager.rb +1 -1
  207. data/lib/couchbase/management/user_manager.rb +1 -1
  208. data/lib/couchbase/management/view_index_manager.rb +1 -1
  209. data/lib/couchbase/mutation_state.rb +1 -1
  210. data/lib/couchbase/options.rb +49 -4
  211. data/lib/couchbase/query_options.rb +1 -1
  212. data/lib/couchbase/railtie.rb +1 -1
  213. data/lib/couchbase/scope.rb +7 -6
  214. data/lib/couchbase/search_options.rb +1 -1
  215. data/lib/couchbase/subdoc.rb +2 -2
  216. data/lib/couchbase/utils.rb +1 -1
  217. data/lib/couchbase/utils/time.rb +1 -1
  218. data/lib/couchbase/version.rb +9 -9
  219. data/lib/couchbase/view_options.rb +1 -1
  220. data/lib/rails/generators/couchbase/config/config_generator.rb +1 -1
  221. metadata +5 -5
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ struct collection_create_request {
49
49
  [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
50
50
  {
51
51
  encoded.method = "POST";
52
- encoded.path = fmt::format("/pools/default/buckets/{}/collections/{}", bucket_name, scope_name);
52
+ encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections", bucket_name, scope_name);
53
53
  encoded.headers["content-type"] = "application/x-www-form-urlencoded";
54
54
  encoded.body = fmt::format("name={}", utils::string_codec::form_encode(collection_name));
55
55
  if (max_expiry > 0) {
@@ -60,27 +60,31 @@ struct collection_create_request {
60
60
  };
61
61
 
62
62
  collection_create_response
63
- make_response(error_context::http&& ctx, collection_create_request&, collection_create_request::encoded_response_type&& encoded)
63
+ make_response(error_context::http&& ctx,
64
+ collection_create_request& /* request */,
65
+ collection_create_request::encoded_response_type&& encoded)
64
66
  {
65
67
  collection_create_response response{ ctx };
66
68
  if (!response.ctx.ec) {
67
69
  switch (encoded.status_code) {
68
- case 400:
69
- if (encoded.body.find("Collection with this name already exists") != std::string::npos) {
70
+ case 400: {
71
+ std::regex collection_exists("Collection with name .+ already exists");
72
+ if (std::regex_search(encoded.body, collection_exists)) {
70
73
  response.ctx.ec = std::make_error_code(error::management_errc::collection_exists);
71
74
  } else if (encoded.body.find("Not allowed on this version of cluster") != std::string::npos) {
72
75
  response.ctx.ec = std::make_error_code(error::common_errc::feature_not_available);
73
76
  } else {
74
77
  response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
75
78
  }
76
- break;
77
- case 404:
78
- if (encoded.body.find("Scope with this name is not found") != std::string::npos) {
79
+ } break;
80
+ case 404: {
81
+ std::regex scope_not_found("Scope with name .+ is not found");
82
+ if (std::regex_search(encoded.body, scope_not_found)) {
79
83
  response.ctx.ec = std::make_error_code(error::common_errc::scope_not_found);
80
84
  } else {
81
85
  response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
82
86
  }
83
- break;
87
+ } break;
84
88
  case 200: {
85
89
  tao::json::value payload{};
86
90
  try {
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@
17
17
 
18
18
  #pragma once
19
19
 
20
+ #include <regex>
21
+
20
22
  #include <tao/json.hpp>
21
23
 
22
24
  #include <version.hxx>
@@ -48,13 +50,13 @@ struct collection_drop_request {
48
50
  [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
49
51
  {
50
52
  encoded.method = "DELETE";
51
- encoded.path = fmt::format("/pools/default/buckets/{}/collections/{}/{}", bucket_name, scope_name, collection_name);
53
+ encoded.path = fmt::format("/pools/default/buckets/{}/scopes/{}/collections/{}", bucket_name, scope_name, collection_name);
52
54
  return {};
53
55
  }
54
56
  };
55
57
 
56
58
  collection_drop_response
57
- make_response(error_context::http&& ctx, collection_drop_request&, collection_drop_request::encoded_response_type&& encoded)
59
+ make_response(error_context::http&& ctx, collection_drop_request& /* request */, collection_drop_request::encoded_response_type&& encoded)
58
60
  {
59
61
  collection_drop_response response{ ctx };
60
62
  if (!response.ctx.ec) {
@@ -62,15 +64,17 @@ make_response(error_context::http&& ctx, collection_drop_request&, collection_dr
62
64
  case 400:
63
65
  response.ctx.ec = std::make_error_code(error::common_errc::unsupported_operation);
64
66
  break;
65
- case 404:
66
- if (encoded.body.find("Collection with this name is not found") != std::string::npos) {
67
+ case 404: {
68
+ std::regex scope_not_found("Scope with name .+ is not found");
69
+ std::regex collection_not_found("Collection with name .+ is not found");
70
+ if (std::regex_search(encoded.body, collection_not_found)) {
67
71
  response.ctx.ec = std::make_error_code(error::common_errc::collection_not_found);
68
- } else if (encoded.body.find("Scope with this name is not found") != std::string::npos) {
72
+ } else if (std::regex_search(encoded.body, scope_not_found)) {
69
73
  response.ctx.ec = std::make_error_code(error::common_errc::scope_not_found);
70
74
  } else {
71
75
  response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
72
76
  }
73
- break;
77
+ } break;
74
78
  case 200: {
75
79
  tao::json::value payload{};
76
80
  try {
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@ struct decrement_request {
45
45
  std::optional<std::uint16_t> durability_timeout{};
46
46
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
47
47
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
48
+ bool preserve_expiry{ false };
48
49
 
49
50
  [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
50
51
  {
@@ -62,6 +63,9 @@ struct decrement_request {
62
63
  if (durability_level != protocol::durability_level::none) {
63
64
  encoded.body().durability(durability_level, durability_timeout);
64
65
  }
66
+ if (preserve_expiry) {
67
+ encoded.body().preserve_expiry();
68
+ }
65
69
  return {};
66
70
  }
67
71
  };
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@ struct increment_request {
47
47
  std::optional<std::uint16_t> durability_timeout{};
48
48
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
49
49
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
50
+ bool preserve_expiry{ false };
50
51
 
51
52
  [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
52
53
  {
@@ -64,6 +65,9 @@ struct increment_request {
64
65
  if (durability_level != protocol::durability_level::none) {
65
66
  encoded.body().durability(durability_level, durability_timeout);
66
67
  }
68
+ if (preserve_expiry) {
69
+ encoded.body().preserve_expiry();
70
+ }
67
71
  return {};
68
72
  }
69
73
  };
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -70,6 +70,7 @@ struct mutate_in_request {
70
70
  std::optional<std::uint16_t> durability_timeout{};
71
71
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
72
72
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
73
+ bool preserve_expiry{ false };
73
74
 
74
75
  [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& ctx)
75
76
  {
@@ -102,6 +103,9 @@ struct mutate_in_request {
102
103
  if (durability_level != protocol::durability_level::none) {
103
104
  encoded.body().durability(durability_level, durability_timeout);
104
105
  }
106
+ if (preserve_expiry) {
107
+ encoded.body().preserve_expiry();
108
+ }
105
109
  return {};
106
110
  }
107
111
  };
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -380,6 +380,7 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
380
380
  bool syntax_error = false;
381
381
  bool server_timeout = false;
382
382
  bool invalid_argument = false;
383
+ bool cas_mismatch = false;
383
384
 
384
385
  if (response.payload.meta_data.errors) {
385
386
  for (const auto& error : *response.payload.meta_data.errors) {
@@ -401,6 +402,11 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
401
402
  case 4090: /* IKey: "plan.build_prepared.name_not_in_encoded_plan" */
402
403
  prepared_statement_failure = true;
403
404
  break;
405
+ case 12009: /* IKey: "datastore.couchbase.DML_error" */
406
+ if (error.message.find("CAS mismatch") != std::string::npos) {
407
+ cas_mismatch = true;
408
+ }
409
+ break;
404
410
  case 12004: /* IKey: "datastore.couchbase.primary_idx_not_found" */
405
411
  case 12016: /* IKey: "datastore.couchbase.index_not_found" */
406
412
  index_not_found = true;
@@ -429,6 +435,8 @@ make_response(error_context::query&& ctx, query_request& request, query_request:
429
435
  response.ctx.ec = std::make_error_code(error::query_errc::planning_failure);
430
436
  } else if (index_not_found) {
431
437
  response.ctx.ec = std::make_error_code(error::common_errc::index_not_found);
438
+ } else if (cas_mismatch) {
439
+ response.ctx.ec = std::make_error_code(error::common_errc::cas_mismatch);
432
440
  } else {
433
441
  response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
434
442
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ struct replace_request {
46
46
  std::optional<std::uint16_t> durability_timeout{};
47
47
  std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
48
48
  io::retry_context<io::retry_strategy::best_effort> retries{ false };
49
+ bool preserve_expiry{ false };
49
50
 
50
51
  [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
51
52
  {
@@ -59,6 +60,9 @@ struct replace_request {
59
60
  if (durability_level != protocol::durability_level::none) {
60
61
  encoded.body().durability(durability_level, durability_timeout);
61
62
  }
63
+ if (preserve_expiry) {
64
+ encoded.body().preserve_expiry();
65
+ }
62
66
  return {};
63
67
  }
64
68
  };
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020-2021 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright 2020 Couchbase, Inc.
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.