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

Function put_dbopt

sql/sql_db.cc:386–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384*/
385
386static my_bool put_dbopt(const char *dbname, Schema_specification_st *create)
387{
388 my_dbopt_t *opt;
389 uint length;
390 my_bool error= 0;
391 DBUG_ENTER("put_dbopt");
392
393 length= (uint) strlen(dbname);
394
395 mysql_rwlock_wrlock(&LOCK_dboptions);
396 if (!(opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname,
397 length)))
398 {
399 /* Options are not in the hash, insert them */
400 char *tmp_name;
401 char *tmp_comment= NULL;
402 if (!my_multi_malloc(key_memory_dboptions_hash, MYF(MY_WME | MY_ZEROFILL),
403 &opt, (uint) sizeof(*opt), &tmp_name, (uint) length+1,
404 &tmp_comment, (uint) DATABASE_COMMENT_MAXLEN+1,
405 NullS))
406 {
407 error= 1;
408 goto end;
409 }
410
411 opt->name= tmp_name;
412 strmov(opt->name, dbname);
413 opt->name_length= length;
414 opt->comment.str= tmp_comment;
415 if (unlikely((error= my_hash_insert(&dboptions, (uchar*) opt))))
416 {
417 my_free(opt);
418 goto end;
419 }
420 }
421
422 /* Update / write options in hash */
423 opt->charset= create->default_table_charset;
424
425 if (create->schema_comment)
426 {
427 strmov(opt->comment.str, create->schema_comment->str);
428 opt->comment.length= create->schema_comment->length;
429 }
430
431end:
432 mysql_rwlock_unlock(&LOCK_dboptions);
433 DBUG_RETURN(error);
434}
435
436
437/*

Callers 2

write_db_optFunction · 0.85
load_db_optFunction · 0.85

Calls 5

my_hash_searchFunction · 0.85
my_multi_mallocFunction · 0.85
strmovFunction · 0.85
my_hash_insertFunction · 0.85
my_freeFunction · 0.85

Tested by

no test coverage detected