From 0b5c41acc70395e03798dcf715967244d10407c3 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.blaudden" <> Date: Tue, 20 Feb 2007 12:06:04 +0100 Subject: [PATCH 1/2] Bug#25807 LOAD DATA INFILE does not work with Pipes - Additional fix for io_cache_init being called on a closed file --- mysys/mf_iocache.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index e40490776f8..d2ace12da4d 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -170,24 +170,28 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, info->arg = 0; info->alloced_buffer = 0; info->buffer=0; + info->seek_not_done= 0; - pos= my_tell(file, MYF(0)); - if ((pos == (my_off_t) -1) && (my_errno == ESPIPE)) + if (file >= 0) { - /* - This kind of object doesn't support seek() or tell(). Don't set a flag - that will make us again try to seek() later and fail. - */ - info->seek_not_done= 0; - /* - Additionally, if we're supposed to start somewhere other than the - the beginning of whatever this file is, then somebody made a bad - assumption. - */ - DBUG_ASSERT(seek_offset == 0); + pos= my_tell(file, MYF(0)); + if ((pos == (my_off_t) -1) && (my_errno == ESPIPE)) + { + /* + This kind of object doesn't support seek() or tell(). Don't set a + flag that will make us again try to seek() later and fail. + */ + info->seek_not_done= 0; + /* + Additionally, if we're supposed to start somewhere other than the + the beginning of whatever this file is, then somebody made a bad + assumption. + */ + DBUG_ASSERT(seek_offset == 0); + } + else + info->seek_not_done= test(seek_offset != pos); } - else - info->seek_not_done= test(file >= 0 && seek_offset != pos); info->disk_writes= 0; #ifdef THREAD From a799f2b6379d4772a8189e9fb19a564d56ebc3f2 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.blaudden" <> Date: Tue, 20 Feb 2007 13:06:01 +0100 Subject: [PATCH 2/2] Change "exec echo" commands with different delimiters that are also escape chars to use "write_file" to avoid confusion about what's what. --- mysql-test/t/mysql.test | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 4270d8dec80..b46e4d5e595 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -250,16 +250,22 @@ drop table t17583; # # This should work just fine... ---exec echo "DELIMITER /" > $MYSQLTEST_VARDIR/tmp/bug21412.sql ---exec echo "SELECT 1/" >> $MYSQLTEST_VARDIR/tmp/bug21412.sql +--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql +DELIMITER / +SELECT 1/ +EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 # This should give an error... ---exec echo "DELIMITER \\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql +DELIMITER \ +EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 # As should this... ---exec echo "DELIMITER \\\\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--write_file $MYSQLTEST_VARDIR/tmp/bug21412.sql +DELIMITER \\ +EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 --echo End of 5.0 tests