Commit 97febc4d authored by monty@mysql.com's avatar monty@mysql.com

Code cleanups while doing review of pushed code

parent 0944bed7
......@@ -21,19 +21,6 @@
isamdatabase.
*/
/*
state.open_count in the .MYI file is used the following way:
- For the first change of the file in this process it's incremented with
mi_mark_file_change(). (We have a write lock on the file in this case)
- In mi_close() it's decremented by _mi_decrement_open_count() if it
was incremented in the same process.
This mean that if we are the only process using the file, the open_count
tells us if the MYISAM file wasn't properly closed. (This is true if
my_disable_locking is set).
*/
#include "myisamdef.h"
#ifdef __WIN__
#include <errno.h>
......@@ -426,7 +413,24 @@ int _mi_test_if_changed(register MI_INFO *info)
} /* _mi_test_if_changed */
/* Put a mark in the .MYI file that someone is updating the table */
/*
Put a mark in the .MYI file that someone is updating the table
DOCUMENTATION
state.open_count in the .MYI file is used the following way:
- For the first change of the .MYI file in this process open_count is
incremented by mi_mark_file_change(). (We have a write lock on the file
when this happens)
- In mi_close() it's decremented by _mi_decrement_open_count() if it
was incremented in the same process.
This mean that if we are the only process using the file, the open_count
tells us if the MYISAM file wasn't properly closed. (This is true if
my_disable_locking is set).
*/
int _mi_mark_file_changed(MI_INFO *info)
{
......
......@@ -544,7 +544,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen= 0);
int mysql_ha_close(THD *thd, TABLE_LIST *tables);
int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags);
int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags);
/* mysql_ha_flush mode_flags bits */
#define MYSQL_HA_CLOSE_FINAL 0x00
#define MYSQL_HA_REOPEN_ON_USAGE 0x01
......
......@@ -72,7 +72,7 @@ static enum enum_ha_read_modes rkey_to_rnext[]=
thd->open_tables=thd->handler_tables; \
thd->handler_tables=tmp; }
static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, int mode_flags);
static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags);
/*
......@@ -156,8 +156,9 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
uint aliaslen;
int err;
DBUG_ENTER("mysql_ha_open");
DBUG_PRINT("enter",("mysql_ha_open: '%s'.'%s' as '%s' reopen %d",
tables->db, tables->real_name, tables->alias, reopen));
DBUG_PRINT("enter",("'%s'.'%s' as '%s' reopen: %d",
tables->db, tables->real_name, tables->alias,
(int) reopen));
if (! hash_inited(&thd->handler_tables_hash))
{
......@@ -174,7 +175,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (hash_search(&thd->handler_tables_hash, (byte*) tables->alias,
strlen(tables->alias) + 1))
{
DBUG_PRINT("info",("mysql_ha_open: duplicate '%s'", tables->alias));
DBUG_PRINT("info",("duplicate '%s'", tables->alias));
if (! reopen)
my_printf_error(ER_NONUNIQ_TABLE, ER(ER_NONUNIQ_TABLE),
MYF(0), tables->alias);
......@@ -214,10 +215,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
&name, namelen,
&alias, aliaslen,
NullS)))
{
DBUG_PRINT("exit",("mysql_ha_open: malloc ERROR"));
goto err;
}
/* structure copy */
*hash_tables= *tables;
hash_tables->db= db;
......@@ -237,11 +235,11 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (! reopen)
send_ok(&thd->net);
DBUG_PRINT("exit",("mysql_ha_open: OK"));
DBUG_PRINT("exit",("OK"));
DBUG_RETURN(0);
err:
DBUG_PRINT("exit",("mysql_ha_open: ERROR"));
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(-1);
}
......@@ -270,7 +268,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
bool was_flushed= FALSE;
bool not_opened;
DBUG_ENTER("mysql_ha_close");
DBUG_PRINT("enter",("mysql_ha_close: '%s'.'%s' as '%s'",
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
tables->db, tables->real_name, tables->alias));
if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash,
......@@ -290,7 +288,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
#if MYSQL_VERSION_ID < 40100
if (*tables->db && strcmp(hash_tables->db, tables->db))
{
DBUG_PRINT("info",("mysql_ha_close: wrong db"));
DBUG_PRINT("info",("wrong db"));
hash_tables= NULL;
}
else
......@@ -325,12 +323,12 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0),
tables->alias, "HANDLER");
#endif
DBUG_PRINT("exit",("mysql_ha_close: ERROR"));
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(-1);
}
send_ok(&thd->net);
DBUG_PRINT("exit",("mysql_ha_close: OK"));
DBUG_PRINT("exit", ("OK"));
DBUG_RETURN(0);
}
......@@ -368,7 +366,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
bool was_flushed;
MYSQL_LOCK *lock;
DBUG_ENTER("mysql_ha_read");
DBUG_PRINT("enter",("mysql_ha_read: '%s'.'%s' as '%s'",
DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
tables->db, tables->real_name, tables->alias));
List<Item> list;
......@@ -381,9 +379,9 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
strlen(tables->alias) + 1)))
{
table= hash_tables->table;
DBUG_PRINT("info",("mysql_ha_read: found in hash '%s'.'%s' as '%s' tab %p",
hash_tables->db, hash_tables->real_name,
hash_tables->alias, table));
DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p",
hash_tables->db, hash_tables->real_name,
hash_tables->alias, table));
if (!table)
{
/*
......@@ -391,12 +389,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
*/
if (mysql_ha_open(thd, hash_tables, 1))
{
DBUG_PRINT("exit",("mysql_ha_read: reopen failed"));
DBUG_PRINT("exit",("reopen failed"));
goto err0;
}
table= hash_tables->table;
DBUG_PRINT("info",("mysql_ha_read: re-opened '%s'.'%s' as '%s' tab %p",
DBUG_PRINT("info",("re-opened '%s'.'%s' as '%s' tab %p",
hash_tables->db, hash_tables->real_name,
hash_tables->alias, table));
}
......@@ -404,7 +402,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
#if MYSQL_VERSION_ID < 40100
if (*tables->db && strcmp(table->table_cache_key, tables->db))
{
DBUG_PRINT("info",("mysql_ha_read: wrong db"));
DBUG_PRINT("info",("wrong db"));
table= NULL;
}
#endif
......@@ -575,12 +573,13 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
ok:
mysql_unlock_tables(thd,lock);
send_eof(&thd->net);
DBUG_PRINT("exit",("mysql_ha_read: OK"));
DBUG_PRINT("exit",("OK"));
DBUG_RETURN(0);
err:
mysql_unlock_tables(thd,lock);
err0:
DBUG_PRINT("exit",("mysql_ha_read: ERROR"));
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(-1);
}
......@@ -614,24 +613,23 @@ err0:
0 ok
*/
int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags)
{
TABLE_LIST **tmp_tables_p;
TABLE_LIST *tmp_tables;
TABLE **table_ptr;
bool was_flushed;
DBUG_ENTER("mysql_ha_flush");
DBUG_PRINT("enter",("mysql_ha_flush: tables %p mode_flags 0x%02x",
tables, mode_flags));
DBUG_PRINT("enter", ("tables: %p mode_flags: 0x%02x", tables, mode_flags));
if (tables)
{
/* Close all tables in the list. */
for (tmp_tables= tables ; tmp_tables; tmp_tables= tmp_tables->next)
{
DBUG_PRINT("info",("mysql_ha_flush: in tables list '%s'.'%s' as '%s'",
tmp_tables->db, tmp_tables->real_name,
tmp_tables->alias));
DBUG_PRINT("info-in-tables-list",("'%s'.'%s' as '%s'",
tmp_tables->db, tmp_tables->real_name,
tmp_tables->alias));
/* Close all currently open handler tables with the same base table. */
table_ptr= &(thd->handler_tables);
while (*table_ptr)
......@@ -640,7 +638,7 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
! my_strcasecmp((*table_ptr)->table_cache_key, tmp_tables->db)) &&
! my_strcasecmp((*table_ptr)->real_name, tmp_tables->real_name))
{
DBUG_PRINT("info",("mysql_ha_flush: *table_ptr '%s'.'%s' as '%s'",
DBUG_PRINT("info",("*table_ptr '%s'.'%s' as '%s'",
(*table_ptr)->table_cache_key,
(*table_ptr)->real_name,
(*table_ptr)->table_name));
......@@ -669,7 +667,6 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
}
}
DBUG_PRINT("exit",("mysql_ha_flush: OK"));
DBUG_RETURN(0);
}
......@@ -691,15 +688,15 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
0 ok
*/
static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, int mode_flags)
static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags)
{
TABLE_LIST *hash_tables;
TABLE *table= *table_ptr;
bool was_flushed;
DBUG_ENTER("mysql_ha_flush_table");
DBUG_PRINT("info",("mysql_ha_flush_table: '%s'.'%s' as '%s' flags 0x%02x",
table->table_cache_key, table->real_name,
table->table_name, mode_flags));
DBUG_PRINT("enter",("'%s'.'%s' as '%s' flags: 0x%02x",
table->table_cache_key, table->real_name,
table->table_name, mode_flags));
if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash,
(*table_ptr)->table_name,
......@@ -723,7 +720,6 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, int mode_flags)
VOID(pthread_cond_broadcast(&COND_refresh));
}
DBUG_PRINT("exit",("mysql_ha_flush_table: OK"));
DBUG_RETURN(0);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment