MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / Name_string

Class Name_string

sql/item.h:350–407  ·  view source on GitHub ↗

Storage for name strings. Enpowers Simple_cstring with allocation routines from the sql_strmake family. This class must stay as small as possible as we often pass it into functions using call-by-value evaluation. Don't add new members or virual methods into this class! */

Source from the content-addressed store, hash-verified

348 Don't add new members or virual methods into this class!
349*/
350class Name_string: public Simple_cstring
351{
352private:
353 void set_or_copy(const char *str, size_t length, bool is_null_terminated)
354 {
355 if (is_null_terminated)
356 set(str, length);
357 else
358 copy(str, length);
359 }
360public:
361 Name_string(): Simple_cstring() {}
362 /*
363 Please do NOT add constructor Name_string(const char *str) !
364 It will involve hidden strlen() call, which can affect
365 performance negatively. Use Name_string(str, len) instead.
366 */
367 Name_string(const char *str, size_t length):
368 Simple_cstring(str, length) {}
369 Name_string(const LEX_STRING str): Simple_cstring(str) {}
370 Name_string(const char *str, size_t length, bool is_null_terminated):
371 Simple_cstring()
372 {
373 set_or_copy(str, length, is_null_terminated);
374 }
375 Name_string(const LEX_STRING str, bool is_null_terminated):
376 Simple_cstring()
377 {
378 set_or_copy(str.str, str.length, is_null_terminated);
379 }
380 /**
381 Allocate space using sql_strmake() or sql_strmake_with_convert().
382 */
383 void copy(const char *str, size_t length, const CHARSET_INFO *cs);
384 /**
385 Variants for copy(), for various argument combinations.
386 */
387 void copy(const char *str, size_t length)
388 {
389 copy(str, length, system_charset_info);
390 }
391 void copy(const char *str)
392 {
393 copy(str, (str ? strlen(str) : 0), system_charset_info);
394 }
395 void copy(const LEX_STRING lex)
396 {
397 copy(lex.str, lex.length);
398 }
399 void copy(const LEX_STRING *lex)
400 {
401 copy(lex->str, lex->length);
402 }
403 void copy(const Name_string str)
404 {
405 copy(str.ptr(), str.length());
406 }
407};

Callers 6

Item_blobMethod · 0.85
Item_empty_stringMethod · 0.85
Item_return_intMethod · 0.85
copy_nameMethod · 0.85
Item_case_exprMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected