Commit 1dd4bd5f authored by monty@mysql.com's avatar monty@mysql.com

Merge mysql.com:/home/my/mysql-4.0 into mysql.com:/home/my/mysql-4.1

parents 01232b2c 9954abef
...@@ -267,10 +267,8 @@ static int write_to_table(char *filename, MYSQL *sock) ...@@ -267,10 +267,8 @@ static int write_to_table(char *filename, MYSQL *sock)
DBUG_ENTER("write_to_table"); DBUG_ENTER("write_to_table");
DBUG_PRINT("enter",("filename: %s",filename)); DBUG_PRINT("enter",("filename: %s",filename));
local_file= sock->unix_socket == 0 || opt_local_file;
fn_format(tablename, filename, "", "", 1 | 2); /* removes path & ext. */ fn_format(tablename, filename, "", "", 1 | 2); /* removes path & ext. */
if (local_file) if (! opt_local_file)
strmov(hard_path,filename); strmov(hard_path,filename);
else else
my_load_path(hard_path, filename, NULL); /* filename includes the path */ my_load_path(hard_path, filename, NULL); /* filename includes the path */
...@@ -289,7 +287,7 @@ static int write_to_table(char *filename, MYSQL *sock) ...@@ -289,7 +287,7 @@ static int write_to_table(char *filename, MYSQL *sock)
to_unix_path(hard_path); to_unix_path(hard_path);
if (verbose) if (verbose)
{ {
if (local_file) if (opt_local_file)
fprintf(stdout, "Loading data from LOCAL file: %s into %s\n", fprintf(stdout, "Loading data from LOCAL file: %s into %s\n",
hard_path, tablename); hard_path, tablename);
else else
...@@ -298,7 +296,7 @@ static int write_to_table(char *filename, MYSQL *sock) ...@@ -298,7 +296,7 @@ static int write_to_table(char *filename, MYSQL *sock)
} }
sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'", sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'",
opt_low_priority ? "LOW_PRIORITY" : "", opt_low_priority ? "LOW_PRIORITY" : "",
local_file ? "LOCAL" : "", hard_path); opt_local_file ? "LOCAL" : "", hard_path);
end= strend(sql_statement); end= strend(sql_statement);
if (replace) if (replace)
end= strmov(end, " REPLACE"); end= strmov(end, " REPLACE");
......
...@@ -21,19 +21,6 @@ ...@@ -21,19 +21,6 @@
isamdatabase. 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" #include "myisamdef.h"
/* lock table by F_UNLCK, F_RDLCK or F_WRLCK */ /* lock table by F_UNLCK, F_RDLCK or F_WRLCK */
...@@ -439,7 +426,24 @@ int _mi_test_if_changed(register MI_INFO *info) ...@@ -439,7 +426,24 @@ int _mi_test_if_changed(register MI_INFO *info)
} /* _mi_test_if_changed */ } /* _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) int _mi_mark_file_changed(MI_INFO *info)
{ {
......
...@@ -681,7 +681,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen= 0); ...@@ -681,7 +681,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_close(THD *thd, TABLE_LIST *tables);
int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, int mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows); 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 */ /* mysql_ha_flush mode_flags bits */
#define MYSQL_HA_CLOSE_FINAL 0x00 #define MYSQL_HA_CLOSE_FINAL 0x00
#define MYSQL_HA_REOPEN_ON_USAGE 0x01 #define MYSQL_HA_REOPEN_ON_USAGE 0x01
......
...@@ -71,7 +71,7 @@ static enum enum_ha_read_modes rkey_to_rnext[]= ...@@ -71,7 +71,7 @@ static enum enum_ha_read_modes rkey_to_rnext[]=
thd->open_tables=thd->handler_tables; \ thd->open_tables=thd->handler_tables; \
thd->handler_tables=tmp; } 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);
/* /*
...@@ -151,8 +151,9 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -151,8 +151,9 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
uint dblen, namelen, aliaslen, counter; uint dblen, namelen, aliaslen, counter;
int err; int err;
DBUG_ENTER("mysql_ha_open"); DBUG_ENTER("mysql_ha_open");
DBUG_PRINT("enter",("mysql_ha_open: '%s'.'%s' as '%s' reopen %d", DBUG_PRINT("enter",("'%s'.'%s' as '%s' reopen: %d",
tables->db, tables->real_name, tables->alias, reopen)); tables->db, tables->real_name, tables->alias,
(int) reopen));
if (! hash_inited(&thd->handler_tables_hash)) if (! hash_inited(&thd->handler_tables_hash))
{ {
...@@ -170,7 +171,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -170,7 +171,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (hash_search(&thd->handler_tables_hash, (byte*) tables->alias, if (hash_search(&thd->handler_tables_hash, (byte*) tables->alias,
strlen(tables->alias) + 1)) strlen(tables->alias) + 1))
{ {
DBUG_PRINT("info",("mysql_ha_open: duplicate '%s'", tables->alias)); DBUG_PRINT("info",("duplicate '%s'", tables->alias));
if (! reopen) if (! reopen)
my_printf_error(ER_NONUNIQ_TABLE, ER(ER_NONUNIQ_TABLE), my_printf_error(ER_NONUNIQ_TABLE, ER(ER_NONUNIQ_TABLE),
MYF(0), tables->alias); MYF(0), tables->alias);
...@@ -210,10 +211,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -210,10 +211,7 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
&name, namelen, &name, namelen,
&alias, aliaslen, &alias, aliaslen,
NullS))) NullS)))
{
DBUG_PRINT("exit",("mysql_ha_open: malloc ERROR"));
goto err; goto err;
}
/* structure copy */ /* structure copy */
*hash_tables= *tables; *hash_tables= *tables;
hash_tables->db= db; hash_tables->db= db;
...@@ -233,11 +231,11 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -233,11 +231,11 @@ int mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (! reopen) if (! reopen)
send_ok(thd); send_ok(thd);
DBUG_PRINT("exit",("mysql_ha_open: OK")); DBUG_PRINT("exit",("OK"));
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
DBUG_PRINT("exit",("mysql_ha_open: ERROR")); DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
...@@ -266,7 +264,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables) ...@@ -266,7 +264,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
bool was_flushed= FALSE; bool was_flushed= FALSE;
bool not_opened; bool not_opened;
DBUG_ENTER("mysql_ha_close"); 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)); tables->db, tables->real_name, tables->alias));
if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash,
...@@ -286,7 +284,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables) ...@@ -286,7 +284,7 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
#if MYSQL_VERSION_ID < 40100 #if MYSQL_VERSION_ID < 40100
if (*tables->db && strcmp(hash_tables->db, tables->db)) 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; hash_tables= NULL;
} }
else else
...@@ -322,12 +320,12 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables) ...@@ -322,12 +320,12 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0), my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0),
tables->alias, "HANDLER"); tables->alias, "HANDLER");
#endif #endif
DBUG_PRINT("exit",("mysql_ha_close: ERROR")); DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
send_ok(thd); send_ok(thd);
DBUG_PRINT("exit",("mysql_ha_close: OK")); DBUG_PRINT("exit", ("OK"));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -370,7 +368,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -370,7 +368,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
uint key_len; uint key_len;
bool was_flushed; bool was_flushed;
DBUG_ENTER("mysql_ha_read"); 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)); tables->db, tables->real_name, tables->alias));
LINT_INIT(key); LINT_INIT(key);
...@@ -385,7 +383,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -385,7 +383,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
strlen(tables->alias) + 1))) strlen(tables->alias) + 1)))
{ {
table= hash_tables->table; table= hash_tables->table;
DBUG_PRINT("info",("mysql_ha_read: found in hash '%s'.'%s' as '%s' tab %p", DBUG_PRINT("info-in-hash",("'%s'.'%s' as '%s' tab %p",
hash_tables->db, hash_tables->real_name, hash_tables->db, hash_tables->real_name,
hash_tables->alias, table)); hash_tables->alias, table));
if (!table) if (!table)
...@@ -395,12 +393,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -395,12 +393,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
*/ */
if (mysql_ha_open(thd, hash_tables, 1)) if (mysql_ha_open(thd, hash_tables, 1))
{ {
DBUG_PRINT("exit",("mysql_ha_read: reopen failed")); DBUG_PRINT("exit",("reopen failed"));
goto err0; goto err0;
} }
table= hash_tables->table; 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->db, hash_tables->real_name,
hash_tables->alias, table)); hash_tables->alias, table));
} }
...@@ -408,7 +406,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -408,7 +406,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
#if MYSQL_VERSION_ID < 40100 #if MYSQL_VERSION_ID < 40100
if (*tables->db && strcmp(table->table_cache_key, tables->db)) 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; table= NULL;
} }
#endif #endif
...@@ -584,12 +582,13 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -584,12 +582,13 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
ok: ok:
mysql_unlock_tables(thd,lock); mysql_unlock_tables(thd,lock);
send_eof(thd); send_eof(thd);
DBUG_PRINT("exit",("mysql_ha_read: OK")); DBUG_PRINT("exit",("OK"));
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
mysql_unlock_tables(thd,lock); mysql_unlock_tables(thd,lock);
err0: err0:
DBUG_PRINT("exit",("mysql_ha_read: ERROR")); DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
...@@ -623,22 +622,21 @@ err0: ...@@ -623,22 +622,21 @@ err0:
0 ok 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_p;
TABLE_LIST *tmp_tables; TABLE_LIST *tmp_tables;
TABLE **table_ptr; TABLE **table_ptr;
bool was_flushed; bool was_flushed;
DBUG_ENTER("mysql_ha_flush"); DBUG_ENTER("mysql_ha_flush");
DBUG_PRINT("enter",("mysql_ha_flush: tables %p mode_flags 0x%02x", DBUG_PRINT("enter", ("tables: %p mode_flags: 0x%02x", tables, mode_flags));
tables, mode_flags));
if (tables) if (tables)
{ {
/* Close all tables in the list. */ /* Close all tables in the list. */
for (tmp_tables= tables ; tmp_tables; tmp_tables= tmp_tables->next) for (tmp_tables= tables ; tmp_tables; tmp_tables= tmp_tables->next)
{ {
DBUG_PRINT("info",("mysql_ha_flush: in tables list '%s'.'%s' as '%s'", DBUG_PRINT("info-in-tables-list",("'%s'.'%s' as '%s'",
tmp_tables->db, tmp_tables->real_name, tmp_tables->db, tmp_tables->real_name,
tmp_tables->alias)); tmp_tables->alias));
/* Close all currently open handler tables with the same base table. */ /* Close all currently open handler tables with the same base table. */
...@@ -651,7 +649,7 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags) ...@@ -651,7 +649,7 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
! my_strcasecmp(&my_charset_latin1, (*table_ptr)->real_name, ! my_strcasecmp(&my_charset_latin1, (*table_ptr)->real_name,
tmp_tables->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)->table_cache_key,
(*table_ptr)->real_name, (*table_ptr)->real_name,
(*table_ptr)->table_name)); (*table_ptr)->table_name));
...@@ -680,7 +678,6 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags) ...@@ -680,7 +678,6 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
} }
} }
DBUG_PRINT("exit",("mysql_ha_flush: OK"));
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -702,13 +699,13 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags) ...@@ -702,13 +699,13 @@ int mysql_ha_flush(THD *thd, TABLE_LIST *tables, int mode_flags)
0 ok 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_LIST *hash_tables;
TABLE *table= *table_ptr; TABLE *table= *table_ptr;
bool was_flushed; bool was_flushed;
DBUG_ENTER("mysql_ha_flush_table"); DBUG_ENTER("mysql_ha_flush_table");
DBUG_PRINT("info",("mysql_ha_flush_table: '%s'.'%s' as '%s' flags 0x%02x", DBUG_PRINT("enter",("'%s'.'%s' as '%s' flags: 0x%02x",
table->table_cache_key, table->real_name, table->table_cache_key, table->real_name,
table->table_name, mode_flags)); table->table_name, mode_flags));
...@@ -735,6 +732,5 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, int mode_flags) ...@@ -735,6 +732,5 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, int mode_flags)
VOID(pthread_cond_broadcast(&COND_refresh)); VOID(pthread_cond_broadcast(&COND_refresh));
} }
DBUG_PRINT("exit",("mysql_ha_flush_table: OK"));
DBUG_RETURN(0); 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