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

Function ignore_db_dirs_process_additions

sql/sql_show.cc:273–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271*/
272
273bool
274ignore_db_dirs_process_additions()
275{
276 ulong i;
277 size_t len;
278 char *ptr;
279 LEX_STRING *dir;
280
281 DBUG_ASSERT(opt_ignore_db_dirs == NULL);
282
283 if (my_hash_init(&ignore_db_dirs_hash,
284 lower_case_table_names ?
285 character_set_filesystem : &my_charset_bin,
286 0, 0, 0, db_dirs_hash_get_key,
287 my_free,
288 HASH_UNIQUE))
289 return true;
290
291 /* len starts from 1 because of the terminating zero. */
292 len= 1;
293 for (i= 0; i < ignore_db_dirs_array.elements; i++)
294 {
295 get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
296 len+= dir->length + 1; // +1 for the comma
297 }
298
299 /* No delimiter for the last directory. */
300 if (len > 1)
301 len--;
302
303 /* +1 the terminating zero */
304 ptr= opt_ignore_db_dirs= (char *) my_malloc(len + 1, MYF(0));
305 if (!ptr)
306 return true;
307
308 /* Make sure we have an empty string to start with. */
309 *ptr= 0;
310
311 for (i= 0; i < ignore_db_dirs_array.elements; i++)
312 {
313 get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
314 if (my_hash_insert(&ignore_db_dirs_hash, (uchar *) dir))
315 return true;
316 ptr= strnmov(ptr, dir->str, dir->length);
317 if (i + 1 < ignore_db_dirs_array.elements)
318 ptr= strmov(ptr, ",");
319
320 /*
321 Set the transferred array element to NULL to avoid double free
322 in case of error.
323 */
324 dir= NULL;
325 set_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
326 }
327
328 /* make sure the string is terminated */
329 DBUG_ASSERT(ptr - opt_ignore_db_dirs <= (ptrdiff_t) len);
330 *ptr= 0;

Callers 1

mysqld.ccFile · 0.85

Calls 6

get_dynamicFunction · 0.85
my_mallocFunction · 0.85
my_hash_insertFunction · 0.85
strnmovFunction · 0.85
strmovFunction · 0.85
set_dynamicFunction · 0.85

Tested by

no test coverage detected