summaryrefslogtreecommitdiff
path: root/sql/ha_innodb.cc
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-08-20 00:52:43 +0200
committerunknown <serg@serg.mylan>2004-08-20 00:52:43 +0200
commit04c39153435896d9f49fe1b5b80bd7e11edf7bf4 (patch)
tree5fff92365d8baf56b0bfb2391843398321d56ee2 /sql/ha_innodb.cc
parent6e1b567ab3afd324606918ebc30f5205aacdc14a (diff)
parentd1c5ca31f615592f62280ef2d005fa1201541027 (diff)
downloadmariadb-git-04c39153435896d9f49fe1b5b80bd7e11edf7bf4.tar.gz
merged
BitKeeper/etc/ignore: auto-union include/my_global.h: Auto merged mysys/mf_tempfile.c: Auto merged mysql-test/r/rpl_heap.result: Auto merged mysql-test/t/rpl_heap.test: Auto merged sql/ha_innodb.cc: Auto merged
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r--sql/ha_innodb.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index b1e5a16bc32..5aa7c02fcc0 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -40,6 +40,7 @@ have disables the InnoDB inlining in this file. */
#include <m_ctype.h>
#include <hash.h>
#include <myisampack.h>
+#include <mysys_err.h>
#define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1))
@@ -433,6 +434,7 @@ innobase_mysql_tmpfile(void)
/* out: temporary file descriptor, or < 0 on error */
{
char filename[FN_REFLEN];
+ int fd2 = -1;
File fd = create_temp_file(filename, NullS, "ib",
#ifdef __WIN__
O_BINARY | O_TRUNC | O_SEQUENTIAL |
@@ -440,12 +442,31 @@ innobase_mysql_tmpfile(void)
#endif /* __WIN__ */
O_CREAT | O_EXCL | O_RDWR,
MYF(MY_WME));
-#ifndef __WIN__
if (fd >= 0) {
+#ifndef __WIN__
+ /* On Windows, open files cannot be removed, but files can be
+ created with the O_TEMPORARY flag to the same effect
+ ("delete on close"). */
unlink(filename);
- }
#endif /* !__WIN__ */
- return(fd);
+ /* Copy the file descriptor, so that the additional resources
+ allocated by create_temp_file() can be freed by invoking
+ my_close().
+
+ Because the file descriptor returned by this function
+ will be passed to fdopen(), it will be closed by invoking
+ fclose(), which in turn will invoke close() instead of
+ my_close(). */
+ fd2 = dup(fd);
+ if (fd2 < 0) {
+ DBUG_PRINT("error",("Got error %d on dup",fd2));
+ my_errno=errno;
+ my_error(EE_OUT_OF_FILERESOURCES,
+ MYF(ME_BELL+ME_WAITTANG), filename, my_errno);
+ }
+ my_close(fd, MYF(MY_WME));
+ }
+ return(fd2);
}
/*************************************************************************