Commit ba82edd4 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix problems with ODBC raised by Adding the type TYPE_BIGINT (longlong).

parent 1d67d9bf
...@@ -162,8 +162,8 @@ PQRYRES MyODBCCols(PGLOBAL g, char *tab, char *dsn); ...@@ -162,8 +162,8 @@ PQRYRES MyODBCCols(PGLOBAL g, char *tab, char *dsn);
#if defined(MYSQL_SUPPORT) #if defined(MYSQL_SUPPORT)
PQRYRES MyColumns(PGLOBAL g, char *host, char *db, char *user, char *pwd, PQRYRES MyColumns(PGLOBAL g, char *host, char *db, char *user, char *pwd,
char *table, char *colpat, int port, bool key); char *table, char *colpat, int port, bool key);
enum enum_field_types PLGtoMYSQL(int type, bool gdf);
#endif // MYSQL_SUPPORT #endif // MYSQL_SUPPORT
enum enum_field_types PLGtoMYSQL(int type, bool gdf);
#if defined(WIN32) #if defined(WIN32)
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *classname, PWMIUT wp= NULL); PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *classname, PWMIUT wp= NULL);
#endif // WIN32 #endif // WIN32
......
...@@ -48,6 +48,8 @@ int MYSQLtoPLG(char *typname) ...@@ -48,6 +48,8 @@ int MYSQLtoPLG(char *typname)
!stricmp(typname, "time") || !stricmp(typname, "timestamp") || !stricmp(typname, "time") || !stricmp(typname, "timestamp") ||
!stricmp(typname, "year")) !stricmp(typname, "year"))
type = TYPE_DATE; type = TYPE_DATE;
else if (!stricmp(typname, "bigint") || !stricmp(typname, "longlong"))
type = TYPE_BIGINT;
else else
type = TYPE_ERROR; type = TYPE_ERROR;
...@@ -77,6 +79,9 @@ enum enum_field_types PLGtoMYSQL(int type, bool gdf) ...@@ -77,6 +79,9 @@ enum enum_field_types PLGtoMYSQL(int type, bool gdf)
case TYPE_STRING: case TYPE_STRING:
mytype = MYSQL_TYPE_VARCHAR; mytype = MYSQL_TYPE_VARCHAR;
break; break;
case TYPE_BIGINT:
mytype = MYSQL_TYPE_LONGLONG;
break;
default: default:
mytype = MYSQL_TYPE_NULL; mytype = MYSQL_TYPE_NULL;
} // endswitch mytype } // endswitch mytype
......
...@@ -219,8 +219,8 @@ PQRYRES ODBCColumns(PGLOBAL g, ODBConn *op, char *dsn, char *table, ...@@ -219,8 +219,8 @@ PQRYRES ODBCColumns(PGLOBAL g, ODBConn *op, char *dsn, char *table,
/**************************************************************************/ /**************************************************************************/
PQRYRES MyODBCCols(PGLOBAL g, char *tab, char *dsn) PQRYRES MyODBCCols(PGLOBAL g, char *tab, char *dsn)
{ {
int n; int type, len, prec;
PCOLRES crp; PCOLRES crpt, crpl, crpp;
PQRYRES qrp; PQRYRES qrp;
ODBConn *ocp = new(g) ODBConn(g, NULL); ODBConn *ocp = new(g) ODBConn(g, NULL);
...@@ -247,14 +247,28 @@ PQRYRES MyODBCCols(PGLOBAL g, char *tab, char *dsn) ...@@ -247,14 +247,28 @@ PQRYRES MyODBCCols(PGLOBAL g, char *tab, char *dsn)
/* Keep only the info used by ha_connect::pre_create. */ /* Keep only the info used by ha_connect::pre_create. */
/************************************************************************/ /************************************************************************/
qrp->Colresp = qrp->Colresp->Next->Next; // Skip Owner and Table names qrp->Colresp = qrp->Colresp->Next->Next; // Skip Owner and Table names
crp = qrp->Colresp->Next; // DB type
crpt = qrp->Colresp->Next; // SQL type
crpl = crpt->Next->Next; // Length
crpp = crpl->Next->Next; // Decimals
for (int i = 0; i < qrp->Nblin; i++) {
// Types must be PLG types, not SQL types // Types must be PLG types, not SQL types
for (int i = 0; i < qrp->Nblin; i++) type = crpt->Kdata->GetIntValue(i);
crp->Kdata->SetValue(TranslateSQLType(crp->Kdata->GetIntValue(i),0,n),i); len = crpl->Kdata->GetIntValue(i);
prec = crpp->Kdata->GetIntValue(i);
type = TranslateSQLType(type, prec, len);
crpt->Kdata->SetValue(type, i);
// Some data sources do not count prec in length
if (type == TYPE_FLOAT)
len += (prec + 2); // To be safe
// Could have been changed for blobs or numeric
crpl->Kdata->SetValue(len, i);
} // endfor i
crp = crp->Next->Next->Next->Next; // Should be Radix crpp->Next = crpp->Next->Next->Next; // Should be Remark
crp->Next = crp->Next->Next->Next; // Should be Remark
qrp->Nbcol = 7; // Was 11, skipped 4 qrp->Nbcol = 7; // Was 11, skipped 4
return qrp; return qrp;
} // end of MyODBCCols } // end of MyODBCCols
......
...@@ -210,7 +210,7 @@ short GetSQLType(int type) ...@@ -210,7 +210,7 @@ short GetSQLType(int type)
case TYPE_SHORT: tp = SQL_SMALLINT; break; case TYPE_SHORT: tp = SQL_SMALLINT; break;
case TYPE_INT: tp = SQL_INTEGER; break; case TYPE_INT: tp = SQL_INTEGER; break;
case TYPE_DATE: tp = SQL_TIMESTAMP; break; case TYPE_DATE: tp = SQL_TIMESTAMP; break;
case TYPE_BIGINT: case TYPE_BIGINT: tp = SQL_BIGINT; break; // (-5)
case TYPE_FLOAT: tp = SQL_DOUBLE; break; case TYPE_FLOAT: tp = SQL_DOUBLE; break;
} // endswitch type } // endswitch type
...@@ -229,7 +229,7 @@ int GetSQLCType(int type) ...@@ -229,7 +229,7 @@ int GetSQLCType(int type)
case TYPE_SHORT: tp = SQL_C_SHORT; break; case TYPE_SHORT: tp = SQL_C_SHORT; break;
case TYPE_INT: tp = SQL_C_LONG; break; case TYPE_INT: tp = SQL_C_LONG; break;
case TYPE_DATE: tp = SQL_C_TIMESTAMP; break; case TYPE_DATE: tp = SQL_C_TIMESTAMP; break;
case TYPE_BIGINT: case TYPE_BIGINT: tp = SQL_C_SBIGINT; break;
case TYPE_FLOAT: tp = SQL_C_DOUBLE; break; case TYPE_FLOAT: tp = SQL_C_DOUBLE; break;
} // endswitch type } // endswitch type
......
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