summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-10-29 21:59:03 +0200
committerunknown <monty@hundin.mysql.fi>2002-10-29 21:59:03 +0200
commitea3ffb9b3efedc03baf011467a0b84f394b1b19e (patch)
tree5eb822c41165cc8204269340f47d7a10e2b83d7f /sql
parent14cbecdc8b53b60dcaf101368bd3df3ae5a7c75e (diff)
downloadmariadb-git-ea3ffb9b3efedc03baf011467a0b84f394b1b19e.tar.gz
Added back old LARGEFILE handling
Fixed reference to freed memory in acl_init()/grant_init() Fixed possible memory leak. (Could only happen in very strange circumstances) Fixed bug in ALTER TABLE with BDB tables Updated mysql-test for valgrind Docs/manual.texi: ChangeLog acinclude.m4: Added back old LARGEFILE handling. (Needed to get MySQL to compile on Solaris 2.9 with gcc 3.x) configure.in: Added back old LARGEFILE handling. (Needed to get MySQL to compile on Solaris 2.9 with gcc 3.x) libmysqld/lib_sql.cc: Fixed reference to freed memory mysql-test/mysql-test-run.sh: Added option --valgrind mysys/Makefile.am: Removed warning when doing make sql/mysqld.cc: Free regexp memory on shutdown. read 'des' key files from data directory Fixed reference to freed memory in grant_init() sql/slave.cc: Fixed wrong printf() argument sql/sql_acl.cc: Fixed reference to freed memory sql/sql_acl.h: Fixed reference to freed memory sql/sql_base.cc: Fixed possible memory leak. (Could only happen in very strange circumstances) sql/sql_parse.cc: Updated arguments to grant_reload() sql/sql_table.cc: Fixed bug in ALTER TABLE with BDB tables sql/sql_yacc.yy: memset -> bzero
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc13
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_acl.cc27
-rw-r--r--sql/sql_acl.h6
-rw-r--r--sql/sql_base.cc13
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_table.cc14
-rw-r--r--sql/sql_yacc.yy2
8 files changed, 52 insertions, 27 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f3aef7f1622..1bb1ff1de74 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -858,6 +858,9 @@ void clean_up(bool print_message)
bitmap_free(&temp_pool);
free_max_user_conn();
end_slave_list();
+#ifdef USE_REGEX
+ regex_end();
+#endif
#if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
if (!opt_bootstrap)
@@ -1894,8 +1897,6 @@ int main(int argc, char **argv)
if (!ssl_acceptor_fd)
opt_use_ssl = 0;
}
- if (des_key_file)
- load_des_key_file(des_key_file);
#endif /* HAVE_OPENSSL */
#ifdef HAVE_LIBWRAP
@@ -1968,6 +1969,10 @@ int main(int argc, char **argv)
reset_floating_point_exceptions();
init_thr_lock();
init_slave_list();
+#ifdef HAVE_OPENSSL
+ if (des_key_file)
+ load_des_key_file(des_key_file);
+#endif /* HAVE_OPENSSL */
/* Setup log files */
if (opt_log)
@@ -2032,7 +2037,7 @@ int main(int argc, char **argv)
exit(1);
}
start_signal_handler(); // Creates pidfile
- if (acl_init(opt_noacl))
+ if (acl_init((THD*) 0, opt_noacl))
{
abort_loop=1;
select_thread_in_use=0;
@@ -2044,7 +2049,7 @@ int main(int argc, char **argv)
exit(1);
}
if (!opt_noacl)
- (void) grant_init();
+ (void) grant_init((THD*) 0);
init_max_user_conn();
init_update_queries();
diff --git a/sql/slave.cc b/sql/slave.cc
index 824191078fc..dc1464dcca1 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1450,7 +1450,7 @@ bool flush_master_info(MASTER_INFO* mi)
DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos));
my_b_seek(file, 0L);
- my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n",
+ my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n",
mi->master_log_name, llstr(mi->master_log_pos, lbuf),
mi->host, mi->user,
mi->password, mi->port, mi->connect_retry
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 867163be90d..3875e51a75a 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -119,6 +119,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
SYNOPSIS
acl_init()
+ thd Thread handler
dont_read_acl_tables Set to 1 if run with --skip-grant
RETURN VALUES
@@ -127,9 +128,9 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
*/
-my_bool acl_init(bool dont_read_acl_tables)
+my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
{
- THD *thd, *org_thd;
+ THD *thd;
TABLE_LIST tables[3];
TABLE *table;
READ_RECORD read_record_info;
@@ -147,7 +148,6 @@ my_bool acl_init(bool dont_read_acl_tables)
/*
To be able to run this from boot, we allocate a temporary THD
*/
- org_thd=current_thd; // Save for restore
if (!(thd=new THD))
DBUG_RETURN(1); /* purecov: inspected */
thd->store_globals();
@@ -339,6 +339,11 @@ end:
delete thd;
if (org_thd)
org_thd->store_globals(); /* purecov: inspected */
+ else
+ {
+ /* Remember that we don't have a THD */
+ my_pthread_setspecific_ptr(THR_THD, 0);
+ }
DBUG_RETURN(return_val);
}
@@ -385,7 +390,7 @@ void acl_reload(THD *thd)
delete_dynamic(&acl_wild_hosts);
hash_free(&acl_check_hosts);
- if (acl_init(0))
+ if (acl_init(thd, 0))
{ // Error. Revert to old list
acl_free(); /* purecov: inspected */
acl_hosts=old_acl_hosts;
@@ -2268,9 +2273,9 @@ void grant_free(void)
/* Init grant array if possible */
-my_bool grant_init(void)
+my_bool grant_init(THD *org_thd)
{
- THD *thd, *org_thd;
+ THD *thd;
TABLE_LIST tables[2];
MYSQL_LOCK *lock;
my_bool return_val= 1;
@@ -2286,7 +2291,6 @@ my_bool grant_init(void)
if (!initialized)
DBUG_RETURN(0); /* purecov: tested */
- org_thd=current_thd;
if (!(thd=new THD))
DBUG_RETURN(1); /* purecov: deadcode */
thd->store_globals();
@@ -2344,13 +2348,18 @@ end:
delete thd;
if (org_thd)
org_thd->store_globals();
+ else
+ {
+ /* Remember that we don't have a THD */
+ my_pthread_setspecific_ptr(THR_THD, 0);
+ }
DBUG_RETURN(return_val);
}
/* Reload grant array if possible */
-void grant_reload(void)
+void grant_reload(THD *thd)
{
HASH old_hash_tables;bool old_grant_option;
MEM_ROOT old_mem;
@@ -2364,7 +2373,7 @@ void grant_reload(void)
old_grant_option = grant_option;
old_mem = memex;
- if (grant_init())
+ if (grant_init(thd))
{ // Error. Revert to old hash
grant_free(); /* purecov: deadcode */
hash_tables=old_hash_tables; /* purecov: deadcode */
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index 326a55ddd0c..6925b6b406c 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -81,7 +81,7 @@
/* prototypes */
-my_bool acl_init(bool dont_read_acl_tables);
+my_bool acl_init(THD *thd, bool dont_read_acl_tables);
void acl_reload(THD *thd);
void acl_free(bool end=0);
ulong acl_get(const char *host, const char *ip, const char *bin_ip,
@@ -98,9 +98,9 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list,
int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
List <LEX_COLUMN> &column_list, ulong rights,
bool revoke);
-my_bool grant_init(void);
+my_bool grant_init(THD *thd);
void grant_free(void);
-void grant_reload(void);
+void grant_reload(THD *thd);
bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
uint show_command=0, bool dont_print_error=0);
bool check_grant_column (THD *thd,TABLE *table, const char *name, uint length,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index d58bc64e975..fa967d645ef 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1513,11 +1513,13 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
TABLE *tmp_table;
DBUG_ENTER("open_temporary_table");
- // the extra size in my_malloc() is for table_cache_key
- // 4 bytes for master thread id if we are in the slave
- // 1 byte to terminate db
- // 1 byte to terminate table_name
- // total of 6 extra bytes in my_malloc in addition to table/db stuff
+ /*
+ The extra size in my_malloc() is for table_cache_key
+ 4 bytes for master thread id if we are in the slave
+ 1 byte to terminate db
+ 1 byte to terminate table_name
+ total of 6 extra bytes in my_malloc in addition to table/db stuff
+ */
if (!(tmp_table=(TABLE*) my_malloc(sizeof(*tmp_table)+(uint) strlen(db)+
(uint) strlen(table_name)+6,
MYF(MY_WME))))
@@ -1529,6 +1531,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
ha_open_options,
tmp_table))
{
+ my_free((char*) tmp_table,MYF(0));
DBUG_RETURN(0);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 693de0dccb7..e0c3492458b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3350,7 +3350,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
if (options & REFRESH_GRANT)
{
acl_reload(thd);
- grant_reload();
+ grant_reload(thd);
if (mqh_used)
reset_mqh(thd,(LEX_USER *) NULL,true);
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index bca7b79c132..865b30cdb39 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1910,16 +1910,24 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
#ifdef HAVE_BERKELEY_DB
if (old_db_type == DB_TYPE_BERKELEY_DB)
{
- (void) berkeley_flush_logs();
/*
For the alter table to be properly flushed to the logs, we
have to open the new table. If not, we get a problem on server
shutdown.
*/
- if (!open_tables(thd, table_list)) // Should always succeed
+ char path[FN_REFLEN];
+ (void) sprintf(path,"%s/%s/%s",mysql_data_home,new_db,table_name);
+ fn_format(path,path,"","",4);
+ table=open_temporary_table(thd, path, new_db, tmp_name,0);
+ if (table)
{
- close_thread_table(thd, &table_list->table);
+ intern_close_table(table);
+ my_free((char*) table, MYF(0));
}
+ else
+ sql_print_error("Warning: Could not open BDB table %s.%s after rename\n",
+ new_db,table_name);
+ (void) berkeley_flush_logs();
}
#endif
table_list->table=0; // For query cache
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 5367bc897b3..730b04e4863 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -667,7 +667,7 @@ change:
{
LEX *lex = Lex;
lex->sql_command = SQLCOM_CHANGE_MASTER;
- memset(&lex->mi, 0, sizeof(lex->mi));
+ bzero((char*) &lex->mi, sizeof(lex->mi));
} master_defs;
master_defs: