Commit ad41e7ee authored by Olivier Bertrand's avatar Olivier Bertrand

Fix incorrect DBF type setting for SORT and BIGINT.

parent 7af8c83d
...@@ -963,7 +963,7 @@ ...@@ -963,7 +963,7 @@
#define MSG_VALTYPE_NOMATCH "Non matching Value types" #define MSG_VALTYPE_NOMATCH "Non matching Value types"
#define MSG_VALUE_ERROR "Column %s: value is null" #define MSG_VALUE_ERROR "Column %s: value is null"
#define MSG_VALUE_NOT_ALLOC "Value not allocated for column R%d %s" #define MSG_VALUE_NOT_ALLOC "Value not allocated for column R%d %s"
#define MSG_VALUE_TOO_BIG "Value %d too big for column %s" #define MSG_VALUE_TOO_BIG "Value %lld too big for column %s"
#define MSG_VALUE_TOO_LONG "Value %s too long for column %s of length %d" #define MSG_VALUE_TOO_LONG "Value %s too long for column %s of length %d"
#define MSG_VAL_ALLOC_ERR "Cannot allocate value node" #define MSG_VAL_ALLOC_ERR "Cannot allocate value node"
#define MSG_VAL_TOO_LONG "Value field %s too long for %s" #define MSG_VAL_TOO_LONG "Value field %s too long for %s"
......
...@@ -512,6 +512,7 @@ bool DBFFAM::OpenTableFile(PGLOBAL g) ...@@ -512,6 +512,7 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
/****************************************************************************/ /****************************************************************************/
bool DBFFAM::AllocateBuffer(PGLOBAL g) bool DBFFAM::AllocateBuffer(PGLOBAL g)
{ {
char c;
int rc; int rc;
MODE mode = Tdbp->GetMode(); MODE mode = Tdbp->GetMode();
...@@ -570,12 +571,29 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) ...@@ -570,12 +571,29 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
header->Reclen = (ushort)reclen; header->Reclen = (ushort)reclen;
descp = (DESCRIPTOR*)header; descp = (DESCRIPTOR*)header;
// Currently only standard Xbase types are supported
for (cdp = tdp->GetCols(); cdp; cdp = cdp->GetNext()) { for (cdp = tdp->GetCols(); cdp; cdp = cdp->GetNext()) {
descp++; descp++;
switch ((c = *GetFormatType(cdp->GetType()))) {
case 'S': // Short integer
case 'L': // Large (big) integer
c = 'N'; // Numeric
case 'N': // Numeric (integer)
case 'F': // Float (double)
descp->Decimals = (uchar)cdp->F.Prec;
case 'C': // Char
case 'D': // Date
break;
default: // Should never happen
sprintf(g->Message, "Unsupported DBF type %c for column %s",
c, cdp->GetName());
return true;
} // endswitch c
strncpy(descp->Name, cdp->GetName(), 11); strncpy(descp->Name, cdp->GetName(), 11);
descp->Type = *GetFormatType(cdp->GetType()); descp->Type = c;
descp->Length = (uchar)cdp->GetLong(); descp->Length = (uchar)cdp->GetLong();
descp->Decimals = (uchar)cdp->F.Prec;
} // endfor cdp } // endfor cdp
*(char*)(++descp) = EOH; *(char*)(++descp) = EOH;
......
...@@ -963,7 +963,7 @@ ...@@ -963,7 +963,7 @@
#define MSG_VALTYPE_NOMATCH "Disparité types de valeur" #define MSG_VALTYPE_NOMATCH "Disparité types de valeur"
#define MSG_VALUE_ERROR "Colonne %s: bloc valeur nul" #define MSG_VALUE_ERROR "Colonne %s: bloc valeur nul"
#define MSG_VALUE_NOT_ALLOC "Valeur non allouée pour la colonne R%d %s" #define MSG_VALUE_NOT_ALLOC "Valeur non allouée pour la colonne R%d %s"
#define MSG_VALUE_TOO_BIG "Valeur %d trop grande pour la colonne %s" #define MSG_VALUE_TOO_BIG "Valeur %lld trop grande pour la colonne %s"
#define MSG_VALUE_TOO_LONG "Valeur %s trop longue pour la colonne %s de longueur %d" #define MSG_VALUE_TOO_LONG "Valeur %s trop longue pour la colonne %s de longueur %d"
#define MSG_VAL_ALLOC_ERR "Allocation impossible du noeud valeur" #define MSG_VAL_ALLOC_ERR "Allocation impossible du noeud valeur"
#define MSG_VAL_TOO_LONG "Valeur %s trop longue pour le champ %s" #define MSG_VAL_TOO_LONG "Valeur %s trop longue pour le champ %s"
......
...@@ -963,7 +963,7 @@ ...@@ -963,7 +963,7 @@
#define MSG_VALTYPE_NOMATCH "Disparit‚ types de valeur" #define MSG_VALTYPE_NOMATCH "Disparit‚ types de valeur"
#define MSG_VALUE_ERROR "Colonne %s: bloc valeur nul" #define MSG_VALUE_ERROR "Colonne %s: bloc valeur nul"
#define MSG_VALUE_NOT_ALLOC "Valeur non allou‚e pour la colonne R%d %s" #define MSG_VALUE_NOT_ALLOC "Valeur non allou‚e pour la colonne R%d %s"
#define MSG_VALUE_TOO_BIG "Valeur %d trop grande pour la colonne %s" #define MSG_VALUE_TOO_BIG "Valeur %lld trop grande pour la colonne %s"
#define MSG_VALUE_TOO_LONG "Valeur %s trop longue pour la colonne %s de longueur %d" #define MSG_VALUE_TOO_LONG "Valeur %s trop longue pour la colonne %s de longueur %d"
#define MSG_VAL_ALLOC_ERR "Allocation impossible du noeud valeur" #define MSG_VAL_ALLOC_ERR "Allocation impossible du noeud valeur"
#define MSG_VAL_TOO_LONG "Valeur %s trop longue pour le champ %s" #define MSG_VAL_TOO_LONG "Valeur %s trop longue pour le champ %s"
......
...@@ -355,8 +355,10 @@ void BINCOL::ReadColumn(PGLOBAL g) ...@@ -355,8 +355,10 @@ void BINCOL::ReadColumn(PGLOBAL g)
case 'T': // Tiny integer case 'T': // Tiny integer
Value->SetValue((int)*p); Value->SetValue((int)*p);
break; break;
case 'I': // Integer or
case 'L': // Long Integer case 'L': // Long Integer
strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
Value->SetValue(*(int*)p); Value->SetValue(*(int*)p);
break; break;
case 'F': // Float case 'F': // Float
...@@ -383,9 +385,9 @@ void BINCOL::ReadColumn(PGLOBAL g) ...@@ -383,9 +385,9 @@ void BINCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
void BINCOL::WriteColumn(PGLOBAL g) void BINCOL::WriteColumn(PGLOBAL g)
{ {
char *p, *s; char *p, *s;
int n; longlong n;
PTDBFIX tdbp = (PTDBFIX)To_Tdb; PTDBFIX tdbp = (PTDBFIX)To_Tdb;
if (trace) { if (trace) {
htrc("BIN WriteColumn: col %s R%d coluse=%.4X status=%.4X", htrc("BIN WriteColumn: col %s R%d coluse=%.4X status=%.4X",
...@@ -419,30 +421,42 @@ void BINCOL::WriteColumn(PGLOBAL g) ...@@ -419,30 +421,42 @@ void BINCOL::WriteColumn(PGLOBAL g)
break; break;
case 'S': // Short integer case 'S': // Short integer
n = Value->GetIntValue(); n = Value->GetBigintValue();
if (n > 32767 || n < -32768) { if (n > 32767LL || n < -32768LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31); longjmp(g->jumper[g->jump_level], 31);
} else if (Status) } else if (Status)
*(short *)p = (short)n; *(short *)p = (short)n;
break; break;
case 'T': // Short integer case 'T': // Tiny integer
n = Value->GetIntValue(); n = Value->GetBigintValue();
if (n > 255 || n < -256) { if (n > 255LL || n < -256LL) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name); sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31); longjmp(g->jumper[g->jump_level], 31);
} else if (Status) } else if (Status)
*p = (char)n; *p = (char)n;
break; break;
case 'I': // Integer or
case 'L': // Long Integer case 'L': // Long Integer
if (Status) strcpy(g->Message, "Format L is deprecated, use I");
longjmp(g->jumper[g->jump_level], 11);
case 'I': // Integer
n = Value->GetBigintValue();
if (n > INT_MAX || n < INT_MIN) {
sprintf(g->Message, MSG(VALUE_TOO_BIG), n, Name);
longjmp(g->jumper[g->jump_level], 31);
} else if (Status)
*(int *)p = Value->GetIntValue(); *(int *)p = Value->GetIntValue();
break;
case 'B': // Large (big) integer
if (Status)
*(longlong *)p = (longlong)Value->GetBigintValue();
break; break;
case 'F': // Float case 'F': // Float
case 'R': // Real case 'R': // Real
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment