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

Function compute_digest_text

sql/sql_digest.cc:170–280  ·  view source on GitHub ↗

Iterate token array and updates digest_text. */

Source from the content-addressed store, hash-verified

168 Iterate token array and updates digest_text.
169*/
170void compute_digest_text(const sql_digest_storage* digest_storage,
171 String *digest_text)
172{
173 DBUG_ASSERT(digest_storage != NULL);
174 uint byte_count= digest_storage->m_byte_count;
175 String *digest_output= digest_text;
176 uint tok= 0;
177 uint current_byte= 0;
178 lex_token_string *tok_data;
179
180 /* Reset existing data */
181 digest_output->length(0);
182
183 if (byte_count > digest_storage->m_token_array_length)
184 {
185 digest_output->append('\0');
186 return;
187 }
188
189 /* Convert text to utf8 */
190 const CHARSET_INFO *from_cs= get_charset(digest_storage->m_charset_number, MYF(0));
191 const CHARSET_INFO *to_cs= &my_charset_utf8mb3_bin;
192
193 if (from_cs == NULL)
194 {
195 /*
196 Can happen, as we do dirty reads on digest_storage,
197 which can be written to in another thread.
198 */
199 digest_output->append('\0');
200 return;
201 }
202
203 char id_buffer[NAME_LEN + 1]= {'\0'};
204 char *id_string;
205 size_t id_length;
206 bool convert_text= !my_charset_same(from_cs, to_cs);
207
208 while (current_byte < byte_count)
209 {
210 current_byte= read_token(digest_storage, current_byte, &tok);
211
212 if (tok <= 0 || tok >= array_elements(lex_token_array)
213 || current_byte > max_digest_length)
214 return;
215
216 tok_data= &lex_token_array[tok];
217
218 switch (tok)
219 {
220 /* All identifiers are printed with their name. */
221 case IDENT:
222 case IDENT_QUOTED:
223 case TOK_IDENT:
224 {
225 char *id_ptr= NULL;
226 int id_len= 0;
227 uint err_cs= 0;

Callers 2

make_row_part_2Method · 0.85
make_rowMethod · 0.85

Calls 7

get_charsetFunction · 0.85
my_charset_sameFunction · 0.85
read_identifierFunction · 0.85
my_convertFunction · 0.85
read_tokenFunction · 0.70
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected