diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-12-28 15:46:49 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-12-28 15:46:49 +0100 |
commit | c055e5e0efcdd3750550230a483cdf8847b3d414 (patch) | |
tree | 77384e1d1f2f168c3d1df7a58d72a620f3416e46 /storage/connect/odbconn.cpp | |
parent | 889b08b050a1d7e8a5bb842e5d72b4b18be139e4 (diff) | |
download | mariadb-git-c055e5e0efcdd3750550230a483cdf8847b3d414.tar.gz |
- Add the DECIMAL data type (TYPE_DECIM)
Change the variable name of the DOUBLE type from TYPE_FLOAT to TYPE_DOUBLE
Change some names to reflect ODBC version 3. This affects some variable
names, function names and catalog table column names.
Qualifier -> Catalog
Owner (Creator) -> Schema
Length -> Precision
Prec -> Scale
modified:
storage/connect/catalog.h
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/filamdbf.cpp
storage/connect/global.h
storage/connect/ha_connect.cc
storage/connect/myconn.cpp
storage/connect/mysql-test/connect/r/mysql_new.result
storage/connect/mysql-test/connect/r/odbc_oracle.result
storage/connect/myutil.cpp
storage/connect/odbconn.cpp
storage/connect/plgdbutl.cpp
storage/connect/rcmsg.c
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabcol.cpp
storage/connect/tabcol.h
storage/connect/tabdos.cpp
storage/connect/tabfmt.cpp
storage/connect/tabmysql.cpp
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabutil.cpp
storage/connect/tabwmi.cpp
storage/connect/tabxml.cpp
storage/connect/valblk.cpp
storage/connect/value.cpp
storage/connect/value.h
storage/connect/xindex.cpp
storage/connect/xobject.cpp
storage/connect/xobject.h
- Fix crash when GetTDB returned NULL in Open_Table
modified:
storage/connect/ha_connect.cc
- Fix assert error setting double values from PSZ
modified:
storage/connect/valblk.cpp
Diffstat (limited to 'storage/connect/odbconn.cpp')
-rw-r--r-- | storage/connect/odbconn.cpp | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index 846d8963502..a8a393d0ab7 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -1,5 +1,5 @@ /************ Odbconn C++ Functions Source Code File (.CPP) ************/ -/* Name: ODBCONN.CPP Version 1.8 */ +/* Name: ODBCONN.CPP Version 1.9 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ /* */ @@ -78,8 +78,9 @@ static short GetSQLType(int type) case TYPE_INT: tp = SQL_INTEGER; break; case TYPE_DATE: tp = SQL_TIMESTAMP; break; case TYPE_BIGINT: tp = SQL_BIGINT; break; // (-5) - case TYPE_FLOAT: tp = SQL_DOUBLE; break; - case TYPE_TINY : tp = SQL_TINYINT; break; + case TYPE_DOUBLE: tp = SQL_DOUBLE; break; + case TYPE_TINY: tp = SQL_TINYINT; break; + case TYPE_DECIM: tp = SQL_DECIMAL; break; } // endswitch type return tp; @@ -98,8 +99,9 @@ static int GetSQLCType(int type) case TYPE_INT: tp = SQL_C_LONG; break; case TYPE_DATE: tp = SQL_C_TIMESTAMP; break; case TYPE_BIGINT: tp = SQL_C_SBIGINT; break; - case TYPE_FLOAT: tp = SQL_C_DOUBLE; break; + case TYPE_DOUBLE: tp = SQL_C_DOUBLE; break; case TYPE_TINY : tp = SQL_C_TINYINT; break; + case TYPE_DECIM: tp = SQL_C_CHAR; break; } // endswitch type return tp; @@ -125,8 +127,9 @@ int TranslateSQLType(int stp, int prec, int& len, char& v) break; case SQL_NUMERIC: // 2 case SQL_DECIMAL: // 3 - type = (prec || len > 20) ? TYPE_FLOAT - : (len > 10) ? TYPE_BIGINT : TYPE_INT; +// type = (prec || len > 20) ? TYPE_DOUBLE +// : (len > 10) ? TYPE_BIGINT : TYPE_INT; + type = TYPE_DECIM; break; case SQL_INTEGER: // 4 type = TYPE_INT; @@ -141,7 +144,7 @@ int TranslateSQLType(int stp, int prec, int& len, char& v) case SQL_FLOAT: // 6 case SQL_REAL: // 7 case SQL_DOUBLE: // 8 - type = TYPE_FLOAT; + type = TYPE_DOUBLE; break; case SQL_DATETIME: // 9 // case SQL_DATE: // 9 @@ -312,9 +315,9 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table, } else if (!maxres) maxres = 20000; -// n = ocp->GetMaxValue(SQL_MAX_QUALIFIER_NAME_LEN); +// n = ocp->GetMaxValue(SQL_MAX_CATALOG_NAME_LEN); // length[0] = (n) ? (n + 1) : 0; -// n = ocp->GetMaxValue(SQL_MAX_USER_NAME_LEN); +// n = ocp->GetMaxValue(SQL_MAX_SCHEMA_NAME_LEN); // length[1] = (n) ? (n + 1) : 0; // n = ocp->GetMaxValue(SQL_MAX_TABLE_NAME_LEN); // length[2] = (n) ? (n + 1) : 0; @@ -425,7 +428,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) /************************************************************************/ /* 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 Schema and Table names crpt = qrp->Colresp->Next; // SQL type crpl = crpt->Next->Next; // Length @@ -440,7 +443,7 @@ PQRYRES MyODBCCols(PGLOBAL g, char *dsn, char *tab, bool info) crpt->Kdata->SetValue(type, i); // Some data sources do not count prec in length - if (type == TYPE_FLOAT) + if (type == TYPE_DOUBLE) len += (prec + 2); // To be safe // Could have been changed for blobs or numeric @@ -588,9 +591,9 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, if (!maxres) maxres = 10000; // This is completely arbitrary -// n = ocp->GetMaxValue(SQL_MAX_QUALIFIER_NAME_LEN); +// n = ocp->GetMaxValue(SQL_MAX_CATALOG_NAME_LEN); // length[0] = (n) ? (n + 1) : 0; -// n = ocp->GetMaxValue(SQL_MAX_USER_NAME_LEN); +// n = ocp->GetMaxValue(SQL_MAX_SCHEMA_NAME_LEN); // length[1] = (n) ? (n + 1) : 0; n = ocp->GetMaxValue(SQL_MAX_TABLE_NAME_LEN); length[2] = (n) ? (n + 1) : 128; @@ -678,9 +681,9 @@ PQRYRES ODBCPrimaryKeys(PGLOBAL g, ODBConn *op, char *dsn, char *table) /************************************************************************/ n = ocp->GetMaxValue(SQL_MAX_COLUMNS_IN_TABLE); maxres = (n) ? (int)n : 250; - n = ocp->GetMaxValue(SQL_MAX_QUALIFIER_NAME_LEN); + n = ocp->GetMaxValue(SQL_MAX_CATALOG_NAME_LEN); length[0] = (n) ? (n + 1) : 128; - n = ocp->GetMaxValue(SQL_MAX_USER_NAME_LEN); + n = ocp->GetMaxValue(SQL_MAX_SCHEMA_NAME_LEN); length[1] = (n) ? (n + 1) : 128; n = ocp->GetMaxValue(SQL_MAX_TABLE_NAME_LEN); length[2] = (n) ? (n + 1) : 128; @@ -761,11 +764,11 @@ PQRYRES ODBCStatistics(PGLOBAL g, ODBConn *op, char *dsn, char *pat, /************************************************************************/ n = 1 + ocp->GetMaxValue(SQL_MAX_COLUMNS_IN_INDEX); maxres = (n) ? (int)n : 32; - n = ocp->GetMaxValue(SQL_MAX_USER_NAME_LEN); + n = ocp->GetMaxValue(SQL_MAX_SCHEMA_NAME_LEN); length[1] = (n) ? (n + 1) : 128; n = ocp->GetMaxValue(SQL_MAX_TABLE_NAME_LEN); length[2] = length[5] = (n) ? (n + 1) : 128; - n = ocp->GetMaxValue(SQL_MAX_QUALIFIER_NAME_LEN); + n = ocp->GetMaxValue(SQL_MAX_CATALOG_NAME_LEN); length[0] = length[4] = (n) ? (n + 1) : length[2]; n = ocp->GetMaxValue(SQL_MAX_COLUMN_NAME_LEN); length[7] = (n) ? (n + 1) : 128; @@ -1648,35 +1651,35 @@ int ODBConn::ExecuteSQL(void) /***********************************************************************/ bool ODBConn::BindParam(ODBCCOL *colp) { - void *buf; - UWORD n = colp->GetRank(); - SWORD ct, sqlt; - UDWORD len; - SQLLEN *strlen = colp->GetStrLen(); - RETCODE rc; + void *buf; + int buftype = colp->GetResultType(); + SQLUSMALLINT n = colp->GetRank(); + SQLSMALLINT ct, sqlt, dec, nul; + SQLULEN colsize; + SQLLEN len; + SQLLEN *strlen = colp->GetStrLen(); + SQLRETURN rc; -#if 0 try { - SWORD dec, nul; - rc = SQLDescribeParam(m_hstmt, n, &sqlt, &len, &dec, &nul); + rc = SQLDescribeParam(m_hstmt, n, &sqlt, &colsize, &dec, &nul); if (!Check(rc)) - ThrowDBX(rc, m_hstmt); + ThrowDBX(rc, "SQLDescribeParam", m_hstmt); } catch(DBX *x) { strcpy(m_G->Message, x->GetErrorMessage(0)); + colsize = colp->GetPrecision(); + sqlt = GetSQLType(buftype); } // end try/catch -#endif // 0 buf = colp->GetBuffer(0); - len = IsTypeNum(colp->GetResultType()) ? 0 : colp->GetBuflen(); - ct = GetSQLCType(colp->GetResultType()); - sqlt = GetSQLType(colp->GetResultType()); - *strlen = IsTypeNum(colp->GetResultType()) ? 0 : SQL_NTS; + len = IsTypeChar(buftype) ? colp->GetBuflen() : 0; + ct = GetSQLCType(buftype); + *strlen = IsTypeChar(buftype) ? SQL_NTS : 0; try { rc = SQLBindParameter(m_hstmt, n, SQL_PARAM_INPUT, ct, sqlt, - len, 0, buf, 0, strlen); + colsize, dec, buf, len, strlen); if (!Check(rc)) ThrowDBX(rc, "SQLBindParameter", m_hstmt); @@ -2228,7 +2231,7 @@ int ODBConn::GetCatInfo(CATPARM *cap) ((STRBLK*)crp->Kdata)->SetSorted(true); } // endif len - pval[n] = AllocateValue(g, crp->Type, len, 0); + pval[n] = AllocateValue(g, crp->Type, len); buffer = pval[n]->GetTo_Val(); vl = vlen + n; |