Commit 7132c590 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix a miscalculation of column length in ODBCTables

- Clean code in Value.h

modified:
  storage/connect/odbconn.cpp
  storage/connect/value.h
parent fa4aa616
......@@ -491,9 +491,11 @@ PQRYRES ODBCDrivers(PGLOBAL g, bool info)
/***********************************************************************/
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
{
static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
static int dbtype[] = {DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR, DB_CHAR};
static int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_STRING};
static XFLD fldtyp[] = {FLD_QUALIF, FLD_OWNER, FLD_NAME,
FLD_TYPE, FLD_REM};
static unsigned int length[] = {0, 0, 0, 16, 128};
int n, ncol = 5;
int maxres;
......@@ -517,9 +519,9 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
n = ocp->GetMaxValue(SQL_MAX_QUALIFIER_NAME_LEN);
length[0] = (n) ? (n + 1) : 128;
n = ocp->GetMaxValue(SQL_MAX_USER_NAME_LEN);
length[0] = (n) ? (n + 1) : 128;
n = ocp->GetMaxValue(SQL_MAX_TABLE_NAME_LEN);
length[1] = (n) ? (n + 1) : 128;
n = ocp->GetMaxValue(SQL_MAX_TABLE_NAME_LEN);
length[2] = (n) ? (n + 1) : 128;
} else {
maxres = 0;
length[0] = 128;
......@@ -534,7 +536,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
/* Allocate the structures used to refer to the result set. */
/************************************************************************/
qrp = PlgAllocResult(g, ncol, maxres, IDS_TABLES, dbtype, buftyp,
NULL, length, true, true);
fldtyp, length, true, true);
if (info)
return qrp;
......
......@@ -86,7 +86,7 @@ class DllExport VALUE : public BLOCK {
void SetNullable(bool b) {Nullable = b;}
int GetType(void) {return Type;}
int GetClen(void) {return Clen;}
void SetPrec(int prec) {Prec = prec;}
void SetPrec(int prec) {Prec = prec;}
void SetGlobal(PGLOBAL g) {Global = g;}
// Methods
......@@ -148,7 +148,7 @@ class DllExport TYPVAL : public VALUE {
virtual int GetValLen(void);
virtual int GetValPrec() {return 0;}
virtual int GetSize(void) {return sizeof(TYPE);}
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
virtual short GetShortValue(void) {return (short)Tval;}
virtual int GetIntValue(void) {return (int)Tval;}
virtual longlong GetBigintValue(void) {return (longlong)Tval;}
......@@ -222,7 +222,7 @@ bool TYPVAL<PSZ>::IsZero(void) {return *Tval == 0;}
void TYPVAL<PSZ>::Reset(void) {*Tval = 0;}
int TYPVAL<PSZ>::GetValPrec() {return (Ci) ? 1 : 0;}
int TYPVAL<PSZ>::GetSize(void) {return (Tval) ? strlen(Tval) : 0;}
PSZ TYPVAL<PSZ>::GetCharValue(void) {return Tval;}
PSZ TYPVAL<PSZ>::GetCharValue(void) {return Tval;}
short TYPVAL<PSZ>::GetShortValue(void) {return (short)atoi(Tval);}
int TYPVAL<PSZ>::GetIntValue(void) {return atol(Tval);}
longlong TYPVAL<PSZ>::GetBigintValue(void) {return atoll(Tval);}
......
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