Skip to content

Conversation

theyueli
Copy link
Contributor

@theyueli theyueli commented Dec 6, 2023

fixes #2242 #2253

Reference:
The definition of Redis verbatim strings: https://redis.io/docs/reference/protocol-spec/#verbatim-strings

"For example, the Redis command INFO outputs a report that includes newlines. When using RESP3, redis-cli displays it correctly because it is sent as a Verbatim String reply (with its three bytes being "txt"). When using RESP2, however, the redis-cli is hard-coded to look for the INFO command to ensure its correct display to the user."

@theyueli theyueli added bug Something isn't working enhancement New feature or request labels Dec 6, 2023
@theyueli theyueli self-assigned this Dec 6, 2023
DVLOG(1) << "Unknown verbatim reply format: " << format;
return;
}
iovec v[4] = {IoVec(lenpref), IoVec(format_str), IoVec(str), IoVec(kCRLF)};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a small preference to reduce number of vectors (it's more efficient).
Therefore, I suggest to increase tmp buffer size to accommodate the format prefix as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done.

chakaz
chakaz previously approved these changes Dec 6, 2023
if (!is_resp3_)
return SendBulkString(str);

char tmp[absl::numbers_internal::kFastToBufferSize + 7];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: if you use std::array you'll get out-of-bound checks in debug runs (plus .size() instead of ABSL_ARRAYSIZE)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will keep the raw array to be consistent with other places...

@theyueli theyueli merged commit f89b65c into dragonflydb:main Dec 7, 2023
@theyueli theyueli deleted the verbatim branch December 7, 2023 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: INFO command shall use verbatim string for its reply when RESP3 is used
3 participants