ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [19/50] ignite git commit: IGNITE-2241: Implemented TypeInfoQuery.
Date Mon, 25 Jan 2016 11:55:21 GMT
IGNITE-2241: Implemented TypeInfoQuery.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7c3f277
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7c3f277
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7c3f277

Branch: refs/heads/ignite-1786
Commit: a7c3f277dd5bad124f7d73771e40a3816c27ea08
Parents: 77ba349
Author: isapego <isapego@gridgain.com>
Authored: Thu Jan 14 18:05:01 2016 +0300
Committer: isapego <isapego@gridgain.com>
Committed: Thu Jan 14 18:05:01 2016 +0300

----------------------------------------------------------------------
 .../include/ignite/odbc/query/type_info_query.h | 109 ++++++
 .../include/ignite/odbc/type_traits.h           |   8 +
 .../odbc-driver/project/vs/odbc-driver.vcxproj  |   2 +
 .../project/vs/odbc-driver.vcxproj.filters      |   6 +
 .../src/query/foreign_keys_query.cpp            |   4 +
 .../src/query/primary_keys_query.cpp            |   4 -
 .../odbc-driver/src/query/type_info_query.cpp   | 381 +++++++++++++++++++
 .../cpp/odbc/odbc-driver/src/type_traits.cpp    |  56 ++-
 8 files changed, 564 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/type_info_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/type_info_query.h
