couchbase 3.2.0 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/README.md +24 -18
  2. package/binding.gyp +88 -85
  3. package/deps/lcb/CMakeLists.txt +1 -1
  4. package/deps/lcb/CONTRIBUTING.md +1 -1
  5. package/deps/lcb/README.markdown +2 -2
  6. package/deps/lcb/RELEASE_NOTES.markdown +99 -14
  7. package/deps/lcb/cmake/Modules/GetVersionInfo.cmake +1 -1
  8. package/deps/lcb/contrib/cbsasl/src/scram-sha/scram_utils.cc +22 -26
  9. package/deps/lcb/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +20 -7
  10. package/deps/lcb/doc/Doxyfile +1 -1
  11. package/deps/lcb/example/CMakeLists.txt +4 -4
  12. package/deps/lcb/example/libuvdirect/main.c +39 -12
  13. package/deps/lcb/example/minimal/durability.cc +149 -0
  14. package/deps/lcb/example/minimal/query.c +11 -9
  15. package/deps/lcb/gyp_config/common/libcouchbase/configuration.h +3 -3
  16. package/deps/lcb/gyp_config/linux/arm64/config.h +243 -0
  17. package/deps/lcb/include/libcouchbase/couchbase.h +80 -5
  18. package/deps/lcb/include/libcouchbase/error.h +2 -0
  19. package/deps/lcb/include/libcouchbase/ixmgmt.h +15 -10
  20. package/deps/lcb/include/libcouchbase/tracing.h +2 -2
  21. package/deps/lcb/include/memcached/protocol_binary.h +21 -0
  22. package/deps/lcb/libcouchbase.gyp +347 -349
  23. package/deps/lcb/packaging/deb/control +1 -1
  24. package/deps/lcb/src/analytics/analytics_handle.cc +13 -5
  25. package/deps/lcb/src/analytics/analytics_handle.hh +29 -0
  26. package/deps/lcb/src/bootstrap.cc +6 -3
  27. package/deps/lcb/src/capi/cmd_analytics.cc +12 -1
  28. package/deps/lcb/src/capi/cmd_analytics.hh +30 -0
  29. package/deps/lcb/src/capi/cmd_counter.hh +23 -0
  30. package/deps/lcb/src/capi/cmd_exists.hh +24 -1
  31. package/deps/lcb/src/capi/cmd_get.hh +22 -0
  32. package/deps/lcb/src/capi/cmd_get_replica.hh +23 -0
  33. package/deps/lcb/src/capi/cmd_http.hh +7 -0
  34. package/deps/lcb/src/capi/cmd_query.cc +11 -1
  35. package/deps/lcb/src/capi/cmd_query.hh +31 -0
  36. package/deps/lcb/src/capi/cmd_remove.hh +23 -0
  37. package/deps/lcb/src/capi/cmd_search.cc +6 -0
  38. package/deps/lcb/src/capi/cmd_search.hh +23 -0
  39. package/deps/lcb/src/capi/cmd_store.hh +33 -21
  40. package/deps/lcb/src/capi/cmd_subdoc.hh +35 -0
  41. package/deps/lcb/src/capi/cmd_touch.hh +23 -0
  42. package/deps/lcb/src/capi/cmd_unlock.hh +23 -0
  43. package/deps/lcb/src/capi/cmd_view.hh +6 -0
  44. package/deps/lcb/src/capi/collection_qualifier.hh +2 -2
  45. package/deps/lcb/src/cntl.cc +45 -11
  46. package/deps/lcb/src/crypto.cc +2 -2
  47. package/deps/lcb/src/dns-srv.cc +5 -3
  48. package/deps/lcb/src/errmap.cc +5 -9
  49. package/deps/lcb/src/errmap.h +7 -3
  50. package/deps/lcb/src/handler.cc +24 -18
  51. package/deps/lcb/src/hostlist.h +2 -2
  52. package/deps/lcb/src/http/http-priv.h +2 -2
  53. package/deps/lcb/src/http/http.cc +5 -2
  54. package/deps/lcb/src/instance.cc +20 -11
  55. package/deps/lcb/src/internal.h +9 -0
  56. package/deps/lcb/src/lcbio/connect.cc +14 -2
  57. package/deps/lcb/src/lcbio/connect.h +2 -2
  58. package/deps/lcb/src/lcbio/ctx.cc +4 -2
  59. package/deps/lcb/src/lcbio/ioutils.cc +9 -10
  60. package/deps/lcb/src/lcbio/manager.cc +1 -1
  61. package/deps/lcb/src/mcserver/mcserver.cc +9 -6
  62. package/deps/lcb/src/mcserver/negotiate.cc +39 -17
  63. package/deps/lcb/src/n1ql/ixmgmt.cc +1 -2
  64. package/deps/lcb/src/n1ql/query_handle.cc +41 -19
  65. package/deps/lcb/src/n1ql/query_handle.hh +28 -1
  66. package/deps/lcb/src/operations/counter.cc +18 -5
  67. package/deps/lcb/src/operations/exists.cc +25 -4
  68. package/deps/lcb/src/operations/get.cc +39 -19
  69. package/deps/lcb/src/operations/get_replica.cc +28 -8
  70. package/deps/lcb/src/operations/observe.cc +1 -1
  71. package/deps/lcb/src/operations/ping.cc +8 -8
  72. package/deps/lcb/src/operations/pktfwd.cc +2 -1
  73. package/deps/lcb/src/operations/remove.cc +39 -22
  74. package/deps/lcb/src/operations/store.cc +18 -5
  75. package/deps/lcb/src/operations/subdoc.cc +18 -6
  76. package/deps/lcb/src/operations/touch.cc +34 -16
  77. package/deps/lcb/src/operations/unlock.cc +24 -5
  78. package/deps/lcb/src/packetutils.h +3 -2
  79. package/deps/lcb/src/retryq.cc +24 -5
  80. package/deps/lcb/src/search/search.cc +1 -0
  81. package/deps/lcb/src/search/search_handle.cc +30 -8
  82. package/deps/lcb/src/search/search_handle.hh +29 -0
  83. package/deps/lcb/src/settings.cc +1 -1
  84. package/deps/lcb/src/ssl/ssl_common.c +6 -7
  85. package/deps/lcb/src/tracing/span.cc +47 -14
  86. package/deps/lcb/src/tracing/tracer.cc +11 -2
  87. package/deps/lcb/src/tracing/tracing-internal.h +105 -93
  88. package/deps/lcb/src/utilities.cc +43 -0
  89. package/deps/lcb/src/utilities.h +53 -0
  90. package/deps/lcb/src/vbucket/vbucket.c +34 -33
  91. package/deps/lcb/src/views/view_handle.cc +13 -5
  92. package/deps/lcb/src/views/view_handle.hh +29 -0
  93. package/deps/lcb/tests/CMakeLists.txt +21 -0
  94. package/deps/lcb/tests/basic/t_ctlcodes.cc +24 -3
  95. package/deps/lcb/tests/basic/t_jsparse.cc +8 -0
  96. package/deps/lcb/tests/basic/t_n1qlstrings.cc +73 -0
  97. package/deps/lcb/tests/iotests/mock-environment.cc +30 -1
  98. package/deps/lcb/tests/iotests/mock-environment.h +49 -0
  99. package/deps/lcb/tests/iotests/mock-unit-test.cc +104 -6
  100. package/deps/lcb/tests/iotests/mock-unit-test.h +34 -0
  101. package/deps/lcb/tests/iotests/t_collections.cc +1 -1
  102. package/deps/lcb/tests/iotests/t_confmon.cc +4 -2
  103. package/deps/lcb/tests/iotests/t_get.cc +109 -7
  104. package/deps/lcb/tests/iotests/t_http.cc +9 -4
  105. package/deps/lcb/tests/iotests/t_lock.cc +18 -0
  106. package/deps/lcb/tests/iotests/t_mutate.cc +157 -63
  107. package/deps/lcb/tests/iotests/t_n1ql.cc +330 -33
  108. package/deps/lcb/tests/iotests/t_views.cc +1 -0
  109. package/deps/lcb/tests/iotests/testutil.cc +168 -0
  110. package/deps/lcb/tests/iotests/testutil.h +116 -0
  111. package/deps/lcb/tests/mocksupport/procutil.c +32 -28
  112. package/deps/lcb/tests/mocksupport/server.c +0 -1
  113. package/deps/lcb/tests/mocksupport/timeout.c +2 -2
  114. package/deps/lcb/tools/cbc.cc +7 -0
  115. package/dist/analyticsindexmanager.js +512 -524
  116. package/dist/binding.d.ts +3 -0
  117. package/dist/bindingutilities.js +4 -0
  118. package/dist/bucket.js +1 -1
  119. package/dist/bucketmanager.d.ts +31 -1
  120. package/dist/bucketmanager.js +194 -186
  121. package/dist/cluster.d.ts +7 -0
  122. package/dist/cluster.js +48 -38
  123. package/dist/collection.js +11 -17
  124. package/dist/collectionmanager.js +181 -197
  125. package/dist/connection.d.ts +3 -1
  126. package/dist/connection.js +27 -16
  127. package/dist/couchbase.d.ts +1 -0
  128. package/dist/couchbase.js +3 -13
  129. package/dist/datastructures.js +239 -310
  130. package/dist/diagnosticsexecutor.js +70 -85
  131. package/dist/errors.d.ts +70 -0
  132. package/dist/errors.js +96 -2
  133. package/dist/eventingfunctionmanager.d.ts +804 -0
  134. package/dist/eventingfunctionmanager.js +993 -0
  135. package/dist/httpexecutor.d.ts +2 -1
  136. package/dist/httpexecutor.js +30 -37
  137. package/dist/queryindexmanager.js +240 -266
  138. package/dist/scope.js +10 -4
  139. package/dist/sdspecs.d.ts +1 -1
  140. package/dist/searchexecutor.js +3 -0
  141. package/dist/searchindexmanager.js +240 -271
  142. package/dist/searchquery.d.ts +17 -0
  143. package/dist/searchquery.js +22 -1
  144. package/dist/searchtypes.d.ts +7 -2
  145. package/dist/searchtypes.js +2 -2
  146. package/dist/usermanager.js +251 -264
  147. package/dist/utilities.d.ts +2 -0
  148. package/dist/utilities.js +7 -2
  149. package/dist/viewexecutor.js +1 -1
  150. package/dist/viewindexmanager.js +131 -150
  151. package/package.json +1 -1
  152. package/src/addondata.cpp +58 -0
  153. package/src/addondata.h +40 -0
  154. package/src/binding.cpp +3 -1
  155. package/src/cas.h +2 -2
  156. package/src/connection.cpp +25 -178
  157. package/src/connection.h +8 -65
  158. package/src/connection_ops.cpp +57 -34
  159. package/src/constants.cpp +3 -0
  160. package/src/instance.cpp +235 -0
  161. package/src/instance.h +102 -0
  162. package/src/{connection_callbacks.cpp → instance_callbacks.cpp} +34 -34
  163. package/src/logger.cpp +11 -1
  164. package/src/logger.h +3 -0
  165. package/src/metrics.cpp +10 -0
  166. package/src/metrics.h +3 -0
  167. package/src/mutationtoken.h +2 -2
  168. package/src/opbuilder.h +13 -15
  169. package/src/respreader.cpp +1 -0
  170. package/src/respreader.h +6 -4
  171. package/src/tracespan.h +11 -11
  172. package/src/tracing.cpp +11 -0
  173. package/src/tracing.h +3 -0
  174. package/src/valueparser.h +5 -0
  175. package/deps/lcb/example/observe/durability.c +0 -110
