summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2015-05-07 16:59:25 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2015-05-07 16:59:25 +0200
commit3a889b1f90271b64f9bd3e42ec7c1b05908d2b39 (patch)
tree2f1759c463654a7d864583d160493f654d538d01
parent12bebceb8e37d7c8a57a56ea3391d2d76f74d5b4 (diff)
downloadmariadb-git-3a889b1f90271b64f9bd3e42ec7c1b05908d2b39.tar.gz
Fix a bug in init_table_share that caused syntax error with Boolean options:
oom|= sql->append(vull ? "ON" : "OFF"); replaced by: oom|= sql->append(vull ? "YES" : "NO"); modified: ha_connect.cc Make DBF tables to be usable in big-endian machines (test version) modified: filamdbf.cpp
-rw-r--r--storage/connect/filamdbf.cpp25
-rw-r--r--storage/connect/ha_connect.cc2
2 files changed, 17 insertions, 10 deletions
diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp
index 98b8bb6fd95..7acbba309b2 100644
--- a/storage/connect/filamdbf.cpp
+++ b/storage/connect/filamdbf.cpp
@@ -115,6 +115,7 @@ typedef struct _descriptor {
/* Side effects: */
/* Moves file pointer to byte 32; fills buffer at buf with */
/* first 32 bytes of file. */
+/* Converts numeric values to platform byte ordering (LE in file) */
/****************************************************************************/
static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
{
@@ -142,6 +143,11 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
} else
strcpy(g->Message, MSG(DBASE_FILE));
+ // Convert numeric fields to have them in platform byte ordering
+ buf->Records = uint4korr(&buf->Records);
+ buf->Headlen = uint2korr(&buf->Headlen);
+ buf->Reclen = uint2korr(&buf->Reclen);
+
// Check last byte(s) of header
if (fseek(file, buf->Headlen - dbc, SEEK_SET) != 0) {
sprintf(g->Message, MSG(BAD_HEADER), fn);
@@ -565,8 +571,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
header->Filedate[0] = datm->tm_year - 100;
header->Filedate[1] = datm->tm_mon + 1;
header->Filedate[2] = datm->tm_mday;
- header->Headlen = (ushort)hlen;
- header->Reclen = (ushort)reclen;
+ int2store(&header->Headlen, hlen);
+ int2store(&header->Reclen, reclen);
descp = (DESCRIPTOR*)header;
// Currently only standard Xbase types are supported
@@ -729,7 +735,7 @@ bool DBFFAM::CopyHeader(PGLOBAL g)
if (Headlen) {
void *hdr = PlugSubAlloc(g, NULL, Headlen);
size_t n, hlen = (size_t)Headlen;
- int pos = ftell(Stream);
+ int pos = ftell(Stream);
if (fseek(Stream, 0, SEEK_SET))
strcpy(g->Message, "Seek error in CopyHeader");
@@ -863,13 +869,14 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
if (n > Records) {
// Update the number of rows in the file header
- char filename[_MAX_PATH];
+ char filename[_MAX_PATH], nRecords[4];
+ int4store(&nRecords, n);
PlugSetPath(filename, To_File, Tdbp->GetPath());
if ((Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "r+b")))
{
fseek(Stream, 4, SEEK_SET); // Get header.Records position
- fwrite(&n, sizeof(int), 1, Stream);
+ fwrite(nRecords, sizeof(nRecords), 1, Stream);
fclose(Stream);
Stream= NULL;
Records= n; // Update Records value
@@ -944,13 +951,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
/************************************************************************/
DBFHEADER *hp = (DBFHEADER*)Memory;
- if (Lrecl != (int)hp->Reclen) {
- sprintf(g->Message, MSG(BAD_LRECL), Lrecl, hp->Reclen);
+ if (Lrecl != (int)uint2korr(&hp->Reclen)) {
+ sprintf(g->Message, MSG(BAD_LRECL), Lrecl, uint2korr(&hp->Reclen));
return true;
} // endif Lrecl
- Records = (int)hp->Records;
- Headlen = (int)hp->Headlen;
+ Records = (int)uint4korr(&hp->Records);
+ Headlen = (int)uint2korr(&hp->Headlen);
} // endif Headlen
/**************************************************************************/
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 765c04bd2be..f2827f56cd8 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -4901,7 +4901,7 @@ static int init_table_share(THD* thd,
oom|= sql->append(' ');
oom|= sql->append(opt->name);
oom|= sql->append('=');
- oom|= sql->append(vull ? "ON" : "OFF");
+ oom|= sql->append(vull ? "YES" : "NO");
} // endif vull
break;