libcouchbase 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/ext/libcouchbase/CMakeLists.txt +51 -25
- data/ext/libcouchbase/CONTRIBUTING.md +46 -65
- data/ext/libcouchbase/RELEASE_NOTES.markdown +163 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +9 -11
- data/ext/libcouchbase/cmake/Modules/FindProfiler.cmake +16 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +6 -6
- data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
- data/ext/libcouchbase/cmake/configure +16 -0
- data/ext/libcouchbase/example/CMakeLists.txt +17 -2
- data/ext/libcouchbase/example/analytics/.gitignore +1 -0
- data/ext/libcouchbase/example/analytics/analytics.c +158 -0
- data/ext/libcouchbase/example/analytics/build-queries.rb +34 -0
- data/ext/libcouchbase/example/analytics/cJSON.c +1 -0
- data/ext/libcouchbase/example/analytics/cJSON.h +1 -0
- data/ext/libcouchbase/example/analytics/queries.h +113 -0
- data/ext/libcouchbase/example/analytics/queries/00-show-dataverse.json +5 -0
- data/ext/libcouchbase/example/analytics/queries/01-setup-dataset-breweries.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/02-setup-dataset-beers.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/03-initiate-shadow.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/04-list-datasets.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/05-count-breweries.json +5 -0
- data/ext/libcouchbase/example/analytics/queries/06-first-brewery.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/07-key-based-lookup.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/08-exact-match-lookup.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/09-exact-match-lookup-different-shape.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/10-other-query-filters.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/11-equijoin.json +9 -0
- data/ext/libcouchbase/example/analytics/queries/12-equijoin-select-star.json +10 -0
- data/ext/libcouchbase/example/analytics/queries/13-ansi-join.json +8 -0
- data/ext/libcouchbase/example/analytics/queries/14-join-select-values.json +8 -0
- data/ext/libcouchbase/example/analytics/queries/15-nested-outer-join.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/16-theta-join.json +8 -0
- data/ext/libcouchbase/example/analytics/queries/17-existential-quantification.json +9 -0
- data/ext/libcouchbase/example/analytics/queries/18-universal-quantification.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/19-simple-aggregation.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/20-simple-aggregation-unwrapped-value.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/21-simple-aggregation-explicit.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/22-grouping-and-aggregation.json +6 -0
- data/ext/libcouchbase/example/analytics/queries/23-grouping-and-aggregation-with-hint.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/24-grouping-and-limits.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/25-named-parameters.json +7 -0
- data/ext/libcouchbase/example/analytics/queries/26-positional-parameters.json +7 -0
- data/ext/libcouchbase/example/crypto/common_provider.c +2 -0
- data/ext/libcouchbase/example/crypto/common_provider.h +2 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +5 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +0 -1
- data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +16 -26
- data/ext/libcouchbase/example/db/db.c +10 -6
- data/ext/libcouchbase/example/fts/.gitignore +1 -0
- data/ext/libcouchbase/example/fts/build-queries.rb +33 -0
- data/ext/libcouchbase/example/fts/fts.c +142 -0
- data/ext/libcouchbase/example/fts/queries.h +61 -0
- data/ext/libcouchbase/example/fts/queries/00-simple-text-query.json +12 -0
- data/ext/libcouchbase/example/fts/queries/01-simple-text-query-on-non-default-index.json +9 -0
- data/ext/libcouchbase/example/fts/queries/02-simple-text-query-on-stored-field.json +13 -0
- data/ext/libcouchbase/example/fts/queries/03-match-query-with-facet.json +19 -0
- data/ext/libcouchbase/example/fts/queries/04-docid-query.json +11 -0
- data/ext/libcouchbase/example/fts/queries/05-unanalyzed-term-query-with-fuzziness-level-of-0.json +13 -0
- data/ext/libcouchbase/example/fts/queries/06-unanalyzed-term-query-with-fuzziness-level-of-2.json +14 -0
- data/ext/libcouchbase/example/fts/queries/07-match-phrase-query.json +13 -0
- data/ext/libcouchbase/example/fts/queries/08-phrase-query.json +16 -0
- data/ext/libcouchbase/example/fts/queries/09-query-string-query.json +9 -0
- data/ext/libcouchbase/example/fts/queries/10-conjunction-query.json +21 -0
- data/ext/libcouchbase/example/fts/queries/11-wild-card-query.json +13 -0
- data/ext/libcouchbase/example/fts/queries/12-numeric-range-query.json +11 -0
- data/ext/libcouchbase/example/fts/queries/13-regexp-query.json +13 -0
- data/ext/libcouchbase/example/minimal/.gitignore +1 -0
- data/ext/libcouchbase/example/minimal/query.c +185 -0
- data/ext/libcouchbase/example/subdoc/subdoc-xattrs.c +2 -2
- data/ext/libcouchbase/example/tracing/cJSON.c +1 -1
- data/ext/libcouchbase/example/tracing/cJSON.h +1 -1
- data/ext/libcouchbase/include/libcouchbase/cbft.h +38 -4
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +8 -97
- data/ext/libcouchbase/include/libcouchbase/cntl.h +288 -8
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +47 -10
- data/ext/libcouchbase/include/libcouchbase/crypto.h +214 -48
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +12 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +33 -2
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +1 -1
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +87 -13
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +3 -7
- data/ext/libcouchbase/include/libcouchbase/tracing.h +174 -56
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +21 -1
- data/ext/libcouchbase/include/libcouchbase/views.h +49 -4
- data/ext/libcouchbase/packaging/deb/control +2 -3
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +7 -5
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +7 -5
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +14 -12
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +3 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +14 -6
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +7 -5
- data/ext/libcouchbase/src/bootstrap.cc +6 -1
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +2 -7
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +1 -1
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +4 -11
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +29 -36
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +4 -2
- data/ext/libcouchbase/src/cntl.cc +181 -151
- data/ext/libcouchbase/src/config_static.h +1 -1
- data/ext/libcouchbase/src/connspec.cc +5 -1
- data/ext/libcouchbase/src/connspec.h +3 -1
- data/ext/libcouchbase/src/crypto.cc +93 -80
- data/ext/libcouchbase/src/dns-srv.cc +1 -1
- data/ext/libcouchbase/src/handler.cc +0 -1
- data/ext/libcouchbase/src/http/http-priv.h +1 -0
- data/ext/libcouchbase/src/http/http.cc +1 -2
- data/ext/libcouchbase/src/instance.cc +21 -2
- data/ext/libcouchbase/src/internal.h +1 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +24 -3
- data/ext/libcouchbase/src/lcbio/ioutils.cc +1 -1
- data/ext/libcouchbase/src/lcbio/rw-inl.h +22 -1
- data/ext/libcouchbase/src/lcbio/ssl.h +2 -0
- data/ext/libcouchbase/src/mc/compress.cc +18 -11
- data/ext/libcouchbase/src/mc/mcreq.c +2 -0
- data/ext/libcouchbase/src/mc/mcreq.h +1 -1
- data/ext/libcouchbase/src/mcserver/mcserver.cc +163 -6
- data/ext/libcouchbase/src/mcserver/negotiate.cc +17 -7
- data/ext/libcouchbase/src/n1ql/n1ql.cc +12 -3
- data/ext/libcouchbase/src/newconfig.cc +4 -3
- data/ext/libcouchbase/src/nodeinfo.cc +1 -7
- data/ext/libcouchbase/src/operations/observe.cc +1 -0
- data/ext/libcouchbase/src/operations/ping.cc +5 -3
- data/ext/libcouchbase/src/retryq.cc +22 -0
- data/ext/libcouchbase/src/retryq.h +2 -1
- data/ext/libcouchbase/src/rnd.cc +5 -12
- data/ext/libcouchbase/src/settings.c +4 -7
- data/ext/libcouchbase/src/settings.h +6 -2
- data/ext/libcouchbase/src/strcodecs/base64.c +59 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +2 -0
- data/ext/libcouchbase/src/trace.h +2 -2
- data/ext/libcouchbase/src/tracing/span.cc +177 -45
- data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +70 -28
- data/ext/libcouchbase/src/tracing/tracing-internal.h +33 -48
- data/ext/libcouchbase/src/vbucket/vbucket.c +146 -30
- data/ext/libcouchbase/src/wait.cc +1 -1
- data/ext/libcouchbase/tests/CMakeLists.txt +13 -4
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_misc.cc +2 -2
- data/ext/libcouchbase/tests/iotests/t_views.cc +1 -1
- data/ext/libcouchbase/tests/iotests/testutil.cc +3 -2
- data/ext/libcouchbase/tests/vbucket/confdata/map_node_present_nodesext_missing_nodes.json +94 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +15 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +11 -6
- data/ext/libcouchbase/tools/cbc-handlers.h +9 -0
- data/ext/libcouchbase/tools/cbc-proxy.cc +1 -1
- data/ext/libcouchbase/tools/cbc.cc +33 -5
- data/ext/libcouchbase/tools/common/options.cc +1 -1
- data/ext/libcouchbase/tools/extract-packets.rb +110 -0
- data/lib/libcouchbase/connection.rb +13 -5
- data/lib/libcouchbase/ext/tasks.rb +1 -1
- data/lib/libcouchbase/version.rb +1 -1
- metadata +62 -7
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Fetch list of all breweries paired with their associated beers, with the
|
|
3
|
+
// list enumerating the brewery name and the beer name for each such pair,
|
|
4
|
+
// while also limiting the answer set size to at most 3 results.
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT bw.name AS brewer, br.name AS beer FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Fetch list of all breweries paired with their associated beers, including
|
|
3
|
+
// all attributes, while also limiting the answer set size to at most 3
|
|
4
|
+
// results.
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT * FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3",
|
|
7
|
+
"pretty": true
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Fetch list of all breweries paired with their associated beers, including
|
|
3
|
+
// all attributes, while also limiting the answer set size to at most 3
|
|
4
|
+
// results. With ANSI JOINS!
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT * FROM breweries bw JOIN beers br ON br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3",
|
|
7
|
+
"pretty": true
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Fetch list of all breweries paired with their associated beers, including
|
|
3
|
+
// all attributes, while also limiting the answer set size to at most 3
|
|
4
|
+
// results. Select values explicitly.
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT VALUE {\"bw\": bw, \"br\": br} FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id ORDER BY bw.name, br.name LIMIT 3",
|
|
7
|
+
"pretty": true
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// For each brewery produce an object that contains the brewery name along with
|
|
3
|
+
// a list of all of the brewery’s offered beer names and alcohol percentages
|
|
4
|
+
{
|
|
5
|
+
"statement": "SELECT bw.name AS brewer, (SELECT br.name, br.abv FROM beers br WHERE br.brewery_id = meta(bw).id ORDER BY br.name) AS beers FROM breweries bw ORDER BY bw.name LIMIT 2",
|
|
6
|
+
"pretty": true
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// For each Arizona brewery get the brewery's name, location, and a list of
|
|
3
|
+
// competitors' names -- where competitors are other breweries that are
|
|
4
|
+
// geographically close to their location
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT bw1.name AS brewer, bw1.geo AS location, (SELECT VALUE bw2.name FROM breweries bw2 WHERE bw2.name != bw1.name AND abs(bw1.geo.lat - bw2.geo.lat) <= 0.1 AND abs(bw2.geo.lon - bw1.geo.lon) <= 0.1) AS competitors FROM breweries bw1 WHERE bw1.state = 'Arizona' ORDER BY bw1.name LIMIT 3",
|
|
7
|
+
"pretty": true
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Find those breweries whose beers include at least one IPA and return the
|
|
3
|
+
// brewery’s name, phone number, and complete list of beer names and associated
|
|
4
|
+
// alcohol levels.
|
|
5
|
+
{
|
|
6
|
+
"statement": "WITH nested_breweries AS ( SELECT bw.name AS brewer, bw.phone, ( SELECT br.name, br.abv FROM beers br WHERE br.brewery_id = meta(bw).id ORDER BY br.name) AS beers FROM breweries bw) SELECT VALUE nb FROM nested_breweries nb WHERE (SOME b IN nb.beers SATISFIES b.name LIKE '%IPA%') ORDER BY nb.brewer LIMIT 2",
|
|
7
|
+
"pretty": true
|
|
8
|
+
}
|
|
9
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Find those breweries that only have seriously strong beers
|
|
3
|
+
{
|
|
4
|
+
"statement": "WITH nested_breweries AS ( SELECT bw.name AS brewer, bw.phone, ( SELECT br.name, br.abv FROM beers br WHERE br.brewery_id = meta(bw).id ORDER BY br.name) AS beers FROM breweries bw) SELECT VALUE nb FROM nested_breweries nb WHERE (EVERY b IN nb.beers SATISFIES b.abv >= 10) AND ARRAY_COUNT(nb.beers) > 0 ORDER BY nb.brewer LIMIT 5",
|
|
5
|
+
"pretty": true
|
|
6
|
+
}
|
|
7
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// For each brewery that offers more than 30 beers, the following group-by or
|
|
3
|
+
// aggregate query reports the number of beers that it offers
|
|
4
|
+
{
|
|
5
|
+
"statement": "SELECT br.brewery_id, COUNT(*) AS num_beers FROM beers br GROUP BY br.brewery_id HAVING COUNT(*) > 30 ORDER BY COUNT(*) DESC"
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// For each brewery that offers more than 30 beers, the following group-by or
|
|
3
|
+
// aggregate query reports the number of beers that it offers. With a
|
|
4
|
+
// hash-based aggregation hint.
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT br.brewery_id, COUNT(*) AS num_beers FROM beers br /*+ hash */ GROUP BY br.brewery_id HAVING COUNT(*) > 30 ORDER BY COUNT(*) DESC"
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// vim: ft=javascript
|
|
2
|
+
// Return the top three breweries based on their numbers of offered beers. Also
|
|
3
|
+
// illustrate the use of multiple aggregate functions to compute various
|
|
4
|
+
// alcohol content statistics for their beers
|
|
5
|
+
{
|
|
6
|
+
"statement": "SELECT bw.name, COUNT(*) AS num_beers, AVG(br.abv) AS abv_avg, MIN(br.abv) AS abv_min, MAX(br.abv) AS abv_max FROM breweries bw, beers br WHERE br.brewery_id = meta(bw).id GROUP BY bw.name ORDER BY num_beers DESC LIMIT 3"
|
|
7
|
+
}
|
|
@@ -39,6 +39,7 @@ static void op_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
|
|
|
39
39
|
if (rb->rc == LCB_SUCCESS) {
|
|
40
40
|
const lcb_RESPGET *rg = (const lcb_RESPGET *)rb;
|
|
41
41
|
lcbcrypto_CMDDECRYPT dcmd = {};
|
|
42
|
+
lcbcrypto_FIELDSPEC field = {};
|
|
42
43
|
lcb_error_t err;
|
|
43
44
|
|
|
44
45
|
printf("VALUE: %.*s\n", (int)rg->nvalue, rg->value);
|
|
@@ -48,6 +49,10 @@ static void op_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
|
|
|
48
49
|
dcmd.ndoc = rg->nvalue;
|
|
49
50
|
dcmd.out = NULL;
|
|
50
51
|
dcmd.nout = 0;
|
|
52
|
+
dcmd.nfields = 1;
|
|
53
|
+
dcmd.fields = &field;
|
|
54
|
+
field.name = "message";
|
|
55
|
+
field.alg = "AES-256-HMAC-SHA256";
|
|
51
56
|
err = lcbcrypto_decrypt_fields(instance, &dcmd);
|
|
52
57
|
if (err != LCB_SUCCESS) {
|
|
53
58
|
die(instance, "Couldn't decrypt field 'message'", err);
|
|
@@ -63,7 +63,6 @@ static void store_encrypted(lcb_t instance, const char *key, const char *val)
|
|
|
63
63
|
ecmd.fields = &field;
|
|
64
64
|
field.name = "message";
|
|
65
65
|
field.alg = "AES-256-HMAC-SHA256";
|
|
66
|
-
field.kid = "mypublickey";
|
|
67
66
|
|
|
68
67
|
err = lcbcrypto_encrypt_fields(instance, &ecmd);
|
|
69
68
|
if (err != LCB_SUCCESS) {
|
|
@@ -41,17 +41,9 @@ static void osp_release_bytes(lcbcrypto_PROVIDER *provider, void *bytes)
|
|
|
41
41
|
(void)provider;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
static
|
|
45
|
-
uint8_t **key, size_t *key_len)
|
|
44
|
+
static const char *osp_get_key_id(lcbcrypto_PROVIDER *provider)
|
|
46
45
|
{
|
|
47
|
-
|
|
48
|
-
*key = malloc(*key_len);
|
|
49
|
-
memcpy(*key, common_aes256_key, *key_len);
|
|
50
|
-
|
|
51
|
-
(void)type;
|
|
52
|
-
(void)keyid;
|
|
53
|
-
(void)provider;
|
|
54
|
-
return LCB_SUCCESS;
|
|
46
|
+
return common_aes256_key_id;
|
|
55
47
|
}
|
|
56
48
|
|
|
57
49
|
static lcb_error_t osp_generate_iv(struct lcbcrypto_PROVIDER *provider, uint8_t **iv, size_t *iv_len)
|
|
@@ -170,15 +162,14 @@ static lcb_error_t osp_verify_signature(struct lcbcrypto_PROVIDER *provider, con
|
|
|
170
162
|
}
|
|
171
163
|
|
|
172
164
|
static lcb_error_t osp_encrypt(struct lcbcrypto_PROVIDER *provider, const uint8_t *input, size_t input_len,
|
|
173
|
-
const uint8_t *
|
|
174
|
-
size_t *output_len)
|
|
165
|
+
const uint8_t *iv, size_t iv_len, uint8_t **output, size_t *output_len)
|
|
175
166
|
{
|
|
176
167
|
EVP_CIPHER_CTX *ctx;
|
|
177
168
|
const EVP_CIPHER *cipher;
|
|
178
169
|
int rc, len, block_len, out_len;
|
|
179
170
|
uint8_t *out;
|
|
180
171
|
|
|
181
|
-
if (iv_len != 16
|
|
172
|
+
if (iv_len != 16) {
|
|
182
173
|
return LCB_EINVAL;
|
|
183
174
|
}
|
|
184
175
|
|
|
@@ -187,7 +178,7 @@ static lcb_error_t osp_encrypt(struct lcbcrypto_PROVIDER *provider, const uint8_
|
|
|
187
178
|
return LCB_EINVAL;
|
|
188
179
|
}
|
|
189
180
|
cipher = EVP_aes_256_cbc();
|
|
190
|
-
rc = EVP_EncryptInit_ex(ctx, cipher, NULL,
|
|
181
|
+
rc = EVP_EncryptInit_ex(ctx, cipher, NULL, common_aes256_key, iv);
|
|
191
182
|
if (rc != 1) {
|
|
192
183
|
EVP_CIPHER_CTX_free(ctx);
|
|
193
184
|
return LCB_EINVAL;
|
|
@@ -215,15 +206,14 @@ static lcb_error_t osp_encrypt(struct lcbcrypto_PROVIDER *provider, const uint8_
|
|
|
215
206
|
}
|
|
216
207
|
|
|
217
208
|
static lcb_error_t osp_decrypt(struct lcbcrypto_PROVIDER *provider, const uint8_t *input, size_t input_len,
|
|
218
|
-
const uint8_t *
|
|
219
|
-
size_t *output_len)
|
|
209
|
+
const uint8_t *iv, size_t iv_len, uint8_t **output, size_t *output_len)
|
|
220
210
|
{
|
|
221
211
|
EVP_CIPHER_CTX *ctx;
|
|
222
212
|
const EVP_CIPHER *cipher;
|
|
223
213
|
int rc, len, out_len;
|
|
224
214
|
uint8_t *out;
|
|
225
215
|
|
|
226
|
-
if (iv_len != 16
|
|
216
|
+
if (iv_len != 16) {
|
|
227
217
|
return LCB_EINVAL;
|
|
228
218
|
}
|
|
229
219
|
|
|
@@ -232,7 +222,7 @@ static lcb_error_t osp_decrypt(struct lcbcrypto_PROVIDER *provider, const uint8_
|
|
|
232
222
|
return LCB_EINVAL;
|
|
233
223
|
}
|
|
234
224
|
cipher = EVP_aes_256_cbc();
|
|
235
|
-
rc = EVP_DecryptInit_ex(ctx, cipher, NULL,
|
|
225
|
+
rc = EVP_DecryptInit_ex(ctx, cipher, NULL, common_aes256_key, iv);
|
|
236
226
|
if (rc != 1) {
|
|
237
227
|
EVP_CIPHER_CTX_free(ctx);
|
|
238
228
|
return LCB_EINVAL;
|
|
@@ -261,15 +251,15 @@ static lcb_error_t osp_decrypt(struct lcbcrypto_PROVIDER *provider, const uint8_
|
|
|
261
251
|
lcbcrypto_PROVIDER *osp_create()
|
|
262
252
|
{
|
|
263
253
|
lcbcrypto_PROVIDER *provider = calloc(1, sizeof(lcbcrypto_PROVIDER));
|
|
264
|
-
provider->version =
|
|
254
|
+
provider->version = 1;
|
|
265
255
|
provider->destructor = osp_free;
|
|
266
|
-
provider->v.
|
|
267
|
-
provider->v.
|
|
268
|
-
provider->v.
|
|
269
|
-
provider->v.
|
|
270
|
-
provider->v.
|
|
271
|
-
provider->v.
|
|
272
|
-
provider->v.
|
|
256
|
+
provider->v.v1.release_bytes = osp_release_bytes;
|
|
257
|
+
provider->v.v1.generate_iv = osp_generate_iv;
|
|
258
|
+
provider->v.v1.sign = osp_sign;
|
|
259
|
+
provider->v.v1.verify_signature = osp_verify_signature;
|
|
260
|
+
provider->v.v1.encrypt = osp_encrypt;
|
|
261
|
+
provider->v.v1.decrypt = osp_decrypt;
|
|
262
|
+
provider->v.v1.get_key_id = osp_get_key_id;
|
|
273
263
|
return provider;
|
|
274
264
|
}
|
|
275
265
|
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* RUN:
|
|
27
27
|
*
|
|
28
28
|
* valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes ./db
|
|
29
|
-
* ./db key size <host:port> <bucket> <passwd>
|
|
30
|
-
* db.exe key size <host:port> <bucket> <passwd>
|
|
29
|
+
* ./db key size <host:port> <bucket> <passwd> <username>
|
|
30
|
+
* db.exe key size <host:port> <bucket> <passwd> <username>
|
|
31
31
|
*/
|
|
32
32
|
#include <stdio.h>
|
|
33
33
|
#include <libcouchbase/couchbase.h>
|
|
@@ -106,6 +106,9 @@ int main(int argc, char *argv[])
|
|
|
106
106
|
if (argc > 4) {
|
|
107
107
|
create_options.v.v3.passwd = argv[4];
|
|
108
108
|
}
|
|
109
|
+
if (argc > 5) {
|
|
110
|
+
create_options.v.v3.username = argv[5];
|
|
111
|
+
}
|
|
109
112
|
|
|
110
113
|
INSTALL_SIGINT_HANDLER();
|
|
111
114
|
|
|
@@ -151,16 +154,17 @@ int main(int argc, char *argv[])
|
|
|
151
154
|
}
|
|
152
155
|
lcb_wait3(instance, LCB_WAIT_NOCHECK);
|
|
153
156
|
fprintf(stderr, "Benchmarking... CTRL-C to stop\n");
|
|
154
|
-
{
|
|
155
|
-
lcb_CMDGET cmd = {
|
|
157
|
+
while (1) {
|
|
158
|
+
lcb_CMDGET cmd = {0};
|
|
156
159
|
LCB_CMD_SET_KEY(&cmd, key, nkey);
|
|
157
160
|
err = lcb_get3(instance, NULL, &cmd);
|
|
158
161
|
if (err != LCB_SUCCESS) {
|
|
159
|
-
fprintf(stderr, "Failed to get: %s\n", lcb_strerror(NULL, err));
|
|
162
|
+
fprintf(stderr, "Failed to schedule get operation: %s\n", lcb_strerror(NULL, err));
|
|
160
163
|
exit(EXIT_FAILURE);
|
|
161
164
|
}
|
|
165
|
+
lcb_wait3(instance, LCB_WAIT_NOCHECK);
|
|
166
|
+
fprintf(stderr, "retry\n");
|
|
162
167
|
}
|
|
163
|
-
lcb_wait3(instance, LCB_WAIT_NOCHECK);
|
|
164
168
|
lcb_destroy(instance);
|
|
165
169
|
|
|
166
170
|
exit(EXIT_SUCCESS);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fts
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
# Copyright 2018 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
|
+
require 'json'
|
|
18
|
+
|
|
19
|
+
paths = Dir[File.join(__dir__, 'queries', '*.json')].sort
|
|
20
|
+
File.open(File.join(__dir__, 'queries.h'), 'w+') do |out|
|
|
21
|
+
out.puts("// This file was generated by queries.rb")
|
|
22
|
+
out.puts("typedef struct fts_query_str { const char *comment; size_t query_len; const char *query; } fts_query_str;")
|
|
23
|
+
out.puts("size_t num_queries = #{paths.size};")
|
|
24
|
+
out.puts("fts_query_str queries[#{paths.size + 1}] = {")
|
|
25
|
+
paths.each do |path|
|
|
26
|
+
lines = File.readlines(path)
|
|
27
|
+
comment = lines[1].gsub(%r{^//\s*}, '').strip
|
|
28
|
+
query = lines.reject { |line| line.start_with?('//') }.join
|
|
29
|
+
query_str = JSON.generate(JSON.parse(query))
|
|
30
|
+
out.puts("{#{comment.inspect},\n #{query_str.size},\n #{query_str.inspect}},\n\n")
|
|
31
|
+
end
|
|
32
|
+
out.puts("{NULL, 0, NULL}};")
|
|
33
|
+
end
|