@@ -288,6 +288,7 @@ bool Reader::parse(const char* beginDoc,
288
288
  const char* endDoc,
289
289
  Value& root,
290
290
  bool collectComments) {
291
+ try {
291
292
  if (!features_.allowComments_) {
292
293
  collectComments = false;
293
294
  }
@@ -324,6 +325,21 @@ bool Reader::parse(const char* beginDoc,
324
325
  }
325
326
  }
326
327
  return successful;
328
+ } catch (const RuntimeError &e) {
329
+ Token token;
330
+ token.type_ = tokenError;
331
+ token.start_ = beginDoc;
332
+ token.end_ = endDoc;
333
+ addError(std::string("RuntimeError: ") + e.what(), token);
334
+ return false;
335
+ } catch (const LogicError &e) {
336
+ Token token;
337
+ token.type_ = tokenError;
338
+ token.start_ = beginDoc;
339
+ token.end_ = endDoc;
340
+ addError(std::string("LogicError: ") + e.what(), token);
341
+ return false;
342
+ }
327
343
  }
328
344
 
329
345
  bool Reader::readValue() {
@@ -2356,15 +2372,13 @@ RuntimeError::RuntimeError(std::string const& msg)
2356
2372
  LogicError::LogicError(std::string const& msg)
2357
2373
  : Exception(msg)
2358
2374
  {}
2359
- void throwRuntimeError(std::string const& )
2375
+ void throwRuntimeError(std::string const& msg)
2360
2376
  {
2361
- assert(false);
2362
- // throw RuntimeError(msg);
2377
+ throw RuntimeError(msg);
2363
2378
  }
2364
- void throwLogicError(std::string const&)
2379
+ void throwLogicError(std::string const& msg)
2365
2380
  {
2366
- assert(false);
2367
- // throw LogicError(msg);
2381
+ throw LogicError(msg);
2368
2382
  }
2369
2383
 
2370
2384
  // //////////////////////////////////////////////////////////////////
@@ -4019,7 +4033,6 @@ void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
4019
4033
  std::string FastWriter::write(const Value& root) {
4020
4034
  document_ = "";
4021
4035
  writeValue(root);
4022
- document_ += "\n";
4023
4036
  return document_;
4024
4037
  }
4025
4038
 
@@ -38,7 +38,7 @@ PROJECT_NAME = "Couchbase C Client"
38
38
  # could be handy for archiving the generated documentation or if some version
39
39
  # control system is used.
40
40
 
41
- PROJECT_NUMBER = 3.2.0
41
+ PROJECT_NUMBER = 3.2.4
42
42
 
43
43
  # Using the PROJECT_BRIEF tag one can provide an optional one line description
44
44
  # for a project that appears at the top of each page and should give viewer a
@@ -8,7 +8,7 @@ MACRO(ADD_EXAMPLE name dir linkspec incspec)
8
8
  TARGET_LINK_LIBRARIES(${name} couchbase ${linkspec})
9
9
 
10
10
  GET_TARGET_PROPERTY(_tmp_inc ${name} INCLUDE_DIRECTORIES)
11
- LIST(APPEND ${_tmp_inc} ${dir} ${incspec})
11
+ LIST(APPEND _tmp_inc ${incspec})
12
12
  SET_TARGET_PROPERTIES(${name} PROPERTIES INCLUDE_DIRECTORIES "${_tmp_inc}")
13
13
  ENDMACRO()
14
14
 
@@ -72,6 +72,9 @@ TARGET_LINK_LIBRARIES(subdoc-tombstone couchbase)
72
72
  TARGET_LINK_LIBRARIES(subdoc-multi couchbase)
73
73
  TARGET_LINK_LIBRARIES(subdoc-xattrs couchbase)
74
74
 
75
+ ADD_EXECUTABLE(durability minimal/durability.cc)
76
+ TARGET_LINK_LIBRARIES(durability couchbase)
77
+
75
78
  ADD_EXECUTABLE(minimal minimal/minimal.c)
76
79
  TARGET_LINK_LIBRARIES(minimal couchbase)
77
80
 
@@ -87,9 +90,6 @@ TARGET_LINK_LIBRARIES(g3cp couchbase)
87
90
  ADD_EXECUTABLE(g3cp-async minimal/g3cp-async.c)
88
91
  TARGET_LINK_LIBRARIES(g3cp-async couchbase)
89
92
 
90
- ADD_EXECUTABLE(durability observe/durability.c)
91
- TARGET_LINK_LIBRARIES(durability couchbase)
92
-
93
93
  ADD_EXECUTABLE(management-eventing management/eventing.cc)
94
94
  TARGET_LINK_LIBRARIES(management-eventing couchbase)
95
95
 
@@ -52,9 +52,17 @@ static void delete_timer()
52
52
  uv_close((uv_handle_t *)&timer, timer_close_cb);
53
53
  }