b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/type_info_query.h
new file mode 100644
index 0000000..ca9b879
--- /dev/null
+++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/type_info_query.h
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_TYPE_INFO_QUERY
+#define _IGNITE_ODBC_DRIVER_TYPE_INFO_QUERY
+
+#include "ignite/odbc/query/query.h"
+
+namespace ignite
+{
+    namespace odbc
+    {
+        namespace query
+        {
+            /**
+             * Type info query.
+             */
+            class TypeInfoQuery : public Query
+            {
+            public:
+                /**
+                 * Constructor.
+                 *
+                 * @param diag Diagnostics collector.
+                 * @param sqlType SQL type.
+                 */
+                TypeInfoQuery(diagnostic::Diagnosable& diag, int16_t sqlType);
+
+                /**
+                 * Destructor.
+                 */
+                virtual ~TypeInfoQuery();
+
+                /**
+                 * Execute query.
+                 *
+                 * @return True on success.
+                 */
+                virtual SqlResult Execute();
+
+                /**
+                 * Get column metadata.
+                 *
+                 * @return Column metadata.
+                 */
+                virtual const meta::ColumnMetaVector& GetMeta() const;
+
+                /**
+                 * Fetch next result row to application buffers.
+                 *
+                 * @return Operation result.
+                 */
+                virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+                /**
+                 * Close query.
+                 *
+                 * @return True on success.
+                 */
+                virtual SqlResult Close();
+
+                /**
+                 * Check if data is available.
+                 *
+                 * @return True if data is available.
+                 */
+                virtual bool DataAvailable() const;
+
+                /**
+                 * Get number of rows affected by the statement.
+                 *
+                 * @return Number of rows affected by the statement.
+                 */
+                virtual int64_t AffectedRows() const;
+                
+            private:
+                IGNITE_NO_COPY_ASSIGNMENT(TypeInfoQuery);
+
+                /** Columns metadata. */
+                meta::ColumnMetaVector columnsMeta;
+
+                /** Executed flag. */
+                bool executed;
+
+                /** Requested types. */
+                std::vector<int8_t> types;
+
+                /** Query cursor. */
+                std::vector<int8_t>::const_iterator cursor;
+            };
+        }
+    }
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/type_traits.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/type_traits.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/type_traits.h
index 094e189..ba7b78a 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/type_traits.h
+++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/type_traits.h
@@ -177,6 +177,14 @@ namespace ignite
             bool IsSqlTypeSupported(int16_t type);
 
             /**
+             * Get corresponding binary type for ODBC SQL type.
+             *
+             * @param sqlType SQL type.
+             * @return Binary type.
+             */
+            int8_t SqlTypeToBinary(int16_t sqlType);
+
+            /**
              * Convert ODBC type to driver type alias.
              *
              * @param ODBC type;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
index a85adf3..925b1b9 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
+++ b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
@@ -170,6 +170,7 @@
     <ClCompile Include="..\..\src\query\foreign_keys_query.cpp" />
     <ClCompile Include="..\..\src\query\primary_keys_query.cpp" />
     <ClCompile Include="..\..\src\query\table_metadata_query.cpp" />
+    <ClCompile Include="..\..\src\query\type_info_query.cpp" />
     <ClCompile Include="..\..\src\result_page.cpp" />
     <ClCompile Include="..\..\src\row.cpp" />
     <ClCompile Include="..\..\src\statement.cpp" />
@@ -204,6 +205,7 @@
     <ClInclude Include="..\..\include\ignite\odbc\query\primary_keys_query.h" />
     <ClInclude Include="..\..\include\ignite\odbc\query\query.h" />
     <ClInclude Include="..\..\include\ignite\odbc\query\table_metadata_query.h" />
+    <ClInclude Include="..\..\include\ignite\odbc\query\type_info_query.h" />
     <ClInclude Include="..\..\include\ignite\odbc\result_page.h" />
     <ClInclude Include="..\..\include\ignite\odbc\row.h" />
     <ClInclude Include="..\..\include\ignite\odbc\statement.h" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
index 650bfe4..69c3c10 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
@@ -106,6 +106,9 @@
     <ClCompile Include="..\..\src\decimal.cpp">
       <Filter>Code</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\query\type_info_query.cpp">
+      <Filter>Code\query</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="module.def">
@@ -207,5 +210,8 @@
     <ClInclude Include="..\..\include\ignite\odbc\decimal.h">
       <Filter>Code</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\include\ignite\odbc\query\type_info_query.h">
+      <Filter>Code\query</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/src/query/foreign_keys_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/foreign_keys_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/foreign_keys_query.cpp
index 83aba0c..65246d6 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/foreign_keys_query.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/query/foreign_keys_query.cpp
@@ -89,7 +89,11 @@ namespace ignite
             SqlResult ForeignKeysQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
             {
                 if (!executed)
+                {
+                    diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
                     return SQL_RESULT_ERROR;
+                }
 
                 return SQL_RESULT_NO_DATA;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/src/query/primary_keys_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/primary_keys_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/primary_keys_query.cpp
index b1a508e..a6c7f67 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/primary_keys_query.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/query/primary_keys_query.cpp
@@ -114,13 +114,9 @@ namespace ignite
                     return SQL_RESULT_ERROR;
                 }
 
-                LOG_MSG("1\n");
-
                 if (cursor == meta.end())
                     return SQL_RESULT_NO_DATA;
 
-                LOG_MSG("2\n");
-
                 app::ColumnBindingMap::iterator it;
 
                 for (it = columnBindings.begin(); it != columnBindings.end(); ++it)

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/src/query/type_info_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/type_info_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/type_info_query.cpp
new file mode 100644
index 0000000..69766a1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/query/type_info_query.cpp
@@ -0,0 +1,381 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <cassert>
+
+#include <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/query/type_info_query.h"
+
+namespace
+{
+    enum ResultColumn
+    {
+        /** Data source�dependent data-type name. */
+        TYPE_NAME = 1,
+
+        /** SQL data type. */
+        DATA_TYPE,
+
+        /** The maximum column size that the server supports for this data type. */
+        COLUMN_SIZE,
+
+        /** Character or characters used to prefix a literal. */
+        LITERAL_PREFIX,
+
+        /** Character or characters used to terminate a literal. */
+        LITERAL_SUFFIX,
+
+        /**
+         * A list of keywords, separated by commas, corresponding to each
+         * parameter that the application may specify in parentheses when using
+         * the name that is returned in the TYPE_NAME field.
+         */
+        CREATE_PARAMS,
+
+        /** Whether the data type accepts a NULL value. */
+        NULLABLE,
+
+        /**
+         * Whether a character data type is case-sensitive in collations and
+         * comparisons.
+         */
+        CASE_SENSITIVE,
+
+        /** How the data type is used in a WHERE clause. */
+        SEARCHABLE,
+
+        /** Whether the data type is unsigned. */
+        UNSIGNED_ATTRIBUTE,
+
+        /** Whether the data type has predefined fixed precision and scale. */
+        FIXED_PREC_SCALE,
+
+        /** Whether the data type is autoincrementing. */
+        AUTO_UNIQUE_VALUE,
+
+        /**
+         * Localized version of the data source�dependent name of the data
+         * type.
+         */
+        LOCAL_TYPE_NAME,
+
+        /** The minimum scale of the data type on the data source. */
+        MINIMUM_SCALE,
+
+        /** The maximum scale of the data type on the data source. */
+        MAXIMUM_SCALE,
+
+        /**
+         * The value of the SQL data type as it appears in the SQL_DESC_TYPE
+         * field of the descriptor.
+         */
+        SQL_DATA_TYPE,
+
+        /**
+         * When the value of SQL_DATA_TYPE is SQL_DATETIME or SQL_INTERVAL,
+         * this column contains the datetime/interval subcode.
+         */
+        SQL_DATETIME_SUB,
+
+        /**
+         * If the data type is an approximate numeric type, this column
+         * contains the value 2 to indicate that COLUMN_SIZE specifies a number
+         * of bits.
+         */
+        NUM_PREC_RADIX,
+
+        /**
+         * If the data type is an interval data type, then this column contains
+         * the value of the interval leading precision.
+         */
+        INTERVAL_PRECISION
+    };
+}
+
+namespace ignite
+{
+    namespace odbc
+    {
+        namespace query
+        {
+            TypeInfoQuery::TypeInfoQuery(diagnostic::Diagnosable& diag, int16_t sqlType)
:
+                Query(diag),
+                columnsMeta(),
+                executed(false),
+                types(),
+                cursor(types.end())
+            {
+                using namespace ignite::impl::binary;
+                using namespace ignite::odbc::type_traits;
+
+                using meta::ColumnMeta;
+
+                columnsMeta.reserve(19);
+
+                const std::string sch("");
+                const std::string tbl("");
+
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "TYPE_NAME",          SqlTypeName::VARCHAR,
 IGNITE_TYPE_STRING));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "DATA_TYPE",          SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_SIZE",        SqlTypeName::INTEGER,
 IGNITE_TYPE_INT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "LITERAL_PREFIX",     SqlTypeName::VARCHAR,
 IGNITE_TYPE_STRING));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "LITERAL_SUFFIX",     SqlTypeName::VARCHAR,
 IGNITE_TYPE_STRING));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "CREATE_PARAMS",      SqlTypeName::VARCHAR,
 IGNITE_TYPE_STRING));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "NULLABLE",           SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "CASE_SENSITIVE",     SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "SEARCHABLE",         SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "UNSIGNED_ATTRIBUTE", SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "FIXED_PREC_SCALE",   SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "AUTO_UNIQUE_VALUE",  SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "LOCAL_TYPE_NAME",    SqlTypeName::VARCHAR,
 IGNITE_TYPE_STRING));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "MINIMUM_SCALE",      SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "MAXIMUM_SCALE",      SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "SQL_DATA_TYPE",      SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "SQL_DATETIME_SUB",   SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "NUM_PREC_RADIX",     SqlTypeName::INTEGER,
 IGNITE_TYPE_INT));
