Commit da1c91fb authored by Daniel Black's avatar Daniel Black Committed by Andrew Hutchings

MDEV-30713 field length handling for CONNECT engine

fp->field_length was unsigned and therefore the negative
condition around it.

Backport of cc182aca fixes it, however to correct the
consistent use of types pcf->Length needs to be unsigned
too.

At one point pcf->Precision is assigned from pcf->Length so
that's also unsigned.

GetTypeSize is assigned to length and has a length argument.
A -1 default value seemed dangerious to case, so at least 0
should assert if every hit.
parent 3d27f6d7
...@@ -39,9 +39,9 @@ typedef struct _colinfo { ...@@ -39,9 +39,9 @@ typedef struct _colinfo {
PCSZ Name; PCSZ Name;
int Type; int Type;
int Offset; int Offset;
int Length; unsigned Length;
int Key; int Key;
int Precision; unsigned Precision;
int Scale; int Scale;
int Opt; int Opt;
int Freq; int Freq;
......
...@@ -1618,10 +1618,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) ...@@ -1618,10 +1618,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
pcf->Scale= 0; pcf->Scale= 0;
pcf->Opt= (fop) ? (int)fop->opt : 0; pcf->Opt= (fop) ? (int)fop->opt : 0;
if (fp->field_length >= 0) pcf->Length= fp->field_length;
pcf->Length= fp->field_length;
else
pcf->Length= 256; // BLOB?
pcf->Precision= pcf->Length; pcf->Precision= pcf->Length;
......
...@@ -466,7 +466,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt) ...@@ -466,7 +466,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
if (Quote) { if (Quote) {
// Tabname can have both database and table identifiers, we need to parse // Tabname can have both database and table identifiers, we need to parse
if (res= strstr(buf, ".")) if ((res= strstr(buf, ".")))
{ {
// Parse schema // Parse schema
my_len= res - buf + 1; my_len= res - buf + 1;
......
...@@ -163,9 +163,9 @@ PCSZ GetTypeName(int type) ...@@ -163,9 +163,9 @@ PCSZ GetTypeName(int type)
/***********************************************************************/ /***********************************************************************/
/* GetTypeSize: returns the PlugDB internal type size. */ /* GetTypeSize: returns the PlugDB internal type size. */
/***********************************************************************/ /***********************************************************************/
int GetTypeSize(int type, int len) unsigned GetTypeSize(int type, unsigned len)
{ {
switch (type) { switch (type) {
case TYPE_DECIM: case TYPE_DECIM:
case TYPE_BIN: case TYPE_BIN:
case TYPE_STRING: len = len * sizeof(char); break; case TYPE_STRING: len = len * sizeof(char); break;
...@@ -176,7 +176,7 @@ int GetTypeSize(int type, int len) ...@@ -176,7 +176,7 @@ int GetTypeSize(int type, int len)
case TYPE_DOUBLE: len = sizeof(double); break; case TYPE_DOUBLE: len = sizeof(double); break;
case TYPE_TINY: len = sizeof(char); break; case TYPE_TINY: len = sizeof(char); break;
case TYPE_PCHAR: len = sizeof(char*); break; case TYPE_PCHAR: len = sizeof(char*); break;
default: len = -1; default: len = 0;
} // endswitch type } // endswitch type
return len; return len;
......
...@@ -41,7 +41,7 @@ typedef struct _datpar *PDTP; // For DTVAL ...@@ -41,7 +41,7 @@ typedef struct _datpar *PDTP; // For DTVAL
/***********************************************************************/ /***********************************************************************/
// Exported functions // Exported functions
DllExport PCSZ GetTypeName(int); DllExport PCSZ GetTypeName(int);
DllExport int GetTypeSize(int, int); DllExport unsigned GetTypeSize(int, unsigned);
#ifdef ODBC_SUPPORT #ifdef ODBC_SUPPORT
/* This function is exported for use in OEM table type DLLs */ /* This function is exported for use in OEM table type DLLs */
DllExport int TranslateSQLType(int stp, int prec, DllExport int TranslateSQLType(int stp, int prec,
......
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