54
54
 
55
+ static void query_callback(lcb_INSTANCE *instance, int cbtype, const lcb_RESPQUERY *resp)
56
+ {
57
+ printf("invoke query callback: %s, final: %s\n", lcb_strerror_short(lcb_respquery_status(resp)),
58
+ lcb_respquery_is_final(resp) ? "true" : "false");
59
+ (void)instance;
60
+ (void)cbtype;
61
+ (void)resp;
62
+ }
63
+
55
64
  static void bootstrap_callback(lcb_INSTANCE *instance, lcb_STATUS err)
56
65
  {
57
- lcb_CMDSTORE *cmd;
58
66
  if (err != LCB_SUCCESS) {
59
67
  fprintf(stderr, "bootstrap error: %s\n", lcb_strerror_short(err));
60
68
  lcb_destroy_async(instance, NULL);
@@ -62,16 +70,35 @@ static void bootstrap_callback(lcb_INSTANCE *instance, lcb_STATUS err)
62
70
  }
63
71
  printf("successfully bootstrapped\n");
64
72
  fflush(stdout);
65
- /* Since we've got our configuration, let's go ahead and store a value */
66
- lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
67
- lcb_cmdstore_key(cmd, key, nkey);
68
- lcb_cmdstore_value(cmd, val, nval);
69
- err = lcb_store(instance, NULL, cmd);
70
- lcb_cmdstore_destroy(cmd);
71
- if (err != LCB_SUCCESS) {
72
- fprintf(stderr, "failed to set up store request: %s\n", lcb_strerror_short(err));
73
- lcb_destroy_async(instance, NULL);
74
- return;
73
+ {
74
+ /* Since we've got our configuration, let's go ahead and store a value */
75
+ lcb_CMDSTORE *cmd;
76
+ lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
77
+ lcb_cmdstore_key(cmd, key, nkey);
78
+ lcb_cmdstore_value(cmd, val, nval);
79
+ err = lcb_store(instance, NULL, cmd);
80
+ lcb_cmdstore_destroy(cmd);
81
+ if (err != LCB_SUCCESS) {
82
+ fprintf(stderr, "failed to set up store request: %s\n", lcb_strerror_short(err));
83
+ lcb_destroy_async(instance, NULL);
84
+ return;
85
+ }
86
+ }
87
+
88
+ {
89
+ lcb_CMDQUERY *cmd;
90
+ lcb_cmdquery_create(&cmd);
91
+ const char *statement = "SELECT 'hello' AS greeting";
92
+ lcb_cmdquery_statement(cmd, statement, strlen(statement));
93
+ lcb_cmdquery_callback(cmd, query_callback);
94
+ err = lcb_query(instance, NULL, cmd);
95
+ lcb_cmdquery_destroy(cmd);
96
+ if (err != LCB_SUCCESS) {
97
+ fprintf(stderr, "failed to set up query request: %s\n", lcb_strerror_short(err));
98
+ lcb_destroy_async(instance, NULL);
99
+ return;
100
+ }
101
+ printf("scheduled query\n");
75
102
  }
76
103
  }
77
104
 
@@ -238,7 +265,7 @@ int main(int argc, char **argv)
238
265
  nreq = nresp = atoi(argv[4]);
239
266
  }
