From b9c910909c3e04ceab8d0d514ba6213015787c5a Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Fri, 15 May 2015 11:56:29 +0200 Subject: Fix a bug in BIN buffer initialisation (in FIXFAM::AllocateBuffer) modified: storage/connect/filamfix.cpp Second version of BIN table new field format (1st one was buggy) modified: storage/connect/tabfix.cpp modified: storage/connect/tabfix.h Make bin.test not to fail in big-endian machines modified: storage/connect/mysql-test/connect/r/bin.result modified: storage/connect/mysql-test/connect/t/bin.test Fix a bug causing wrong default offset to be generated when virtual or special columns were placed beetween standard columns. Also calculate the good offset for BIN columns with new field format. modified: storage/connect/reldef.cpp --- storage/connect/filamfix.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'storage/connect/filamfix.cpp') diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index 4dedd3375b0..c352db47044 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -46,6 +46,7 @@ #include "plgdbsem.h" #include "filamfix.h" #include "tabdos.h" +#include "tabfix.h" #include "osutil.h" #ifndef INVALID_SET_FILE_POINTER @@ -133,18 +134,35 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) if (Tdbp->GetFtype() == RECFM_BIN) { // The buffer must be prepared depending on column types int n = 0; + bool b = false; PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); - PCOLDEF cdp; +// PCOLDEF cdp; + PBINCOL colp; // Prepare the first line of the buffer memset(To_Buf, 0, Buflen); +#if 0 for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) { - if (IsTypeNum(cdp->GetType())) - memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen()); + if (!IsTypeNum(cdp->GetType())) { + memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen()); + b = true; + } // endif not num - n = MY_MAX(n, cdp->GetPoff() + cdp->GetClen()); + n = MY_MAX(n, cdp->GetOffset() + cdp->GetClen()); } // endfor cdp +#endif // 0 + + for (colp = (PBINCOL)Tdbp->GetColumns(); colp; + colp = (PBINCOL)colp->GetNext()) + if (!colp->IsSpecial()) { + if (!IsTypeNum(colp->GetResultType())) { + memset(To_Buf + colp->GetDeplac(), ' ', colp->GetLength()); + b = true; + } // endif not num + + n = MY_MAX(n, colp->GetDeplac() + colp->GetFileSize()); + } // endif !special // We do this for binary table because the lrecl can have been // specified with additional space to include line ending. @@ -156,9 +174,10 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) } // endif n - // Now repeat this for the whole buffer - for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl) - memcpy(To_Buf + len, To_Buf, Lrecl); + if (b) + // Now repeat this for the whole buffer + for (int len = Lrecl; len <= Buflen - Lrecl; len += Lrecl) + memcpy(To_Buf + len, To_Buf, Lrecl); } else { memset(To_Buf, ' ', Buflen); -- cgit v1.2.1