summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/connect/filamfix.cpp8
-rw-r--r--storage/connect/maputil.cpp14
-rw-r--r--storage/connect/mysql-test/connect/r/updelx.result4
-rwxr-xr-xstorage/connect/xindex.cpp46
4 files changed, 49 insertions, 23 deletions
diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp
index da05e7b824f..1fa72d52746 100644
--- a/storage/connect/filamfix.cpp
+++ b/storage/connect/filamfix.cpp
@@ -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);
diff --git a/storage/connect/maputil.cpp b/storage/connect/maputil.cpp
index 7104259ebad..97c638b4254 100644
--- a/storage/connect/maputil.cpp
+++ b/storage/connect/maputil.cpp
@@ -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
diff --git a/storage/connect/mysql-test/connect/r/updelx.result b/storage/connect/mysql-test/connect/r/updelx.result
index 1c9df294e00..2aed1e06928 100644
--- a/storage/connect/mysql-test/connect/r/updelx.result
+++ b/storage/connect/mysql-test/connect/r/updelx.result
@@ -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
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp
index 6d1b2a13ea3..b121968277f 100755
--- a/storage/connect/xindex.cpp
+++ b/storage/connect/xindex.cpp
@@ -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