Commit 34558504 authored by unknown's avatar unknown

Fixed that LOAD DATA INFILE works with transactions.

Fix for lower case filenames


BitKeeper/deleted/.del-select.tst~2e626fa07144d2c8:
  Delete: mysql-test/misc/select.tst
Docs/manual.texi:
  Better examples for sub selects
bdb/lock/lock_region.c:
  Fixed not critical error
mysql-test/r/gemini.result:
  Testcase for load data infile
mysql-test/t/gemini.test:
  Testcase for load data infile
sql/sql_load.cc:
  Fixed that LOAD DATA INFILE works with transactions
sql/sql_show.cc:
  Fix for lower case filenames
sql/sql_string.cc:
  cleanup
parent c0d11f1e
...@@ -3730,18 +3730,31 @@ list in this manual. @xref{TODO}. ...@@ -3730,18 +3730,31 @@ list in this manual. @xref{TODO}.
@cindex sub-selects @cindex sub-selects
The following will not yet work in MySQL: MySQL currently only supports sub selects of the form @code{INSERT
... SELECT ...} and @code{REPLACE ... SELECT ...}. You can however use
the function @code{IN()} in other contexts.
In many cases you can rewrite the query without a sub-select:
@example @example
SELECT * FROM table1 WHERE id IN (SELECT id FROM table2); SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
@end example
This can be re-written as:
@example
SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
@end example
The queries:
@example
SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2); SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id); SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id);
@end example @end example
However, in many cases you can rewrite the query without a sub-select: Can be rewritten as:
@example @example
SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
@end example @end example
...@@ -3777,11 +3790,9 @@ second instance of the interpreter: ...@@ -3777,11 +3790,9 @@ second instance of the interpreter:
prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb
@end example @end example
MySQL only supports @code{INSERT ... SELECT ...} and MySQL 4.0 supports multi-table deletes that can be used to efficiently
@code{REPLACE ... SELECT ...} Independent sub-selects will probably delete rows based on information from one table or even from many tables
be available in Version 4.0. You can now use the function @code{IN()} in at the same time.
other contexts, however.
@node Missing SELECT INTO TABLE, Missing Transactions, Missing Sub-selects, Missing functions @node Missing SELECT INTO TABLE, Missing Transactions, Missing Sub-selects, Missing functions
@subsubsection @code{SELECT INTO TABLE} @subsubsection @code{SELECT INTO TABLE}
...@@ -291,6 +291,7 @@ __lock_init(dbenv, lt) ...@@ -291,6 +291,7 @@ __lock_init(dbenv, lt)
sizeof(struct __db_lock), MUTEX_ALIGN, &lp)) != 0) sizeof(struct __db_lock), MUTEX_ALIGN, &lp)) != 0)
goto mem_err; goto mem_err;
lp->status = DB_LSTAT_FREE; lp->status = DB_LSTAT_FREE;
lp->gen=0;
if ((ret = __db_shmutex_init(dbenv, &lp->mutex, if ((ret = __db_shmutex_init(dbenv, &lp->mutex,
R_OFFSET(&lt->reginfo, &lp->mutex) + DB_FCNTL_OFF_LOCK, R_OFFSET(&lt->reginfo, &lp->mutex) + DB_FCNTL_OFF_LOCK,
MUTEX_SELF_BLOCK, &lt->reginfo, MUTEX_SELF_BLOCK, &lt->reginfo,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -362,3 +362,9 @@ _userid ...@@ -362,3 +362,9 @@ _userid
marc@anyware.co.uk marc@anyware.co.uk
_userid _userid
marc@anyware.co.uk marc@anyware.co.uk
f1
65
379
468
469
508
65,-1,1
379,-1,1
468,-1,1
469,-1,1
508,-1,1
...@@ -338,3 +338,18 @@ SELECT * FROM t1; ...@@ -338,3 +338,18 @@ SELECT * FROM t1;
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk'; SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
drop table t1; drop table t1;
set autocommit=1; set autocommit=1;
#
# Test of load data infile
#
CREATE TABLE if not exists `t1` (
`f1` int(11) unsigned NOT NULL default '0',
`f2` tinyint(3) unsigned NOT NULL default '0',
`f3` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`f1`)
) TYPE=Gemini;
lock table t1 write;
load data infile ''../../std_data/gemini.dat' ignore into table t1 fields terminated by ',';
select f1 from t1;
drop table t1;
...@@ -71,6 +71,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -71,6 +71,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
String *field_term=ex->field_term,*escaped=ex->escaped, String *field_term=ex->field_term,*escaped=ex->escaped,
*enclosed=ex->enclosed; *enclosed=ex->enclosed;
bool is_fifo=0; bool is_fifo=0;
bool using_transactions;
DBUG_ENTER("mysql_load"); DBUG_ENTER("mysql_load");
if (escaped->length() > 1 || enclosed->length() > 1) if (escaped->length() > 1 || enclosed->length() > 1)
...@@ -239,8 +241,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -239,8 +241,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
free_blobs(table); /* if pack_blob was used */ free_blobs(table); /* if pack_blob was used */
table->copy_blobs=0; table->copy_blobs=0;
thd->count_cuted_fields=0; /* Don`t calc cuted fields */ thd->count_cuted_fields=0; /* Don`t calc cuted fields */
using_transactions = table->file->has_transactions();
if (error) if (error)
DBUG_RETURN(-1); // Error on read {
if (using_transactions)
ha_autocommit_or_rollback(thd,error);
DBUG_RETURN(-1); // Error on read
}
sprintf(name,ER(ER_LOAD_INFO),info.records,info.deleted, sprintf(name,ER(ER_LOAD_INFO),info.records,info.deleted,
info.records-info.copied,thd->cuted_fields); info.records-info.copied,thd->cuted_fields);
send_ok(&thd->net,info.copied+info.deleted,0L,name); send_ok(&thd->net,info.copied+info.deleted,0L,name);
...@@ -248,7 +255,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -248,7 +255,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if(!thd->slave_thread) if(!thd->slave_thread)
mysql_update_log.write(thd,thd->query,thd->query_length); mysql_update_log.write(thd,thd->query,thd->query_length);
if (!table->file->has_transactions()) if (!using_transactions)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
if (!read_file_from_client && mysql_bin_log.is_open()) if (!read_file_from_client && mysql_bin_log.is_open())
{ {
...@@ -257,7 +264,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -257,7 +264,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
handle_duplicates); handle_duplicates);
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
DBUG_RETURN(0); if (using_transactions)
error=ha_autocommit_or_rollback(thd,error);
DBUG_RETURN(error);
} }
......
...@@ -182,6 +182,8 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, ...@@ -182,6 +182,8 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
TABLE_LIST table_list; TABLE_LIST table_list;
DBUG_ENTER("mysql_find_files"); DBUG_ENTER("mysql_find_files");
if (wild && !wild[0])
wild=0;
bzero((char*) &table_list,sizeof(table_list)); bzero((char*) &table_list,sizeof(table_list));
if (!(dirp = my_dir(path,MYF(MY_WME | (dir ? MY_WANT_STAT : 0))))) if (!(dirp = my_dir(path,MYF(MY_WME | (dir ? MY_WANT_STAT : 0)))))
...@@ -200,7 +202,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, ...@@ -200,7 +202,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
#endif #endif
{ {
if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat.st_mode) || if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat.st_mode) ||
(wild && wild[0] && wild_compare(file->name,wild))) (wild && wild_compare(file->name,wild)))
continue; continue;
} }
} }
...@@ -211,8 +213,16 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, ...@@ -211,8 +213,16 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
is_prefix(file->name,tmp_file_prefix)) is_prefix(file->name,tmp_file_prefix))
continue; continue;
*ext=0; *ext=0;
if (wild && wild[0] && wild_compare(file->name,wild)) if (wild)
continue; {
if (lower_case_table_names)
{
if (wild_case_compare(file->name,wild))
continue;
}
else if (wild_compare(file->name,wild))
continue;
}
} }
/* Don't show tables where we don't have any privileges */ /* Don't show tables where we don't have any privileges */
if (db && !(col_access & TABLE_ACLS)) if (db && !(col_access & TABLE_ACLS))
......
...@@ -542,8 +542,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) ...@@ -542,8 +542,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
#endif #endif
int wild_case_compare(const char *str,const char *str_end, int wild_case_compare(const char *str,const char *str_end,
const char *wildstr,const char *wildend, const char *wildstr,const char *wildend,
char escape) char escape)
{ {
int result= -1; // Not found, using wildcards int result= -1; // Not found, using wildcards
#ifdef USE_MB #ifdef USE_MB
...@@ -677,7 +677,7 @@ int wild_case_compare(String &match,String &wild, char escape) ...@@ -677,7 +677,7 @@ int wild_case_compare(String &match,String &wild, char escape)
*/ */
int wild_compare(const char *str,const char *str_end, int wild_compare(const char *str,const char *str_end,
const char *wildstr,const char *wildend,char escape) const char *wildstr,const char *wildend,char escape)
{ {
int result= -1; // Not found, using wildcards int result= -1; // Not found, using wildcards
while (wildstr != wildend) while (wildstr != wildend)
......
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