MCPcopy Create free account
hub / github.com/Tencent/phxsql / GetDBNameFromAuthBuf

Method GetDBNameFromAuthBuf

phxsqlproxy/io_channel.cpp:233–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void IOChannel::GetDBNameFromAuthBuf(const char * buf, int buf_size) {
234 if (buf_size < 36) {
235 return;
236 }
237
238 uint32_t client_property = 0;
239 memcpy(&client_property, buf + 4, 4);
240
241 if (client_property & CLIENT_CONNECT_WITH_DB) {
242 const char * offset = buf + 36;
243 //skip username
244 offset += strlen(offset) + 1;
245
246 //skip authorize data
247 int len_field_size = 0;
248 uint64_t len = DecodedLengthBinary(offset, buf_size - (offset - buf), len_field_size);
249 if (len == (uint64_t)(-1LL))
250 return;
251 offset += len_field_size + len;
252
253 //this is the db's name
254 if (strlen(offset)) {
255 db_name_ = std::string(offset, strlen(offset));
256 }
257 LOG_DEBUG("client property %u CLIENT_CONNECT_WITH_DB %d ret db [%s]",
258 client_property, (int) CLIENT_CONNECT_WITH_DB, db_name_.c_str());
259 }
260}
261
262void IOChannel::GetDBNameFromReqBuf(const char * buf, int buf_size) {
263 if (buf_size > 5) {

Callers

nothing calls this directly

Calls 1

DecodedLengthBinaryFunction · 0.85

Tested by

no test coverage detected