Skip to content

Commit b347d91

Browse files
committed
MB-41550: Add hello flag for SubdocReplaceBodyWithXattr
Change-Id: I5de5276bc77078b2a33f7954b8aef843149a47ab Reviewed-on: http://review.couchbase.org/c/kv_engine/+/138165 Tested-by: Build Bot <[email protected]> Reviewed-by: Paolo Cocchi <[email protected]>
1 parent a029b1e commit b347d91

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

daemon/datatype_filter.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void DatatypeFilter::enable(cb::mcbp::Feature feature) {
5151
case cb::mcbp::Feature::PiTR:
5252
case cb::mcbp::Feature::SubdocCreateAsDeleted:
5353
case cb::mcbp::Feature::SubdocDocumentMacroSupport:
54+
case cb::mcbp::Feature::SubdocReplaceBodyWithXattr:
5455
throw std::invalid_argument("Datatype::enable invalid feature:" +
5556
std::to_string(int(feature)));
5657
}

daemon/protocol/mcbp/hello_packet_executor.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void buildRequestVector(FeatureSet& requested, cb::sized_buffer<const uint16_t>
8585
case cb::mcbp::Feature::PiTR:
8686
case cb::mcbp::Feature::SubdocCreateAsDeleted:
8787
case cb::mcbp::Feature::SubdocDocumentMacroSupport:
88+
case cb::mcbp::Feature::SubdocReplaceBodyWithXattr:
8889

8990
// This isn't very optimal, but we've only got a handfull of elements ;)
9091
if (!containsFeature(requested, feature)) {
@@ -118,6 +119,7 @@ void buildRequestVector(FeatureSet& requested, cb::sized_buffer<const uint16_t>
118119
case cb::mcbp::Feature::PreserveTtl:
119120
case cb::mcbp::Feature::PiTR:
120121
case cb::mcbp::Feature::SubdocCreateAsDeleted:
122+
case cb::mcbp::Feature::SubdocReplaceBodyWithXattr:
121123
// No other dependency
122124
break;
123125

@@ -353,7 +355,8 @@ void process_hello_packet_executor(Cookie& cookie) {
353355
case cb::mcbp::Feature::SubdocDocumentMacroSupport:
354356
case cb::mcbp::Feature::PiTR:
355357
case cb::mcbp::Feature::SubdocCreateAsDeleted:
356-
// VAttr, PiTR, SubdocCreateAsDeleted are only informative
358+
case cb::mcbp::Feature::SubdocReplaceBodyWithXattr:
359+
// Informative features don't need special handling
357360
added = true;
358361
break;
359362
} // end switch

docs/BinaryProtocol.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,7 @@ The following features is defined:
18251825
| 0x0016 | PiTR |
18261826
| 0x0017 | SubdocCreateAsDeleted support |
18271827
| 0x0018 | SubdocDocumentMacroSupport |
1828+
| 0x0019 | SubdocReplaceBodyWithXattr |
18281829

18291830
* `Datatype` - The client understands the 'non-null' values in the
18301831
[datatype field](#data-types). The server expects the client to fill
@@ -1908,6 +1909,9 @@ The following features is defined:
19081909
disable anything on the server). It may be used from the client to
19091910
determine if the server supports using the virtual attribute $document
19101911
in macros. Requires XATTR
1912+
* `SubdocReplaceBodyWithXattr` This is purely information (it does not enable /
1913+
disable anything on the server). It may be used from the client to
1914+
determine if the server supports the command SubdocReplaceBodyWithXattr.
19111915

19121916
Response:
19131917

include/mcbp/protocol/feature.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <cstdint>
2020
#include <string>
2121

22-
namespace cb {
23-
namespace mcbp {
22+
namespace cb::mcbp {
23+
2424
/**
2525
* Definition of hello's features.
2626
* Note regarding JSON:0x1. Previously this was named DATATYPE and
@@ -88,9 +88,12 @@ enum class Feature : uint16_t {
8888
/// Does the server support using the virtual $document attributes in macro
8989
/// expansion ( "${document.CAS}" etc)
9090
SubdocDocumentMacroSupport = 0x18,
91+
92+
/// Does the server support SubdocReplaceBodyWithXattr introduced in
93+
/// Cheshire-Cat
94+
SubdocReplaceBodyWithXattr = 0x19,
9195
};
9296

93-
} // namespace mcbp
94-
} // namespace cb
97+
} // namespace cb::mcbp
9598

9699
std::string to_string(cb::mcbp::Feature feature);

protocol/mcbp/feature.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ std::string to_string(cb::mcbp::Feature feature) {
6969
return "SubdocCreateAsDeleted";
7070
case cb::mcbp::Feature::SubdocDocumentMacroSupport:
7171
return "SubdocDocumentMacroSupport";
72+
case cb::mcbp::Feature::SubdocReplaceBodyWithXattr:
73+
return "SubdocReplaceBodyWithXattr";
7274
}
7375

7476
throw std::invalid_argument(

protocol/mcbp/feature_test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ const std::map<cb::mcbp::Feature, std::string> blueprint = {
4444
{cb::mcbp::Feature::PiTR, "PiTR"},
4545
{cb::mcbp::Feature::SubdocCreateAsDeleted, "SubdocCreateAsDeleted"},
4646
{cb::mcbp::Feature::SubdocDocumentMacroSupport,
47-
"SubdocDocumentMacroSupport"}}};
47+
"SubdocDocumentMacroSupport"},
48+
{cb::mcbp::Feature::SubdocReplaceBodyWithXattr,
49+
"SubdocReplaceBodyWithXattr"}}};
4850

4951
TEST(to_string, LegalValues) {
5052
for (const auto& entry : blueprint) {

tests/testapp/testapp.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,8 @@ MemcachedConnection& TestappTest::prepare(MemcachedConnection& connection) {
13021302
{cb::mcbp::Feature::MUTATION_SEQNO,
13031303
cb::mcbp::Feature::XATTR,
13041304
cb::mcbp::Feature::XERROR,
1305-
cb::mcbp::Feature::SELECT_BUCKET}};
1305+
cb::mcbp::Feature::SELECT_BUCKET,
1306+
cb::mcbp::Feature::SubdocReplaceBodyWithXattr}};
13061307
if (hasSnappySupport() == ClientSnappySupport::Yes) {
13071308
features.push_back(cb::mcbp::Feature::SNAPPY);
13081309
}

0 commit comments

Comments
 (0)