| 384 | */ |
| 385 | |
| 386 | static 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 | |
| 431 | end: |
| 432 | mysql_rwlock_unlock(&LOCK_dboptions); |
| 433 | DBUG_RETURN(error); |
| 434 | } |
| 435 | |
| 436 | |
| 437 | /* |
no test coverage detected