Commit 66ffa094 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix a test failure. Due to mmap on void file being accepted on Windows

  while returning an error on Linux. Now accepted on linux.
modified:
  storage/connect/maputil.cpp

- Fix a BUG in the XHUGE class. lseek64 was wrongly regarded as in error
  when returning 0 instead of -1. This produced wrong index files.
modified:
  storage/connect/filamfix.cpp
  storage/connect/maputil.cpp
  storage/connect/xindex.cpp

- Fix length mismatch (tab instead of blanks?)
modified:
  storage/connect/mysql-test/connect/r/updelx.result
parent 8f0e7528
...@@ -647,7 +647,9 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org) ...@@ -647,7 +647,9 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
} // endif } // endif
#else // !WIN32 #else // !WIN32
if (lseek64(h, pos, org) < 0) { if (lseek64(h, pos, org) < 0) {
sprintf(g->Message, MSG(ERROR_IN_LSK), errno); // sprintf(g->Message, MSG(ERROR_IN_LSK), errno);
sprintf(g->Message, "lseek64: %s", strerror(errno));
printf("%s\n", g->Message);
return true; return true;
} // endif } // endif
#endif // !WIN32 #endif // !WIN32
...@@ -849,7 +851,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) ...@@ -849,7 +851,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
#else // UNIX #else // UNIX
int rc = 0; int rc = 0;
int oflag = O_LARGEFILE; // Enable file size > 2G int oflag = O_LARGEFILE; // Enable file size > 2G
mode_t tmode = 0; mode_t tmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
/*********************************************************************/ /*********************************************************************/
/* Create the file object according to access mode */ /* Create the file object according to access mode */
...@@ -874,7 +876,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g) ...@@ -874,7 +876,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
break; break;
case MODE_INSERT: case MODE_INSERT:
oflag |= (O_WRONLY | O_CREAT | O_APPEND); oflag |= (O_WRONLY | O_CREAT | O_APPEND);
tmode = S_IREAD | S_IWRITE; // tmode = S_IREAD | S_IWRITE;
break; break;
default: default:
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode); sprintf(g->Message, MSG(BAD_OPEN_MODE), mode);
......
...@@ -164,17 +164,19 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName, ...@@ -164,17 +164,19 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} // endif fstat } // endif fstat
filesize = st.st_size; if ((filesize = st.st_size))
// Now we are ready to load the file. If mmap() is available we try // Now we are ready to load the file. If mmap() is available we try
// this first. If not available or it failed we try to load it. // this first. If not available or it failed we try to load it.
mm->memory = mmap(NULL, filesize, protmode, MAP_SHARED, fd, 0); mm->memory = mmap(NULL, filesize, protmode, MAP_SHARED, fd, 0);
else
mm->memory = 0;
if (mm->memory != MAP_FAILED) { if (mm->memory != MAP_FAILED) {
mm->lenL = (mm->memory != 0) ? filesize : 0; mm->lenL = (mm->memory != 0) ? filesize : 0;
mm->lenH = 0; mm->lenH = 0;
} else { } else {
strcpy(g->Message, "Memory mapping failed"); strcpy(g->Message, "Memory mapping failed");
close(fd);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} // endif memory } // endif memory
......
...@@ -2478,7 +2478,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2478,7 +2478,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
} // endif } // endif
if (trace) if (trace)
htrc(" Xopen: filename=%s mode=%d\n", filename, mode); htrc(" Xopen: filename=%s id=%d mode=%d\n", filename, id, mode);
#if defined(WIN32) #if defined(WIN32)
LONG high = 0; LONG high = 0;
...@@ -2570,7 +2570,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2570,7 +2570,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
#else // UNIX #else // UNIX
int oflag = O_LARGEFILE; // Enable file size > 2G int oflag = O_LARGEFILE; // Enable file size > 2G
mode_t pmod = 0; mode_t pmod = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
/*********************************************************************/ /*********************************************************************/
/* Create the file object according to access mode */ /* Create the file object according to access mode */
...@@ -2581,7 +2581,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2581,7 +2581,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
break; break;
case MODE_WRITE: case MODE_WRITE:
oflag |= O_WRONLY | O_CREAT | O_TRUNC; oflag |= O_WRONLY | O_CREAT | O_TRUNC;
pmod = S_IREAD | S_IWRITE; // pmod = S_IREAD | S_IWRITE;
break; break;
case MODE_INSERT: case MODE_INSERT:
oflag |= (O_WRONLY | O_APPEND); oflag |= (O_WRONLY | O_APPEND);
...@@ -2614,6 +2614,9 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2614,6 +2614,9 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return true; return true;
} // endif } // endif
if (trace)
htrc("INSERT: NewOff=%lld\n", NewOff.Val);
} else if (mode == MODE_WRITE) { } else if (mode == MODE_WRITE) {
if (id >= 0) { if (id >= 0) {
// New not sep index file. Write the header. // New not sep index file. Write the header.
...@@ -2621,18 +2624,26 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode) ...@@ -2621,18 +2624,26 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
NewOff.Low = write(Hfile, &noff, sizeof(noff)); NewOff.Low = write(Hfile, &noff, sizeof(noff));
} // endif id } // endif id
if (trace)
htrc("WRITE: NewOff=%lld\n", NewOff.Val);
} else if (mode == MODE_READ && id >= 0) { } else if (mode == MODE_READ && id >= 0) {
// Get offset from the header // Get offset from the header
if (read(Hfile, noff, sizeof(noff)) != sizeof(noff)) { if (read(Hfile, noff, sizeof(noff)) != sizeof(noff)) {
sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno)); sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno));
return true; return true;
} // endif MAX_INDX } // endif read
if (trace)
htrc("noff[%d]=%lld\n", id, noff[id].Val);
// Position the cursor at the offset of this index // Position the cursor at the offset of this index
if (!lseek64(Hfile, noff[id].Val, SEEK_SET)) { if (lseek64(Hfile, noff[id].Val, SEEK_SET) < 0) {
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Hseek"); sprintf(g->Message, "(XHUGE)lseek64: %s (%lld)", strerror(errno), noff[id].Val);
printf("%s\n", g->Message);
// sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Hseek");
return true; return true;
} // endif } // endif lseek64
} // endif mode } // endif mode
#endif // UNIX #endif // UNIX
...@@ -2766,6 +2777,9 @@ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc) ...@@ -2766,6 +2777,9 @@ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
/***********************************************************************/ /***********************************************************************/
void XHUGE::Close(char *fn, int id) void XHUGE::Close(char *fn, int id)
{ {
if (trace)
htrc("XHUGE::Close: fn=%s id=%d NewOff=%lld\n", fn, id, NewOff.Val);
#if defined(WIN32) #if defined(WIN32)
if (id >= 0 && fn) { if (id >= 0 && fn) {
CloseFileHandle(Hfile); CloseFileHandle(Hfile);
...@@ -2783,10 +2797,18 @@ void XHUGE::Close(char *fn, int id) ...@@ -2783,10 +2797,18 @@ void XHUGE::Close(char *fn, int id)
} // endif id } // endif id
#else // !WIN32 #else // !WIN32
if (id >= 0 && fn) { if (id >= 0 && fn) {
fcntl(Hfile, F_SETFD, O_WRONLY); if (Hfile != INVALID_HANDLE_VALUE) {
if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) {
ssize_t nbw = write(Hfile, &NewOff, sizeof(IOFF));
if (lseek(Hfile, id * sizeof(IOFF), SEEK_SET)) if (nbw != (signed)sizeof(IOFF))
write(Hfile, &NewOff, sizeof(IOFF)); htrc("Error writing index file header: %s\n", strerror(errno));
} else
htrc("(XHUGE::Close)lseek64: %s (%d)\n", strerror(errno), id);
} else
htrc("(XHUGE)error reopening %s: %s\n", fn, strerror(errno));
} // endif id } // endif id
#endif // !WIN32 #endif // !WIN32
......
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