MCPcopy Create free account
hub / github.com/MariaDB/server / assign_fixed_string

Function assign_fixed_string

sql/sql_signal.cc:81–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81static bool assign_fixed_string(MEM_ROOT *mem_root,
82 CHARSET_INFO *dst_cs,
83 size_t max_char,
84 String *dst,
85 const String* src)
86{
87 bool truncated;
88 size_t numchars;
89 CHARSET_INFO *src_cs;
90 const char* src_str;
91 const char* src_end;
92 size_t src_len;
93 size_t to_copy;
94 char* dst_str;
95 size_t dst_len;
96 size_t dst_copied;
97 uint32 dummy_offset;
98
99 src_str= src->ptr();
100 if (src_str == NULL)
101 {
102 dst->set((const char*) NULL, 0, dst_cs);
103 return false;
104 }
105
106 src_cs= src->charset();
107 src_len= src->length();
108 src_end= src_str + src_len;
109 numchars= src_cs->numchars(src_str, src_end);
110
111 if (numchars <= max_char)
112 {
113 to_copy= src->length();
114 truncated= false;
115 }
116 else
117 {
118 numchars= max_char;
119 to_copy= dst_cs->charpos(src_str, src_end, numchars);
120 truncated= true;
121 }
122
123 if (String::needs_conversion(to_copy, src_cs, dst_cs, & dummy_offset))
124 {
125 dst_len= numchars * dst_cs->mbmaxlen;
126 dst_str= (char*) alloc_root(mem_root, dst_len + 1);
127 if (dst_str)
128 {
129 dst_copied= String_copier().well_formed_copy(dst_cs, dst_str, dst_len,
130 src_cs, src_str, src_len,
131 numchars);
132 DBUG_ASSERT(dst_copied <= dst_len);
133 dst_len= dst_copied; /* In case the copy truncated the data */
134 dst_str[dst_copied]= '\0';
135 }
136 }
137 else
138 {

Callers 2

assign_condition_itemFunction · 0.85

Calls 9

alloc_rootFunction · 0.85
String_copierClass · 0.85
ptrMethod · 0.45
setMethod · 0.45
charsetMethod · 0.45
lengthMethod · 0.45
numcharsMethod · 0.45
charposMethod · 0.45
well_formed_copyMethod · 0.45

Tested by

no test coverage detected