+                columnsMeta.push_back(ColumnMeta(sch, tbl, "INTERVAL_PRECISION", SqlTypeName::SMALLINT,
IGNITE_TYPE_SHORT));
+
+                assert(IsSqlTypeSupported(sqlType));
+
+                if (sqlType == SQL_ALL_TYPES)
+                {
+                    types.push_back(IGNITE_TYPE_STRING);
+                    types.push_back(IGNITE_TYPE_SHORT);
+                    types.push_back(IGNITE_TYPE_INT);
+                    types.push_back(IGNITE_TYPE_DECIMAL);
+                    types.push_back(IGNITE_TYPE_FLOAT);
+                    types.push_back(IGNITE_TYPE_DOUBLE);
+                    types.push_back(IGNITE_TYPE_BOOL);
+                    types.push_back(IGNITE_TYPE_BYTE);
+                    types.push_back(IGNITE_TYPE_LONG);
+                    types.push_back(IGNITE_TYPE_UUID);
+                    types.push_back(IGNITE_TYPE_BINARY);
+                }
+                else
+                    types.push_back(SqlTypeToBinary(sqlType));
+            }
+
+            TypeInfoQuery::~TypeInfoQuery()
+            {
+                // No-op.
+            }
+
+            SqlResult TypeInfoQuery::Execute()
+            {
+                cursor = types.begin();
+
+                executed = true;
+
+                return SQL_RESULT_SUCCESS;
+            }
+
+            const meta::ColumnMetaVector & TypeInfoQuery::GetMeta() const
+            {
+                return columnsMeta;
+            }
+
+            SqlResult TypeInfoQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
+            {
+                using namespace ignite::impl::binary;
+
+                if (!executed)
+                {
+                    diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+                    return SQL_RESULT_ERROR;
+                }
+
+                if (cursor == types.end())
+                    return SQL_RESULT_NO_DATA;
+
+                app::ColumnBindingMap::iterator it;
+
+                for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
+                {
+                    uint16_t columnIdx = it->first;
+                    app::ApplicationDataBuffer& buffer = it->second;
+                    int8_t currentType = *cursor;
+
+                    switch (columnIdx)
+                    {
+                        case TYPE_NAME:
+                        {
+                            buffer.PutString(type_traits::BinaryTypeToSqlTypeName(currentType));
+
+                            break;
+                        }
+
+                        case DATA_TYPE:
+                        case SQL_DATA_TYPE:
+                        {
+                            buffer.PutInt16(type_traits::BinaryToSqlType(currentType));
+
+                            break;
+                        }
+
+                        case COLUMN_SIZE:
+                        {
+                            buffer.PutInt32(type_traits::BinaryTypeColumnSize(currentType));
+
+                            break;
+                        }
+
+                        case LITERAL_PREFIX:
+                        {
+                            if (currentType == IGNITE_TYPE_STRING)
+                                buffer.PutString("'");
+                            else if (currentType == IGNITE_TYPE_BINARY)
+                                buffer.PutString("0x");
+                            else
+                                buffer.PutNull();
+
+                            break;
+                        }
+
+                        case LITERAL_SUFFIX:
+                        {
+                            if (currentType == IGNITE_TYPE_STRING)
+                                buffer.PutString("'");
+                            else
+                                buffer.PutNull();
+
+                            break;
+                        }
+
+                        case CREATE_PARAMS:
+                        {
+                            buffer.PutNull();
+
+                            break;
+                        }
+
+                        case NULLABLE:
+                        {
+                            buffer.PutInt32(type_traits::BinaryTypeNullability(currentType));
+
+                            break;
+                        }
+
+                        case CASE_SENSITIVE:
+                        {
+                            if (currentType == IGNITE_TYPE_STRING)
+                                buffer.PutInt16(SQL_TRUE);
+                            else
+                                buffer.PutInt16(SQL_FALSE);
+
+                            break;
+                        }
+
+                        case SEARCHABLE:
+                        {
+                            buffer.PutInt16(SQL_SEARCHABLE);
+
+                            break;
+                        }
+
+                        case UNSIGNED_ATTRIBUTE:
+                        {
+                            buffer.PutInt16(type_traits::BinaryTypeUnsigned(currentType));
+
+                            break;
+                        }
+
+                        case FIXED_PREC_SCALE:
+                        {
+                            buffer.PutInt16(SQL_FALSE);
+
+                            break;
+                        }
+
+                        case AUTO_UNIQUE_VALUE:
+                        {
+                            buffer.PutInt16(SQL_FALSE);
+
+                            break;
+                        }
+
+                        case LOCAL_TYPE_NAME:
+                        {
+                            buffer.PutNull();
+
+                            break;
+                        }
+
+                        case MINIMUM_SCALE:
+                        case MAXIMUM_SCALE:
+                        {
+                            buffer.PutInt16(type_traits::BinaryTypeDecimalDigits(currentType));
+
+                            break;
+                        }
+
+                        case SQL_DATETIME_SUB:
+                        {
+                            buffer.PutNull();
+
+                            break;
+                        }
+
+                        case NUM_PREC_RADIX:
+                        {
+                            buffer.PutInt32(type_traits::BinaryTypeNumPrecRadix(currentType));
+
+                            break;
+                        }
+
+                        case INTERVAL_PRECISION:
+                        {
+                            buffer.PutNull();
+
+                            break;
+                        }
+
+                        default:
+                            break;
+                    }
+                }
+
+                ++cursor;
+
+                return SQL_RESULT_SUCCESS;
+            }
+
+            SqlResult TypeInfoQuery::Close()
+            {
+                cursor = types.end();
+
+                executed = false;
+
+                return SQL_RESULT_SUCCESS;
+            }
+
+            bool TypeInfoQuery::DataAvailable() const
+            {
+                return cursor != types.end();;
+            }
+
+            int64_t TypeInfoQuery::AffectedRows() const
+            {
+                return 0;
+            }
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c3f277/modules/platforms/cpp/odbc/odbc-driver/src/type_traits.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/type_traits.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/type_traits.cpp
index 813d606..8cf9aff 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/type_traits.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/type_traits.cpp
@@ -174,7 +174,6 @@ namespace ignite
                 return SqlTypeName::BINARY;
             }
 
