mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
- 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
This commit is contained in:
parent
8f0e75285e
commit
66ffa09491
4 changed files with 49 additions and 23 deletions
|
@ -647,7 +647,9 @@ bool BGXFAM::BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, int org)
|
|||
} // endif
|
||||
#else // !WIN32
|
||||
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;
|
||||
} // endif
|
||||
#endif // !WIN32
|
||||
|
@ -849,7 +851,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
|
|||
#else // UNIX
|
||||
int rc = 0;
|
||||
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 */
|
||||
|
@ -874,7 +876,7 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
|
|||
break;
|
||||
case MODE_INSERT:
|
||||
oflag |= (O_WRONLY | O_CREAT | O_APPEND);
|
||||
tmode = S_IREAD | S_IWRITE;
|
||||
// tmode = S_IREAD | S_IWRITE;
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, MSG(BAD_OPEN_MODE), mode);
|
||||
|
|
|
@ -154,7 +154,7 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
|
|||
} // endswitch
|
||||
|
||||
// Try to open the addressed file.
|
||||
fd= global_open(g, MSGID_NONE, fileName, openMode);
|
||||
fd= global_open(g, MSGID_NONE, fileName, openMode);
|
||||
|
||||
if (fd != INVALID_HANDLE_VALUE && mode != MODE_INSERT) {
|
||||
/* We must know about the size of the file. */
|
||||
|
@ -164,17 +164,19 @@ HANDLE CreateFileMap(PGLOBAL g, LPCSTR fileName,
|
|||
return INVALID_HANDLE_VALUE;
|
||||
} // endif fstat
|
||||
|
||||
filesize = st.st_size;
|
||||
|
||||
// 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.
|
||||
mm->memory = mmap(NULL, filesize, protmode, MAP_SHARED, fd, 0);
|
||||
if ((filesize = st.st_size))
|
||||
// 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.
|
||||
mm->memory = mmap(NULL, filesize, protmode, MAP_SHARED, fd, 0);
|
||||
else
|
||||
mm->memory = 0;
|
||||
|
||||
if (mm->memory != MAP_FAILED) {
|
||||
mm->lenL = (mm->memory != 0) ? filesize : 0;
|
||||
mm->lenH = 0;
|
||||
} else {
|
||||
strcpy(g->Message, "Memory mapping failed");
|
||||
close(fd);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
} // endif memory
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ id msg
|
|||
UPDATE t1 SET msg = 'sixty' WHERE id = 60;
|
||||
SELECT * FROM t1 WHERE id = 60;
|
||||
id msg
|
||||
60 sixty
|
||||
60 sixty
|
||||
DELETE FROM t1 WHERE id = 4;
|
||||
SELECT * FROM t1;
|
||||
id msg
|
||||
|
@ -809,7 +809,7 @@ id msg
|
|||
UPDATE t1 SET msg = 'sixty' WHERE id = 60;
|
||||
SELECT * FROM t1 WHERE id = 60;
|
||||
id msg
|
||||
60 sixty
|
||||
60 sixty
|
||||
DELETE FROM t1 WHERE id = 4;
|
||||
SELECT * FROM t1;
|
||||
id msg
|
||||
|
|
|
@ -2470,7 +2470,7 @@ void *XFILE::FileView(PGLOBAL g, char *fn)
|
|||
/***********************************************************************/
|
||||
bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
||||
{
|
||||
IOFF noff[MAX_INDX];
|
||||
IOFF noff[MAX_INDX];
|
||||
|
||||
if (Hfile != INVALID_HANDLE_VALUE) {
|
||||
sprintf(g->Message, MSG(FILE_OPEN_YET), filename);
|
||||
|
@ -2478,7 +2478,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||
} // endif
|
||||
|
||||
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)
|
||||
LONG high = 0;
|
||||
|
@ -2570,7 +2570,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||
|
||||
#else // UNIX
|
||||
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 */
|
||||
|
@ -2581,7 +2581,7 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||
break;
|
||||
case MODE_WRITE:
|
||||
oflag |= O_WRONLY | O_CREAT | O_TRUNC;
|
||||
pmod = S_IREAD | S_IWRITE;
|
||||
// pmod = S_IREAD | S_IWRITE;
|
||||
break;
|
||||
case MODE_INSERT:
|
||||
oflag |= (O_WRONLY | O_APPEND);
|
||||
|
@ -2614,6 +2614,9 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||
return true;
|
||||
} // endif
|
||||
|
||||
if (trace)
|
||||
htrc("INSERT: NewOff=%lld\n", NewOff.Val);
|
||||
|
||||
} else if (mode == MODE_WRITE) {
|
||||
if (id >= 0) {
|
||||
// New not sep index file. Write the header.
|
||||
|
@ -2621,18 +2624,26 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
|
|||
NewOff.Low = write(Hfile, &noff, sizeof(noff));
|
||||
} // endif id
|
||||
|
||||
if (trace)
|
||||
htrc("WRITE: NewOff=%lld\n", NewOff.Val);
|
||||
|
||||
} else if (mode == MODE_READ && id >= 0) {
|
||||
// Get offset from the header
|
||||
if (read(Hfile, noff, sizeof(noff)) != sizeof(noff)) {
|
||||
sprintf(g->Message, MSG(READ_ERROR), "Index file", strerror(errno));
|
||||
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
|
||||
if (!lseek64(Hfile, noff[id].Val, SEEK_SET)) {
|
||||
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Hseek");
|
||||
if (lseek64(Hfile, noff[id].Val, SEEK_SET) < 0) {
|
||||
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;
|
||||
} // endif
|
||||
} // endif lseek64
|
||||
|
||||
} // endif mode
|
||||
#endif // UNIX
|
||||
|
@ -2766,6 +2777,9 @@ int XHUGE::Write(PGLOBAL g, void *buf, int n, int size, bool& rc)
|
|||
/***********************************************************************/
|
||||
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 (id >= 0 && fn) {
|
||||
CloseFileHandle(Hfile);
|
||||
|
@ -2783,10 +2797,18 @@ void XHUGE::Close(char *fn, int id)
|
|||
} // endif id
|
||||
#else // !WIN32
|
||||
if (id >= 0 && fn) {
|
||||
fcntl(Hfile, F_SETFD, O_WRONLY);
|
||||
|
||||
if (lseek(Hfile, id * sizeof(IOFF), SEEK_SET))
|
||||
write(Hfile, &NewOff, sizeof(IOFF));
|
||||
if (Hfile != INVALID_HANDLE_VALUE) {
|
||||
if (lseek64(Hfile, id * sizeof(IOFF), SEEK_SET) >= 0) {
|
||||
ssize_t nbw = write(Hfile, &NewOff, sizeof(IOFF));
|
||||
|
||||
if (nbw != (signed)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 // !WIN32
|
||||
|
|
Loading…
Add table
Reference in a new issue