240
267
  if (argc > 5) {
241
- interval = atoi(argv[4]);
268
+ interval = atoi(argv[5]);
242
269
  }
243
270
  /* Store the event base as the user cookie in our instance so that
244
271
  * we may terminate the program when we're done */
@@ -0,0 +1,149 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2017-2020 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include <string>
19
+ #include <iostream>
20
+ #include <cstdlib>
21
+
22
+ #include <libcouchbase/couchbase.h>
23
+
24
+ static void die(const char *msg, lcb_STATUS err)
25
+ {
26
+ std::cerr << "[ERROR] " << msg << ": " << lcb_strerror_short(err) << "\n";
27
+ exit(EXIT_FAILURE);
28
+ }
29
+
30
+ static void store_with_observe_callback(lcb_INSTANCE *, int, const lcb_RESPSTORE *resp)
31
+ {
32
+ lcb_STATUS rc = lcb_respstore_status(resp);
33
+ int store_ok, exists_master, persisted_master;
34
+ uint16_t num_responses, num_replicated, num_persisted;
35
+
36
+ lcb_respstore_observe_stored(resp, &store_ok);
37
+ lcb_respstore_observe_master_exists(resp, &exists_master);
38
+ lcb_respstore_observe_master_persisted(resp, &persisted_master);
39
+ lcb_respstore_observe_num_responses(resp, &num_responses);
40
+ lcb_respstore_observe_num_replicated(resp, &num_replicated);
41
+ lcb_respstore_observe_num_persisted(resp, &num_persisted);
42
+
43
+ std::cout << "Got status of operation: " << lcb_strerror_short(rc) << "\n";
44
+ std::cout << "Stored: " << (store_ok ? "true" : "false") << "\n";
45
+ std::cout << "Number of round-trips: " << num_responses << "\n";
46
+ std::cout << "In memory on master: " << (exists_master ? "true" : "false") << "\n";
47
+ std::cout << "Persisted on master: " << (persisted_master ? "true" : "false") << "\n";
48
+ std::cout << "Nodes have value replicated: " << num_replicated << "\n";
49
+ std::cout << "Nodes have value persisted (including master): " << num_persisted << "\n";
50
+ }
51
+
52
+ static void do_store_with_observe_durability(lcb_INSTANCE *instance)
53
+ {
54
+ lcb_install_callback(instance, LCB_CALLBACK_STORE, reinterpret_cast<lcb_RESPCALLBACK>(store_with_observe_callback));
55
+
56
+ std::string key = "docid";
57
+ std::string value = "[1,2,3]";
58
+
59
+ // tag::durability[]
60
+ lcb_CMDSTORE *cmd;
61
+ lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
62
+ lcb_cmdstore_key(cmd, key.data(), key.size());
63
+ lcb_cmdstore_value(cmd, value.data(), value.size());
64
+ lcb_cmdstore_durability_observe(cmd, -1, -1);
65
+ // end::durability[]
66
+
67
+ lcb_sched_enter(instance);
68
+ lcb_STATUS err = lcb_store(instance, nullptr, cmd);
69
+ lcb_cmdstore_destroy(cmd);
70
+ if (err != LCB_SUCCESS) {
71
+ printf("Unable to schedule store+durability operation: %s\n", lcb_strerror_short(err));
72
+ lcb_sched_fail(instance);
73
+ return;
74
+ }
75
+ lcb_sched_leave(instance);
76
+ lcb_wait(instance, LCB_WAIT_DEFAULT);
77
+ }
78
+
79
+ static void store_callback(lcb_INSTANCE *, int, const lcb_RESPSTORE *resp)
80
+ {
81
+ lcb_STATUS rc = lcb_respstore_status(resp);
82
+ std::cout << "Got status of operation: " << lcb_strerror_short(rc) << "\n";
83
+ }
84
+
85
+ static void do_store_with_server_durability(lcb_INSTANCE *instance)
86
+ {
87
+ lcb_install_callback(instance, LCB_CALLBACK_STORE, reinterpret_cast<lcb_RESPCALLBACK>(store_callback));
88
+
89
+ std::string key = "docid";
90
+ std::string value = "[1,2,3]";
91
+
92
+ lcb_CMDSTORE *cmd;
93
+ lcb_cmdstore_create(&cmd, LCB_STORE_UPSERT);
94
+ lcb_cmdstore_key(cmd, key.data(), key.size());
95
+ lcb_cmdstore_value(cmd, value.data(), value.size());
96
+ lcb_cmdstore_durability(cmd, LCB_DURABILITYLEVEL_MAJORITY);
97
+
98
+ lcb_sched_enter(instance);
99
+ lcb_STATUS err = lcb_store(instance, nullptr, cmd);
100
+ lcb_cmdstore_destroy(cmd);
101
+ if (err != LCB_SUCCESS) {
102
+ printf("Unable to schedule store+durability operation: %s\n", lcb_strerror_short(err));
103
+ lcb_sched_fail(instance);
104
+ return;
105
+ }
106
+ lcb_sched_leave(instance);
107
+ lcb_wait(instance, LCB_WAIT_DEFAULT);
108
+ }
109
+
110
+ int main(int, char **)
111
+ {
112
+ lcb_STATUS rc;
113
+ std::string connection_string = "couchbase://localhost";
114
+ std::string username = "Administrator";
115
+ std::string password = "password";
116
+
117
+ lcb_CREATEOPTS *create_options = nullptr;
118
+ lcb_createopts_create(&create_options, LCB_TYPE_BUCKET);
119
+ lcb_createopts_connstr(create_options, connection_string.data(), connection_string.size());
120
+ lcb_createopts_credentials(create_options, username.data(), username.size(), password.data(), password.size());
121
+
122
+ lcb_INSTANCE *instance;
123
+ rc = lcb_create(&instance, create_options);
124
+ lcb_createopts_destroy(create_options);
125
+ if (rc != LCB_SUCCESS) {
126
+ die("Couldn't create couchbase handle", rc);
127
+ }
128
+
129
+ rc = lcb_connect(instance);
130
+ if (rc != LCB_SUCCESS) {
131
+ die("Couldn't schedule connection", rc);
132
+ }
133
+
134
+ lcb_wait(instance, LCB_WAIT_DEFAULT);
135
+
136
+ rc = lcb_get_bootstrap_status(instance);
137
+ if (rc != LCB_SUCCESS) {
138
+ die("Couldn't bootstrap from cluster", rc);
139
+ }
140
+
141
+ std::cout << "--- Performing store with observe-based durability check\n";
142
+ do_store_with_observe_durability(instance);
143
+
144
+ std::cout << "--- Performing store server-side durability check\n";
145
+ do_store_with_server_durability(instance);
146
+
147
+ lcb_destroy(instance);
148
+ return 0;
149
+ }
@@ -71,7 +71,7 @@ static void row_callback(lcb_INSTANCE *instance, int type, const lcb_RESPQUERY *
71
71
 
72
72
  lcb_respquery_row(resp, &row, &nrow);
73
73
  ln2space(row, nrow);
74
- fprintf(stderr, "[\x1b[%dmQUERY\x1b[0m] %s, (%d) %.*s\n", err2color(rc), lcb_strerror_short(rc), (int)nrow,
74
+ fprintf(stderr, "[\x1b[%dmQUERY\x1b[0m] %s, (size=%d) %.*s\n", err2color(rc), lcb_strerror_short(rc), (int)nrow,
75
75
  (int)nrow, row);
76
76
  if (lcb_respquery_is_final(resp)) {
77
77
  fprintf(stderr, "\n");
@@ -120,7 +120,6 @@ static void sigint_handler(int unused)
120
120
 
121
121
  int main(int argc, char *argv[])
122
122
  {
123
- lcb_STATUS err;
124
123
  lcb_INSTANCE *instance;
125
124
  char *bucket = NULL;
126
125
  const char *key = "user:king_arthur";
@@ -171,11 +170,14 @@ int main(int argc, char *argv[])
171
170
  }
172
171
 
173
172
  {
174
- lcb_CMDN1XMGMT cmd = {0};
175
- cmd.callback = idx_callback;
176
- cmd.spec.flags = LCB_N1XSPEC_F_PRIMARY;
177
- cmd.spec.ixtype = LCB_N1XSPEC_T_GSI;
178
- check(lcb_n1x_create(instance, NULL, &cmd), "schedule N1QL index creation operation");
173
+ lcb_CMDQUERY *cmd;
174
+ char query[1024] = {0};
175
+ lcb_cmdquery_create(&cmd);
176
+ snprintf(query, sizeof(query), "CREATE PRIMARY INDEX ON `%s` USING gsi", bucket);
177
+ check(lcb_cmdquery_statement(cmd, query, strlen(query)), "set QUERY statement");
178
+ lcb_cmdquery_callback(cmd, row_callback);
179
+ check(lcb_query(instance, NULL, cmd), "schedule QUERY INDEX create operation");
180
+ lcb_cmdquery_destroy(cmd);
179
181
  lcb_wait(instance, LCB_WAIT_DEFAULT);
180
182
  }
181
183
 
@@ -189,12 +191,12 @@ int main(int argc, char *argv[])
189
191
  while (running) {
190
192
  lcb_CMDQUERY *cmd;
191
193
  char query[1024] = {0};
192
- const char *param = "\"African Swallows\"";
194
+ const char *params = "[\"African Swallows\"]";
193
195
  lcb_cmdquery_create(&cmd);
194
196
 
195
197
  snprintf(query, sizeof(query), "SELECT * FROM `%s` WHERE $1 in interests LIMIT 1", bucket);
196
198
  check(lcb_cmdquery_statement(cmd, query, strlen(query)), "set QUERY statement");
197
- check(lcb_cmdquery_positional_param(cmd, param, strlen(param)), "set QUERY positional parameter");
199
+ check(lcb_cmdquery_positional_params(cmd, params, strlen(params)), "set QUERY positional parameters");
198
200
  check(lcb_cmdquery_option(cmd, "pretty", strlen("pretty"), "false", strlen("false")),
199
201
  "set QUERY 'pretty' option");
200
202
  lcb_cmdquery_callback(cmd, row_callback);
@@ -33,7 +33,7 @@
33
33
  */
34
34
 
35
35
  /** @brief libcouchbase version string */
36
- #define LCB_VERSION_STRING "3.2.0-njs"
36
+ #define LCB_VERSION_STRING "3.2.4-njs"
37
37
 
38
38
  /**@brief libcouchbase hex version
39
39
  *
@@ -50,12 +50,12 @@
50
50
  * 2.1.3 | 0x020103
51
51
  * 3.0.15 | 0x030015
52
52
  */
53
- #define LCB_VERSION 0x030200
53
+ #define LCB_VERSION 0x030204
54
54
 
55
55
  /**@brief The SCM revision ID
56
56
  * @see LCB_CNTL_CHANGESET
57
57
  */
58
- #define LCB_VERSION_CHANGESET "c712686af5825f2f05c89112e555cd09906aa727"
58
+ #define LCB_VERSION_CHANGESET "38cc0708dfcc5a706c6b21dc80bcd84f05890225"
59
59
 
60
60
  /**@brief The client ID
61
61
  */
@@ -0,0 +1,243 @@
1
+ /* src/config.h. Generated from config.h.in by configure. */
2
+ /* src/config.h.in. Generated from configure.ac by autoheader. */
3
+
4
+ #if defined(_WIN32) && !defined(HAVE_CONFIG_H)
5
+ /* skip config.h contents on a non-autotools win32 build */
6
+ #include "win32/config.h"
7
+ #define CONFIG_H
8
+ #endif
9
+
10
+ #ifndef CONFIG_H
11
+ #define CONFIG_H
12
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
13
+ /*
14
+ * Copyright 2010, 2011 Couchbase, Inc.
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+
29
+ /*
30
+ * This file is generated by running configure. Any changes you make to this
31
+ * file will be overwritten the next time you run configure. If you want to
32
+ * make permanent changes to the file you should edit configure.ac instead.
33
+ * All platform-specific includes should be placed inside config_static.h
34
+ * to keep the config.h as small as possible. That allows us for easily
35
+ * use another build systems with a poor support for automake (like Windows)
36
+ *
37
+ * @author Trond Norbye
38
+ */
39
+
40
+ #define HAVE_PKCS5_PBKDF2_HMAC 1
41
+
42
+ #define HAVE_ARPA_NAMESER_H 1
43
+ #define HAVE_RES_SEARCH 1
44
+
45
+ /* Define if building universal (internal helper macro) */
46
+ /* #undef AC_APPLE_UNIVERSAL_BUILD */
47
+
48
+ /* Build plugins */
49
+ /* #undef BUILD_PLUGINS */
50
+
51
+ /* gcov enabled */
52
+ /* #undef ENABLE_GCOV */
53
+
54
+ /* tcov enabled */
55
+ /* #undef ENABLE_TCOV */
56
+
57
+ /* Define to 1 if you have the `alarm' function. */
58
+ #define HAVE_ALARM 1
59
+
60
+ /* Define to 1 if you have the <arpa/inet.h> header file. */
61
+ #define HAVE_ARPA_INET_H 1
62
+
63
+ /* Define to 1 if you have the `clock_gettime' function. */
64
+ /* #undef HAVE_CLOCK_GETTIME */
65
+
66
+ /* We have CouchbaseMock.jar */
67
+ /* #undef HAVE_COUCHBASEMOCK */
68
+
69
+ /* Define to 1 if you have the <dlfcn.h> header file. */
70
+ #define HAVE_DLFCN_H 1
71
+
72
+ /* Enables SystemTap / DTrace Support */
73
+ /* #undef HAVE_DTRACE */
74
+
75
+ /* Define to 1 if you have the <event.h> header file. */
76
+ /* #undef HAVE_EVENT_H */
77
+
78
+ /* Define to 1 if you have the <ev.h> header file. */
79
+ /* #undef HAVE_EV_H */
80
+
81
+ /* Define to 1 if you have the <fcntl.h> header file. */
82
+ #define HAVE_FCNTL_H 1
83
+
84
+ /* Define to 1 if you have the `gethrtime' function. */
85
+ /* #undef HAVE_GETHRTIME */
86
+
87
+ /* Define to 1 if you have the `gettimeofday' function. */
88
+ #define HAVE_GETTIMEOFDAY 1
89
+
90
+ /* Have ntohll */
91
+ /* #undef HAVE_HTONLL */
92
+
93
+ /* Define to 1 if you have the <inttypes.h> header file. */
94
+ #define HAVE_INTTYPES_H 1
95
+
96
+ /* I will build libcouchbase_debug.so */
97
+ /* #undef HAVE_LIBCOUCHBASE_DEBUG */
98
+
99
+ /* We have libev3 */
100
+ /* #undef HAVE_LIBEV3 */
101
+
102
+ /* We have libev4 */
103
+ /* #undef HAVE_LIBEV4 */
104
+
105
+ /* We have libevent */
106
+ /* #undef HAVE_LIBEVENT */
107
+
108
+ /* We have libevent2 */
109
+ /* #undef HAVE_LIBEVENT2 */
110
+
111
+ /* Have non-standard place for libev header */
112
+ /* #undef HAVE_LIBEV_EV_H */
113
+
114
+ /* We have libuv */
115
+ /* #undef HAVE_LIBUV */
116
+
117
+ /* Define to 1 if you have the `xnet' library (-lxnet). */
118
+ /* #undef HAVE_LIBXNET */
119
+
120
+ /* We have libyajl2 */
121
+ /* #undef HAVE_LIBYAJL2 */
122
+
123
+ /* Define to 1 if you have the <limits.h> header file. */
124
+ #define HAVE_LIMITS_H 1
125
+
126
+ /* Define to 1 if you have the <mach/mach_time.h> header file. */
127
+ /* #undef HAVE_MACH_MACH_TIME_H */
128
+
129
+ /* Define to 1 if you have the <memory.h> header file. */
130
+ #define HAVE_MEMORY_H 1
131
+
132
+ /* Define to 1 if you have the <netdb.h> header file. */
133
+ #define HAVE_NETDB_H 1
134
+
135
+ /* Define to 1 if you have the <netinet/in.h> header file. */
136
+ #define HAVE_NETINET_IN_H 1
137
+
138
+ /* Define to 1 if you have the `QueryPerformanceCounter' function. */
139
+ /* #undef HAVE_QUERYPERFORMANCECOUNTER */
140
+
141
+ /* Define to 1 if you have the `setitimer' function. */
142
+ #define HAVE_SETITIMER 1
143
+
144
+ /* Define to 1 if you have the <stdarg.h> header file. */
145
+ #define HAVE_STDARG_H 1
146
+
147
+ /* Define to 1 if you have the <stdint.h> header file. */
148
+ #define HAVE_STDINT_H 1
149
+
150
+ /* Define to 1 if you have the <stdlib.h> header file. */
151
+ #define HAVE_STDLIB_H 1
152
+
153
+ /* Define to 1 if you have the <strings.h> header file. */
154
+ #define HAVE_STRINGS_H 1
155
+
156
+ /* Define to 1 if you have the <string.h> header file. */
157
+ #define HAVE_STRING_H 1
158
+
159
+ /* Define to 1 if you have the <sys/sdt.h> header file. */
160
+ /* #undef HAVE_SYS_SDT_H */
161
+
162
+ /* Define to 1 if you have the <sys/socket.h> header file. */
163
+ #define HAVE_SYS_SOCKET_H 1
164
+
165
+ /* Define to 1 if you have the <sys/stat.h> header file. */
166
+ #define HAVE_SYS_STAT_H 1
167
+
168
+ /* Define to 1 if you have the <sys/time.h> header file. */
169
+ #define HAVE_SYS_TIME_H 1
170
+
171
+ /* Define to 1 if you have the <sys/types.h> header file. */
172
+ #define HAVE_SYS_TYPES_H 1
173
+
174
+ /* Define to 1 if you have the <sys/uio.h> header file. */
175
+ #define HAVE_SYS_UIO_H 1
176
+
177
+ /* Define to 1 if you have the <unistd.h> header file. */
178
+ #define HAVE_UNISTD_H 1
179
+
180
+ /* Define to 1 if you have the <winsock2.h> header file. */
181
+ /* #undef HAVE_WINSOCK2_H */
182
+
183
+ /* Define to 1 if you have the <ws2tcpip.h> header file. */
184
+ /* #undef HAVE_WS2TCPIP_H */
185
+
186
+ /* Define to the sub-directory in which libtool stores uninstalled libraries.
187
+ */
188
+ #define LT_OBJDIR ".libs/"
189
+
190
+ /* Define to 1 if your C compiler doesn't accept -c and -o together. */
191
+ /* #undef NO_MINUS_C_MINUS_O */
192
+
193
+ /* Define to 1 if you have the ANSI C header files. */
194
+ #define STDC_HEADERS 1
195
+
196
+ /* Defined for systems where EAGAIN != EWOULDBLOCK */
197
+ /* #undef USE_EAGAIN */
198
+
199
+ /* Enable extensions on AIX 3, Interix. */
200
+ #ifndef _ALL_SOURCE
201
+ #define _ALL_SOURCE 1
202
+ #endif
203
+ /* Enable GNU extensions on systems that have them. */
204
+ #ifndef _GNU_SOURCE
205
+ #define _GNU_SOURCE 1
206
+ #endif
207
+ /* Enable threading extensions on Solaris. */
208
+ #ifndef _POSIX_PTHREAD_SEMANTICS
209
+ #define _POSIX_PTHREAD_SEMANTICS 1
210
+ #endif
211
+ /* Enable extensions on HP NonStop. */
212
+ #ifndef _TANDEM_SOURCE
213
+ #define _TANDEM_SOURCE 1
214
+ #endif
215
+ /* Enable general extensions on Solaris. */
216
+ #ifndef __EXTENSIONS__
217
+ #define __EXTENSIONS__ 1
218
+ #endif
219
+
220
+ /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
221
+ significant byte first (like Motorola and SPARC, unlike Intel). */
222
+ #if defined AC_APPLE_UNIVERSAL_BUILD
223
+ #if defined __BIG_ENDIAN__
224
+ #define WORDS_BIGENDIAN 1
225
+ #endif
226
+ #else
227
+ #ifndef WORDS_BIGENDIAN
228
+ /* # undef WORDS_BIGENDIAN */
229
+ #endif
230
+ #endif
231
+
232
+ /* Define to 1 if on MINIX. */
233
+ /* #undef _MINIX */
234
+
235
+ /* Define to 2 if the system does not provide POSIX.1 features except with
236
+ this defined. */
237
+ /* #undef _POSIX_1_SOURCE */
238
+
239
+ /* Define to 1 if you need to in order for `stat' and other things to work. */
240
+ /* #undef _POSIX_SOURCE */
241
+
242
+ #include "config_static.h"
243
+ #endif