| 4532 | } |
| 4533 | |
| 4534 | int STDCALL |
| 4535 | mysql_options4(MYSQL *mysql,enum mysql_option option, |
| 4536 | const void *arg1, const void *arg2) |
| 4537 | { |
| 4538 | DBUG_ENTER("mysql_option"); |
| 4539 | DBUG_PRINT("enter",("option: %d",(int) option)); |
| 4540 | |
| 4541 | switch (option) |
| 4542 | { |
| 4543 | case MYSQL_OPT_CONNECT_ATTR_ADD: |
| 4544 | { |
| 4545 | LEX_STRING *elt; |
| 4546 | char *key, *value; |
| 4547 | size_t key_len= arg1 ? strlen(arg1) : 0, |
| 4548 | value_len= arg2 ? strlen(arg2) : 0; |
| 4549 | size_t attr_storage_length= key_len + value_len; |
| 4550 | |
| 4551 | /* we can't have a zero length key */ |
| 4552 | if (!key_len) |
| 4553 | { |
| 4554 | set_mysql_error(mysql, CR_INVALID_PARAMETER_NO, unknown_sqlstate); |
| 4555 | DBUG_RETURN(1); |
| 4556 | } |
| 4557 | |
| 4558 | /* calculate the total storage length of the attribute */ |
| 4559 | attr_storage_length+= get_length_store_length(key_len); |
| 4560 | attr_storage_length+= get_length_store_length(value_len); |
| 4561 | |
| 4562 | ENSURE_EXTENSIONS_PRESENT(&mysql->options); |
| 4563 | |
| 4564 | /* |
| 4565 | Throw and error if the maximum combined length of the attribute value |
| 4566 | will be greater than the maximum that we can safely transmit. |
| 4567 | */ |
| 4568 | if (attr_storage_length + |
| 4569 | mysql->options.extension->connection_attributes_length > |
| 4570 | MAX_CONNECTION_ATTR_STORAGE_LENGTH) |
| 4571 | { |
| 4572 | set_mysql_error(mysql, CR_INVALID_PARAMETER_NO, unknown_sqlstate); |
| 4573 | DBUG_RETURN(1); |
| 4574 | } |
| 4575 | |
| 4576 | if (!my_hash_inited(&mysql->options.extension->connection_attributes)) |
| 4577 | { |
| 4578 | if (my_hash_init(&mysql->options.extension->connection_attributes, |
| 4579 | &my_charset_bin, 0, 0, 0, (my_hash_get_key) get_attr_key, |
| 4580 | my_free, HASH_UNIQUE)) |
| 4581 | { |
| 4582 | set_mysql_error(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate); |
| 4583 | DBUG_RETURN(1); |
| 4584 | } |
| 4585 | } |
| 4586 | if (!my_multi_malloc(MY_WME, |
| 4587 | &elt, 2 * sizeof(LEX_STRING), |
| 4588 | &key, key_len + 1, |
| 4589 | &value, value_len + 1, |
| 4590 | NULL)) |
| 4591 | { |
no test coverage detected