diff options
author | Michael Widenius <monty@askmonty.org> | 2013-04-17 23:37:06 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-04-17 23:37:06 +0300 |
commit | 8b714e507f9e2c216ad043a10db99ea558e9285b (patch) | |
tree | c73d5355619001021e0426fa1a955bf68f90fc5d | |
parent | 8e526985800678de20356cece1183f49f69c26f9 (diff) | |
download | mariadb-git-8b714e507f9e2c216ad043a10db99ea558e9285b.tar.gz |
Changed the client library to only mark memory as THREAD_SPECIFIC if one has called
mysql_options() with MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY
include/mysql.h:
Added MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY
include/mysql.h.pp:
Updated file
sql-common/client.c:
Marked client memory as THREAD_SPECIFIC
sql/event_db_repository.cc:
Fixed compiler warning
sql/slave.cc:
Marked client memory as THREAD_SPECIFIC
storage/federatedx/federatedx_io_mysql.cc:
Marked client memory as THREAD_SPECIFIC
storage/federatedx/ha_federatedx.cc:
Marked client memory as THREAD_SPECIFIC
storage/sphinx/ha_sphinx.cc:
Marked client memory as THREAD_SPECIFIC
-rw-r--r-- | include/mysql.h | 4 | ||||
-rw-r--r-- | include/mysql.h.pp | 6 | ||||
-rw-r--r-- | sql-common/client.c | 11 | ||||
-rw-r--r-- | sql/event_db_repository.cc | 2 | ||||
-rw-r--r-- | sql/slave.cc | 10 | ||||
-rw-r--r-- | storage/federatedx/federatedx_io_mysql.cc | 6 | ||||
-rw-r--r-- | storage/federatedx/ha_federatedx.cc | 3 | ||||
-rw-r--r-- | storage/sphinx/ha_sphinx.cc | 12 |
8 files changed, 41 insertions, 13 deletions
diff --git a/include/mysql.h b/include/mysql.h index fa62026b44a..122b5a2751f 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -169,7 +169,7 @@ enum mysql_option MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, MYSQL_PROGRESS_CALLBACK, /* MariaDB options */ - MYSQL_OPT_NONBLOCK=6000 + MYSQL_OPT_NONBLOCK=6000, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY }; /** @@ -194,7 +194,7 @@ struct st_mysql_options { unsigned long max_allowed_packet; my_bool use_ssl; /* if to use SSL or not */ my_bool compress,named_pipe; - my_bool unused1; + my_bool use_thread_specific_memory; my_bool unused2; my_bool unused3; my_bool unused4; diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 331183180c0..b3a56dfd90b 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -83,7 +83,7 @@ enum enum_mysql_set_option my_bool my_net_init(NET *net, Vio* vio, unsigned int my_flags); void my_net_local_init(NET *net); void net_end(NET *net); - void net_clear(NET *net, my_bool clear_buffer); +void net_clear(NET *net, my_bool clear_buffer); my_bool net_realloc(NET *net, size_t length); my_bool net_flush(NET *net); my_bool my_net_write(NET *net,const unsigned char *packet, size_t len); @@ -263,7 +263,7 @@ enum mysql_option MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, MYSQL_PROGRESS_CALLBACK, - MYSQL_OPT_NONBLOCK=6000 + MYSQL_OPT_NONBLOCK=6000, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY }; struct st_mysql_options_extention; struct st_mysql_options { @@ -282,7 +282,7 @@ struct st_mysql_options { unsigned long max_allowed_packet; my_bool use_ssl; my_bool compress,named_pipe; - my_bool unused1; + my_bool use_thread_specific_memory; my_bool unused2; my_bool unused3; my_bool unused4; diff --git a/sql-common/client.c b/sql-common/client.c index 2d83f2ef215..507917b0722 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -892,7 +892,9 @@ void free_old_query(MYSQL *mysql) if (mysql->fields) free_root(&mysql->field_alloc,MYF(0)); /* Assume rowlength < 8192 */ - init_alloc_root(&mysql->field_alloc, 8192, 0, MYF(MY_THREAD_SPECIFIC)); + init_alloc_root(&mysql->field_alloc, 8192, 0, + MYF(mysql->options.use_thread_specific_memory ? + MY_THREAD_SPECIFIC : 0)); mysql->fields= 0; mysql->field_count= 0; /* For API */ mysql->warning_count= 0; @@ -1578,7 +1580,9 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, DBUG_RETURN(0); } /* Assume rowlength < 8192 */ - init_alloc_root(&result->alloc, 8192, 0, MYF(MY_THREAD_SPECIFIC)); + init_alloc_root(&result->alloc, 8192, 0, + MYF(mysql->options.use_thread_specific_memory ? + MY_THREAD_SPECIFIC : 0)); result->alloc.min_malloc=sizeof(MYSQL_ROWS); prev_ptr= &result->data; result->rows=0; @@ -4206,6 +4210,9 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg) case MYSQL_OPT_RECONNECT: mysql->reconnect= *(my_bool *) arg; break; + case MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY: + mysql->options.use_thread_specific_memory= *(my_bool *) arg; + break; case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: if (*(my_bool*) arg) mysql->options.client_flag|= CLIENT_SSL_VERIFY_SERVER_CERT; diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index b7e82d8b4b9..edd4e248038 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -163,7 +163,7 @@ const TABLE_FIELD_TYPE event_table_fields[ET_FIELD_COUNT] = }; static const TABLE_FIELD_DEF - event_table_def= {ET_FIELD_COUNT, event_table_fields}; +event_table_def= {ET_FIELD_COUNT, event_table_fields, 0, (uint*) 0}; class Event_db_intact : public Table_check_intact { diff --git a/sql/slave.cc b/sql/slave.cc index 0a260272929..36d26e76dce 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5004,6 +5004,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, int last_errno= -2; // impossible error ulong err_count=0; char llbuff[22]; + my_bool my_true= 1; DBUG_ENTER("connect_to_master"); #ifndef DBUG_OFF @@ -5015,6 +5016,8 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout); mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout); + mysql_options(mysql, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, + (char*) &my_true); #ifdef HAVE_OPENSSL if (mi->ssl) @@ -5130,14 +5133,15 @@ MYSQL *rpl_connect_master(MYSQL *mysql) { THD *thd= current_thd; Master_info *mi= my_pthread_getspecific_ptr(Master_info*, RPL_MASTER_INFO); + bool allocated= false; + my_bool my_true= 1; + if (!mi) { sql_print_error("'rpl_connect_master' must be called in slave I/O thread context."); return NULL; } - bool allocated= false; - if (!mysql) { if(!(mysql= mysql_init(NULL))) @@ -5157,6 +5161,8 @@ MYSQL *rpl_connect_master(MYSQL *mysql) */ mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout); mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout); + mysql_options(mysql, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, + (char*) &my_true); #ifdef HAVE_OPENSSL if (mi->ssl) diff --git a/storage/federatedx/federatedx_io_mysql.cc b/storage/federatedx/federatedx_io_mysql.cc index effbe899e7f..cc45ae059ae 100644 --- a/storage/federatedx/federatedx_io_mysql.cc +++ b/storage/federatedx/federatedx_io_mysql.cc @@ -423,8 +423,10 @@ int federatedx_io_mysql::actual_query(const char *buffer, uint length) if (!mysql.net.vio) { + my_bool my_true= 1; + if (!(mysql_init(&mysql))) - DBUG_RETURN(-1); + DBUG_RETURN(-1); /* BUG# 17044 Federated Storage Engine is not UTF8 clean @@ -433,6 +435,8 @@ int federatedx_io_mysql::actual_query(const char *buffer, uint length) */ /* this sets the csname like 'set names utf8' */ mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, get_charsetname()); + mysql_options(&mysql, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, + (char*) &my_true); if (!mysql_real_connect(&mysql, get_hostname(), diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index d760fcf082f..c3f5e6add73 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -3593,12 +3593,15 @@ int ha_federatedx::discover_assisted(handlerton *hton, THD* thd, MYSQL_RES *res; MYSQL_ROW rdata; ulong *rlen; + my_bool my_true= 1; if (parse_url(thd->mem_root, &tmp_share, table_s, 1)) return HA_WRONG_CREATE_OPTION; mysql_init(&mysql); mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, cs->csname); + mysql_options(&mysql, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, + (char*) &my_true); if (!mysql_real_connect(&mysql, tmp_share.hostname, tmp_share.username, tmp_share.password, tmp_share.database, diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 23bf21b6cbe..9f5097b59ce 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -2333,7 +2333,11 @@ int ha_sphinx::write_row ( byte * ) SPH_RET ( ER_OUT_OF_RESOURCES ); unsigned int uTimeout = 1; - mysql_options ( pConn, MYSQL_OPT_CONNECT_TIMEOUT, (const char*)&uTimeout ); + my_bool my_true= 1; + mysql_options(pConn, MYSQL_OPT_CONNECT_TIMEOUT, + (const char*) &uTimeout); + mysql_options(pConn, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, + (char*) &my_true); if ( !mysql_real_connect ( pConn, m_pShare->m_sHost, "root", "", "", m_pShare->m_iPort, m_pShare->m_sSocket, 0 ) ) SPH_RET ( HandleMysqlError ( pConn, ER_CONNECT_TO_FOREIGN_DATA_SOURCE ) ); @@ -2392,7 +2396,11 @@ int ha_sphinx::delete_row ( const byte * ) SPH_RET ( ER_OUT_OF_RESOURCES ); unsigned int uTimeout = 1; - mysql_options ( pConn, MYSQL_OPT_CONNECT_TIMEOUT, (const char*)&uTimeout ); + my_bool my_true= 1; + mysql_options(pConn, MYSQL_OPT_CONNECT_TIMEOUT, + (const char*) &uTimeout); + mysql_options(pConn, MYSQL_OPT_USE_THREAD_SPECIFIC_MEMORY, + (char*) &my_true); if ( !mysql_real_connect ( pConn, m_pShare->m_sHost, "root", "", "", m_pShare->m_iPort, m_pShare->m_sSocket, 0 ) ) SPH_RET ( HandleMysqlError ( pConn, ER_CONNECT_TO_FOREIGN_DATA_SOURCE ) ); |