Skip to content

Commit c4dcfb6

Browse files
committed
Merge branch 'merge-innodb-5.6' into 10.0
5.6.30
2 parents 872649c + f1aae86 commit c4dcfb6

File tree

9 files changed

+355
-130
lines changed

9 files changed

+355
-130
lines changed

storage/innobase/fil/fil0fil.cc

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -3047,8 +3047,6 @@ fil_create_link_file(
30473047
const char* tablename, /*!< in: tablename */
30483048
const char* filepath) /*!< in: pathname of tablespace */
30493049
{
3050-
os_file_t file;
3051-
ibool success;
30523050
dberr_t err = DB_SUCCESS;
30533051
char* link_filepath;
30543052
char* prev_filepath = fil_read_link_file(tablename);
@@ -3067,13 +3065,24 @@ fil_create_link_file(
30673065

30683066
link_filepath = fil_make_isl_name(tablename);
30693067

3070-
file = os_file_create_simple_no_error_handling(
3071-
innodb_file_data_key, link_filepath,
3072-
OS_FILE_CREATE, OS_FILE_READ_WRITE, &success);
3068+
/** Check if the file already exists. */
3069+
FILE* file = NULL;
3070+
ibool exists;
3071+
os_file_type_t ftype;
30733072

3074-
if (!success) {
3075-
/* The following call will print an error message */
3076-
ulint error = os_file_get_last_error(true);
3073+
bool success = os_file_status(link_filepath, &exists, &ftype);
3074+
3075+
ulint error = 0;
3076+
if (success && !exists) {
3077+
file = fopen(link_filepath, "w");
3078+
if (file == NULL) {
3079+
/* This call will print its own error message */
3080+
error = os_file_get_last_error(true);
3081+
}
3082+
} else {
3083+
error = OS_FILE_ALREADY_EXISTS;
3084+
}
3085+
if (error != 0) {
30773086

30783087
ut_print_timestamp(stderr);
30793088
fputs(" InnoDB: Cannot create file ", stderr);
@@ -3098,13 +3107,17 @@ fil_create_link_file(
30983107
return(err);
30993108
}
31003109

3101-
if (!os_file_write(link_filepath, file, filepath, 0,
3102-
strlen(filepath))) {
3110+
ulint rbytes = fwrite(filepath, 1, strlen(filepath), file);
3111+
if (rbytes != strlen(filepath)) {
3112+
os_file_get_last_error(true);
3113+
ib_logf(IB_LOG_LEVEL_ERROR,
3114+
"cannot write link file "
3115+
"%s",filepath);
31033116
err = DB_ERROR;
31043117
}
31053118

31063119
/* Close the file, we only need it at startup */
3107-
os_file_close(file);
3120+
fclose(file);
31083121

31093122
mem_free(link_filepath);
31103123

0 commit comments

Comments
 (0)