-
             bool IsApplicationTypeSupported(int16_t type)
             {
                 return ToDriverType(type) != IGNITE_ODBC_C_TYPE_UNSUPPORTED;
@@ -198,13 +197,13 @@ namespace ignite
                     case SQL_VARBINARY:
                     case SQL_LONGVARBINARY:
                     case SQL_GUID:
+                    case SQL_DECIMAL:
                         return true;
 
                     case SQL_WCHAR:
                     case SQL_WVARCHAR:
                     case SQL_WLONGVARCHAR:
                     case SQL_REAL:
-                    case SQL_DECIMAL:
                     case SQL_NUMERIC:
                     case SQL_TYPE_DATE:
                     case SQL_TYPE_TIME:
@@ -227,6 +226,59 @@ namespace ignite
                 }
             }
 
+            int8_t SqlTypeToBinary(int16_t sqlType)
+            {
+                using namespace ignite::impl::binary;
+
+                switch (sqlType)
+                {
+                    case SQL_CHAR:
+                    case SQL_VARCHAR:
+                    case SQL_LONGVARCHAR:
+                        return IGNITE_TYPE_STRING;
+
+                    case SQL_SMALLINT:
+                        return IGNITE_TYPE_SHORT;
+
+                    case SQL_TINYINT:
+                        return IGNITE_TYPE_BYTE;
+
+                    case SQL_INTEGER:
+                        return IGNITE_TYPE_INT;
+
+                    case SQL_BIGINT:
+                        return IGNITE_TYPE_LONG;
+
+                    case SQL_FLOAT:
+                        return IGNITE_TYPE_FLOAT;
+
+                    case SQL_DOUBLE:
+                        return IGNITE_TYPE_DOUBLE;
+
+                    case SQL_BIT:
+                        return IGNITE_TYPE_BOOL;
+
+                    case SQL_BINARY:
+                    case SQL_VARBINARY:
+                    case SQL_LONGVARBINARY:
+                        return IGNITE_TYPE_BINARY;
+
+                    case SQL_DECIMAL:
+                        return IGNITE_TYPE_DECIMAL;
+
+                    case SQL_GUID:
+                        return IGNITE_TYPE_UUID;
+
+                    case SQL_TYPE_DATE:
+                        return IGNITE_TYPE_DATE;
+
+                    default:
+                        break;
+                }
+
+                return -1;
+            }
+
             IgniteSqlType ToDriverType(int16_t type)
             {
                 switch (type)


Mime
View raw message