summaryrefslogtreecommitdiff
path: root/innobase/fil/fil0fil.c
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2005-01-21 18:16:02 +0200
committerunknown <heikki@hundin.mysql.fi>2005-01-21 18:16:02 +0200
commit3cbafff2e039f2916212dd8c2cd63fba410d2e23 (patch)
tree7125ee2765ee0fbd669fdf7519cf31947c9b3cae /innobase/fil/fil0fil.c
parent90f94790986ba8c3938b575d8e5592a7a06471db (diff)
parent6eecb8e4e206db57b3d01c07f0482e86af6b4e12 (diff)
downloadmariadb-git-3cbafff2e039f2916212dd8c2cd63fba410d2e23.tar.gz
Merge hundin.mysql.fi:/home/heikki/mysql-4.1
into hundin.mysql.fi:/home/heikki/mysql-5.0 innobase/dict/dict0crea.c: Auto merged innobase/dict/dict0dict.c: Auto merged innobase/dict/dict0load.c: Auto merged innobase/fil/fil0fil.c: Auto merged
Diffstat (limited to 'innobase/fil/fil0fil.c')
-rw-r--r--innobase/fil/fil0fil.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
index f2d0790892e..2a2ce73bd7f 100644
--- a/innobase/fil/fil0fil.c
+++ b/innobase/fil/fil0fil.c
@@ -480,28 +480,33 @@ fil_node_open_file(
ut_a(node->n_pending == 0);
ut_a(node->open == FALSE);
- /* printf("Opening file %s\n", node->name); */
+ if (node->size == 0) {
+ /* It must be a single-table tablespace and we do not know the
+ size of the file yet. First we open the file in the normal
+ mode, no async I/O here, for simplicity. Then do some checks,
+ and close the file again.
+ NOTE that we could not use the simple file read function
+ os_file_read() in Windows to read from a file opened for
+ async I/O! */
+
+ node->handle = os_file_create_simple_no_error_handling(
+ node->name, OS_FILE_OPEN,
+ OS_FILE_READ_ONLY, &success);
+ if (!success) {
+ /* The following call prints an error message */
+ os_file_get_last_error(TRUE);
- if (space->purpose == FIL_LOG) {
- node->handle = os_file_create(node->name, OS_FILE_OPEN,
- OS_FILE_AIO, OS_LOG_FILE, &ret);
- } else if (node->is_raw_disk) {
- node->handle = os_file_create(node->name,
- OS_FILE_OPEN_RAW,
- OS_FILE_AIO, OS_DATA_FILE, &ret);
- } else {
- node->handle = os_file_create(node->name, OS_FILE_OPEN,
- OS_FILE_AIO, OS_DATA_FILE, &ret);
- }
-
- ut_a(ret);
-
- node->open = TRUE;
+ ut_print_timestamp(stderr);
- system->n_open++;
+ fprintf(stderr,
+" InnoDB: Fatal error: cannot open %s\n."
+"InnoDB: Have you deleted .ibd files under a running mysqld server?\n",
+ node->name);
+ ut_a(0);
+ }
- if (node->size == 0) {
ut_a(space->purpose != FIL_LOG);
+ ut_a(space->id != 0);
os_file_get_size(node->handle, &size_low, &size_high);
@@ -511,11 +516,6 @@ fil_node_open_file(
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
#else
- /* It must be a single-table tablespace and we do not know the
- size of the file yet */
-
- ut_a(space->id != 0);
-
if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
fprintf(stderr,
"InnoDB: Error: the size of single-table tablespace file %s\n"
@@ -539,6 +539,10 @@ fil_node_open_file(
ut_free(buf2);
+ /* Close the file now that we have read the space id from it */
+
+ os_file_close(node->handle);
+
if (space_id == ULINT_UNDEFINED || space_id == 0) {
fprintf(stderr,
"InnoDB: Error: tablespace id %lu in file %s is not sensible\n",
@@ -566,6 +570,30 @@ fil_node_open_file(
space->size += node->size;
}
+ /* printf("Opening file %s\n", node->name); */
+
+ /* Open the file for reading and writing, in Windows normally in the
+ unbuffered async I/O mode, though global variables may make
+ os_file_create() to fall back to the normal file I/O mode. */
+
+ if (space->purpose == FIL_LOG) {
+ node->handle = os_file_create(node->name, OS_FILE_OPEN,
+ OS_FILE_AIO, OS_LOG_FILE, &ret);
+ } else if (node->is_raw_disk) {
+ node->handle = os_file_create(node->name,
+ OS_FILE_OPEN_RAW,
+ OS_FILE_AIO, OS_DATA_FILE, &ret);
+ } else {
+ node->handle = os_file_create(node->name, OS_FILE_OPEN,
+ OS_FILE_AIO, OS_DATA_FILE, &ret);
+ }
+
+ ut_a(ret);
+
+ node->open = TRUE;
+
+ system->n_open++;
+
if (space->purpose == FIL_TABLESPACE && space->id != 0) {
/* Put the node to the LRU list */
UT_LIST_ADD_FIRST(LRU, system->LRU, node);