summaryrefslogtreecommitdiff
path: root/storage/connect/filamfix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/connect/filamfix.cpp')
-rw-r--r--storage/connect/filamfix.cpp54
1 files changed, 42 insertions, 12 deletions
diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp
index 1fa72d52746..980d558eee5 100644
--- a/storage/connect/filamfix.cpp
+++ b/storage/connect/filamfix.cpp
@@ -52,7 +52,6 @@
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
-extern "C" int trace;
extern int num_read, num_there, num_eq[2]; // Statistics
/* --------------------------- Class FIXFAM -------------------------- */
@@ -131,18 +130,49 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g)
/*******************************************************************/
/* For Insert the buffer must be prepared. */
/*******************************************************************/
- memset(To_Buf, ' ', Buflen);
+ if (Tdbp->GetFtype() == RECFM_BIN) {
+ // The buffer must be prepared depending on column types
+ int n = 0;
+ PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
+ PCOLDEF cdp;
- if (/*Tdbp->GetFtype() < 2 &&*/ !Padded)
- // If not binary, the file is physically a text file.
- // We do it also for binary table because the lrecl can have been
+ // Prepare the first line of the buffer
+ memset(To_Buf, 0, Buflen);
+
+ for (cdp = defp->GetCols(); cdp; cdp = cdp->GetNext()) {
+ if (IsTypeNum(cdp->GetType()))
+ memset(To_Buf + cdp->GetOffset(), ' ', cdp->GetClen());
+
+ n = MY_MAX(n, cdp->GetPoff() + cdp->GetClen());
+ } // endfor cdp
+
+ // We do this for binary table because the lrecl can have been
// specified with additional space to include line ending.
- for (int len = Lrecl; len <= Buflen; len += Lrecl) {
-#if defined(WIN32)
- To_Buf[len - 2] = '\r';
-#endif // WIN32
- To_Buf[len - 1] = '\n';
- } // endfor len
+ if (n < Lrecl && Ending) {
+ To_Buf[Lrecl - 1] = '\n';
+
+ if (n < Lrecl - 1 && Ending == 2)
+ To_Buf[Lrecl - 2] = '\r';
+
+ } // 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);
+
+ } else {
+ memset(To_Buf, ' ', Buflen);
+
+ if (!Padded)
+ // The file is physically a text file.
+ for (int len = Lrecl; len <= Buflen; len += Lrecl) {
+ if (Ending == 2)
+ To_Buf[len - 2] = '\r';
+
+ To_Buf[len - 1] = '\n';
+ } // endfor len
+
+ } // endif Ftype
Rbuf = Nrec; // To be used by WriteDB
} // endif Insert
@@ -205,7 +235,7 @@ int FIXFAM::WriteModifiedBlock(PGLOBAL g)
// NOTE: Next line was added to avoid a very strange fread bug.
// When the fseek is not executed (even the file has the good
// pointer position) the next read can happen anywhere in the file.
- OldBlk = CurBlk; // This will force fseek to be executed
+ OldBlk = -2; // This will force fseek to be executed
Modif = 0;
return rc;
} // end of WriteModifiedBlock