You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/01/27 11:39:34 UTC
[01/28] ignite git commit: IGNITE-2447: Renamed ODBC classes to
follow naming convention.
Repository: ignite
Updated Branches:
refs/heads/ignite-1786 abe6fdb57 -> 12ad51cee
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetColumnsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetColumnsMetaResult.java
deleted file mode 100644
index d211862..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetColumnsMetaResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.processors.odbc.GridOdbcColumnMeta;
-
-import java.util.Collection;
-
-/**
- * Query get columns meta result.
- */
-public class QueryGetColumnsMetaResult {
- /** Query result rows. */
- private Collection<GridOdbcColumnMeta> meta;
-
- /**
- * @param meta Column metadata.
- */
- public QueryGetColumnsMetaResult(Collection<GridOdbcColumnMeta> meta) {
- this.meta = meta;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<GridOdbcColumnMeta> getMeta() {
- return meta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetTablesMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetTablesMetaResult.java
deleted file mode 100644
index ae39538..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryGetTablesMetaResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.processors.odbc.GridOdbcTableMeta;
-
-import java.util.Collection;
-
-/**
- * Query get columns meta result.
- */
-public class QueryGetTablesMetaResult {
- /** Query result rows. */
- private Collection<GridOdbcTableMeta> meta;
-
- /**
- * @param meta Column metadata.
- */
- public QueryGetTablesMetaResult(Collection<GridOdbcTableMeta> meta) {
- this.meta = meta;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<GridOdbcTableMeta> getMeta() {
- return meta;
- }
-}
[12/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp b/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp
new file mode 100644
index 0000000..43d6842
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp
@@ -0,0 +1,121 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/query/special_columns_query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ SpecialColumnsQuery::SpecialColumnsQuery(diagnostic::Diagnosable& diag,
+ int16_t type, const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable) :
+ Query(diag),
+ type(type),
+ catalog(catalog),
+ schema(schema),
+ table(table),
+ scope(scope),
+ nullable(nullable),
+ executed(false),
+ columnsMeta()
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::odbc::type_traits;
+
+ using meta::ColumnMeta;
+
+ columnsMeta.reserve(8);
+
+ const std::string sch("");
+ const std::string tbl("");
+
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "SCOPE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_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, "TYPE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_SIZE", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "BUFFER_LENGTH", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "DECIMAL_DIGITS", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PSEUDO_COLUMN", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ }
+
+ SpecialColumnsQuery::~SpecialColumnsQuery()
+ {
+ // No-op.
+ }
+
+ SqlResult SpecialColumnsQuery::Execute()
+ {
+ executed = true;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ const meta::ColumnMetaVector& SpecialColumnsQuery::GetMeta() const
+ {
+ return columnsMeta;
+ }
+
+ SqlResult SpecialColumnsQuery::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;
+ }
+
+ SqlResult SpecialColumnsQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_NO_DATA;
+ }
+
+ SqlResult SpecialColumnsQuery::Close()
+ {
+ executed = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool SpecialColumnsQuery::DataAvailable() const
+ {
+ return false;
+ }
+
+ int64_t SpecialColumnsQuery::AffectedRows() const
+ {
+ return 0;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp b/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp
new file mode 100644
index 0000000..42850cf
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp
@@ -0,0 +1,242 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/message.h"
+#include "ignite/odbc/query/table_metadata_query.h"
+
+namespace
+{
+ enum ResultColumn
+ {
+ /** Catalog name. NULL if not applicable to the data source. */
+ TABLE_CAT = 1,
+
+ /** Schema name. NULL if not applicable to the data source. */
+ TABLE_SCHEM,
+
+ /** Table name. */
+ TABLE_NAME,
+
+ /** Table type. */
+ TABLE_TYPE,
+
+ /** A description of the column. */
+ REMARKS
+ };
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ TableMetadataQuery::TableMetadataQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& catalog,const std::string& schema,
+ const std::string& table, const std::string& tableType) :
+ Query(diag),
+ connection(connection),
+ catalog(catalog),
+ schema(schema),
+ table(table),
+ tableType(tableType),
+ executed(false),
+ meta(),
+ columnsMeta()
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::odbc::type_traits;
+
+ using meta::ColumnMeta;
+
+ columnsMeta.reserve(5);
+
+ const std::string sch("");
+ const std::string tbl("");
+
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_TYPE", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "REMARKS", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ }
+
+ TableMetadataQuery::~TableMetadataQuery()
+ {
+ // No-op.
+ }
+
+ SqlResult TableMetadataQuery::Execute()
+ {
+ if (executed)
+ Close();
+
+ SqlResult result = MakeRequestGetTablesMeta();
+
+ if (result == SQL_RESULT_SUCCESS)
+ {
+ executed = true;
+
+ cursor = meta.begin();
+ }
+
+ return result;
+ }
+
+ const meta::ColumnMetaVector& TableMetadataQuery::GetMeta() const
+ {
+ return columnsMeta;
+ }
+
+ SqlResult TableMetadataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cursor == meta.end())
+ return SQL_RESULT_NO_DATA;
+
+ app::ColumnBindingMap::iterator it;
+
+ for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
+ GetColumn(it->first, it->second);
+
+ ++cursor;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult TableMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cursor == meta.end())
+ return SQL_RESULT_NO_DATA;
+
+ const meta::TableMeta& currentColumn = *cursor;
+
+ switch (columnIdx)
+ {
+ case TABLE_CAT:
+ {
+ buffer.PutString(currentColumn.GetCatalogName());
+ break;
+ }
+
+ case TABLE_SCHEM:
+ {
+ buffer.PutString(currentColumn.GetSchemaName());
+ break;
+ }
+
+ case TABLE_NAME:
+ {
+ buffer.PutString(currentColumn.GetTableName());
+ break;
+ }
+
+ case TABLE_TYPE:
+ {
+ buffer.PutString(currentColumn.GetTableType());
+ break;
+ }
+
+ case REMARKS:
+ {
+ buffer.PutNull();
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult TableMetadataQuery::Close()
+ {
+ meta.clear();
+
+ executed = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool TableMetadataQuery::DataAvailable() const
+ {
+ return cursor != meta.end();
+ }
+
+ int64_t TableMetadataQuery::AffectedRows() const
+ {
+ return 0;
+ }
+
+ SqlResult TableMetadataQuery::MakeRequestGetTablesMeta()
+ {
+ QueryGetTablesMetaRequest req(catalog, schema, table, tableType);
+ QueryGetTablesMetaResponse rsp;
+
+ bool success = connection.SyncMessage(req, rsp);
+
+ if (!success)
+ {
+ diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
+ {
+ LOG_MSG("Error: %s\n", rsp.GetError().c_str());
+
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ meta = rsp.GetMeta();
+
+ for (size_t i = 0; i < meta.size(); ++i)
+ {
+ LOG_MSG("[%d] CatalogName: %s\n", i, meta[i].GetCatalogName().c_str());
+ LOG_MSG("[%d] SchemaName: %s\n", i, meta[i].GetSchemaName().c_str());
+ LOG_MSG("[%d] TableName: %s\n", i, meta[i].GetTableName().c_str());
+ LOG_MSG("[%d] TableType: %s\n", i, meta[i].GetTableType().c_str());
+ LOG_MSG("\n");
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/type_info_query.cpp b/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
new file mode 100644
index 0000000..efba734
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
@@ -0,0 +1,394 @@
+/*
+ * 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)
+ {
+ 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)
+ GetColumn(it->first, it->second);
+
+ ++cursor;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult TypeInfoQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
+ {
+ 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;
+
+ 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;
+ }
+
+ 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/e8287063/modules/platforms/cpp/odbc/src/result_page.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/result_page.cpp b/modules/platforms/cpp/odbc/src/result_page.cpp
new file mode 100644
index 0000000..4464481
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/result_page.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 <ignite/impl/interop/interop_input_stream.h>
+
+#include "ignite/odbc/result_page.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ ResultPage::ResultPage() :
+ last(false), size(0), data(DEFAULT_ALLOCATED_MEMORY)
+ {
+ //No-op.
+ }
+
+ ResultPage::~ResultPage()
+ {
+ //No-op.
+ }
+
+ void ResultPage::Read(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ last = reader.ReadBool();
+ size = reader.ReadInt32();
+
+ ignite::impl::interop::InteropInputStream& stream = *reader.GetStream();
+
+ int32_t dataToRead = stream.Remaining();
+
+ data.Length(dataToRead);
+
+ if (dataToRead)
+ {
+ data.Reallocate(dataToRead);
+
+ reader.GetStream()->ReadInt8Array(data.Data(), dataToRead);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/row.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/row.cpp b/modules/platforms/cpp/odbc/src/row.cpp
new file mode 100644
index 0000000..5e5a00e
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/row.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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 <ignite/impl/interop/interop_stream_position_guard.h>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/row.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ Row::Row(ignite::impl::interop::InteropUnpooledMemory& pageData) :
+ rowBeginPos(0), pos(rowBeginPos), size(0), pageData(pageData),
+ stream(&pageData), reader(&stream), columns()
+ {
+ if (pageData.Length() >= 4)
+ {
+ Reinit();
+ }
+ }
+
+ Row::~Row()
+ {
+ // No-op.
+ }
+
+ bool Row::EnsureColumnDiscovered(uint16_t columnIdx)
+ {
+ if (columns.size() >= columnIdx)
+ return true;
+
+ if (columnIdx > GetSize() || columnIdx < 1)
+ return false;
+
+ if (columns.empty())
+ {
+ Column newColumn(reader);
+
+ if (!newColumn.IsValid())
+ return false;
+
+ columns.push_back(newColumn);
+ }
+
+ while (columns.size() < columnIdx)
+ {
+ Column& column = columns.back();
+
+ stream.Position(column.GetEndPosition());
+
+ Column newColumn(reader);
+
+ if (!newColumn.IsValid())
+ return false;
+
+ columns.push_back(newColumn);
+ }
+
+ return true;
+ }
+
+ SqlResult Row::ReadColumnToBuffer(uint16_t columnIdx, app::ApplicationDataBuffer& dataBuf)
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::impl::interop;
+
+ if (!EnsureColumnDiscovered(columnIdx))
+ return SQL_RESULT_ERROR;
+
+ Column& column = GetColumn(columnIdx);
+
+ return column.ReadToBuffer(reader, dataBuf);
+ }
+
+ bool Row::MoveToNext()
+ {
+ int32_t lastColumnIdx = GetSize();
+
+ if (!EnsureColumnDiscovered(lastColumnIdx))
+ return false;
+
+ Column& lastColumn = GetColumn(lastColumnIdx);
+
+ stream.Position(lastColumn.GetEndPosition());
+
+ Reinit();
+
+ return true;
+ }
+
+ void Row::Reinit()
+ {
+ size = stream.ReadInt32();
+
+ rowBeginPos = stream.Position();
+
+ columns.clear();
+
+ columns.reserve(size);
+
+ pos = 0;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/statement.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/statement.cpp b/modules/platforms/cpp/odbc/src/statement.cpp
new file mode 100644
index 0000000..4bf0db9
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/statement.cpp
@@ -0,0 +1,529 @@
+/*
+ * 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 "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/query/data_query.h"
+#include "ignite/odbc/query/column_metadata_query.h"
+#include "ignite/odbc/query/table_metadata_query.h"
+#include "ignite/odbc/query/foreign_keys_query.h"
+#include "ignite/odbc/query/primary_keys_query.h"
+#include "ignite/odbc/query/type_info_query.h"
+#include "ignite/odbc/query/special_columns_query.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/message.h"
+#include "ignite/odbc/statement.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ Statement::Statement(Connection& parent) :
+ connection(parent), columnBindings(), currentQuery(),
+ rowsFetched(0), rowStatuses(0), paramBindOffset(0), columnBindOffset(0)
+ {
+ // No-op.
+ }
+
+ Statement::~Statement()
+ {
+ // No-op.
+ }
+
+ void Statement::BindColumn(uint16_t columnIdx, const app::ApplicationDataBuffer& buffer)
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ columnBindings[columnIdx] = buffer;
+
+ columnBindings[columnIdx].SetPtrToOffsetPtr(&columnBindOffset);
+ }
+
+ void Statement::UnbindColumn(uint16_t columnIdx)
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ columnBindings.erase(columnIdx);
+ }
+
+ void Statement::UnbindAllColumns()
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ columnBindings.clear();
+ }
+
+ void Statement::SetColumnBindOffsetPtr(size_t * ptr)
+ {
+ columnBindOffset = ptr;
+ }
+
+ size_t * Statement::GetColumnBindOffsetPtr()
+ {
+ return columnBindOffset;
+ }
+
+ int32_t Statement::GetColumnNumber()
+ {
+ int32_t res;
+
+ IGNITE_ODBC_API_CALL(InternalGetColumnNumber(res));
+
+ return res;
+ }
+
+ SqlResult Statement::InternalGetColumnNumber(int32_t &res)
+ {
+ const meta::ColumnMetaVector* meta = GetMeta();
+
+ if (!meta)
+ {
+ AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ res = static_cast<int32_t>(meta->size());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Statement::BindParameter(uint16_t paramIdx, const app::Parameter& param)
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ paramBindings[paramIdx] = param;
+
+ paramBindings[paramIdx].GetBuffer().SetPtrToOffsetPtr(¶mBindOffset);
+ }
+
+ void Statement::UnbindParameter(uint16_t paramIdx)
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ paramBindings.erase(paramIdx);
+ }
+
+ void Statement::UnbindAllParameters()
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ paramBindings.clear();
+ }
+
+ uint16_t Statement::GetParametersNumber()
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ return static_cast<uint16_t>(paramBindings.size());
+ }
+
+ void Statement::SetParamBindOffsetPtr(size_t* ptr)
+ {
+ IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
+
+ paramBindOffset = ptr;
+ }
+
+ size_t * Statement::GetParamBindOffsetPtr()
+ {
+ return paramBindOffset;
+ }
+
+ void Statement::GetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ IGNITE_ODBC_API_CALL(InternalGetColumnData(columnIdx, buffer));
+ }
+
+ SqlResult Statement::InternalGetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ if (!currentQuery.get())
+ {
+ AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE, "Cursor is not in the open state.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ SqlResult res = currentQuery->GetColumn(columnIdx, buffer);
+
+ return res;
+ }
+
+ void Statement::PrepareSqlQuery(const std::string& query)
+ {
+ return PrepareSqlQuery(query.data(), query.size());
+ }
+
+ void Statement::PrepareSqlQuery(const char* query, size_t len)
+ {
+ IGNITE_ODBC_API_CALL(InternalPrepareSqlQuery(query, len));
+ }
+
+ SqlResult Statement::InternalPrepareSqlQuery(const char* query, size_t len)
+ {
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ std::string sql(query, len);
+
+ currentQuery.reset(new query::DataQuery(*this, connection, sql, paramBindings));
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Statement::ExecuteSqlQuery(const std::string& query)
+ {
+ ExecuteSqlQuery(query.data(), query.size());
+ }
+
+ void Statement::ExecuteSqlQuery(const char* query, size_t len)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteSqlQuery(query, len));
+ }
+
+ SqlResult Statement::InternalExecuteSqlQuery(const char* query, size_t len)
+ {
+ SqlResult result = InternalPrepareSqlQuery(query, len);
+
+ if (result != SQL_RESULT_SUCCESS)
+ return result;
+
+ return InternalExecuteSqlQuery();
+ }
+
+ void Statement::ExecuteSqlQuery()
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteSqlQuery());
+ }
+
+ SqlResult Statement::InternalExecuteSqlQuery()
+ {
+ if (!currentQuery.get())
+ {
+ AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not prepared.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::ExecuteGetColumnsMetaQuery(const std::string& schema,
+ const std::string& table, const std::string& column)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteGetColumnsMetaQuery(schema, table, column));
+ }
+
+ SqlResult Statement::InternalExecuteGetColumnsMetaQuery(const std::string& schema,
+ const std::string& table, const std::string& column)
+ {
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ std::string cache(schema);
+
+ if (cache.empty())
+ cache = connection.GetCache();
+
+ currentQuery.reset(new query::ColumnMetadataQuery(*this, connection, cache, table, column));
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::ExecuteGetTablesMetaQuery(const std::string& catalog,
+ const std::string& schema, const std::string& table, const std::string& tableType)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteGetTablesMetaQuery(catalog, schema, table, tableType));
+ }
+
+ SqlResult Statement::InternalExecuteGetTablesMetaQuery(const std::string& catalog,
+ const std::string& schema, const std::string& table, const std::string& tableType)
+ {
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ std::string cache(schema);
+
+ if (cache.empty())
+ cache = connection.GetCache();
+
+ currentQuery.reset(new query::TableMetadataQuery(*this, connection, catalog, cache, table, tableType));
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::ExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
+ const std::string& primarySchema, const std::string& primaryTable,
+ const std::string& foreignCatalog, const std::string& foreignSchema,
+ const std::string& foreignTable)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteGetForeignKeysQuery(primaryCatalog,
+ primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable));
+ }
+
+ SqlResult Statement::InternalExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
+ const std::string& primarySchema, const std::string& primaryTable,
+ const std::string& foreignCatalog, const std::string& foreignSchema,
+ const std::string& foreignTable)
+ {
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ currentQuery.reset(new query::ForeignKeysQuery(*this, connection, primaryCatalog, primarySchema,
+ primaryTable, foreignCatalog, foreignSchema, foreignTable));
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::ExecuteGetPrimaryKeysQuery(const std::string& catalog, const std::string& schema,
+ const std::string& table)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteGetPrimaryKeysQuery(catalog, schema, table));
+ }
+
+ SqlResult Statement::InternalExecuteGetPrimaryKeysQuery(const std::string& catalog, const std::string& schema,
+ const std::string& table)
+ {
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ currentQuery.reset(new query::PrimaryKeysQuery(*this, connection, catalog, schema, table));
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::ExecuteSpecialColumnsQuery(int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteSpecialColumnsQuery(type,
+ catalog, schema, table, scope, nullable));
+ }
+
+ SqlResult Statement::InternalExecuteSpecialColumnsQuery(int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable)
+ {
+ if (type != SQL_BEST_ROWID && type != SQL_ROWVER)
+ {
+ AddStatusRecord(SQL_STATE_HY097_COLUMN_TYPE_OUT_OF_RANGE,
+ "An invalid IdentifierType value was specified.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ currentQuery.reset(new query::SpecialColumnsQuery(*this, type,
+ catalog, schema, table, scope, nullable));
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::ExecuteGetTypeInfoQuery(int16_t sqlType)
+ {
+ IGNITE_ODBC_API_CALL(InternalExecuteGetTypeInfoQuery(sqlType));
+ }
+
+ SqlResult Statement::InternalExecuteGetTypeInfoQuery(int16_t sqlType)
+ {
+ if (!type_traits::IsSqlTypeSupported(sqlType))
+ {
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Data type is not supported.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (currentQuery.get())
+ currentQuery->Close();
+
+ currentQuery.reset(new query::TypeInfoQuery(*this, sqlType));
+
+ return currentQuery->Execute();
+ }
+
+ void Statement::Close()
+ {
+ IGNITE_ODBC_API_CALL(InternalClose());
+ }
+
+ SqlResult Statement::InternalClose()
+ {
+ if (!currentQuery.get())
+ {
+ AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE, "Cursor is not in the open state.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ SqlResult result = currentQuery->Close();
+
+ if (result == SQL_RESULT_SUCCESS)
+ currentQuery.reset();
+
+ return result;
+ }
+
+ void Statement::FetchRow()
+ {
+ IGNITE_ODBC_API_CALL(InternalFetchRow());
+ }
+
+ SqlResult Statement::InternalFetchRow()
+ {
+ if (rowsFetched)
+ *rowsFetched = 0;
+
+ if (!currentQuery.get())
+ {
+ AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE, "Cursor is not in the open state.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ SqlResult res = currentQuery->FetchNextRow(columnBindings);
+
+ if (res == SQL_RESULT_SUCCESS)
+ {
+ if (rowsFetched)
+ *rowsFetched = 1;
+
+ if (rowStatuses)
+ rowStatuses[0] = SQL_ROW_SUCCESS;
+ }
+
+ return res;
+ }
+
+ const meta::ColumnMetaVector* Statement::GetMeta() const
+ {
+ if (!currentQuery.get())
+ return 0;
+
+ return ¤tQuery->GetMeta();
+ }
+
+ bool Statement::DataAvailable() const
+ {
+ return currentQuery.get() && currentQuery->DataAvailable();
+ }
+
+ void Statement::GetColumnAttribute(uint16_t colIdx, uint16_t attrId,
+ char* strbuf, int16_t buflen, int16_t* reslen, SqlLen* numbuf)
+ {
+ IGNITE_ODBC_API_CALL(InternalGetColumnAttribute(colIdx, attrId,
+ strbuf, buflen, reslen, numbuf));
+ }
+
+ SqlResult Statement::InternalGetColumnAttribute(uint16_t colIdx,
+ uint16_t attrId, char* strbuf, int16_t buflen, int16_t* reslen,
+ SqlLen* numbuf)
+ {
+ const meta::ColumnMetaVector *meta = GetMeta();
+
+ if (!meta)
+ {
+ AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (colIdx > meta->size() + 1 || colIdx < 1)
+ {
+ AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Column index is out of range.", 0, colIdx);
+
+ return SQL_RESULT_ERROR;
+ }
+
+ const meta::ColumnMeta& columnMeta = meta->at(colIdx - 1);
+
+ bool found = false;
+
+ if (numbuf)
+ found = columnMeta.GetAttribute(attrId, *numbuf);
+
+ if (!found)
+ {
+ std::string out;
+
+ found = columnMeta.GetAttribute(attrId, out);
+
+ size_t outSize = out.size();
+
+ if (found && strbuf)
+ outSize = utility::CopyStringToBuffer(out, strbuf, buflen);
+
+ if (found && strbuf)
+ *reslen = static_cast<int16_t>(outSize);
+ }
+
+ if (!found)
+ {
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Unknown attribute.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ int64_t Statement::AffectedRows()
+ {
+ int64_t rowCnt = 0;
+
+ IGNITE_ODBC_API_CALL(InternalAffectedRows(rowCnt));
+
+ return rowCnt;
+ }
+
+ SqlResult Statement::InternalAffectedRows(int64_t& rowCnt)
+ {
+ if (!currentQuery.get())
+ {
+ AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ rowCnt = currentQuery->AffectedRows();
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Statement::SetRowsFetchedPtr(size_t* ptr)
+ {
+ rowsFetched = ptr;
+ }
+
+ size_t* Statement::GetRowsFetchedPtr()
+ {
+ return rowsFetched;
+ }
+
+ void Statement::SetRowStatusesPtr(uint16_t* ptr)
+ {
+ rowStatuses = ptr;
+ }
+
+ uint16_t * Statement::GetRowStatusesPtr()
+ {
+ return rowStatuses;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/type_traits.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/type_traits.cpp b/modules/platforms/cpp/odbc/src/type_traits.cpp
new file mode 100644
index 0000000..03e525f
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/type_traits.cpp
@@ -0,0 +1,657 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/type_traits.h"
+
+namespace
+{
+ /** Default display size. */
+ enum { DEFAULT_DISPLAY_SIZE = 34 };
+
+ /** Default variable size data display size. */
+ enum { DEFAULT_VARDATA_DISPLAY_SIZE = 64 };
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace type_traits
+ {
+ const std::string SqlTypeName::VARCHAR("LONG VARCHAR");
+
+ const std::string SqlTypeName::SMALLINT("SMALLINT");
+
+ const std::string SqlTypeName::INTEGER("INTEGER");
+
+ const std::string SqlTypeName::DECIMAL("DECIMAL");
+
+ const std::string SqlTypeName::FLOAT("FLOAT");
+
+ const std::string SqlTypeName::DOUBLE("DOUBLE");
+
+ const std::string SqlTypeName::BIT("BIT");
+
+ const std::string SqlTypeName::TINYINT("TINYINT");
+
+ const std::string SqlTypeName::BIGINT("BIGINT");
+
+ const std::string SqlTypeName::BINARY("LONG VARBINARY");
+
+ const std::string SqlTypeName::DATE("DATE");
+
+ const std::string SqlTypeName::GUID("GUID");
+
+#ifdef ODBC_DEBUG
+
+#define DBG_STR_CASE(x) case x: return #x
+
+ const char* StatementAttrIdToString(long id)
+ {
+ switch (id)
+ {
+ DBG_STR_CASE(SQL_ATTR_APP_PARAM_DESC);
+ DBG_STR_CASE(SQL_ATTR_APP_ROW_DESC);
+ DBG_STR_CASE(SQL_ATTR_ASYNC_ENABLE);
+ DBG_STR_CASE(SQL_ATTR_CONCURRENCY);
+ DBG_STR_CASE(SQL_ATTR_CURSOR_SCROLLABLE);
+ DBG_STR_CASE(SQL_ATTR_CURSOR_SENSITIVITY);
+ DBG_STR_CASE(SQL_ATTR_CURSOR_TYPE);
+ DBG_STR_CASE(SQL_ATTR_ENABLE_AUTO_IPD);
+ DBG_STR_CASE(SQL_ATTR_FETCH_BOOKMARK_PTR);
+ DBG_STR_CASE(SQL_ATTR_IMP_PARAM_DESC);
+ DBG_STR_CASE(SQL_ATTR_IMP_ROW_DESC);
+ DBG_STR_CASE(SQL_ATTR_KEYSET_SIZE);
+ DBG_STR_CASE(SQL_ATTR_MAX_LENGTH);
+ DBG_STR_CASE(SQL_ATTR_MAX_ROWS);
+ DBG_STR_CASE(SQL_ATTR_METADATA_ID);
+ DBG_STR_CASE(SQL_ATTR_NOSCAN);
+ DBG_STR_CASE(SQL_ATTR_PARAM_BIND_OFFSET_PTR);
+ DBG_STR_CASE(SQL_ATTR_PARAM_BIND_TYPE);
+ DBG_STR_CASE(SQL_ATTR_PARAM_OPERATION_PTR);
+ DBG_STR_CASE(SQL_ATTR_PARAM_STATUS_PTR);
+ DBG_STR_CASE(SQL_ATTR_PARAMS_PROCESSED_PTR);
+ DBG_STR_CASE(SQL_ATTR_PARAMSET_SIZE);
+ DBG_STR_CASE(SQL_ATTR_QUERY_TIMEOUT);
+ DBG_STR_CASE(SQL_ATTR_RETRIEVE_DATA);
+ DBG_STR_CASE(SQL_ATTR_ROW_ARRAY_SIZE);
+ DBG_STR_CASE(SQL_ATTR_ROW_BIND_OFFSET_PTR);
+ DBG_STR_CASE(SQL_ATTR_ROW_BIND_TYPE);
+ DBG_STR_CASE(SQL_ATTR_ROW_NUMBER);
+ DBG_STR_CASE(SQL_ATTR_ROW_OPERATION_PTR);
+ DBG_STR_CASE(SQL_ATTR_ROW_STATUS_PTR);
+ DBG_STR_CASE(SQL_ATTR_ROWS_FETCHED_PTR);
+ DBG_STR_CASE(SQL_ATTR_SIMULATE_CURSOR);
+ DBG_STR_CASE(SQL_ATTR_USE_BOOKMARKS);
+ default:
+ break;
+ }
+ return "<< UNKNOWN ID >>";
+ }
+
+#undef DBG_STR_CASE
+#endif
+
+ const std::string& BinaryTypeToSqlTypeName(int8_t binaryType)
+ {
+ using namespace ignite::impl::binary;
+
+ switch (binaryType)
+ {
+ case IGNITE_TYPE_STRING:
+ return SqlTypeName::VARCHAR;
+
+ case IGNITE_TYPE_SHORT:
+ return SqlTypeName::SMALLINT;
+
+ case IGNITE_TYPE_INT:
+ return SqlTypeName::INTEGER;
+
+ case IGNITE_TYPE_DECIMAL:
+ return SqlTypeName::DECIMAL;
+
+ case IGNITE_TYPE_FLOAT:
+ return SqlTypeName::FLOAT;
+
+ case IGNITE_TYPE_DOUBLE:
+ return SqlTypeName::DOUBLE;
+
+ case IGNITE_TYPE_BOOL:
+ return SqlTypeName::BIT;
+
+ case IGNITE_TYPE_BYTE:
+ case IGNITE_TYPE_CHAR:
+ return SqlTypeName::TINYINT;
+
+ case IGNITE_TYPE_LONG:
+ return SqlTypeName::BIGINT;
+
+ case IGNITE_TYPE_UUID:
+ return SqlTypeName::GUID;
+
+ case IGNITE_TYPE_DATE:
+ return SqlTypeName::DATE;
+
+ case IGNITE_TYPE_OBJECT:
+ case IGNITE_TYPE_ARRAY_BYTE:
+ case IGNITE_TYPE_ARRAY_SHORT:
+ case IGNITE_TYPE_ARRAY_INT:
+ case IGNITE_TYPE_ARRAY_LONG:
+ case IGNITE_TYPE_ARRAY_FLOAT:
+ case IGNITE_TYPE_ARRAY_DOUBLE:
+ case IGNITE_TYPE_ARRAY_CHAR:
+ case IGNITE_TYPE_ARRAY_BOOL:
+ case IGNITE_TYPE_ARRAY_DECIMAL:
+ case IGNITE_TYPE_ARRAY_STRING:
+ case IGNITE_TYPE_ARRAY_UUID:
+ case IGNITE_TYPE_ARRAY_DATE:
+ case IGNITE_TYPE_ARRAY:
+ case IGNITE_TYPE_COLLECTION:
+ case IGNITE_TYPE_MAP:
+ case IGNITE_TYPE_MAP_ENTRY:
+ case IGNITE_TYPE_BINARY:
+ default:
+ return SqlTypeName::BINARY;
+ }
+
+ return SqlTypeName::BINARY;
+ }
+
+ bool IsApplicationTypeSupported(int16_t type)
+ {
+ return ToDriverType(type) != IGNITE_ODBC_C_TYPE_UNSUPPORTED;
+ }
+
+ bool IsSqlTypeSupported(int16_t type)
+ {
+ switch (type)
+ {
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ case SQL_LONGVARCHAR:
+ case SQL_SMALLINT:
+ case SQL_INTEGER:
+ case SQL_FLOAT:
+ case SQL_DOUBLE:
+ case SQL_BIT:
+ case SQL_TINYINT:
+ case SQL_BIGINT:
+ case SQL_BINARY:
+ 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_NUMERIC:
+ case SQL_TYPE_DATE:
+ case SQL_TYPE_TIME:
+ case SQL_TYPE_TIMESTAMP:
+ case SQL_INTERVAL_MONTH:
+ case SQL_INTERVAL_YEAR:
+ case SQL_INTERVAL_YEAR_TO_MONTH:
+ case SQL_INTERVAL_DAY:
+ case SQL_INTERVAL_HOUR:
+ case SQL_INTERVAL_MINUTE:
+ case SQL_INTERVAL_SECOND:
+ case SQL_INTERVAL_DAY_TO_HOUR:
+ case SQL_INTERVAL_DAY_TO_MINUTE:
+ case SQL_INTERVAL_DAY_TO_SECOND:
+ case SQL_INTERVAL_HOUR_TO_MINUTE:
+ case SQL_INTERVAL_HOUR_TO_SECOND:
+ case SQL_INTERVAL_MINUTE_TO_SECOND:
+ default:
+ return false;
+ }
+ }
+
+ 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)
+ {
+ case SQL_C_CHAR:
+ return IGNITE_ODBC_C_TYPE_CHAR;
+
+ case SQL_C_WCHAR:
+ return IGNITE_ODBC_C_TYPE_WCHAR;
+
+ case SQL_C_SSHORT:
+ return IGNITE_ODBC_C_TYPE_SIGNED_SHORT;
+
+ case SQL_C_USHORT:
+ return IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT;
+
+ case SQL_C_SLONG:
+ return IGNITE_ODBC_C_TYPE_SIGNED_LONG;
+
+ case SQL_C_ULONG:
+ return IGNITE_ODBC_C_TYPE_UNSIGNED_LONG;
+
+ case SQL_C_FLOAT:
+ return IGNITE_ODBC_C_TYPE_FLOAT;
+
+ case SQL_C_DOUBLE:
+ return IGNITE_ODBC_C_TYPE_DOUBLE;
+
+ case SQL_C_BIT:
+ return IGNITE_ODBC_C_TYPE_BIT;
+
+ case SQL_C_STINYINT:
+ return IGNITE_ODBC_C_TYPE_SIGNED_TINYINT;
+
+ case SQL_C_UTINYINT:
+ return IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT;
+
+ case SQL_C_SBIGINT:
+ return IGNITE_ODBC_C_TYPE_SIGNED_BIGINT;
+
+ case SQL_C_UBIGINT:
+ return IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT;
+
+ case SQL_C_BINARY:
+ return IGNITE_ODBC_C_TYPE_BINARY;
+
+ case SQL_C_TYPE_DATE:
+ return IGNITE_ODBC_C_TYPE_TDATE;
+
+ case SQL_C_TYPE_TIME:
+ return IGNITE_ODBC_C_TYPE_TTIME;
+
+ case SQL_C_TYPE_TIMESTAMP:
+ return IGNITE_ODBC_C_TYPE_TTIMESTAMP;
+
+ case SQL_C_NUMERIC:
+ return IGNITE_ODBC_C_TYPE_NUMERIC;
+
+ case SQL_C_GUID:
+ return IGNITE_ODBC_C_TYPE_GUID;
+
+ case SQL_C_DEFAULT:
+ return IGNITE_ODBC_C_TYPE_DEFAULT;
+
+ default:
+ return IGNITE_ODBC_C_TYPE_UNSUPPORTED;
+ }
+ }
+
+ int16_t BinaryToSqlType(int8_t binaryType)
+ {
+ using namespace ignite::impl::binary;
+ switch (binaryType)
+ {
+ case IGNITE_TYPE_BYTE:
+ case IGNITE_TYPE_CHAR:
+ return SQL_TINYINT;
+
+ case IGNITE_TYPE_SHORT:
+ return SQL_SMALLINT;
+
+ case IGNITE_TYPE_INT:
+ return SQL_INTEGER;
+
+ case IGNITE_TYPE_LONG:
+ return SQL_BIGINT;
+
+ case IGNITE_TYPE_FLOAT:
+ return SQL_FLOAT;
+
+ case IGNITE_TYPE_DOUBLE:
+ return SQL_DOUBLE;
+
+ case IGNITE_TYPE_BOOL:
+ return SQL_BIT;
+
+ case IGNITE_TYPE_DECIMAL:
+ return SQL_DECIMAL;
+
+ case IGNITE_TYPE_STRING:
+ return SQL_VARCHAR;
+
+ case IGNITE_TYPE_UUID:
+ return SQL_GUID;
+
+ case IGNITE_TYPE_DATE:
+ return SQL_TYPE_DATE;
+
+ case IGNITE_TYPE_ARRAY_BYTE:
+ case IGNITE_TYPE_ARRAY_SHORT:
+ case IGNITE_TYPE_ARRAY_INT:
+ case IGNITE_TYPE_ARRAY_LONG:
+ case IGNITE_TYPE_ARRAY_FLOAT:
+ case IGNITE_TYPE_ARRAY_DOUBLE:
+ case IGNITE_TYPE_ARRAY_CHAR:
+ case IGNITE_TYPE_ARRAY_BOOL:
+ case IGNITE_TYPE_ARRAY_DECIMAL:
+ case IGNITE_TYPE_ARRAY_STRING:
+ case IGNITE_TYPE_ARRAY_UUID:
+ case IGNITE_TYPE_ARRAY_DATE:
+ case IGNITE_TYPE_ARRAY:
+ case IGNITE_TYPE_COLLECTION:
+ case IGNITE_TYPE_MAP:
+ case IGNITE_TYPE_MAP_ENTRY:
+ case IGNITE_TYPE_BINARY:
+ case IGNITE_TYPE_OBJECT:
+ default:
+ return SQL_BINARY;
+ }
+ }
+
+ int16_t BinaryTypeNullability(int8_t binaryType)
+ {
+ return SQL_NULLABLE_UNKNOWN;
+ }
+
+ int32_t SqlTypeDisplaySize(int16_t type)
+ {
+ switch (type)
+ {
+ case SQL_VARCHAR:
+ case SQL_CHAR:
+ case SQL_WCHAR:
+ case SQL_BINARY:
+ return DEFAULT_VARDATA_DISPLAY_SIZE;
+
+ case SQL_BIT:
+ return 1;
+
+ case SQL_TINYINT:
+ return 4;
+
+ case SQL_SMALLINT:
+ return 6;
+
+ case SQL_INTEGER:
+ return 11;
+
+ case SQL_BIGINT:
+ return 20;
+
+ case SQL_REAL:
+ return 14;
+
+ case SQL_FLOAT:
+ case SQL_DOUBLE:
+ return 24;
+
+ case SQL_TYPE_DATE:
+ return 10;
+
+ case SQL_TYPE_TIME:
+ return 8;
+
+ case SQL_TYPE_TIMESTAMP:
+ return 19;
+
+ case SQL_GUID:
+ return 36;
+
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
+ default:
+ return DEFAULT_DISPLAY_SIZE;
+ }
+ }
+
+ int32_t BinaryTypeDisplaySize(int8_t type)
+ {
+ int16_t sqlType = BinaryToSqlType(type);
+
+ return SqlTypeDisplaySize(sqlType);
+ }
+
+ int32_t SqlTypeColumnSize(int16_t type)
+ {
+ switch (type)
+ {
+ case SQL_VARCHAR:
+ case SQL_CHAR:
+ case SQL_WCHAR:
+ case SQL_BINARY:
+ return DEFAULT_VARDATA_DISPLAY_SIZE;
+
+ case SQL_BIT:
+ return 1;
+
+ case SQL_TINYINT:
+ return 3;
+
+ case SQL_SMALLINT:
+ return 5;
+
+ case SQL_INTEGER:
+ return 10;
+
+ case SQL_BIGINT:
+ return 19;
+
+ case SQL_REAL:
+ return 7;
+
+ case SQL_FLOAT:
+ case SQL_DOUBLE:
+ return 15;
+
+ case SQL_TYPE_DATE:
+ return 10;
+
+ case SQL_TYPE_TIME:
+ return 8;
+
+ case SQL_TYPE_TIMESTAMP:
+ return 19;
+
+ case SQL_GUID:
+ return 36;
+
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
+ default:
+ return DEFAULT_DISPLAY_SIZE;
+ }
+ }
+
+ int32_t BinaryTypeColumnSize(int8_t type)
+ {
+ int16_t sqlType = BinaryToSqlType(type);
+
+ return SqlTypeColumnSize(sqlType);
+ }
+
+ int32_t SqlTypeTransferLength(int16_t type)
+ {
+ switch (type)
+ {
+ case SQL_VARCHAR:
+ case SQL_CHAR:
+ case SQL_WCHAR:
+ case SQL_BINARY:
+ return DEFAULT_VARDATA_DISPLAY_SIZE;
+
+ case SQL_BIT:
+ case SQL_TINYINT:
+ return 1;
+
+ case SQL_SMALLINT:
+ return 2;
+
+ case SQL_INTEGER:
+ return 4;
+
+ case SQL_BIGINT:
+ return 8;
+
+ case SQL_REAL:
+ case SQL_FLOAT:
+ return 4;
+
+ case SQL_DOUBLE:
+ return 8;
+
+ case SQL_TYPE_DATE:
+ case SQL_TYPE_TIME:
+ return 6;
+
+ case SQL_TYPE_TIMESTAMP:
+ return 16;
+
+ case SQL_GUID:
+ return 16;
+
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
+ default:
+ return DEFAULT_DISPLAY_SIZE;
+ }
+ }
+
+ int32_t BinaryTypeTransferLength(int8_t type)
+ {
+ int16_t sqlType = BinaryToSqlType(type);
+
+ return SqlTypeTransferLength(sqlType);
+ }
+
+ int32_t SqlTypeNumPrecRadix(int16_t type)
+ {
+ switch (type)
+ {
+ case SQL_REAL:
+ case SQL_FLOAT:
+ case SQL_DOUBLE:
+ return 2;
+
+ case SQL_BIT:
+ case SQL_TINYINT:
+ case SQL_SMALLINT:
+ case SQL_INTEGER:
+ case SQL_BIGINT:
+ return 10;
+
+ default:
+ return 0;
+ }
+ }
+
+ int32_t BinaryTypeNumPrecRadix(int8_t type)
+ {
+ int16_t sqlType = BinaryToSqlType(type);
+
+ return SqlTypeNumPrecRadix(sqlType);
+ }
+
+ int32_t SqlTypeDecimalDigits(int16_t type)
+ {
+ // Not implemented for the NUMERIC and DECIMAL data types.
+ return -1;
+ }
+
+ int32_t BinaryTypeDecimalDigits(int8_t type)
+ {
+ int16_t sqlType = BinaryToSqlType(type);
+
+ return SqlTypeDecimalDigits(sqlType);
+ }
+
+ bool SqlTypeUnsigned(int16_t type)
+ {
+ switch (type)
+ {
+ case SQL_BIT:
+ case SQL_TINYINT:
+ case SQL_SMALLINT:
+ case SQL_INTEGER:
+ case SQL_BIGINT:
+ case SQL_REAL:
+ case SQL_FLOAT:
+ case SQL_DOUBLE:
+ return false;
+
+ default:
+ return true;
+ }
+ }
+
+ bool BinaryTypeUnsigned(int8_t type)
+ {
+ int16_t sqlType = BinaryToSqlType(type);
+
+ return SqlTypeUnsigned(sqlType);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/utility.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/utility.cpp b/modules/platforms/cpp/odbc/src/utility.cpp
new file mode 100644
index 0000000..6f4ac22
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/utility.cpp
@@ -0,0 +1,105 @@
+/*
+ * 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_utils.h>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+namespace ignite
+{
+ namespace utility
+ {
+ size_t CopyStringToBuffer(const std::string& str, char* buf, size_t buflen)
+ {
+ if (!buf || !buflen)
+ return 0;
+
+ size_t bytesToCopy = std::min(str.size(), static_cast<size_t>(buflen - 1));
+
+ memcpy(buf, str.data(), bytesToCopy);
+ buf[bytesToCopy] = 0;
+
+ return bytesToCopy;
+ }
+
+ void ReadString(ignite::impl::binary::BinaryReaderImpl& reader, std::string& str)
+ {
+ int32_t strLen = reader.ReadString(0, 0);
+ if (!strLen)
+ {
+ str.clear();
+
+ char dummy;
+
+ reader.ReadString(&dummy, sizeof(dummy));
+ }
+ else
+ {
+ str.resize(strLen);
+
+ reader.ReadString(&str[0], static_cast<int32_t>(str.size()));
+ }
+ }
+
+ void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string & str)
+ {
+ writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
+ }
+
+ void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal& decimal)
+ {
+ int8_t hdr = reader.ReadInt8();
+
+ assert(hdr == ignite::impl::binary::IGNITE_TYPE_DECIMAL);
+
+ int32_t scale = reader.ReadInt32();
+
+ int32_t len = reader.ReadInt32();
+
+ std::vector<int8_t> mag;
+
+ mag.resize(len);
+
+ impl::binary::BinaryUtils::ReadInt8Array(reader.GetStream(), mag.data(), static_cast<int32_t>(mag.size()));
+
+ Decimal res(scale, mag.data(), static_cast<int32_t>(mag.size()));
+
+ swap(decimal, res);
+ }
+
+ std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen)
+ {
+ std::string res;
+
+ const char* sqlStrC = reinterpret_cast<const char*>(sqlStr);
+
+ if (!sqlStr || !sqlStrLen)
+ return res;
+
+ if (sqlStrLen == SQL_NTS)
+ res.assign(sqlStrC);
+ else
+ res.assign(sqlStrC, sqlStrLen);
+
+ return res;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/project/vs/ignite.sln
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/project/vs/ignite.sln b/modules/platforms/cpp/project/vs/ignite.sln
index 06a27cb..6d0b6da 100644
--- a/modules/platforms/cpp/project/vs/ignite.sln
+++ b/modules/platforms/cpp/project/vs/ignite.sln
@@ -20,6 +20,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ignite", "..\..\ignite\proj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "binary", "..\..\binary\project\vs\binary.vcxproj", "{4F15669B-92EB-49F0-B774-8F19BAE0B960}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc", "..\..\odbc\project\vs\odbc.vcxproj", "{12F77E12-38FE-42D3-B1DA-7E5979362961}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc-test", "..\..\odbc-test\project\vs\odbc-test.vcxproj", "{309BEA40-495D-463F-98D5-4657F03F6D8F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -68,6 +72,22 @@ Global
{4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|Win32.Build.0 = Release|Win32
{4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|x64.ActiveCfg = Release|x64
{4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|x64.Build.0 = Release|x64
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|Win32.ActiveCfg = Debug|Win32
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|Win32.Build.0 = Debug|Win32
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|x64.ActiveCfg = Debug|x64
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|x64.Build.0 = Debug|x64
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|Win32.ActiveCfg = Release|Win32
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|Win32.Build.0 = Release|Win32
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|x64.ActiveCfg = Release|x64
+ {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|x64.Build.0 = Release|x64
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|Win32.Build.0 = Debug|Win32
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|x64.ActiveCfg = Debug|x64
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|x64.Build.0 = Debug|x64
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|Win32.ActiveCfg = Release|Win32
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|Win32.Build.0 = Release|Win32
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|x64.ActiveCfg = Release|x64
+ {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
[20/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/socket_client.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/socket_client.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/socket_client.h
deleted file mode 100644
index 8a59e15..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/socket_client.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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_SOCKET_CLIENT
-#define _IGNITE_ODBC_DRIVER_SOCKET_CLIENT
-
-#include <stdint.h>
-
-#include "ignite/common/common.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace tcp
- {
- /**
- * Socket client implementation.
- */
- class SocketClient
- {
- public:
- /**
- * Constructor.
- */
- SocketClient();
-
- /**
- * Destructor.
- */
- ~SocketClient();
-
- /**
- * Establish connection with remote TCP service.
- *
- * @param hostname Remote host name.
- * @param port TCP service port.
- * @return True on success.
- */
- bool Connect(const char* hostname, uint16_t port);
-
- /**
- * Close established connection.
- *
- * @return True on success.
- */
- void Close();
-
- /**
- * Send data by established connection.
- *
- * @param data Pointer to data to be sent.
- * @param size Size of the data in bytes.
- * @return Number of bytes that have been sent on success and negative
- * value on failure.
- */
- int Send(const int8_t* data, size_t size);
-
- /**
- * Receive data from established connection.
- *
- * @param data Pointer to data buffer.
- * @param size Size of the buffer in bytes.
- * @return Number of bytes that have been received on success and negative
- * value on failure.
- */
- int Receive(int8_t* buffer, size_t size);
-
- private:
- intptr_t socketHandle;
-
- IGNITE_NO_COPY_ASSIGNMENT(SocketClient)
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index 230a4ec..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/type_traits.h
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * 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_TRAITS
-#define _IGNITE_ODBC_DRIVER_TYPE_TRAITS
-
-#include <stdint.h>
-
-#include <string>
-
-namespace ignite
-{
- namespace odbc
- {
- namespace type_traits
- {
-#ifdef ODBC_DEBUG
- /**
- * Convert statement attribute ID to string containing its name.
- * Debug function.
- * @param type Attribute ID.
- * @return Null-terminated string containing attribute name.
- */
- const char* StatementAttrIdToString(long id);
-#endif
-
- /**
- * ODBC type aliases.
- * We use these so we will not be needed to include system-specific
- * headers in our header files.
- */
- enum IgniteSqlType
- {
- /** Alias for the SQL_C_CHAR type. */
- IGNITE_ODBC_C_TYPE_CHAR,
-
- /** Alias for the SQL_C_WCHAR type. */
- IGNITE_ODBC_C_TYPE_WCHAR,
-
- /** Alias for the SQL_C_SSHORT type. */
- IGNITE_ODBC_C_TYPE_SIGNED_SHORT,
-
- /** Alias for the SQL_C_USHORT type. */
- IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT,
-
- /** Alias for the SQL_C_SLONG type. */
- IGNITE_ODBC_C_TYPE_SIGNED_LONG,
-
- /** Alias for the SQL_C_ULONG type. */
- IGNITE_ODBC_C_TYPE_UNSIGNED_LONG,
-
- /** Alias for the SQL_C_FLOAT type. */
- IGNITE_ODBC_C_TYPE_FLOAT,
-
- /** Alias for the SQL_C_DOUBLE type. */
- IGNITE_ODBC_C_TYPE_DOUBLE,
-
- /** Alias for the SQL_C_BIT type. */
- IGNITE_ODBC_C_TYPE_BIT,
-
- /** Alias for the SQL_C_STINYINT type. */
- IGNITE_ODBC_C_TYPE_SIGNED_TINYINT,
-
- /** Alias for the SQL_C_UTINYINT type. */
- IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT,
-
- /** Alias for the SQL_C_SBIGINT type. */
- IGNITE_ODBC_C_TYPE_SIGNED_BIGINT,
-
- /** Alias for the SQL_C_UBIGINT type. */
- IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT,
-
- /** Alias for the SQL_C_BINARY type. */
- IGNITE_ODBC_C_TYPE_BINARY,
-
- /** Alias for the SQL_C_TDATE type. */
- IGNITE_ODBC_C_TYPE_TDATE,
-
- /** Alias for the SQL_C_TTIME type. */
- IGNITE_ODBC_C_TYPE_TTIME,
-
- /** Alias for the SQL_C_TTIMESTAMP type. */
- IGNITE_ODBC_C_TYPE_TTIMESTAMP,
-
- /** Alias for the SQL_C_NUMERIC type. */
- IGNITE_ODBC_C_TYPE_NUMERIC,
-
- /** Alias for the SQL_C_GUID type. */
- IGNITE_ODBC_C_TYPE_GUID,
-
- /** Alias for the SQL_DEFAULT. */
- IGNITE_ODBC_C_TYPE_DEFAULT,
-
- /** Alias for all unsupported types. */
- IGNITE_ODBC_C_TYPE_UNSUPPORTED
- };
-
- /**
- * SQL type name constants.
- */
- class SqlTypeName
- {
- public:
- /** VARCHAR SQL type name constant. */
- static const std::string VARCHAR;
-
- /** SMALLINT SQL type name constant. */
- static const std::string SMALLINT;
-
- /** INTEGER SQL type name constant. */
- static const std::string INTEGER;
-
- /** DECIMAL SQL type name constant. */
- static const std::string DECIMAL;
-
- /** FLOAT SQL type name constant. */
- static const std::string FLOAT;
-
- /** DOUBLE SQL type name constant. */
- static const std::string DOUBLE;
-
- /** BIT SQL type name constant. */
- static const std::string BIT;
-
- /** TINYINT SQL type name constant. */
- static const std::string TINYINT;
-
- /** BIGINT SQL type name constant. */
- static const std::string BIGINT;
-
- /** BINARY SQL type name constant. */
- static const std::string BINARY;
-
- /** DATE SQL type name constant. */
- static const std::string DATE;
-
- /** GUID SQL type name constant. */
- static const std::string GUID;
- };
-
- /**
- * Get SQL type name for the binary type.
- *
- * @param binaryType Binary type.
- * @return Corresponding SQL type name.
- */
- const std::string& BinaryTypeToSqlTypeName(int8_t binaryType);
-
- /**
- * Check if the C type supported by the current implementation.
- *
- * @param type Application type.
- * @return True if the type is supported.
- */
- bool IsApplicationTypeSupported(int16_t type);
-
- /**
- * Check if the SQL type supported by the current implementation.
- *
- * @param type Application type.
- * @return True if the type is supported.
- */
- 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;
- * @return Internal driver type.
- */
- IgniteSqlType ToDriverType(int16_t type);
-
- /**
- * Convert binary data type to SQL data type.
- *
- * @param binaryType Binary data type.
- * @return SQL data type.
- */
- int16_t BinaryToSqlType(int8_t binaryType);
-
- /**
- * Get binary type SQL nullability.
- *
- * @param binaryType Binary data type.
- * @return SQL_NO_NULLS if the column could not include NULL values.
- * SQL_NULLABLE if the column accepts NULL values.
- * SQL_NULLABLE_UNKNOWN if it is not known whether the
- * column accepts NULL values.
- */
- int16_t BinaryTypeNullability(int8_t binaryType);
-
- /**
- * Get SQL type display size.
- *
- * @param type SQL type.
- * @return Display size.
- */
- int32_t SqlTypeDisplaySize(int16_t type);
-
- /**
- * Get binary type display size.
- *
- * @param type Binary type.
- * @return Display size.
- */
- int32_t BinaryTypeDisplaySize(int8_t type);
-
- /**
- * Get SQL type column size.
- *
- * @param type SQL type.
- * @return Column size.
- */
- int32_t SqlTypeColumnSize(int16_t type);
-
- /**
- * Get binary type column size.
- *
- * @param type Binary type.
- * @return Column size.
- */
- int32_t BinaryTypeColumnSize(int8_t type);
-
- /**
- * Get SQL type transfer octet length.
- *
- * @param type SQL type.
- * @return Transfer octet length.
- */
- int32_t SqlTypeTransferLength(int16_t type);
-
- /**
- * Get binary type transfer octet length.
- *
- * @param type Binary type.
- * @return Transfer octet length.
- */
- int32_t BinaryTypeTransferLength(int8_t type);
-
- /**
- * Get SQL type numeric precision radix.
- *
- * @param type SQL type.
- * @return Numeric precision radix.
- */
- int32_t SqlTypeNumPrecRadix(int8_t type);
-
- /**
- * Get binary type numeric precision radix.
- *
- * @param type Binary type.
- * @return Numeric precision radix.
- */
- int32_t BinaryTypeNumPrecRadix(int8_t type);
-
- /**
- * Get SQL type decimal digits.
- *
- * @param type SQL type.
- * @return Decimal digits.
- */
- int32_t SqlTypeDecimalDigits(int16_t type);
-
- /**
- * Get binary type decimal digits.
- *
- * @param type Binary type.
- * @return Decimal digits.
- */
- int32_t BinaryTypeDecimalDigits(int8_t type);
-
- /**
- * Checks if the SQL type is unsigned.
- *
- * @param type SQL type.
- * @return True if unsigned or non-numeric.
- */
- bool SqlTypeUnsigned(int16_t type);
-
- /**
- * Checks if the binary type is unsigned.
- *
- * @param type Binary type.
- * @return True if unsigned or non-numeric.
- */
- bool BinaryTypeUnsigned(int8_t type);
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
deleted file mode 100644
index 4a2e928..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/utility.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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_UTILITY
-#define _IGNITE_ODBC_DRIVER_UTILITY
-
-#include <string>
-#include <stdint.h>
-
-#ifdef min
-# undef min
-#endif //min
-
-#include <algorithm>
-
-#include <ignite/common/utils.h>
-
-#include "ignite/impl/binary/binary_reader_impl.h"
-#include "ignite/impl/binary/binary_writer_impl.h"
-
-#include "ignite/odbc/decimal.h"
-
-#ifdef ODBC_DEBUG
-
-extern FILE* log_file;
-void logInit(const char*);
-
-# define LOG_MSG(fmt, ...) \
- do { \
- logInit(ODBC_LOG_PATH); \
- fprintf(log_file, "%s: " fmt, __FUNCTION__, __VA_ARGS__); \
- fflush(log_file); \
- } while (false)
-
-#else
-# define LOG_MSG(...)
-#endif
-
-namespace ignite
-{
- namespace utility
- {
- /** Using common version of the util. */
- using ignite::common::utils::IntoLower;
-
- /**
- * Skip leading spaces.
- *
- * @param begin Iterator to the beginning of the character sequence.
- * @param end Iterator to the end of the character sequence.
- * @return Iterator to first non-blanc character.
- */
- template<typename Iterator>
- Iterator SkipLeadingSpaces(Iterator begin, Iterator end)
- {
- Iterator res = begin;
-
- while (isspace(*res) && res != end)
- ++res;
-
- return res;
- }
-
- /**
- * Skip trailing spaces.
- *
- * @param begin Iterator to the beginning of the character sequence.
- * @param end Iterator to the end of the character sequence.
- * @return Iterator to last non-blanc character.
- */
- template<typename Iterator>
- Iterator SkipTrailingSpaces(Iterator begin, Iterator end)
- {
- Iterator res = end - 1;
-
- while (isspace(*res) && res != begin - 1)
- --res;
-
- return res + 1;
- }
-
- /**
- * Remove leading and trailing spaces.
- *
- * @param begin Iterator to the beginning of the character sequence.
- * @param end Iterator to the end of the character sequence.
- * @return String without leading and trailing spaces.
- */
- template<typename Iterator>
- std::string RemoveSurroundingSpaces(Iterator begin, Iterator end)
- {
- std::string res;
-
- if (begin >= end)
- return res;
-
- Iterator skipped_leading = SkipLeadingSpaces(begin, end);
- Iterator skipped_trailing = SkipTrailingSpaces(skipped_leading, end);
-
- res.reserve(skipped_trailing - skipped_leading);
-
- std::copy(skipped_leading, skipped_trailing, std::back_insert_iterator<std::string>(res));
-
- return res;
- }
-
- template<typename T>
- T* GetPointerWithOffset(T* ptr, size_t offset)
- {
- uint8_t* ptrBytes = (uint8_t*)ptr;
-
- return (T*)(ptrBytes + offset);
- }
-
- /**
- * Copy string to buffer of the specific length.
- * @param str String to copy data from.
- * @param buf Buffer to copy data to.
- * @param buflen Length of the buffer.
- * @return Length of the resulting string in buffer.
- */
- size_t CopyStringToBuffer(const std::string& str, char* buf, size_t buflen);
-
- /**
- * Read string from reader.
- * @param reader Reader.
- * @param str String.
- */
- void ReadString(ignite::impl::binary::BinaryReaderImpl& reader, std::string& str);
-
- /**
- * Write string using writer.
- * @param writer Writer.
- * @param str String.
- */
- void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string& str);
-
- /**
- * Read decimal value using reader.
- *
- * @param reader Reader.
- * @param decimal Decimal value.
- */
- void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal& decimal);
-
- /**
- * Convert SQL string buffer to std::string.
- *
- * @param sqlStr SQL string buffer.
- * @param sqlStrLen SQL string length.
- * @return Standard string containing the same data.
- */
- std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen);
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/os/linux/src/system/socket_client.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/os/linux/src/system/socket_client.cpp b/modules/platforms/cpp/odbc/odbc-driver/os/linux/src/system/socket_client.cpp
deleted file mode 100644
index a355625..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/os/linux/src/system/socket_client.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 <sys/socket.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <cstring>
-
-#include <sstream>
-
-#include "ignite/odbc/system/socket_client.h"
-#include "ignite/odbc/utility.h"
-
-#define SOCKET_ERROR (-1)
-
-namespace ignite
-{
- namespace odbc
- {
- namespace tcp
- {
-
- SocketClient::SocketClient() : socketHandle(SOCKET_ERROR)
- {
- // No-op.
- }
-
- SocketClient::~SocketClient()
- {
- Close();
- }
-
- bool SocketClient::Connect(const char* hostname, uint16_t port)
- {
- LOG_MSG("Host: %s, port: %d\n", hostname, port);
-
- addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
-
- std::stringstream converter;
- converter << port;
-
- // Resolve the server address and port
- addrinfo *result = NULL;
- int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result);
-
- if (res != 0)
- return false;
-
- // Attempt to connect to an address until one succeeds
- for (addrinfo *it = result; it != NULL; it = it->ai_next)
- {
- LOG_MSG("Addr: %u.%u.%u.%u\n", it->ai_addr->sa_data[2], it->ai_addr->sa_data[3],
- it->ai_addr->sa_data[4], it->ai_addr->sa_data[5]);
-
- // Create a SOCKET for connecting to server
- socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
-
- if (socketHandle == SOCKET_ERROR)
- return false;
-
- // Connect to server.
- res = connect(socketHandle, it->ai_addr, (int)it->ai_addrlen);
- if (res == SOCKET_ERROR)
- {
- Close();
-
- continue;
- }
- break;
- }
-
- freeaddrinfo(result);
-
- return socketHandle != SOCKET_ERROR;
- }
-
- void SocketClient::Close()
- {
- if (socketHandle != SOCKET_ERROR)
- {
- close(socketHandle);
-
- socketHandle = SOCKET_ERROR;
- }
- }
-
- int SocketClient::Send(const int8_t* data, size_t size)
- {
- return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0);
- }
-
- int SocketClient::Receive(int8_t* buffer, size_t size)
- {
- return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0);
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/os/win/src/system/socket_client.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/os/win/src/system/socket_client.cpp b/modules/platforms/cpp/odbc/odbc-driver/os/win/src/system/socket_client.cpp
deleted file mode 100644
index bc4cdc0..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/os/win/src/system/socket_client.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.
- */
-
-#define WIN32_LEAN_AND_MEAN
-#define _WINSOCKAPI_
-
-#include <windows.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
-
-#include <cstring>
-
-#include <sstream>
-
-#include "ignite/odbc/system/socket_client.h"
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace tcp
- {
-
- SocketClient::SocketClient() : socketHandle(INVALID_SOCKET)
- {
- // No-op.
- }
-
- SocketClient::~SocketClient()
- {
- Close();
- }
-
- bool SocketClient::Connect(const char* hostname, uint16_t port)
- {
- static bool networkInited = false;
-
- // Initing networking if is not inited.
- if (!networkInited)
- {
- WSADATA wsaData;
-
- networkInited = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0);
-
- if (!networkInited)
- return false;
- }
-
- addrinfo *result = NULL;
- addrinfo hints;
-
- LOG_MSG("Host: %s, port: %d\n", hostname, port);
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
-
- std::stringstream converter;
- converter << port;
-
- // Resolve the server address and port
- int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result);
-
- if (res != 0)
- return false;
-
- // Attempt to connect to an address until one succeeds
- for (addrinfo *it = result; it != NULL; it = it->ai_next)
- {
- LOG_MSG("Addr: %u.%u.%u.%u\n", it->ai_addr->sa_data[2], it->ai_addr->sa_data[3],
- it->ai_addr->sa_data[4], it->ai_addr->sa_data[5]);
-
- // Create a SOCKET for connecting to server
- socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
-
- if (socketHandle == INVALID_SOCKET)
- return false;
-
- // Connect to server.
- res = connect(socketHandle, it->ai_addr, static_cast<int>(it->ai_addrlen));
- if (res == SOCKET_ERROR)
- {
- Close();
-
- continue;
- }
- break;
- }
-
- freeaddrinfo(result);
-
- return socketHandle != INVALID_SOCKET;
- }
-
- void SocketClient::Close()
- {
- if (socketHandle != INVALID_SOCKET)
- {
- closesocket(socketHandle);
-
- socketHandle = INVALID_SOCKET;
- }
- }
-
- int SocketClient::Send(const int8_t* data, size_t size)
- {
- return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0);
- }
-
- int SocketClient::Receive(int8_t* buffer, size_t size)
- {
- return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0);
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/project/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/README.TXT b/modules/platforms/cpp/odbc/odbc-driver/project/README.TXT
deleted file mode 100644
index 97f4c64..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/project/README.TXT
+++ /dev/null
@@ -1 +0,0 @@
-Contains IDE projects artifacts.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/project/vs/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/vs/README.TXT b/modules/platforms/cpp/odbc/odbc-driver/project/vs/README.TXT
deleted file mode 100644
index f4fb456..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/README.TXT
+++ /dev/null
@@ -1 +0,0 @@
-Contains Visual Studio project artifacts.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/vs/module.def b/modules/platforms/cpp/odbc/odbc-driver/project/vs/module.def
deleted file mode 100644
index 10e1461..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/module.def
+++ /dev/null
@@ -1,69 +0,0 @@
-
-LIBRARY odbc-driver
-EXPORTS
- ConfigDSN
- SQLAllocConnect
- SQLAllocEnv
- SQLAllocStmt
- SQLAllocHandle
- SQLFreeConnect
- SQLFreeEnv
- SQLFreeStmt
- SQLBindCol
- SQLCancel
- SQLConnect
- SQLDescribeCol
- SQLDisconnect
- SQLError
- SQLExecDirect
- SQLExecute
- SQLExtendedFetch
- SQLFetch
- SQLGetCursorName
- SQLNumResultCols
- SQLPrepare
- SQLRowCount
- SQLSetCursorName
- SQLColumns
- SQLDriverConnect
- SQLGetData
- SQLGetInfo
- SQLGetTypeInfo
- SQLParamData
- SQLPutData
- SQLStatistics
- SQLTables
- SQLBrowseConnect
- SQLColumnPrivileges
- SQLDescribeParam
- SQLForeignKeys
- SQLMoreResults
- SQLNativeSql
- SQLNumParams
- SQLPrimaryKeys
- SQLProcedureColumns
- SQLProcedures
- SQLSetPos
- SQLTablePrivileges
- SQLBindParameter
- SQLCloseCursor
- SQLColAttribute
- SQLCopyDesc
- SQLEndTran
- SQLFetchScroll
- SQLFreeHandle
- SQLGetConnectAttr
- SQLGetDescField
- SQLGetDescRec
- SQLGetDiagField
- SQLGetDiagRec
- SQLGetEnvAttr
- SQLGetStmtAttr
- SQLSetConnectAttr
- SQLSetDescField
- SQLSetDescRec
- SQLSetEnvAttr
- SQLSetStmtAttr
- SQLBulkOperations
- SQLSpecialColumns
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index b327ffd..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
+++ /dev/null
@@ -1,233 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{12F77E12-38FE-42D3-B1DA-7E5979362961}</ProjectGuid>
- <RootNamespace>odbcdriver</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
- <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
- <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
- <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
- <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\os\win\src\system\socket_client.cpp" />
- <ClCompile Include="..\..\src\app\application_data_buffer.cpp" />
- <ClCompile Include="..\..\src\app\parameter.cpp" />
- <ClCompile Include="..\..\src\column.cpp" />
- <ClCompile Include="..\..\src\common_types.cpp" />
- <ClCompile Include="..\..\src\config\configuration.cpp" />
- <ClCompile Include="..\..\src\config\connection_info.cpp" />
- <ClCompile Include="..\..\src\connection.cpp" />
- <ClCompile Include="..\..\src\cursor.cpp" />
- <ClCompile Include="..\..\src\decimal.cpp" />
- <ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp" />
- <ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp" />
- <ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp" />
- <ClCompile Include="..\..\src\environment.cpp" />
- <ClCompile Include="..\..\src\meta\column_meta.cpp" />
- <ClCompile Include="..\..\src\meta\table_meta.cpp" />
- <ClCompile Include="..\..\src\odbc.cpp" />
- <ClCompile Include="..\..\src\query\data_query.cpp" />
- <ClCompile Include="..\..\src\query\column_metadata_query.cpp" />
- <ClCompile Include="..\..\src\query\foreign_keys_query.cpp" />
- <ClCompile Include="..\..\src\query\primary_keys_query.cpp" />
- <ClCompile Include="..\..\src\query\special_columns_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" />
- <ClCompile Include="..\..\src\type_traits.cpp" />
- <ClCompile Include="..\..\src\utility.cpp" />
- </ItemGroup>
- <ItemGroup>
- <None Include="module.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\include\ignite\odbc\app\application_data_buffer.h" />
- <ClInclude Include="..\..\include\ignite\odbc\app\parameter.h" />
- <ClInclude Include="..\..\include\ignite\odbc\column.h" />
- <ClInclude Include="..\..\include\ignite\odbc\common_types.h" />
- <ClInclude Include="..\..\include\ignite\odbc\config\configuration.h" />
- <ClInclude Include="..\..\include\ignite\odbc\config\connection_info.h" />
- <ClInclude Include="..\..\include\ignite\odbc\connection.h" />
- <ClInclude Include="..\..\include\ignite\odbc\cursor.h" />
- <ClInclude Include="..\..\include\ignite\odbc\decimal.h" />
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable.h" />
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h" />
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h" />
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h" />
- <ClInclude Include="..\..\include\ignite\odbc\environment.h" />
- <ClInclude Include="..\..\include\ignite\odbc\message.h" />
- <ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h" />
- <ClInclude Include="..\..\include\ignite\odbc\meta\primary_key_meta.h" />
- <ClInclude Include="..\..\include\ignite\odbc\meta\table_meta.h" />
- <ClInclude Include="..\..\include\ignite\odbc\parser.h" />
- <ClInclude Include="..\..\include\ignite\odbc\query\data_query.h" />
- <ClInclude Include="..\..\include\ignite\odbc\query\column_metadata_query.h" />
- <ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h" />
- <ClInclude Include="..\..\include\ignite\odbc\query\primary_keys_query.h" />
- <ClInclude Include="..\..\include\ignite\odbc\query\query.h" />
- <ClInclude Include="..\..\include\ignite\odbc\query\special_columns_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" />
- <ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h" />
- <ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h" />
- <ClInclude Include="..\..\include\ignite\odbc\type_traits.h" />
- <ClInclude Include="..\..\include\ignite\odbc\utility.h" />
- <ClInclude Include="result_page.h" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\..\binary\project\vs\binary.vcxproj">
- <Project>{4f15669b-92eb-49f0-b774-8f19bae0b960}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\..\common\project\vs\common.vcxproj">
- <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index d47684a..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
+++ /dev/null
@@ -1,229 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Code">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Misc">
- <UniqueIdentifier>{3f714d15-6347-46a7-bc59-d87c1aea900c}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\query">
- <UniqueIdentifier>{b09a6b2e-c30c-4727-8e85-4b315e757706}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\meta">
- <UniqueIdentifier>{71d6243f-e8c9-4f21-a5a3-3dc89641af28}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\config">
- <UniqueIdentifier>{71117941-fa47-4768-afe8-901c94d431c7}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\app">
- <UniqueIdentifier>{dbe40149-df23-4b89-92e4-16817775cd0e}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\system">
- <UniqueIdentifier>{7ab279dc-6586-4b32-aca7-0add0c0ab68a}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\diagnostic">
- <UniqueIdentifier>{df33e506-b5d8-423f-bcc5-1825242a3e28}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\odbc.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\connection.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\environment.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\statement.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\type_traits.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\common_types.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\utility.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\cursor.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\result_page.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\row.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\data_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\column_metadata_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\table_metadata_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\meta\column_meta.cpp">
- <Filter>Code\meta</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\meta\table_meta.cpp">
- <Filter>Code\meta</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\config\configuration.cpp">
- <Filter>Code\config</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\config\connection_info.cpp">
- <Filter>Code\config</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\app\application_data_buffer.cpp">
- <Filter>Code\app</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\app\parameter.cpp">
- <Filter>Code\app</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\foreign_keys_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\primary_keys_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp">
- <Filter>Code\diagnostic</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp">
- <Filter>Code\diagnostic</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp">
- <Filter>Code\diagnostic</Filter>
- </ClCompile>
- <ClCompile Include="..\..\os\win\src\system\socket_client.cpp">
- <Filter>Code\system</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\decimal.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\type_info_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\column.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\query\special_columns_query.cpp">
- <Filter>Code\query</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="module.def">
- <Filter>Misc</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="result_page.h" />
- <ClInclude Include="..\..\include\ignite\odbc\common_types.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\connection.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\cursor.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\environment.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\message.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\parser.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\result_page.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\row.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\statement.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\type_traits.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\utility.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\query.h">
- <Filter>Code\query</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\data_query.h">
- <Filter>Code\query</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\column_metadata_query.h">
- <Filter>Code\query</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\table_metadata_query.h">
- <Filter>Code\query</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h">
- <Filter>Code\meta</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\meta\table_meta.h">
- <Filter>Code\meta</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\config\configuration.h">
- <Filter>Code\config</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\config\connection_info.h">
- <Filter>Code\config</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\app\application_data_buffer.h">
- <Filter>Code\app</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\app\parameter.h">
- <Filter>Code\app</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h">
- <Filter>Code\query</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\primary_keys_query.h">
- <Filter>Code\query</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\meta\primary_key_meta.h">
- <Filter>Code\meta</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h">
- <Filter>Code\diagnostic</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h">
- <Filter>Code\diagnostic</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable.h">
- <Filter>Code\diagnostic</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h">
- <Filter>Code\diagnostic</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h">
- <Filter>Code\system</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h">
- <Filter>Code\system</Filter>
- </ClInclude>
- <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>
- <ClInclude Include="..\..\include\ignite\odbc\column.h">
- <Filter>Code</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\odbc\query\special_columns_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/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
deleted file mode 100644
index e10011b..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * 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 <algorithm>
-#include <string>
-#include <sstream>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/app/application_data_buffer.h"
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace app
- {
- ApplicationDataBuffer::ApplicationDataBuffer() :
- type(type_traits::IGNITE_ODBC_C_TYPE_UNSUPPORTED), buffer(0), buflen(0), reslen(0), offset(0)
- {
- // No-op.
- }
-
- ApplicationDataBuffer::ApplicationDataBuffer(type_traits::IgniteSqlType type,
- void* buffer, SqlLen buflen, SqlLen* reslen, size_t** offset) :
- type(type), buffer(buffer), buflen(buflen), reslen(reslen), offset(offset)
- {
- // No-op.
- }
-
- ApplicationDataBuffer::ApplicationDataBuffer(const ApplicationDataBuffer & other) :
- type(other.type), buffer(other.buffer), buflen(other.buflen), reslen(other.reslen), offset(other.offset)
- {
- // No-op.
- }
-
- ApplicationDataBuffer::~ApplicationDataBuffer()
- {
- // No-op.
- }
-
- ApplicationDataBuffer & ApplicationDataBuffer::operator=(const ApplicationDataBuffer & other)
- {
- type = other.type;
- buffer = other.buffer;
- buflen = other.buflen;
- reslen = other.reslen;
- offset = other.offset;
-
- return *this;
- }
-
- template<typename T>
- void ApplicationDataBuffer::PutNum(T value)
- {
- using namespace type_traits;
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
- {
- PutNumToNumBuffer<signed char>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_BIT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
- {
- PutNumToNumBuffer<unsigned char>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
- {
- PutNumToNumBuffer<short>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
- {
- PutNumToNumBuffer<unsigned short>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
- {
- PutNumToNumBuffer<long>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
- {
- PutNumToNumBuffer<unsigned long>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
- {
- PutNumToNumBuffer<int64_t>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
- {
- PutNumToNumBuffer<uint64_t>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_FLOAT:
- {
- PutNumToNumBuffer<float>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_DOUBLE:
- {
- PutNumToNumBuffer<double>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_CHAR:
- {
- PutValToStrBuffer<char>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_WCHAR:
- {
- PutValToStrBuffer<wchar_t>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_NUMERIC:
- {
- if (GetData())
- {
- SQL_NUMERIC_STRUCT* out =
- reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());
-
- out->precision = 0;
- out->scale = 0;
- out->sign = value > 0 ? 1 : 0;
-
- memset(out->val, 0, SQL_MAX_NUMERIC_LEN);
-
- // TODO: implement propper conversation to numeric type.
- int64_t intVal = static_cast<int64_t>(std::abs(value));
-
- memcpy(out->val, &intVal, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(intVal)));
- }
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_BINARY:
- case IGNITE_ODBC_C_TYPE_DEFAULT:
- {
- if (GetData())
- {
- if (buflen >= sizeof(value))
- {
- memcpy(GetData(), &value, sizeof(value));
-
- if (GetResLen())
- *GetResLen() = sizeof(value);
- }
- else
- {
- memcpy(GetData(), &value, static_cast<size_t>(buflen));
-
- if (GetResLen())
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
- else if (GetResLen())
- {
- *GetResLen() = sizeof(value);
- }
- break;
- }
-
- default:
- {
- if (GetResLen())
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
- }
-
- template<typename Tbuf, typename Tin>
- void ApplicationDataBuffer::PutNumToNumBuffer(Tin value)
- {
- if (GetData())
- {
- Tbuf* out = reinterpret_cast<Tbuf*>(GetData());
- *out = static_cast<Tbuf>(value);
- }
- }
-
- template<typename CharT, typename Tin>
- void ApplicationDataBuffer::PutValToStrBuffer(const Tin & value)
- {
- typedef std::basic_stringstream<CharT> ConverterType;
-
- ConverterType converter;
-
- converter << value;
-
- PutStrToStrBuffer<CharT>(converter.str());
- }
-
- template<typename CharT>
- void ApplicationDataBuffer::PutValToStrBuffer(const int8_t & value)
- {
- typedef std::basic_stringstream<CharT> ConverterType;
-
- ConverterType converter;
-
- converter << static_cast<int>(value);
-
- PutStrToStrBuffer<CharT>(converter.str());
- }
-
- template<typename OutCharT, typename InCharT>
- void ApplicationDataBuffer::PutStrToStrBuffer(const std::basic_string<InCharT>& value)
- {
- SqlLen charSize = static_cast<SqlLen>(sizeof(OutCharT));
-
- if (GetData())
- {
- if (buflen >= charSize)
- {
- OutCharT* out = reinterpret_cast<OutCharT*>(GetData());
-
- SqlLen outLen = (buflen / charSize) - 1;
-
- SqlLen toCopy = std::min<size_t>(outLen, value.size());
-
- for (SqlLen i = 0; i < toCopy; ++i)
- out[i] = value[i];
-
- out[toCopy] = 0;
- }
-
- if (GetResLen())
- {
- if (buflen >= static_cast<SqlLen>((value.size() + 1) * charSize))
- *GetResLen() = static_cast<SqlLen>(value.size());
- else
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
- else if (GetResLen())
- *GetResLen() = value.size();
- }
-
- void ApplicationDataBuffer::PutRawDataToBuffer(void *data, size_t len)
- {
- SqlLen ilen = static_cast<SqlLen>(len);
-
- if (GetData())
- {
- size_t toCopy = static_cast<size_t>(std::min(buflen, ilen));
-
- memcpy(GetData(), data, toCopy);
-
- if (GetResLen())
- {
- if (buflen >= ilen)
- *GetResLen() = ilen;
- else
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
- else if (GetResLen())
- *GetResLen() = ilen;
- }
-
- void ApplicationDataBuffer::PutInt8(int8_t value)
- {
- PutNum(value);
- }
-
- void ApplicationDataBuffer::PutInt16(int16_t value)
- {
- PutNum(value);
- }
-
- void ApplicationDataBuffer::PutInt32(int32_t value)
- {
- PutNum(value);
- }
-
- void ApplicationDataBuffer::PutInt64(int64_t value)
- {
- PutNum(value);
- }
-
- void ApplicationDataBuffer::PutFloat(float value)
- {
- PutNum(value);
- }
-
- void ApplicationDataBuffer::PutDouble(double value)
- {
- PutNum(value);
- }
-
- int32_t ApplicationDataBuffer::PutString(const std::string & value)
- {
- using namespace type_traits;
-
- int32_t used = 0;
-
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
- case IGNITE_ODBC_C_TYPE_BIT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
- case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
- case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
- case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
- case IGNITE_ODBC_C_TYPE_NUMERIC:
- {
- std::stringstream converter(value);
-
- int64_t numValue;
-
- converter >> numValue;
-
- PutNum(numValue);
-
- used = static_cast<int32_t>(value.size());
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_FLOAT:
- case IGNITE_ODBC_C_TYPE_DOUBLE:
- {
- std::stringstream converter(value);
-
- double numValue;
-
- converter >> numValue;
-
- PutNum(numValue);
-
- used = static_cast<int32_t>(value.size());
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_CHAR:
- case IGNITE_ODBC_C_TYPE_BINARY:
- case IGNITE_ODBC_C_TYPE_DEFAULT:
- {
- PutStrToStrBuffer<char>(value);
-
- used = static_cast<int32_t>(GetSize()) - 1;
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_WCHAR:
- {
- PutStrToStrBuffer<wchar_t>(value);
-
- used = (static_cast<int32_t>(GetSize()) / 2) - 1;
-
- break;
- }
-
- default:
- {
- if (GetResLen())
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
-
- return used < 0 ? 0 : used;
- }
-
- void ApplicationDataBuffer::PutGuid(const Guid & value)
- {
- using namespace type_traits;
-
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_CHAR:
- case IGNITE_ODBC_C_TYPE_BINARY:
- case IGNITE_ODBC_C_TYPE_DEFAULT:
- {
- PutValToStrBuffer<char>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_WCHAR:
- {
- PutValToStrBuffer<wchar_t>(value);
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_GUID:
- {
- SQLGUID* guid = reinterpret_cast<SQLGUID*>(GetData());
-
- guid->Data1 = static_cast<uint32_t>(value.GetMostSignificantBits() >> 32);
- guid->Data2 = static_cast<uint16_t>(value.GetMostSignificantBits() >> 16);
- guid->Data3 = static_cast<uint16_t>(value.GetMostSignificantBits());
-
- uint64_t lsb = value.GetLeastSignificantBits();
- for (size_t i = 0; i < sizeof(guid->Data4); ++i)
- guid->Data4[i] = (lsb >> (sizeof(guid->Data4) - i - 1) * 8) & 0xFF;
-
- break;
- }
-
- default:
- {
- if (GetResLen())
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
- }
-
- int32_t ApplicationDataBuffer::PutBinaryData(void *data, size_t len)
- {
- using namespace type_traits;
-
- int32_t used = 0;
-
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_BINARY:
- case IGNITE_ODBC_C_TYPE_DEFAULT:
- {
- PutRawDataToBuffer(data, len);
-
- used = static_cast<int32_t>(GetSize());
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_CHAR:
- {
- std::stringstream converter;
-
- uint8_t *dataBytes = reinterpret_cast<uint8_t*>(data);
-
- for (size_t i = 0; i < len; ++i)
- {
- converter << std::hex
- << std::setfill('0')
- << std::setw(2)
- << static_cast<unsigned>(dataBytes[i]);
- }
-
- PutStrToStrBuffer<char>(converter.str());
-
- used = static_cast<int32_t>(GetSize()) - 1;
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_WCHAR:
- {
- std::wstringstream converter;
-
- uint8_t *dataBytes = reinterpret_cast<uint8_t*>(data);
-
- for (size_t i = 0; i < len; ++i)
- {
- converter << std::hex
- << std::setfill<wchar_t>('0')
- << std::setw(2)
- << static_cast<unsigned>(dataBytes[i]);
- }
-
- PutStrToStrBuffer<wchar_t>(converter.str());
-
- used = static_cast<int32_t>(GetSize() / 2) - 1;
-
- break;
- }
-
- default:
- {
- if (GetResLen())
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
-
- return used < 0 ? 0 : used;
- }
-
- void ApplicationDataBuffer::PutNull()
- {
- if (GetResLen())
- *GetResLen() = SQL_NULL_DATA;
- }
-
- void ApplicationDataBuffer::PutDecimal(const Decimal& value)
- {
- using namespace type_traits;
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
- case IGNITE_ODBC_C_TYPE_BIT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
- case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
- case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
- case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
- case IGNITE_ODBC_C_TYPE_FLOAT:
- case IGNITE_ODBC_C_TYPE_DOUBLE:
- case IGNITE_ODBC_C_TYPE_CHAR:
- case IGNITE_ODBC_C_TYPE_WCHAR:
- {
- PutNum<double>(static_cast<double>(value));
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_NUMERIC:
- {
- if (GetData())
- {
- SQL_NUMERIC_STRUCT* numeric =
- reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());
-
- numeric->sign = value.IsNegative() ? 1 : 0;
- numeric->precision = 0;
- numeric->scale = value.GetScale();
- memcpy(numeric->val, value.GetMagnitude(), std::min<size_t>(SQL_MAX_NUMERIC_LEN, value.GetLength()));
- }
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_DEFAULT:
- {
- if (GetData())
- memcpy(GetData(), &value, std::min(static_cast<size_t>(buflen), sizeof(value)));
-
- if (GetResLen())
- *GetResLen() = sizeof(value);
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_BINARY:
- default:
- {
- if (GetResLen())
- *GetResLen() = SQL_NO_TOTAL;
- }
- }
- }
-
- std::string ApplicationDataBuffer::GetString(size_t maxLen) const
- {
- using namespace type_traits;
- std::string res;
-
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_CHAR:
- {
- res.assign(reinterpret_cast<const char*>(GetData()),
- std::min(maxLen, static_cast<size_t>(buflen)));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
- case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
- case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
- case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
- {
- std::stringstream converter;
-
- converter << GetNum<int64_t>();
-
- res = converter.str();
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_BIT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
- {
- std::stringstream converter;
-
- converter << GetNum<uint64_t>();
-
- res = converter.str();
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_FLOAT:
- {
- std::stringstream converter;
-
- converter << GetNum<float>();
-
- res = converter.str();
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_NUMERIC:
- case IGNITE_ODBC_C_TYPE_DOUBLE:
- {
- std::stringstream converter;
-
- converter << GetNum<double>();
-
- res = converter.str();
-
- break;
- }
-
- default:
- break;
- }
-
- return res;
- }
-
- int8_t ApplicationDataBuffer::GetInt8() const
- {
- return GetNum<int8_t>();
- }
-
- int16_t ApplicationDataBuffer::GetInt16() const
- {
- return GetNum<int16_t>();
- }
-
- int32_t ApplicationDataBuffer::GetInt32() const
- {
- return GetNum<int32_t>();
- }
-
- int64_t ApplicationDataBuffer::GetInt64() const
- {
- return GetNum<int64_t>();
- }
-
- float ApplicationDataBuffer::GetFloat() const
- {
- return GetNum<float>();
- }
-
- double ApplicationDataBuffer::GetDouble() const
- {
- return GetNum<double>();
- }
-
- const void* ApplicationDataBuffer::GetData() const
- {
- return ApplyOffset(buffer);
- }
-
- const SqlLen* ApplicationDataBuffer::GetResLen() const
- {
- return ApplyOffset(reslen);
- }
-
- void* ApplicationDataBuffer::GetData()
- {
- return ApplyOffset(buffer);
- }
-
- SqlLen* ApplicationDataBuffer::GetResLen()
- {
- return ApplyOffset(reslen);
- }
-
- template<typename T>
- T ApplicationDataBuffer::GetNum() const
- {
- using namespace type_traits;
-
- T res = 0;
-
- switch (type)
- {
- case IGNITE_ODBC_C_TYPE_CHAR:
- {
- std::string str = GetString(static_cast<size_t>(buflen));
-
- std::stringstream converter(str);
-
- // Workaround for char types which are recognised as
- // symbolyc types and not numeric types.
- if (sizeof(T) == 1)
- {
- short tmp;
-
- converter >> tmp;
-
- res = static_cast<T>(tmp);
- }
- else
- converter >> res;
-
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
- {
- res = static_cast<T>(*reinterpret_cast<const signed char*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_BIT:
- case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
- {
- res = static_cast<T>(*reinterpret_cast<const unsigned char*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
- {
- res = static_cast<T>(*reinterpret_cast<const signed short*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
- {
- res = static_cast<T>(*reinterpret_cast<const unsigned short*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
- {
- res = static_cast<T>(*reinterpret_cast<const signed long*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
- {
- res = static_cast<T>(*reinterpret_cast<const unsigned long*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
- {
- res = static_cast<T>(*reinterpret_cast<const int64_t*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
- {
- res = static_cast<T>(*reinterpret_cast<const uint64_t*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_FLOAT:
- {
- res = static_cast<T>(*reinterpret_cast<const float*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_DOUBLE:
- {
- res = static_cast<T>(*reinterpret_cast<const double*>(GetData()));
- break;
- }
-
- case IGNITE_ODBC_C_TYPE_NUMERIC:
- {
- const SQL_NUMERIC_STRUCT* numeric =
- reinterpret_cast<const SQL_NUMERIC_STRUCT*>(GetData());
-
- int64_t resInt;
-
- // TODO: implement propper conversation from numeric type.
- memcpy(&resInt, numeric->val, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(resInt)));
-
- if (numeric->sign)
- resInt *= -1;
-
- double resDouble = static_cast<double>(resInt);
-
- for (SQLSCHAR scale = numeric->scale; scale > 0; --scale)
- resDouble /= 10.0;
-
- res = static_cast<T>(resDouble);
-
- break;
- }
-
- default:
- break;
- }
-
- return res;
- }
-
- template<typename T>
- T* ApplicationDataBuffer::ApplyOffset(T* ptr) const
- {
- if (!ptr || !offset || !*offset)
- return ptr;
-
- return utility::GetPointerWithOffset(ptr, **offset);
- }
- }
- }
-}
-
[19/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/app/parameter.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/app/parameter.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/app/parameter.cpp
deleted file mode 100644
index dbe33e1..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/app/parameter.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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 <algorithm>
-#include <string>
-#include <sstream>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/app/parameter.h"
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace app
- {
- Parameter::Parameter() :
- buffer(),
- sqlType(),
- columnSize(),
- decDigits()
- {
- // No-op.
- }
-
- Parameter::Parameter(const ApplicationDataBuffer& buffer, int16_t sqlType,
- size_t columnSize, int16_t decDigits) :
- buffer(buffer),
- sqlType(sqlType),
- columnSize(columnSize),
- decDigits(decDigits)
- {
- // No-op.
- }
-
- Parameter::Parameter(const Parameter & other) :
- buffer(other.buffer),
- sqlType(other.sqlType),
- columnSize(other.columnSize),
- decDigits(other.decDigits)
- {
- // No-op.
- }
-
- Parameter::~Parameter()
- {
- // No-op.
- }
-
- Parameter& Parameter::operator=(const Parameter &other)
- {
- buffer = other.buffer;
- sqlType = other.sqlType;
- columnSize = other.columnSize;
- decDigits = other.decDigits;
-
- return *this;
- }
-
- void Parameter::Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- switch (sqlType)
- {
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_LONGVARCHAR:
- {
- utility::WriteString(writer, buffer.GetString(columnSize));
- break;
- }
-
- case SQL_SMALLINT:
- {
- writer.WriteInt16(buffer.GetInt16());
- break;
- }
-
- case SQL_INTEGER:
- {
- writer.WriteInt32(buffer.GetInt32());
- break;
- }
-
- case SQL_FLOAT:
- {
- writer.WriteFloat(buffer.GetFloat());
- break;
- }
-
- case SQL_DOUBLE:
- {
- writer.WriteDouble(buffer.GetDouble());
- break;
- }
-
- case SQL_TINYINT:
- case SQL_BIT:
- {
- writer.WriteBool(buffer.GetInt8() != 0);
- break;
- }
-
- case SQL_BIGINT:
- {
- writer.WriteInt64(buffer.GetInt64());
- break;
- }
-
- case SQL_BINARY:
- case SQL_VARBINARY:
- case SQL_LONGVARBINARY:
- {
- writer.WriteInt8Array(reinterpret_cast<const int8_t*>(buffer.GetData()),
- static_cast<int32_t>(buffer.GetSize()));
- break;
- }
-
- case SQL_GUID:
- default:
- //TODO: Add GUID type support.
- break;
- }
- }
-
- ApplicationDataBuffer & Parameter::GetBuffer()
- {
- return buffer;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
deleted file mode 100644
index 7b2f1e9..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * 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 <ignite/impl/interop/interop_stream_position_guard.h>
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/column.h"
-
-namespace
-{
- using namespace ignite::impl::interop;
- using namespace ignite::impl::binary;
-
- bool GetObjectLength(InteropInputStream& stream, int32_t& len)
- {
- InteropStreamPositionGuard<InteropInputStream> guard(stream);
-
- int8_t hdr = stream.ReadInt8();
-
- if (hdr != IGNITE_HDR_FULL)
- return false;
-
- int8_t protoVer = stream.ReadInt8();
-
- if (protoVer != IGNITE_PROTO_VER)
- return false;
-
- // Skipping flags
- stream.ReadInt16();
-
- // Skipping typeId
- stream.ReadInt32();
-
- // Skipping hash code
- stream.ReadInt32();
-
- len = stream.ReadInt32();
-
- return true;
- }
-
- /**
- * Read column header and restores position if the column is of
- * complex type.
- * @return Column type header.
- */
- int8_t ReadColumnHeader(ignite::impl::interop::InteropInputStream& stream)
- {
- using namespace ignite::impl::binary;
-
- int32_t headerPos = stream.Position();
-
- int8_t hdr = stream.ReadInt8();
-
- // Check if we need to restore position - to read complex types
- // stream should have unread header, but for primitive types it
- // should not.
- switch (hdr)
- {
- case IGNITE_TYPE_BYTE:
- case IGNITE_TYPE_SHORT:
- case IGNITE_TYPE_CHAR:
- case IGNITE_TYPE_INT:
- case IGNITE_TYPE_LONG:
- case IGNITE_TYPE_FLOAT:
- case IGNITE_TYPE_DOUBLE:
- case IGNITE_TYPE_BOOL:
- case IGNITE_HDR_NULL:
- {
- // No-op.
- break;
- }
-
- default:
- {
- // Restoring position.
- stream.Position(headerPos);
- break;
- }
- }
-
- return hdr;
- }
-}
-
-namespace ignite
-{
- namespace odbc
- {
- Column::Column() :
- type(0), startPos(-1), endPos(-1), offset(0), size(0)
- {
- // No-op.
- }
-
- Column::Column(const Column& other) :
- type(other.type), startPos(other.startPos), endPos(other.endPos),
- offset(other.offset), size(other.size)
- {
- // No-op.
- }
-
- Column& Column::operator=(const Column& other)
- {
- type = other.type;
- startPos = other.startPos;
- endPos = other.endPos;
- offset = other.offset;
- size = other.size;
-
- return *this;
- }
-
- Column::~Column()
- {
- // No-op.
- }
-
- Column::Column(ignite::impl::binary::BinaryReaderImpl& reader) :
- type(0), startPos(-1), endPos(-1), offset(0), size(0)
- {
- ignite::impl::interop::InteropInputStream* stream = reader.GetStream();
-
- if (!stream)
- return;
-
- InteropStreamPositionGuard<InteropInputStream> guard(*stream);
-
- int32_t sizeTmp = 0;
-
- int8_t hdr = ReadColumnHeader(*stream);
-
- int32_t startPosTmp = stream->Position();
-
- switch (hdr)
- {
- case IGNITE_HDR_NULL:
- {
- sizeTmp = 1;
-
- break;
- }
-
- case IGNITE_TYPE_BYTE:
- {
- reader.ReadInt8();
-
- sizeTmp = 1;
-
- break;
- }
-
- case IGNITE_TYPE_BOOL:
- {
- reader.ReadBool();
-
- sizeTmp = 1;
-
- break;
- }
-
- case IGNITE_TYPE_SHORT:
- case IGNITE_TYPE_CHAR:
- {
- reader.ReadInt16();
-
- sizeTmp = 2;
-
- break;
- }
-
- case IGNITE_TYPE_FLOAT:
- {
- reader.ReadFloat();
-
- sizeTmp = 4;
-
- break;
- }
-
- case IGNITE_TYPE_INT:
- {
- reader.ReadInt32();
-
- sizeTmp = 4;
-
- break;
- }
-
- case IGNITE_TYPE_DOUBLE:
- {
- reader.ReadDouble();
-
- sizeTmp = 8;
-
- break;
- }
-
- case IGNITE_TYPE_LONG:
- {
- reader.ReadInt64();
-
- sizeTmp = 8;
-
- break;
- }
-
- case IGNITE_TYPE_STRING:
- {
- std::string str;
- utility::ReadString(reader, str);
-
- sizeTmp = static_cast<int32_t>(str.size());
-
- break;
- }
-
- case IGNITE_TYPE_UUID:
- {
- reader.ReadGuid();
-
- sizeTmp = 16;
-
- break;
- }
-
- case IGNITE_HDR_FULL:
- {
- int32_t len;
-
- if (!GetObjectLength(*stream, len))
- return;
-
- sizeTmp = len;
-
- stream->Position(stream->Position() + len);
-
- break;
- }
-
- case IGNITE_TYPE_DECIMAL:
- {
- Decimal res;
-
- utility::ReadDecimal(reader, res);
-
- sizeTmp = res.GetLength() + 8;
-
- break;
- }
-
- case IGNITE_TYPE_DATE:
- default:
- {
- // This is a fail case.
- return;
- }
- }
-
- type = hdr;
- startPos = startPosTmp;
- endPos = stream->Position();
- size = sizeTmp;
- }
-
- SqlResult Column::ReadToBuffer(ignite::impl::binary::BinaryReaderImpl& reader,
- app::ApplicationDataBuffer& dataBuf)
- {
- using namespace ignite::impl::binary;
- using namespace ignite::impl::interop;
-
- if (!IsValid())
- return SQL_RESULT_ERROR;
-
- if (GetUnreadDataLength() == 0)
- {
- dataBuf.PutNull();
-
- return SQL_RESULT_NO_DATA;
- }
-
- ignite::impl::interop::InteropInputStream* stream = reader.GetStream();
-
- if (!stream)
- return SQL_RESULT_ERROR;
-
- InteropStreamPositionGuard<InteropInputStream> guard(*stream);
-
- stream->Position(startPos);
-
- switch (type)
- {
- case IGNITE_TYPE_BYTE:
- {
- dataBuf.PutInt8(reader.ReadInt8());
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_SHORT:
- case IGNITE_TYPE_CHAR:
- {
- dataBuf.PutInt16(reader.ReadInt16());
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_INT:
- {
- dataBuf.PutInt32(reader.ReadInt32());
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_LONG:
- {
- dataBuf.PutInt64(reader.ReadInt64());
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_FLOAT:
- {
- dataBuf.PutFloat(reader.ReadFloat());
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_DOUBLE:
- {
- dataBuf.PutDouble(reader.ReadDouble());
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_BOOL:
- {
- dataBuf.PutInt8(reader.ReadBool() ? 1 : 0);
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_STRING:
- {
- std::string str;
- utility::ReadString(reader, str);
-
- int32_t written = dataBuf.PutString(str.substr(offset));
-
- IncreaseOffset(written);
-
- break;
- }
-
- case IGNITE_TYPE_UUID:
- {
- Guid guid = reader.ReadGuid();
-
- dataBuf.PutGuid(guid);
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_HDR_NULL:
- {
- dataBuf.PutNull();
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_HDR_FULL:
- {
- int32_t len;
-
- if (!GetObjectLength(*stream, len))
- return SQL_RESULT_ERROR;
-
- std::vector<int8_t> data(len);
-
- stream->ReadInt8Array(&data[0], static_cast<int32_t>(data.size()));
-
- int32_t written = dataBuf.PutBinaryData(data.data() + offset, static_cast<size_t>(len - offset));
-
- IncreaseOffset(written);
-
- break;
- }
-
- case IGNITE_TYPE_DECIMAL:
- {
- Decimal res;
-
- utility::ReadDecimal(reader, res);
-
- dataBuf.PutDecimal(res);
-
- IncreaseOffset(size);
-
- break;
- }
-
- case IGNITE_TYPE_DATE:
- default:
- {
- // This is a fail case. Return false.
- return SQL_RESULT_ERROR;
- }
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- void Column::IncreaseOffset(int32_t value)
- {
- offset += value;
-
- if (offset > size)
- offset = size;
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/common_types.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/common_types.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/common_types.cpp
deleted file mode 100644
index 276d9fd..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/common_types.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/common_types.h"
-
-namespace ignite
-{
- namespace odbc
- {
- int SqlResultToReturnCode(SqlResult result)
- {
- switch (result)
- {
- case SQL_RESULT_SUCCESS:
- return SQL_SUCCESS;
-
- case SQL_RESULT_SUCCESS_WITH_INFO:
- return SQL_SUCCESS_WITH_INFO;
-
- case SQL_RESULT_NO_DATA:
- return SQL_NO_DATA;
-
- case SQL_RESULT_ERROR:
- default:
- return SQL_ERROR;
- }
- }
-
- DiagnosticField DiagnosticFieldToInternal(int16_t field)
- {
- switch (field)
- {
- case SQL_DIAG_CURSOR_ROW_COUNT:
- return IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT;
-
- case SQL_DIAG_DYNAMIC_FUNCTION:
- return IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION;
-
- case SQL_DIAG_DYNAMIC_FUNCTION_CODE:
- return IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE;
-
- case SQL_DIAG_NUMBER:
- return IGNITE_SQL_DIAG_HEADER_NUMBER;
-
- case SQL_DIAG_RETURNCODE:
- return IGNITE_SQL_DIAG_HEADER_RETURNCODE;
-
- case SQL_DIAG_ROW_COUNT:
- return IGNITE_SQL_DIAG_HEADER_ROW_COUNT;
-
- case SQL_DIAG_CLASS_ORIGIN:
- return IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN;
-
- case SQL_DIAG_COLUMN_NUMBER:
- return IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER;
-
- case SQL_DIAG_CONNECTION_NAME:
- return IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME;
-
- case SQL_DIAG_MESSAGE_TEXT:
- return IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT;
-
- case SQL_DIAG_NATIVE:
- return IGNITE_SQL_DIAG_STATUS_NATIVE;
-
- case SQL_DIAG_ROW_NUMBER:
- return IGNITE_SQL_DIAG_STATUS_ROW_NUMBER;
-
- case SQL_DIAG_SERVER_NAME:
- return IGNITE_SQL_DIAG_STATUS_SERVER_NAME;
-
- case SQL_DIAG_SQLSTATE:
- return IGNITE_SQL_DIAG_STATUS_SQLSTATE;
-
- case SQL_DIAG_SUBCLASS_ORIGIN:
- return IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN;
-
- default:
- break;
- }
-
- return IGNITE_SQL_DIAG_UNKNOWN;
- }
-
- EnvironmentAttribute EnvironmentAttributeToInternal(int32_t attr)
- {
- switch (attr)
- {
- case SQL_ATTR_ODBC_VERSION:
- return IGNITE_SQL_ENV_ATTR_ODBC_VERSION;
-
- case SQL_ATTR_OUTPUT_NTS:
- return IGNITE_SQL_ENV_ATTR_OUTPUT_NTS;
-
- default:
- break;
- }
-
- return IGNITE_SQL_ENV_ATTR_UNKNOWN;
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/config/configuration.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/config/configuration.cpp
deleted file mode 100644
index 08ee54b..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/config/configuration.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * 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 <cstring>
-
-#include <string>
-#include <sstream>
-#include <algorithm>
-#include <iterator>
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/config/configuration.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace config
- {
- /** Default values for configuration. */
- namespace dflt
- {
- /** Default value for DSN attribute. */
- const std::string dsn = "Default Apache Ignite DSN";
-
- /** Default value for Driver attribute. */
- const std::string driver = "Apache Ignite";
-
- /** Default value for host attribute. */
- const std::string host = "localhost";
-
- /** Default value for port attribute. */
- const uint16_t port = 11443;
-
- /** Default value for cache attribute. */
- const std::string cache = "Persons";
- }
-
- /** Connection attribute keywords. */
- namespace attrkey
- {
- /** Connection attribute keyword for DSN attribute. */
- const std::string dsn = "dsn";
-
- /** Connection attribute keyword for Driver attribute. */
- const std::string driver = "driver";
-
- /** Connection attribute keyword for server host attribute. */
- const std::string host = "server";
-
- /** Connection attribute keyword for server port attribute. */
- const std::string port = "port";
-
- /** Default value for cache attribute. */
- const std::string cache = "cache";
- }
-
- Configuration::Configuration() :
- dsn(dflt::dsn), driver(dflt::driver),
- host(dflt::host), port(dflt::port),
- cache(dflt::cache)
- {
- // No-op.
- }
-
- Configuration::~Configuration()
- {
- // No-op.
- }
-
- void Configuration::FillFromConnectString(const char* str, size_t len)
- {
- ArgumentMap connect_attributes;
-
- ParseAttributeList(str, len, ';', connect_attributes);
-
- ArgumentMap::const_iterator it;
-
- it = connect_attributes.find(attrkey::dsn);
- if (it != connect_attributes.end())
- dsn = it->second;
- else
- dsn.clear();
-
- it = connect_attributes.find(attrkey::driver);
- if (it != connect_attributes.end())
- driver = it->second;
- else
- driver = dflt::driver;
-
- it = connect_attributes.find(attrkey::host);
- if (it != connect_attributes.end())
- host = it->second;
- else
- host = dflt::host;
-
- it = connect_attributes.find(attrkey::port);
- if (it != connect_attributes.end())
- port = atoi(it->second.c_str());
- else
- port = dflt::port;
-
- it = connect_attributes.find(attrkey::cache);
- if (it != connect_attributes.end())
- cache = it->second;
- else
- cache = dflt::cache;
- }
-
- void Configuration::FillFromConnectString(const std::string& str)
- {
- FillFromConnectString(str.data(), str.size());
- }
-
- std::string Configuration::ToConnectString() const
- {
- std::stringstream connect_string_buffer;
-
- if (!driver.empty())
- connect_string_buffer << attrkey::driver << "={" << driver << "};";
-
- if (!host.empty())
- connect_string_buffer << attrkey::host << '=' << host << ';';
-
- if (port)
- connect_string_buffer << attrkey::port << '=' << port << ';';
-
- if (!dsn.empty())
- connect_string_buffer << attrkey::dsn << '=' << dsn << ';';
-
- if (!cache.empty())
- connect_string_buffer << attrkey::cache << '=' << cache << ';';
-
- return connect_string_buffer.str();
- }
-
- void Configuration::FillFromConfigAttributes(const char * attributes)
- {
- ArgumentMap config_attributes;
-
- size_t len = 0;
-
- // Getting list length. List is terminated by two '\0'.
- while (attributes[len] || attributes[len + 1])
- ++len;
-
- ++len;
-
- ParseAttributeList(attributes, len, '\0', config_attributes);
-
- ArgumentMap::const_iterator it;
-
- it = config_attributes.find(attrkey::dsn);
- if (it != config_attributes.end())
- dsn = it->second;
- else
- dsn = dflt::dsn;
-
- it = config_attributes.find(attrkey::driver);
- if (it != config_attributes.end())
- driver = it->second;
- else
- driver.clear();
-
- it = config_attributes.find(attrkey::host);
- if (it != config_attributes.end())
- host = it->second;
- else
- host.clear();
-
- it = config_attributes.find(attrkey::port);
- if (it != config_attributes.end())
- port = atoi(it->second.c_str());
- else
- port = 0;
-
- it = config_attributes.find(attrkey::cache);
- if (it != config_attributes.end())
- cache = it->second;
- else
- cache.clear();
- }
-
- void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args) const
- {
- std::string connect_str(str, len);
- args.clear();
-
- while (!connect_str.empty())
- {
- size_t attr_begin = connect_str.rfind(delimeter);
-
- if (attr_begin == std::string::npos)
- attr_begin = 0;
- else
- ++attr_begin;
-
- size_t attr_eq_pos = connect_str.rfind('=');
-
- if (attr_eq_pos == std::string::npos)
- attr_eq_pos = 0;
-
- if (attr_begin < attr_eq_pos)
- {
- const char* key_begin = connect_str.data() + attr_begin;
- const char* key_end = connect_str.data() + attr_eq_pos;
-
- const char* value_begin = connect_str.data() + attr_eq_pos + 1;
- const char* value_end = connect_str.data() + connect_str.size();
-
- std::string key = utility::RemoveSurroundingSpaces(key_begin, key_end);
- std::string value = utility::RemoveSurroundingSpaces(value_begin, value_end);
-
- utility::IntoLower(key);
-
- if (value.front() == '{' && value.back() == '}')
- value = value.substr(1, value.size() - 2);
-
- args[key] = value;
- }
-
- if (!attr_begin)
- break;
-
- connect_str.erase(attr_begin - 1);
- }
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/config/connection_info.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/config/connection_info.cpp
deleted file mode 100644
index 0e8e748..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/config/connection_info.cpp
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * 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 <cstring>
-#include <algorithm>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/config/connection_info.h"
-
- // Temporary workaround.
-#ifndef SQL_ASYNC_NOTIFICATION
-#define SQL_ASYNC_NOTIFICATION 10025
-#endif
-
-#ifndef SQL_ASYNC_NOTIFICATION_NOT_CAPABLE
-#define SQL_ASYNC_NOTIFICATION_NOT_CAPABLE 0x00000000L
-#endif
-
-#ifndef SQL_ASYNC_NOTIFICATION_CAPABLE
-#define SQL_ASYNC_NOTIFICATION_CAPABLE 0x00000001L
-#endif
-
-namespace ignite
-{
- namespace odbc
- {
- namespace config
- {
-
-#ifdef ODBC_DEBUG
-
-#define DBG_STR_CASE(x) case x: return #x
-
- const char * ConnectionInfo::InfoTypeToString(InfoType type)
- {
- switch (type)
- {
- DBG_STR_CASE(SQL_DRIVER_NAME);
- DBG_STR_CASE(SQL_DBMS_NAME);
- DBG_STR_CASE(SQL_DRIVER_ODBC_VER);
- DBG_STR_CASE(SQL_DBMS_VER);
- DBG_STR_CASE(SQL_DRIVER_VER);
- DBG_STR_CASE(SQL_COLUMN_ALIAS);
- DBG_STR_CASE(SQL_IDENTIFIER_QUOTE_CHAR);
- DBG_STR_CASE(SQL_CATALOG_NAME_SEPARATOR);
- DBG_STR_CASE(SQL_SPECIAL_CHARACTERS);
- DBG_STR_CASE(SQL_CATALOG_TERM);
- DBG_STR_CASE(SQL_TABLE_TERM);
- DBG_STR_CASE(SQL_SCHEMA_TERM);
- DBG_STR_CASE(SQL_ASYNC_DBC_FUNCTIONS);
- DBG_STR_CASE(SQL_ASYNC_NOTIFICATION);
- DBG_STR_CASE(SQL_GETDATA_EXTENSIONS);
- DBG_STR_CASE(SQL_ODBC_INTERFACE_CONFORMANCE);
- DBG_STR_CASE(SQL_SQL_CONFORMANCE);
- DBG_STR_CASE(SQL_CATALOG_USAGE);
- DBG_STR_CASE(SQL_SCHEMA_USAGE);
- DBG_STR_CASE(SQL_MAX_IDENTIFIER_LEN);
- DBG_STR_CASE(SQL_AGGREGATE_FUNCTIONS);
- DBG_STR_CASE(SQL_NUMERIC_FUNCTIONS);
- DBG_STR_CASE(SQL_STRING_FUNCTIONS);
- DBG_STR_CASE(SQL_TIMEDATE_FUNCTIONS);
- DBG_STR_CASE(SQL_TIMEDATE_ADD_INTERVALS);
- DBG_STR_CASE(SQL_TIMEDATE_DIFF_INTERVALS);
- DBG_STR_CASE(SQL_DATETIME_LITERALS);
- DBG_STR_CASE(SQL_SYSTEM_FUNCTIONS);
- DBG_STR_CASE(SQL_CONVERT_FUNCTIONS);
- DBG_STR_CASE(SQL_OJ_CAPABILITIES);
- DBG_STR_CASE(SQL_POS_OPERATIONS);
- DBG_STR_CASE(SQL_MAX_CONCURRENT_ACTIVITIES);
- DBG_STR_CASE(SQL_CURSOR_COMMIT_BEHAVIOR);
- DBG_STR_CASE(SQL_CURSOR_ROLLBACK_BEHAVIOR);
- DBG_STR_CASE(SQL_TXN_CAPABLE);
- DBG_STR_CASE(SQL_QUOTED_IDENTIFIER_CASE);
- DBG_STR_CASE(SQL_SQL92_NUMERIC_VALUE_FUNCTIONS);
- DBG_STR_CASE(SQL_SQL92_STRING_FUNCTIONS);
- DBG_STR_CASE(SQL_SQL92_DATETIME_FUNCTIONS);
- DBG_STR_CASE(SQL_SQL92_PREDICATES);
- DBG_STR_CASE(SQL_SQL92_RELATIONAL_JOIN_OPERATORS);
- DBG_STR_CASE(SQL_SQL92_VALUE_EXPRESSIONS);
- default:
- break;
- }
- return "<< UNKNOWN TYPE >>";
- }
-
-#undef DBG_STR_CASE
-#endif
-
- ConnectionInfo::ConnectionInfo() : strParams(), intParams(),
- shortParams()
- {
- //========================= String Params =========================
- // Driver name.
- strParams[SQL_DRIVER_NAME] = "Apache Ignite";
- strParams[SQL_DBMS_NAME] = "Apache Ignite";
-
- // ODBC version.
- strParams[SQL_DRIVER_ODBC_VER] = "03.00";
- strParams[SQL_DBMS_VER] = "03.00";
-
-#ifdef SQL_DRIVER_VER
- // Driver version. At a minimum, the version is of the form
- // ##.##.####, where the first two digits are the major version,
- // the next two digits are the minor version, and the last four
- // digits are the release version.
- strParams[SQL_DRIVER_VER] = "01.05.0000";
-#endif // SQL_DRIVER_VER
-
-#ifdef SQL_COLUMN_ALIAS
- // A character string: "Y" if the data source supports column
- // aliases; otherwise, "N".
- strParams[SQL_COLUMN_ALIAS] = "N";
-#endif // SQL_COLUMN_ALIAS
-
-#ifdef SQL_IDENTIFIER_QUOTE_CHAR
- // The character string that is used as the starting and ending
- // delimiter of a quoted (delimited) identifier in SQL statements.
- // Identifiers passed as arguments to ODBC functions do not have to
- // be quoted. If the data source does not support quoted
- // identifiers, a blank is returned.
- strParams[SQL_IDENTIFIER_QUOTE_CHAR] = "";
-#endif // SQL_IDENTIFIER_QUOTE_CHAR
-
-#ifdef SQL_CATALOG_NAME_SEPARATOR
- // A character string: the character or characters that the data
- // source defines as the separator between a catalog name and the
- // qualified name element that follows or precedes it.
- strParams[SQL_CATALOG_NAME_SEPARATOR] = ".";
-#endif // SQL_CATALOG_NAME_SEPARATOR
-
-#ifdef SQL_SPECIAL_CHARACTERS
- // A character string that contains all special characters (that
- // is, all characters except a through z, A through Z, 0 through 9,
- // and underscore) that can be used in an identifier name, such as
- // a table name, column name, or index name, on the data source.
- strParams[SQL_SPECIAL_CHARACTERS] = "";
-#endif // SQL_SPECIAL_CHARACTERS
-
-#ifdef SQL_CATALOG_TERM
- // A character string with the data source vendor's name for
- // a catalog; for example, "database" or "directory". This string
- // can be in upper, lower, or mixed case.
- strParams[SQL_CATALOG_TERM] = "catalog";
-#endif // SQL_CATALOG_TERM
-
-#ifdef SQL_TABLE_TERM
- // A character string with the data source vendor's name for
- // a table; for example, "table" or "file".
- strParams[SQL_TABLE_TERM] = "table";
-#endif // SQL_TABLE_TERM
-
-#ifdef SQL_SCHEMA_TERM
- // A character string with the data source vendor's name for
- // a schema; for example, "owner", "Authorization ID", or "Schema".
- strParams[SQL_SCHEMA_TERM] = "schema";
-#endif // SQL_SCHEMA_TERM
-
-#ifdef SQL_ASYNC_DBC_FUNCTIONS
- //======================== Integer Params =========================
- // Indicates if the driver can execute functions asynchronously
- // on the connection handle.
- // SQL_ASYNC_DBC_CAPABLE = The driver can execute connection
- // functions asynchronously.
- // SQL_ASYNC_DBC_NOT_CAPABLE = The driver can not execute
- // connection functions asynchronously.
- intParams[SQL_ASYNC_DBC_FUNCTIONS] = SQL_ASYNC_DBC_NOT_CAPABLE;
-#endif // SQL_ASYNC_DBC_FUNCTIONS
-
-#ifdef SQL_ASYNC_NOTIFICATION
- // Indicates if the driver supports asynchronous notification.
- // SQL_ASYNC_NOTIFICATION_CAPABLE = Asynchronous execution
- // notification is supported by the driver.
- // SQL_ASYNC_NOTIFICATION_NOT_CAPABLE Asynchronous execution
- // notification is not supported by the driver.
- intParams[SQL_ASYNC_NOTIFICATION] = SQL_ASYNC_NOTIFICATION_NOT_CAPABLE;
-#endif // SQL_ASYNC_NOTIFICATION
-
-#ifdef SQL_GETDATA_EXTENSIONS
- // Bitmask enumerating extensions to SQLGetData.
- intParams[SQL_GETDATA_EXTENSIONS] = SQL_GD_ANY_COLUMN;
-#endif // SQL_GETDATA_EXTENSIONS
-
-#ifdef SQL_ODBC_INTERFACE_CONFORMANCE
- // Indicates the level of the ODBC 3.x interface that the driver
- // complies with.
- intParams[SQL_ODBC_INTERFACE_CONFORMANCE] = SQL_OIC_CORE;
-#endif // SQL_ODBC_INTERFACE_CONFORMANCE
-
-#ifdef SQL_SQL_CONFORMANCE
- // Indicates the level of SQL-92 supported by the driver.
- intParams[SQL_SQL_CONFORMANCE] = 0; // SQL_SC_SQL92_ENTRY;
-#endif // SQL_SQL_CONFORMANCE
-
-#ifdef SQL_CATALOG_USAGE
- // Bitmask enumerating the statements in which catalogs can be used.
- intParams[SQL_CATALOG_USAGE] = 0;
-#endif // SQL_CATALOG_USAGE
-
-#ifdef SQL_SCHEMA_USAGE
- // Bitmask enumerating the statements in which schemas can be used.
- intParams[SQL_SCHEMA_USAGE] = 0;
-#endif // SQL_SCHEMA_USAGE
-
-#ifdef SQL_MAX_IDENTIFIER_LEN
- // Indicates the maximum size in characters that the data source
- // supports for user-defined names.
- intParams[SQL_MAX_IDENTIFIER_LEN] = 128;
-#endif // SQL_MAX_IDENTIFIER_LEN
-
-#ifdef SQL_AGGREGATE_FUNCTIONS
- // Bitmask enumerating support for aggregation functions.
- intParams[SQL_AGGREGATE_FUNCTIONS] = SQL_AF_ALL | SQL_AF_AVG |
- SQL_AF_COUNT | SQL_AF_DISTINCT | SQL_AF_MAX | SQL_AF_MIN |
- SQL_AF_SUM;
-#endif // SQL_AGGREGATE_FUNCTIONS
-
-#ifdef SQL_NUMERIC_FUNCTIONS
- // Bitmask enumerating the scalar numeric functions supported by
- // the driver and associated data source.
- intParams[SQL_NUMERIC_FUNCTIONS] = SQL_FN_NUM_ABS;
-#endif // SQL_NUMERIC_FUNCTIONS
-
-#ifdef SQL_STRING_FUNCTIONS
- // Bitmask enumerating the scalar string functions supported by the
- // driver and associated data source.
- intParams[SQL_STRING_FUNCTIONS] = 0;
-#endif // SQL_STRING_FUNCTIONS
-
-#ifdef SQL_TIMEDATE_FUNCTIONS
- // Bitmask enumerating the scalar date and time functions supported
- // by the driver and associated data source.
- intParams[SQL_TIMEDATE_FUNCTIONS] = 0;
-#endif // SQL_TIMEDATE_FUNCTIONS
-
-#ifdef SQL_TIMEDATE_ADD_INTERVALS
- // Bitmask enumerating timestamp intervals supported by the driver
- // and associated data source for the TIMESTAMPADD scalar function.
- intParams[SQL_TIMEDATE_ADD_INTERVALS] = 0;
-#endif // SQL_TIMEDATE_ADD_INTERVALS
-
-#ifdef SQL_TIMEDATE_DIFF_INTERVALS
- // Bitmask enumerating timestamp intervals supported by the driver
- // and associated data source for the TIMESTAMPDIFF scalar function.
- intParams[SQL_TIMEDATE_DIFF_INTERVALS] = 0;
-#endif // SQL_TIMEDATE_DIFF_INTERVALS
-
-#ifdef SQL_DATETIME_LITERALS
- // Bitmask enumerating the SQL-92 datetime literals supported by
- // the data source.
- intParams[SQL_DATETIME_LITERALS] = 0;
-#endif // SQL_DATETIME_LITERALS
-
-#ifdef SQL_SYSTEM_FUNCTIONS
- // Bitmask enumerating the scalar system functions supported by the
- // driver and associated data source.
- intParams[SQL_SYSTEM_FUNCTIONS] = 0;
-#endif // SQL_SYSTEM_FUNCTIONS
-
-#ifdef SQL_CONVERT_FUNCTIONS
- // Bitmask enumerating the scalar conversion functions supported
- // by the driver and associated data source.
- intParams[SQL_CONVERT_FUNCTIONS] = 0;
-#endif // SQL_CONVERT_FUNCTIONS
-
-#ifdef SQL_OJ_CAPABILITIES
- // Bitmask enumerating the types of outer joins supported by the
- // driver and data source.
- intParams[SQL_OJ_CAPABILITIES] = SQL_OJ_LEFT | SQL_OJ_RIGHT |
- SQL_OJ_FULL | SQL_OJ_NESTED | SQL_OJ_INNER |
- SQL_OJ_ALL_COMPARISON_OPS;
-#endif // SQL_OJ_CAPABILITIES
-
-#ifdef SQL_POS_OPERATIONS
- // Bitmask enumerating the support operations in SQLSetPos.
- intParams[SQL_POS_OPERATIONS] = 0;
-#endif // SQL_POS_OPERATIONS
-
-#ifdef SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
- // Bitmask enumerating the numeric value scalar functions.
- intParams[SQL_SQL92_NUMERIC_VALUE_FUNCTIONS] = 0;
-#endif // SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
-
-#ifdef SQL_SQL92_STRING_FUNCTIONS
- // Bitmask enumerating the string scalar functions.
- intParams[SQL_SQL92_STRING_FUNCTIONS] = 0;
-#endif // SQL_SQL92_STRING_FUNCTIONS
-
-#ifdef SQL_SQL92_DATETIME_FUNCTIONS
- // Bitmask enumerating the datetime scalar functions.
- intParams[SQL_SQL92_DATETIME_FUNCTIONS] = 0;
-#endif // SQL_SQL92_DATETIME_FUNCTIONS
-
-#ifdef SQL_SQL92_VALUE_EXPRESSIONS
- // Bitmask enumerating the value expressions supported,
- // as defined in SQL-92.
- intParams[SQL_SQL92_VALUE_EXPRESSIONS] = SQL_SVE_CASE |
- SQL_SVE_COALESCE | SQL_SVE_NULLIF;
-#endif // SQL_SQL92_VALUE_EXPRESSIONS
-
-#ifdef SQL_SQL92_PREDICATES
- // Bitmask enumerating the datetime scalar functions.
- intParams[SQL_SQL92_PREDICATES] = SQL_SP_BETWEEN |
- SQL_SP_COMPARISON | SQL_SP_EXISTS | SQL_SP_IN |
- SQL_SP_ISNOTNULL | SQL_SP_ISNULL | SQL_SP_LIKE |
- SQL_SP_MATCH_FULL | SQL_SP_MATCH_PARTIAL |
- SQL_SP_MATCH_UNIQUE_FULL | SQL_SP_MATCH_UNIQUE_PARTIAL |
- SQL_SP_OVERLAPS | SQL_SP_QUANTIFIED_COMPARISON |
- SQL_SP_UNIQUE;
-#endif // SQL_SQL92_PREDICATES
-
-#ifdef SQL_SQL92_RELATIONAL_JOIN_OPERATORS
- // Bitmask enumerating the relational join operators supported
- // in a SELECT statement, as defined in SQL-92.
- intParams[SQL_SQL92_RELATIONAL_JOIN_OPERATORS] =
- SQL_SRJO_CORRESPONDING_CLAUSE | SQL_SRJO_CROSS_JOIN |
- SQL_SRJO_EXCEPT_JOIN | SQL_SRJO_EXCEPT_JOIN |
- SQL_SRJO_INNER_JOIN | SQL_SRJO_INTERSECT_JOIN |
- SQL_SRJO_LEFT_OUTER_JOIN | SQL_SRJO_NATURAL_JOIN |
- SQL_SRJO_RIGHT_OUTER_JOIN | SQL_SRJO_UNION_JOIN;
-#endif // SQL_SQL92_RELATIONAL_JOIN_OPERATORS
-
- //========================= Short Params ==========================
-#ifdef SQL_MAX_CONCURRENT_ACTIVITIES
- // The maximum number of active statements that the driver can
- // support for a connection. Zero mean no limit.
- shortParams[SQL_MAX_CONCURRENT_ACTIVITIES] = 32;
-#endif // SQL_MAX_CONCURRENT_ACTIVITIES
-
-#ifdef SQL_CURSOR_COMMIT_BEHAVIOR
- // Indicates how a COMMIT operation affects cursors and prepared
- // statements in the data source.
- shortParams[SQL_CURSOR_COMMIT_BEHAVIOR] = SQL_CB_PRESERVE;
-#endif // SQL_CURSOR_COMMIT_BEHAVIOR
-
-#ifdef SQL_CURSOR_ROLLBACK_BEHAVIOR
- // Indicates how a ROLLBACK operation affects cursors and prepared
- // statements in the data source.
- shortParams[SQL_CURSOR_ROLLBACK_BEHAVIOR] = SQL_CB_PRESERVE;
-#endif // SQL_CURSOR_ROLLBACK_BEHAVIOR
-
-#ifdef SQL_TXN_CAPABLE
- // Describs the transaction support in the driver or data source.
- shortParams[SQL_TXN_CAPABLE] = SQL_TC_NONE;
-#endif // SQL_TXN_CAPABLE
-
-#ifdef SQL_QUOTED_IDENTIFIER_CASE
- // Case-sensitiveness of the quoted identifiers in SQL.
- shortParams[SQL_QUOTED_IDENTIFIER_CASE] = SQL_IC_SENSITIVE;
-#endif // SQL_QUOTED_IDENTIFIER_CASE
- }
-
- ConnectionInfo::~ConnectionInfo()
- {
- // No-op.
- }
-
- SqlResult ConnectionInfo::GetInfo(InfoType type, void* buf,
- short buflen, short* reslen) const
- {
- if (!buf || !buflen)
- return SQL_RESULT_ERROR;
-
- StringInfoMap::const_iterator itStr = strParams.find(type);
-
- if (itStr != strParams.cend())
- {
- unsigned short strlen = static_cast<short>(
- utility::CopyStringToBuffer(itStr->second,
- reinterpret_cast<char*>(buf), buflen));
-
- if (reslen)
- *reslen = strlen;
-
- return SQL_RESULT_SUCCESS;
- }
-
- UintInfoMap::const_iterator itInt = intParams.find(type);
-
- if (itInt != intParams.cend())
- {
- unsigned int *res = reinterpret_cast<unsigned int*>(buf);
-
- *res = itInt->second;
-
- return SQL_RESULT_SUCCESS;
- }
-
- UshortInfoMap::const_iterator itShort = shortParams.find(type);
-
- if (itShort != shortParams.cend())
- {
- unsigned short *res = reinterpret_cast<unsigned short*>(buf);
-
- *res = itShort->second;
-
- return SQL_RESULT_SUCCESS;
- }
-
- return SQL_RESULT_ERROR;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp
deleted file mode 100644
index 28cd7ca..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * 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 <cstring>
-
-#include <sstream>
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/statement.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/config/configuration.h"
-
-// TODO: implement appropriate protocol with de-/serialisation.
-namespace
-{
-#pragma pack(push, 1)
- struct OdbcProtocolHeader
- {
- int32_t len;
- };
-#pragma pack(pop)
-}
-
-namespace ignite
-{
- namespace odbc
- {
- Connection::Connection() : socket(), connected(false), cache(), parser()
- {
- // No-op.
- }
-
- Connection::~Connection()
- {
- // No-op.
- }
-
- const config::ConnectionInfo& Connection::GetInfo() const
- {
- // Connection info is the same for all connections now.
- static config::ConnectionInfo info;
-
- return info;
- }
-
- void Connection::GetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen)
- {
- IGNITE_ODBC_API_CALL(InternalGetInfo(type, buf, buflen, reslen));
- }
-
- SqlResult Connection::InternalGetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen)
- {
- const config::ConnectionInfo& info = GetInfo();
-
- SqlResult res = info.GetInfo(type, buf, buflen, reslen);
-
- if (res != SQL_RESULT_SUCCESS)
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Not implemented.");
-
- return res;
- }
-
- void Connection::Establish(const std::string& server)
- {
- IGNITE_ODBC_API_CALL(InternalEstablish(server));
- }
-
- SqlResult Connection::InternalEstablish(const std::string& server)
- {
- config::Configuration config;
-
- if (server != config.GetDsn())
- {
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown DNS.");
-
- return SQL_RESULT_ERROR;
- }
-
- return InternalEstablish(config.GetHost(), config.GetPort(), config.GetCache());
- }
-
- void Connection::Establish(const std::string& host, uint16_t port, const std::string& cache)
- {
- IGNITE_ODBC_API_CALL(InternalEstablish(host, port, cache));
- }
-
- SqlResult Connection::InternalEstablish(const std::string & host, uint16_t port, const std::string & cache)
- {
- if (connected)
- {
- AddStatusRecord(SQL_STATE_08002_ALREADY_CONNECTED, "Already connected.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cache.empty())
- {
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Cache is not specified.");
-
- return SQL_RESULT_ERROR;
- }
-
- this->cache = cache;
-
- connected = socket.Connect(host.c_str(), port);
-
- if (!connected)
- {
- AddStatusRecord(SQL_STATE_08001_CANNOT_CONNECT, "Failed to establish connection with the host.");
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- void Connection::Release()
- {
- IGNITE_ODBC_API_CALL(InternalRelease());
- }
-
- SqlResult Connection::InternalRelease()
- {
- if (!connected)
- {
- AddStatusRecord(SQL_STATE_08003_NOT_CONNECTED, "Connection is not open.");
-
- return SQL_RESULT_ERROR;
- }
-
- socket.Close();
-
- connected = false;
-
- return SQL_RESULT_SUCCESS;
- }
-
- Statement* Connection::CreateStatement()
- {
- Statement* statement;
-
- IGNITE_ODBC_API_CALL(InternalCreateStatement(statement));
-
- return statement;
- }
-
- SqlResult Connection::InternalCreateStatement(Statement*& statement)
- {
- statement = new Statement(*this);
-
- if (!statement)
- {
- AddStatusRecord(SQL_STATE_HY001_MEMORY_ALLOCATION, "Not enough memory.");
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- bool Connection::Send(const int8_t* data, size_t len)
- {
- if (!connected)
- return false;
-
- size_t sent = 0;
-
- while (sent != len)
- {
- size_t res = socket.Send(data + sent, len - sent);
-
- if (res <= 0)
- return false;
-
- sent += res;
- }
-
- return true;
- }
-
- bool Connection::Receive(std::vector<int8_t>& msg)
- {
- if (!connected)
- return false;
-
- msg.clear();
-
- OdbcProtocolHeader hdr;
-
- int received = socket.Receive(reinterpret_cast<int8_t*>(&hdr), sizeof(hdr));
- LOG_MSG("Received: %d\n", received);
-
- if (received != sizeof(hdr))
- return false;
-
- size_t remain = hdr.len;
- size_t receivedAtAll = 0;
-
- msg.resize(remain);
-
- while (remain)
- {
- received = socket.Receive(&msg[receivedAtAll], remain);
- LOG_MSG("Received: %d\n", received);
- LOG_MSG("remain: %d\n", remain);
-
- if (received <= 0)
- {
- msg.resize(receivedAtAll);
-
- return false;
- }
-
- remain -= static_cast<size_t>(received);
- }
-
- return true;
- }
-
- const std::string& Connection::GetCache() const
- {
- return cache;
- }
-
- diagnostic::DiagnosticRecord Connection::CreateStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum, int32_t columnNum) const
- {
- return diagnostic::DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum);
- }
-
- void Connection::TransactionCommit()
- {
- IGNITE_ODBC_API_CALL(InternalTransactionCommit());
- }
-
- SqlResult Connection::InternalTransactionCommit()
- {
- return SQL_RESULT_SUCCESS;
- }
-
- void Connection::TransactionRollback()
- {
- IGNITE_ODBC_API_CALL(InternalTransactionRollback());
- }
-
- SqlResult Connection::InternalTransactionRollback()
- {
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
- "Rollback operation is not supported.");
-
- return SQL_RESULT_ERROR;
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/cursor.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/cursor.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/cursor.cpp
deleted file mode 100644
index edd1818..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/cursor.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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 "ignite/odbc/cursor.h"
-
-namespace ignite
-{
- namespace odbc
- {
- Cursor::Cursor(int64_t queryId) : queryId(queryId), currentPage(),
- currentPagePos(0), currentRow()
- {
- // No-op.
- }
-
- Cursor::~Cursor()
- {
- // No-op.
- }
-
- bool Cursor::Increment()
- {
- if (currentPage.get() && currentPagePos < currentPage->GetSize())
- {
- ++currentPagePos;
-
- Row *row = currentRow.get();
-
- if (row)
- row->MoveToNext();
-
- return true;
- }
- return false;
- }
-
- bool Cursor::NeedDataUpdate() const
- {
- return !currentPage.get() || (!currentPage->IsLast() &&
- currentPagePos == currentPage->GetSize());
- }
-
- bool Cursor::HasNext() const
- {
- return !currentPage.get() || !currentPage->IsLast() ||
- currentPagePos < currentPage->GetSize();
- }
-
- void Cursor::UpdateData(std::auto_ptr<ResultPage>& newPage)
- {
- currentPage = newPage;
-
- currentPagePos = 1;
-
- currentRow.reset(new Row(currentPage->GetData()));
- }
-
- Row* Cursor::GetRow()
- {
- return currentRow.get();
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/decimal.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/decimal.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/decimal.cpp
deleted file mode 100644
index 0fa37fb..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/decimal.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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 <cstring>
-#include <utility>
-
-#include "ignite/odbc/decimal.h"
-
-namespace ignite
-{
- Decimal::Decimal() :
- scale(0), len(0), magnitude(0)
- {
- // No-op.
- }
-
- Decimal::Decimal(int32_t scale, const int8_t* mag, int32_t len) :
- scale(scale), len(len), magnitude(0)
- {
- magnitude = new int8_t[len];
-
- memcpy(magnitude, mag, len);
- }
-
- Decimal::Decimal(const Decimal& other) :
- scale(other.scale), len(other.len), magnitude(0)
- {
- magnitude = new int8_t[len];
-
- memcpy(magnitude, other.magnitude, len);
- }
-
- Decimal::~Decimal()
- {
- if (magnitude)
- delete[] magnitude;
- }
-
- Decimal& Decimal::operator=(const Decimal& other)
- {
- Decimal tmp(other);
-
- swap(tmp, *this);
-
- return *this;
- }
-
- Decimal::operator double() const
- {
- double res = 0;
-
- int32_t localScale = GetScale();
-
- for (int32_t i = 0; i < len; ++i)
- {
- res = (res * 256) + magnitude[i];
-
- while (localScale && res > 10.0)
- {
- res /= 10.0;
-
- --localScale;
- }
- }
-
- return res * GetSign();
- }
-
- int32_t Decimal::GetScale() const
- {
- return scale & 0x7FFFFFFF;
- }
-
- int32_t Decimal::GetSign() const
- {
- return IsNegative() ? -1 : 1;
- }
-
- bool Decimal::IsNegative() const
- {
- return (scale & 0x80000000) != 0;
- }
-
- int32_t Decimal::GetLength() const
- {
- return scale;
- }
-
- const int8_t* Decimal::GetMagnitude() const
- {
- return magnitude;
- }
-
- void swap(Decimal& first, Decimal& second)
- {
- using std::swap;
-
- std::swap(first.scale, second.scale);
- std::swap(first.len, second.len);
- std::swap(first.magnitude, second.magnitude);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnosable_adapter.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnosable_adapter.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnosable_adapter.cpp
deleted file mode 100644
index d6cf4fe..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnosable_adapter.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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 "ignite/odbc/connection.h"
-#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace diagnostic
- {
- void DiagnosableAdapter::AddStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum, int32_t columnNum)
- {
- if (connection)
- {
- diagnosticRecords.AddStatusRecord(
- connection->CreateStatusRecord(sqlState, message, rowNum, columnNum));
- }
- else
- {
- diagnosticRecords.AddStatusRecord(
- DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum));
- }
- }
-
- void DiagnosableAdapter::AddStatusRecord(SqlState sqlState, const std::string & message)
- {
- AddStatusRecord(sqlState, message, 0, 0);
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record.cpp
deleted file mode 100644
index 568c125..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * 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 <set>
-#include <string>
-
-#include "ignite/odbc/diagnostic/diagnostic_record.h"
-
-namespace
-{
- /** SQLSTATEs defined by Open Group and ISO call-level interface. */
- const std::string ORIGIN_ISO_9075 = "ISO 9075";
-
- /** ODBC-specific SQLSTATEs (all those whose SQLSTATE class is "IM"). */
- const std::string ORIGIN_ODBC_3_0 = "ODBC 3.0";
-
- /** SQL state unknown constant. */
- const std::string STATE_UNKNOWN = "";
-
- /** SQL state 01004 constant. */
- const std::string STATE_01004 = "01004";
-
- /** SQL state 01S01 constant. */
- const std::string STATE_01S01 = "01S01";
-
- /** SQL state 24000 constant. */
- const std::string STATE_24000 = "24000";
-
- /** SQL state 08001 constant. */
- const std::string STATE_08001 = "08001";
-
- /** SQL state 08002 constant. */
- const std::string STATE_08002 = "08002";
-
- /** SQL state 08003 constant. */
- const std::string STATE_08003 = "08003";
-
- /** SQL state HY000 constant. */
- const std::string STATE_HY000 = "HY000";
-
- /** SQL state HY001 constant. */
- const std::string STATE_HY001 = "HY001";
-
- /** SQL state HY010 constant. */
- const std::string STATE_HY010 = "HY010";
-
- /** SQL state HYC00 constant. */
- const std::string STATE_HYC00 = "HYC00";
-
- /** SQL state HYT01 constant. */
- const std::string STATE_HYT01 = "HYT01";
-}
-
-namespace ignite
-{
- namespace odbc
- {
- namespace diagnostic
- {
- DiagnosticRecord::DiagnosticRecord() :
- sqlState(SQL_STATE_UNKNOWN),
- message(),
- connectionName(),
- serverName(),
- rowNum(0),
- columnNum(0)
- {
- // No-op.
- }
-
- DiagnosticRecord::DiagnosticRecord(SqlState sqlState,
- const std::string& message, const std::string& connectionName,
- const std::string& serverName, int32_t rowNum, int32_t columnNum) :
- sqlState(sqlState),
- message(message),
- connectionName(connectionName),
- serverName(serverName),
- rowNum(rowNum),
- columnNum(columnNum)
- {
- // No-op.
- }
-
- DiagnosticRecord::~DiagnosticRecord()
- {
- // No-op.
- }
-
- const std::string& DiagnosticRecord::GetClassOrigin() const
- {
- const std::string& state = GetSqlState();
-
- if (state[0] == 'I' && state[1] == 'M')
- return ORIGIN_ODBC_3_0;
-
- return ORIGIN_ISO_9075;
- }
-
- const std::string& DiagnosticRecord::GetSubclassOrigin() const
- {
- static std::set<std::string> odbcSubclasses;
-
- if (odbcSubclasses.empty())
- {
- odbcSubclasses.insert("01S00");
- odbcSubclasses.insert("01S01");
- odbcSubclasses.insert("01S02");
- odbcSubclasses.insert("01S06");
- odbcSubclasses.insert("01S07");
- odbcSubclasses.insert("07S01");
- odbcSubclasses.insert("08S01");
- odbcSubclasses.insert("21S01");
- odbcSubclasses.insert("21S02");
- odbcSubclasses.insert("25S01");
- odbcSubclasses.insert("25S02");
- odbcSubclasses.insert("25S03");
- odbcSubclasses.insert("42S01");
- odbcSubclasses.insert("42S02");
- odbcSubclasses.insert("42S11");
- odbcSubclasses.insert("42S12");
- odbcSubclasses.insert("42S21");
- odbcSubclasses.insert("42S22");
- odbcSubclasses.insert("HY095");
- odbcSubclasses.insert("HY097");
- odbcSubclasses.insert("HY098");
- odbcSubclasses.insert("HY099");
- odbcSubclasses.insert("HY100");
- odbcSubclasses.insert("HY101");
- odbcSubclasses.insert("HY105");
- odbcSubclasses.insert("HY107");
- odbcSubclasses.insert("HY109");
- odbcSubclasses.insert("HY110");
- odbcSubclasses.insert("HY111");
- odbcSubclasses.insert("HYT00");
- odbcSubclasses.insert("HYT01");
- odbcSubclasses.insert("IM001");
- odbcSubclasses.insert("IM002");
- odbcSubclasses.insert("IM003");
- odbcSubclasses.insert("IM004");
- odbcSubclasses.insert("IM005");
- odbcSubclasses.insert("IM006");
- odbcSubclasses.insert("IM007");
- odbcSubclasses.insert("IM008");
- odbcSubclasses.insert("IM010");
- odbcSubclasses.insert("IM011");
- odbcSubclasses.insert("IM012");
- }
-
- const std::string& state = GetSqlState();
-
- if (odbcSubclasses.find(state) != odbcSubclasses.end())
- return ORIGIN_ODBC_3_0;
-
- return ORIGIN_ISO_9075;
- }
-
- const std::string& DiagnosticRecord::GetMessage() const
- {
- return message;
- }
-
- const std::string& DiagnosticRecord::GetConnectionName() const
- {
- return connectionName;
- }
-
- const std::string& DiagnosticRecord::GetServerName() const
- {
- return serverName;
- }
-
- const std::string& DiagnosticRecord::GetSqlState() const
- {
- switch (sqlState)
- {
- case SQL_STATE_01004_DATA_TRUNCATED:
- return STATE_01004;
-
- case SQL_STATE_01S01_ERROR_IN_ROW:
- return STATE_01S01;
-
- case SQL_STATE_24000_INVALID_CURSOR_STATE:
- return STATE_24000;
-
- case SQL_STATE_08001_CANNOT_CONNECT:
- return STATE_08001;
-
- case SQL_STATE_08002_ALREADY_CONNECTED:
- return STATE_08002;
-
- case SQL_STATE_08003_NOT_CONNECTED:
- return STATE_08003;
-
- case SQL_STATE_HY000_GENERAL_ERROR:
- return STATE_HY000;
-
- case SQL_STATE_HY001_MEMORY_ALLOCATION:
- return STATE_HY001;
-
- case SQL_STATE_HY010_SEQUENCE_ERROR:
- return STATE_HY010;
-
- case SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED:
- return STATE_HYC00;
-
- case SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT:
- return STATE_HYT01;
-
- default:
- break;
- }
-
- return STATE_UNKNOWN;
- }
-
- int32_t DiagnosticRecord::GetRowNumber() const
- {
- return rowNum;
- }
-
- int32_t DiagnosticRecord::GetColumnNumber() const
- {
- return columnNum;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record_storage.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record_storage.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record_storage.cpp
deleted file mode 100644
index 90c0a4f..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/diagnostic/diagnostic_record_storage.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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 <set>
-#include <string>
-
-#include "ignite/odbc/diagnostic/diagnostic_record_storage.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace diagnostic
- {
- DiagnosticRecordStorage::DiagnosticRecordStorage() :
- rowCount(0),
- dynamicFunction(),
- dynamicFunctionCode(0),
- result(SQL_RESULT_SUCCESS),
- rowsAffected(0)
- {
- // No-op.
- }
-
- DiagnosticRecordStorage::~DiagnosticRecordStorage()
- {
- // No-op.
- }
-
- void DiagnosticRecordStorage::SetHeaderRecord(SqlResult result)
- {
- rowCount = 0;
- dynamicFunction.clear();
- dynamicFunctionCode = 0;
- this->result = result;
- rowsAffected = 0;
- }
-
- void DiagnosticRecordStorage::AddStatusRecord(const DiagnosticRecord& record)
- {
- statusRecords.push_back(record);
- }
-
- void DiagnosticRecordStorage::Reset()
- {
- SetHeaderRecord(SQL_RESULT_ERROR);
-
- statusRecords.clear();
- }
-
- SqlResult DiagnosticRecordStorage::GetOperaionResult() const
- {
- return result;
- }
-
- int DiagnosticRecordStorage::GetReturnCode() const
- {
- return SqlResultToReturnCode(result);
- }
-
- int64_t DiagnosticRecordStorage::GetRowCount() const
- {
- return rowCount;
- }
-
- const std::string & DiagnosticRecordStorage::GetDynamicFunction() const
- {
- return dynamicFunction;
- }
-
- int32_t DiagnosticRecordStorage::GetDynamicFunctionCode() const
- {
- return dynamicFunctionCode;
- }
-
- int32_t DiagnosticRecordStorage::GetRowsAffected() const
- {
- return rowsAffected;
- }
-
- int32_t DiagnosticRecordStorage::GetStatusRecordsNumber() const
- {
- return static_cast<int32_t>(statusRecords.size());
- }
-
- const DiagnosticRecord& DiagnosticRecordStorage::GetStatusRecord(int32_t idx) const
- {
- return statusRecords[idx - 1];
- }
-
- bool DiagnosticRecordStorage::IsSuccessful() const
- {
- return result == SQL_RESULT_SUCCESS ||
- result == SQL_RESULT_SUCCESS_WITH_INFO;
- }
-
- SqlResult DiagnosticRecordStorage::GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const
- {
- // Header record.
- switch (field)
- {
- case IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT:
- {
- buffer.PutInt64(GetRowCount());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION:
- {
- buffer.PutString(GetDynamicFunction());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE:
- {
- buffer.PutInt32(GetDynamicFunctionCode());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_HEADER_NUMBER:
- {
- buffer.PutInt32(GetStatusRecordsNumber());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_HEADER_RETURNCODE:
- {
- buffer.PutInt32(GetReturnCode());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_HEADER_ROW_COUNT:
- {
- buffer.PutInt64(GetRowsAffected());
-
- return SQL_RESULT_SUCCESS;
- }
-
- default:
- break;
- }
-
- if (recNum < 1 || static_cast<size_t>(recNum) > statusRecords.size())
- return SQL_RESULT_NO_DATA;
-
- // Status record.
- const DiagnosticRecord& record = GetStatusRecord(recNum);
-
- switch (field)
- {
- case IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN:
- {
- buffer.PutString(record.GetClassOrigin());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER:
- {
- buffer.PutInt32(record.GetColumnNumber());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME:
- {
- buffer.PutString(record.GetConnectionName());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT:
- {
- buffer.PutString(record.GetMessage());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_NATIVE:
- {
- buffer.PutInt32(0);
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_ROW_NUMBER:
- {
- buffer.PutInt64(record.GetRowNumber());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_SERVER_NAME:
- {
- buffer.PutString(record.GetServerName());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_SQLSTATE:
- {
- buffer.PutString(record.GetSqlState());
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN:
- {
- buffer.PutString(record.GetSubclassOrigin());
-
- return SQL_RESULT_SUCCESS;
- }
-
- default:
- break;
- }
-
- return SQL_RESULT_ERROR;
- }
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp
deleted file mode 100644
index ba213ab..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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 "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/environment.h"
-
-namespace ignite
-{
- namespace odbc
- {
- Environment::Environment() :
- odbcVersion(SQL_OV_ODBC3), odbcNts(SQL_TRUE)
- {
- // No-op.
- }
-
- Environment::~Environment()
- {
- // No-op.
- }
-
- Connection* Environment::CreateConnection()
- {
- Connection* connection;
-
- IGNITE_ODBC_API_CALL(InternalCreateConnection(connection));
-
- return connection;
- }
-
- SqlResult Environment::InternalCreateConnection(Connection*& connection)
- {
- connection = new Connection;
-
- if (!connection)
- {
- AddStatusRecord(SQL_STATE_HY001_MEMORY_ALLOCATION, "Not enough memory.");
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- void Environment::TransactionCommit()
- {
- IGNITE_ODBC_API_CALL(InternalTransactionCommit());
- }
-
- SqlResult Environment::InternalTransactionCommit()
- {
- return SQL_RESULT_SUCCESS;
- }
-
- void Environment::TransactionRollback()
- {
- IGNITE_ODBC_API_CALL(InternalTransactionRollback());
- }
-
- SqlResult Environment::InternalTransactionRollback()
- {
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
- "Rollback operation is not supported.");
-
- return SQL_RESULT_ERROR;
- }
-
- void Environment::SetAttribute(int32_t attr, void* value, int32_t len)
- {
- IGNITE_ODBC_API_CALL(InternalSetAttribute(attr, value, len));
- }
-
- SqlResult Environment::InternalSetAttribute(int32_t attr, void* value, int32_t len)
- {
- EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr);
-
- switch (attribute)
- {
- case IGNITE_SQL_ENV_ATTR_ODBC_VERSION:
- {
- int32_t version = reinterpret_cast<int32_t>(value);
-
- if (version != odbcVersion)
- {
- AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED,
- "ODBC version is not supported.");
-
- return SQL_RESULT_SUCCESS_WITH_INFO;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS:
- {
- int32_t nts = reinterpret_cast<int32_t>(value);
-
- if (nts != odbcNts)
- {
- AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED,
- "Only null-termination of strings is supported.");
-
- return SQL_RESULT_SUCCESS_WITH_INFO;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_ENV_ATTR_UNKNOWN:
- default:
- break;
- }
-
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
- "Attribute is not supported.");
-
- return SQL_RESULT_ERROR;
- }
-
- void Environment::GetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer)
- {
- IGNITE_ODBC_API_CALL(InternalGetAttribute(attr, buffer));
- }
-
- SqlResult Environment::InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer)
- {
- EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr);
-
- switch (attribute)
- {
- case IGNITE_SQL_ENV_ATTR_ODBC_VERSION:
- {
- buffer.PutInt32(odbcVersion);
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS:
- {
- buffer.PutInt32(odbcNts);
-
- return SQL_RESULT_SUCCESS;
- }
-
- case IGNITE_SQL_ENV_ATTR_UNKNOWN:
- default:
- break;
- }
-
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
- "Attribute is not supported.");
-
- return SQL_RESULT_ERROR;
- }
- }
-}
-
[24/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
new file mode 100644
index 0000000..c92c7a5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
@@ -0,0 +1,198 @@
+/*
+ * 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_DIAGNOSTIC_RECORD_STORAGE
+#define _IGNITE_ODBC_DRIVER_DIAGNOSTIC_RECORD_STORAGE
+
+#include <stdint.h>
+
+#include <vector>
+
+#include <ignite/common/common.h>
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/app/application_data_buffer.h"
+#include "ignite/odbc/diagnostic/diagnostic_record.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ /**
+ * Diagnostic record.
+ *
+ * Associated with each environment, connection, statement, and
+ * descriptor handle are diagnostic records. These records contain
+ * diagnostic information about the last function called that used
+ * a particular handle. The records are replaced only when another
+ * function is called using that handle. There is no limit to the
+ * number of diagnostic records that can be stored at any one time.
+ *
+ * This class provides interface for interaction with all handle
+ * diagnostic records. That means both header and status records.
+ */
+ class DiagnosticRecordStorage
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ DiagnosticRecordStorage();
+
+ /**
+ * Destructor.
+ */
+ ~DiagnosticRecordStorage();
+
+ /**
+ * Set header record values.
+ *
+ * @param retCode Operation return code.
+ */
+ void SetHeaderRecord(SqlResult result);
+
+ /**
+ * Add status record to diagnostic records.
+ *
+ * @param record Status record.
+ */
+ void AddStatusRecord(const DiagnosticRecord& record);
+
+ /**
+ * Reset diagnostic records state.
+ */
+ void Reset();
+
+ /**
+ * Get result of the last operation.
+ *
+ * @return Result of the last operation.
+ */
+ SqlResult GetOperaionResult() const;
+
+ /**
+ * Get return code of the last operation.
+ *
+ * @return Return code of the last operation.
+ */
+ int GetReturnCode() const;
+
+ /**
+ * Get row count.
+ *
+ * @return Count of rows in cursor.
+ */
+ int64_t GetRowCount() const;
+
+ /**
+ * Get dynamic function.
+ *
+ * @return String that describes the SQL statement
+ * that the underlying function executed.
+ */
+ const std::string& GetDynamicFunction() const;
+
+ /**
+ * Get dynamic function code.
+ *
+ * @return Numeric code that describes the
+ * SQL statement that was executed.
+ */
+ int32_t GetDynamicFunctionCode() const;
+
+ /**
+ * Get number of rows affected.
+ *
+ * @return The number of rows affected by an insert,
+ * delete, or update performed by the last operation.
+ */
+ int32_t GetRowsAffected() const;
+
+ /**
+ * Get status records number.
+ *
+ * @return Number of status records.
+ */
+ int32_t GetStatusRecordsNumber() const;
+
+ /**
+ * Get specified status record.
+ *
+ * @param idx Status record index.
+ * @return Status record instance reference.
+ */
+ const DiagnosticRecord& GetStatusRecord(int32_t idx) const;
+
+ /**
+ * Check if the record is in the success state.
+ *
+ * @return True if the record is in the success state.
+ */
+ bool IsSuccessful() const;
+
+ /**
+ * Get value of the field and put it in buffer.
+ *
+ * @param recNum Diagnostic record number.
+ * @param field Record field.
+ * @param buffer Buffer to put data to.
+ * @return Operation result.
+ */
+ SqlResult GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(DiagnosticRecordStorage);
+
+ /**
+ * Header record field. This field contains the count of rows
+ * in the cursor.
+ */
+ int64_t rowCount;
+
+ /**
+ * Header record field. String that describes the SQL statement
+ * that the underlying function executed.
+ */
+ std::string dynamicFunction;
+
+ /**
+ * Header record field. Numeric code that describes the
+ * SQL statement that was executed.
+ */
+ int32_t dynamicFunctionCode;
+
+ /**
+ * Operation result. This field is mapped to "Return code" header
+ * record field.
+ */
+ SqlResult result;
+
+ /**
+ * Header record field. The number of rows affected by an insert,
+ * delete, or update performed by the last operation.
+ */
+ int32_t rowsAffected;
+
+ /** Status records. */
+ std::vector<DiagnosticRecord> statusRecords;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h b/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h
new file mode 100644
index 0000000..7168aa3
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h
@@ -0,0 +1,137 @@
+/*
+ * 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_ENVIRONMENT
+#define _IGNITE_ODBC_DRIVER_ENVIRONMENT
+
+#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ class Connection;
+
+ /**
+ * ODBC environment.
+ */
+ class Environment : public diagnostic::DiagnosableAdapter
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Environment();
+
+ /**
+ * Destructor.
+ */
+ ~Environment();
+
+ /**
+ * Create connection associated with the environment.
+ *
+ * @return Pointer to valid instance on success or NULL on failure.
+ */
+ Connection* CreateConnection();
+
+ /**
+ * Perform transaction commit on all the associated connections.
+ */
+ void TransactionCommit();
+
+ /**
+ * Perform transaction rollback on all the associated connections.
+ */
+ void TransactionRollback();
+
+ /**
+ * Set attribute.
+ *
+ * @param attr Attribute to set.
+ * @param value Value.
+ * @param len Value length if the attribute is of string type.
+ */
+ void SetAttribute(int32_t attr, void* value, int32_t len);
+
+ /**
+ * Get attribute.
+ *
+ * @param attr Attribute to set.
+ * @param buffer Buffer to put value to.
+ */
+ void GetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer);
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Environment);
+
+ /**
+ * Create connection associated with the environment.
+ * Internal call.
+ *
+ * @return Pointer to valid instance on success or NULL on failure.
+ * @return Operation result.
+ */
+ SqlResult InternalCreateConnection(Connection*& connection);
+
+ /**
+ * Perform transaction commit on all the associated connections.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalTransactionCommit();
+
+ /**
+ * Perform transaction rollback on all the associated connections.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalTransactionRollback();
+
+ /**
+ * Set attribute.
+ * Internal call.
+ *
+ * @param attr Attribute to set.
+ * @param value Value.
+ * @param len Value length if the attribute is of string type.
+ * @return Operation result.
+ */
+ SqlResult InternalSetAttribute(int32_t attr, void* value, int32_t len);
+
+ /**
+ * Get attribute.
+ * Internal call.
+ *
+ * @param attr Attribute to set.
+ * @param buffer Buffer to put value to.
+ * @return Operation result.
+ */
+ SqlResult InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer);
+
+ /** ODBC version. */
+ int32_t odbcVersion;
+
+ /** ODBC null-termintaion of string behaviour. */
+ int32_t odbcNts;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
new file mode 100644
index 0000000..f4d1e3c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
@@ -0,0 +1,630 @@
+/*
+ * 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_MESSAGE
+#define _IGNITE_ODBC_DRIVER_MESSAGE
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/result_page.h"
+#include "ignite/odbc/meta/column_meta.h"
+#include "ignite/odbc/meta/table_meta.h"
+#include "ignite/odbc/app/parameter.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ enum RequestType
+ {
+ REQUEST_TYPE_EXECUTE_SQL_QUERY = 1,
+
+ REQUEST_TYPE_FETCH_SQL_QUERY = 2,
+
+ REQUEST_TYPE_CLOSE_SQL_QUERY = 3,
+
+ REQUEST_TYPE_GET_COLUMNS_METADATA = 4,
+
+ REQUEST_TYPE_GET_TABLES_METADATA = 5
+ };
+
+ enum ResponseStatus
+ {
+ RESPONSE_STATUS_SUCCESS = 0,
+
+ RESPONSE_STATUS_FAILED = 1
+ };
+
+ /**
+ * Query execute request.
+ */
+ class QueryExecuteRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param cache Cache name.
+ * @param sql SQL query.
+ * @param argsNum Number of arguments.
+ */
+ QueryExecuteRequest(const std::string& cache, const std::string& sql,
+ const app::ParameterBindingMap& params) :
+ cache(cache), sql(sql), params(params)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryExecuteRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_EXECUTE_SQL_QUERY);
+ utility::WriteString(writer, cache);
+ utility::WriteString(writer, sql);
+
+ writer.WriteInt32(static_cast<int32_t>(params.size()));
+
+ app::ParameterBindingMap::const_iterator i;
+
+ for (i = params.begin(); i != params.end(); ++i)
+ i->second.Write(writer);
+ }
+
+ private:
+ /** Cache name. */
+ std::string cache;
+
+ /** SQL query. */
+ std::string sql;
+
+ /** Parameters bindings. */
+ const app::ParameterBindingMap& params;
+ };
+
+ /**
+ * Query close request.
+ */
+ class QueryCloseRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param queryId Query ID.
+ */
+ QueryCloseRequest(int64_t queryId) : queryId(queryId)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryCloseRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_CLOSE_SQL_QUERY);
+ writer.WriteInt64(queryId);
+ }
+
+ private:
+ /** Query ID. */
+ int64_t queryId;
+ };
+
+ /**
+ * Query fetch request.
+ */
+ class QueryFetchRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param queryId Query ID.
+ * @param pageSize Required page size.
+ */
+ QueryFetchRequest(int64_t queryId, int32_t pageSize) :
+ queryId(queryId), pageSize(pageSize)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryFetchRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_FETCH_SQL_QUERY);
+ writer.WriteInt64(queryId);
+ writer.WriteInt32(pageSize);
+ }
+
+ private:
+ /** Query ID. */
+ int64_t queryId;
+
+ /** SQL query. */
+ int32_t pageSize;
+ };
+
+ /**
+ * Query get columns metadata request.
+ */
+ class QueryGetColumnsMetaRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param column Column name.
+ */
+ QueryGetColumnsMetaRequest(const std::string& schema, const std::string& table, const std::string& column) :
+ schema(schema), table(table), column(column)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetColumnsMetaRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_GET_COLUMNS_METADATA);
+
+ utility::WriteString(writer, schema);
+ utility::WriteString(writer, table);
+ utility::WriteString(writer, column);
+ }
+
+ private:
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Column search pattern. */
+ std::string column;
+ };
+
+ /**
+ * Query get tables metadata request.
+ */
+ class QueryGetTablesMetaRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableTypes Table types search pattern.
+ */
+ QueryGetTablesMetaRequest(const std::string& catalog, const std::string& schema,
+ const std::string& table, const std::string& tableTypes) :
+ catalog(catalog), schema(schema), table(table), tableTypes(tableTypes)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetTablesMetaRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_GET_TABLES_METADATA);
+
+ utility::WriteString(writer, catalog);
+ utility::WriteString(writer, schema);
+ utility::WriteString(writer, table);
+ utility::WriteString(writer, tableTypes);
+ }
+
+ private:
+ /** Column search pattern. */
+ std::string catalog;
+
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Column search pattern. */
+ std::string tableTypes;
+ };
+
+ /**
+ * Query close response.
+ */
+ class QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryResponse() : status(RESPONSE_STATUS_FAILED), error()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ status = reader.ReadInt8();
+
+ if (status == RESPONSE_STATUS_SUCCESS)
+ {
+ ReadOnSuccess(reader);
+ }
+ else
+ {
+ int32_t errorLen = reader.ReadString(0, 0);
+ error.resize(errorLen);
+
+ reader.ReadString(&error[0], static_cast<int32_t>(error.size()));
+ }
+ }
+
+ /**
+ * Get request processing status.
+ * @return Status.
+ */
+ int8_t GetStatus() const
+ {
+ return status;
+ }
+
+ /**
+ * Get resulting error.
+ * @return Error.
+ */
+ const std::string& GetError() const
+ {
+ return error;
+ }
+
+ protected:
+ /**
+ * Read data if response status is RESPONSE_STATUS_SUCCESS.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader) = 0;
+
+ private:
+ /** Request processing status. */
+ int8_t status;
+
+ /** Error message. */
+ std::string error;
+ };
+
+
+ /**
+ * Query close response.
+ */
+ class QueryCloseResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryCloseResponse() : queryId(0)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryCloseResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ queryId = reader.ReadInt64();
+ }
+
+ /** Query ID. */
+ int64_t queryId;
+ };
+
+ /**
+ * Query execute response.
+ */
+ class QueryExecuteResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryExecuteResponse() : queryId(0), meta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryExecuteResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ /**
+ * Get column metadata.
+ * @return Column metadata.
+ */
+ const meta::ColumnMetaVector& GetMeta() const
+ {
+ return meta;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ queryId = reader.ReadInt64();
+
+ meta::ReadColumnMetaVector(reader, meta);
+ }
+
+ /** Query ID. */
+ int64_t queryId;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector meta;
+ };
+
+ /**
+ * Query fetch response.
+ */
+ class QueryFetchResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ * @param resultPage Result page.
+ */
+ QueryFetchResponse(ResultPage& resultPage) : queryId(0), resultPage(resultPage)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryFetchResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ queryId = reader.ReadInt64();
+
+ resultPage.Read(reader);
+ }
+
+ /** Query ID. */
+ int64_t queryId;
+
+ /** Result page. */
+ ResultPage& resultPage;
+ };
+
+ /**
+ * Query get column metadata response.
+ */
+ class QueryGetColumnsMetaResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryGetColumnsMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetColumnsMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get column metadata.
+ * @return Column metadata.
+ */
+ const meta::ColumnMetaVector& GetMeta() const
+ {
+ return meta;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ meta::ReadColumnMetaVector(reader, meta);
+ }
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector meta;
+ };
+
+ /**
+ * Query get table metadata response.
+ */
+ class QueryGetTablesMetaResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryGetTablesMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetTablesMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get column metadata.
+ * @return Column metadata.
+ */
+ const meta::TableMetaVector& GetMeta() const
+ {
+ return meta;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ meta::ReadTableMetaVector(reader, meta);
+ }
+
+ /** Columns metadata. */
+ meta::TableMetaVector meta;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h
new file mode 100644
index 0000000..9bc7227
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h
@@ -0,0 +1,210 @@
+/*
+ * 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_COLUMN_META
+#define _IGNITE_ODBC_COLUMN_META
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ /**
+ * Column metadata.
+ */
+ class ColumnMeta
+ {
+ public:
+#ifdef ODBC_DEBUG
+ /**
+ * Convert attribute ID to string containing its name.
+ * Debug function.
+ * @param type Attribute ID.
+ * @return Null-terminated string containing attribute name.
+ */
+ static const char* AttrIdToString(uint16_t id);
+#endif
+
+ /**
+ * Default constructor.
+ */
+ ColumnMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param schemaName Schema name.
+ * @param tableName Table name.
+ * @param columnName Column name.
+ * @param typeName Type name.
+ * @param dataType Data type.
+ */
+ ColumnMeta(const std::string& schemaName, const std::string& tableName,
+ const std::string& columnName, const std::string& typeName, int8_t dataType) :
+ schemaName(schemaName), tableName(tableName), columnName(columnName),
+ typeName(typeName), dataType(dataType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~ColumnMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ */
+ ColumnMeta(const ColumnMeta& other) :
+ schemaName(other.schemaName),
+ tableName(other.tableName),
+ columnName(other.columnName),
+ typeName(other.typeName),
+ dataType(other.dataType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy operator.
+ */
+ ColumnMeta& operator=(const ColumnMeta& other)
+ {
+ schemaName = other.schemaName;
+ tableName = other.tableName;
+ columnName = other.columnName;
+ typeName = other.typeName;
+ dataType = other.dataType;
+
+ return *this;
+ }
+
+ /**
+ * Read using reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader);
+
+ /**
+ * Get schema name.
+ * @return Schema name.
+ */
+ const std::string& GetSchemaName() const
+ {
+ return schemaName;
+ }
+
+ /**
+ * Get table name.
+ * @return Table name.
+ */
+ const std::string& GetTableName() const
+ {
+ return tableName;
+ }
+
+ /**
+ * Get column name.
+ * @return Column name.
+ */
+ const std::string& GetColumnName() const
+ {
+ return columnName;
+ }
+
+ /**
+ * Get column type name.
+ * @return Column type name.
+ */
+ const std::string& GetColumnTypeName() const
+ {
+ return typeName;
+ }
+
+ /**
+ * Get data type.
+ * @return Data type.
+ */
+ int8_t GetDataType() const
+ {
+ return dataType;
+ }
+
+ /**
+ * Try to get attribute of a string type.
+ *
+ * @param fieldId Field ID.
+ * @param value Output attribute value.
+ * @return True if the attribute supported and false otherwise.
+ */
+ bool GetAttribute(uint16_t fieldId, std::string& value) const;
+
+ /**
+ * Try to get attribute of a integer type.
+ *
+ * @param fieldId Field ID.
+ * @param value Output attribute value.
+ * @return True if the attribute supported and false otherwise.
+ */
+ bool GetAttribute(uint16_t fieldId, SqlLen& value) const;
+
+ private:
+ /** Schema name. */
+ std::string schemaName;
+
+ /** Table name. */
+ std::string tableName;
+
+ /** Column name. */
+ std::string columnName;
+
+ /** Type name. */
+ std::string typeName;
+
+ /** Data type. */
+ int8_t dataType;
+ };
+
+ /** Column metadata vector alias. */
+ typedef std::vector<ColumnMeta> ColumnMetaVector;
+
+ /**
+ * Read columns metadata collection.
+ * @param reader Reader.
+ * @param meta Collection.
+ */
+ void ReadColumnMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, ColumnMetaVector& meta);
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h
new file mode 100644
index 0000000..e479e10
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h
@@ -0,0 +1,188 @@
+/*
+ * 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_PRIMARY_KEY_META
+#define _IGNITE_ODBC_PRIMARY_KEY_META
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ /**
+ * Primary key metadata.
+ */
+ class PrimaryKeyMeta
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ PrimaryKeyMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param column Column name.
+ * @param keySeq Column sequence number in key (starting with 1).
+ * @param keyName Key name.
+ */
+ PrimaryKeyMeta(const std::string& catalog, const std::string& schema,
+ const std::string& table, const std::string& column, int16_t keySeq,
+ const std::string& keyName) :
+ catalog(catalog),
+ schema(schema),
+ table(table),
+ column(column),
+ keySeq(keySeq),
+ keyName(keyName)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~PrimaryKeyMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ */
+ PrimaryKeyMeta(const PrimaryKeyMeta& other) :
+ catalog(other.catalog),
+ schema(other.schema),
+ table(other.table),
+ column(other.column),
+ keySeq(other.keySeq),
+ keyName(other.keyName)
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy operator.
+ */
+ PrimaryKeyMeta& operator=(const PrimaryKeyMeta& other)
+ {
+ catalog = other.catalog;
+ schema = other.schema;
+ table = other.table;
+ column = other.column;
+ keySeq = other.keySeq;
+ keyName = other.keyName;
+
+ return *this;
+ }
+
+ /**
+ * Get catalog name.
+ * @return Catalog name.
+ */
+ const std::string& GetCatalogName() const
+ {
+ return catalog;
+ }
+
+ /**
+ * Get schema name.
+ * @return Schema name.
+ */
+ const std::string& GetSchemaName() const
+ {
+ return schema;
+ }
+
+ /**
+ * Get table name.
+ * @return Table name.
+ */
+ const std::string& GetTableName() const
+ {
+ return table;
+ }
+
+ /**
+ * Get column name.
+ * @return Column name.
+ */
+ const std::string& GetColumnName() const
+ {
+ return table;
+ }
+
+ /**
+ * Get column sequence number in key.
+ * @return Sequence number in key.
+ */
+ int16_t GetKeySeq() const
+ {
+ return keySeq;
+ }
+
+ /**
+ * Get key name.
+ * @return Key name.
+ */
+ const std::string& GetKeyName() const
+ {
+ return keyName;
+ }
+
+ private:
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Collumn name. */
+ std::string column;
+
+ /** Column sequence number in key. */
+ int16_t keySeq;
+
+ /** Key name. */
+ std::string keyName;
+ };
+
+ /** Table metadata vector alias. */
+ typedef std::vector<PrimaryKeyMeta> PrimaryKeyMetaVector;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h
new file mode 100644
index 0000000..0618217
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h
@@ -0,0 +1,166 @@
+/*
+ * 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_TABLE_META
+#define _IGNITE_ODBC_TABLE_META
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ /**
+ * Table metadata.
+ */
+ class TableMeta
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ TableMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param catalogName Catalog name.
+ * @param schemaName Schema name.
+ * @param tableName Table name.
+ * @param tableType Table type.
+ */
+ TableMeta(const std::string& catalogName, const std::string& schemaName,
+ const std::string& tableName, const std::string& tableType) :
+ catalogName(catalogName), schemaName(schemaName), tableName(tableName),
+ tableType(tableType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~TableMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ */
+ TableMeta(const TableMeta& other) :
+ catalogName(other.catalogName),
+ schemaName(other.schemaName),
+ tableName(other.tableName),
+ tableType(other.tableType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy operator.
+ */
+ TableMeta& operator=(const TableMeta& other)
+ {
+ catalogName = other.catalogName;
+ schemaName = other.schemaName;
+ tableName = other.tableName;
+ tableType = other.tableType;
+
+ return *this;
+ }
+
+ /**
+ * Read using reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader);
+
+ /**
+ * Get catalog name.
+ * @return Catalog name.
+ */
+ const std::string& GetCatalogName() const
+ {
+ return catalogName;
+ }
+
+ /**
+ * Get schema name.
+ * @return Schema name.
+ */
+ const std::string& GetSchemaName() const
+ {
+ return schemaName;
+ }
+
+ /**
+ * Get table name.
+ * @return Table name.
+ */
+ const std::string& GetTableName() const
+ {
+ return tableName;
+ }
+
+ /**
+ * Get table type.
+ * @return Table type.
+ */
+ const std::string& GetTableType() const
+ {
+ return tableType;
+ }
+
+ private:
+ /** Catalog name. */
+ std::string catalogName;
+
+ /** Schema name. */
+ std::string schemaName;
+
+ /** Table name. */
+ std::string tableName;
+
+ /** Table type. */
+ std::string tableType;
+ };
+
+ /** Table metadata vector alias. */
+ typedef std::vector<TableMeta> TableMetaVector;
+
+ /**
+ * Read tables metadata collection.
+ * @param reader Reader.
+ * @param meta Collection.
+ */
+ void ReadTableMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, TableMetaVector& meta);
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
new file mode 100644
index 0000000..8b8f277
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
@@ -0,0 +1,141 @@
+/*
+ * 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_PARSER
+#define _IGNITE_ODBC_DRIVER_PARSER
+
+#include <stdint.h>
+
+#include <vector>
+
+#include <ignite/impl/interop/interop_output_stream.h>
+#include <ignite/impl/interop/interop_input_stream.h>
+#include <ignite/impl/binary/binary_writer_impl.h>
+#include <ignite/impl/binary/binary_reader_impl.h>
+
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Message parser.
+ */
+ class Parser
+ {
+ public:
+ /** Default initial size of operational memory. */
+ enum { DEFAULT_MEM_ALLOCATION = 4096 };
+
+ /**
+ * Constructor.
+ */
+ Parser(int32_t cap = DEFAULT_MEM_ALLOCATION) : inMem(cap), outMem(cap), outStream(&outMem)
+ {
+ //No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~Parser()
+ {
+ //No-op.
+ }
+
+ /**
+ * Encode message and place encoded data in buffer.
+ *
+ * @param msg Message to encode.
+ * @param buf Data buffer.
+ */
+ template<typename MsgT>
+ void Encode(const MsgT& msg, std::vector<int8_t>& buf)
+ {
+ using namespace ignite::impl::binary;
+
+ ResetState();
+
+ BinaryWriterImpl writer(&outStream, 0);
+
+ int32_t msgLenPos = outStream.Reserve(4);
+
+ msg.Write(writer);
+
+ outStream.WriteInt32(msgLenPos, outStream.Position() - 4);
+
+ buf.resize(outStream.Position());
+
+ memcpy(&buf[0], outMem.Data(), outStream.Position());
+ }
+
+ /**
+ * Decode message from data in buffer.
+ *
+ * @param msg Message to decode.
+ * @param buf Data buffer.
+ * @note Can be optimized after InteropMemory refactoring.
+ */
+ template<typename MsgT>
+ void Decode(MsgT& msg, const std::vector<int8_t>& buf)
+ {
+ using namespace ignite::impl::binary;
+
+ //for (size_t i = 0; i < buf.size(); ++i)
+ // LOG_MSG("Data[%0.4d] : %0.3d, %c\n", i, (int)buf[i], buf[i] > 64 && buf[i] < 128 ? buf[i] : '.');
+
+ if (inMem.Capacity() < static_cast<int32_t>(buf.size()))
+ inMem.Reallocate(static_cast<int32_t>(buf.size()));
+
+ memcpy(inMem.Data(), buf.data(), buf.size());
+
+ inMem.Length(static_cast<int32_t>(buf.size()));
+
+ ignite::impl::interop::InteropInputStream inStream(&inMem);
+
+ BinaryReaderImpl reader(&inStream);
+
+ msg.Read(reader);
+ }
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Parser);
+
+ /**
+ * Reset internal state of the parser.
+ */
+ void ResetState()
+ {
+ outMem.Length(0);
+
+ outStream.Position(0);
+ }
+
+ /** Input operational memory. */
+ ignite::impl::interop::InteropUnpooledMemory inMem;
+
+ /** Output operational memory. */
+ ignite::impl::interop::InteropUnpooledMemory outMem;
+
+ /** Output stream. */
+ ignite::impl::interop::InteropOutputStream outStream;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h
new file mode 100644
index 0000000..378e95c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h
@@ -0,0 +1,146 @@
+/*
+ * 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_COLUMN_METADATA_QUERY
+#define _IGNITE_ODBC_DRIVER_COLUMN_METADATA_QUERY
+
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/meta/column_meta.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Connection forward-declaration. */
+ class Connection;
+
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class ColumnMetadataQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Associated connection.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param column Column search pattern.
+ */
+ ColumnMetadataQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& schema,
+ const std::string& table, const std::string& column);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ColumnMetadataQuery();
+
+ /**
+ * 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);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * 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(ColumnMetadataQuery);
+
+ /**
+ * Make get columns metadata requets and use response to set internal state.
+ *
+ * @return Operation result.
+ */
+ SqlResult MakeRequestGetColumnsMeta();
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Column search pattern. */
+ std::string column;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Fetched metadata. */
+ meta::ColumnMetaVector meta;
+
+ /** Metadata cursor. */
+ meta::ColumnMetaVector::iterator cursor;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
new file mode 100644
index 0000000..88550d0
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
@@ -0,0 +1,152 @@
+/*
+ * 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_DATA_QUERY
+#define _IGNITE_ODBC_DRIVER_DATA_QUERY
+
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/app/parameter.h"
+#include "ignite/odbc/cursor.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Connection forward-declaration. */
+ class Connection;
+
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class DataQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Associated connection.
+ * @param sql SQL query string.
+ * @param params SQL params.
+ */
+ DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
+ const std::string& sql, const app::ParameterBindingMap& params);
+
+ /**
+ * Destructor.
+ */
+ virtual ~DataQuery();
+
+ /**
+ * 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.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * 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(DataQuery);
+
+ /**
+ * Make query execute request and use response to set internal
+ * state.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestExecute();
+
+ /**
+ * Make query close request.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestClose();
+
+ /**
+ * Make data fetch request and use response to set internal state.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestFetch();
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** SQL Query. */
+ std::string sql;
+
+ /** Parameter bindings. */
+ const app::ParameterBindingMap& params;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector resultMeta;
+
+ /** Cursor. */
+ std::auto_ptr<Cursor> cursor;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h
new file mode 100644
index 0000000..abd13bc
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h
@@ -0,0 +1,143 @@
+/*
+ * 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_FOREIGN_KEYS_QUERY
+#define _IGNITE_ODBC_DRIVER_FOREIGN_KEYS_QUERY
+
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/query/query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Foreign keys query.
+ */
+ class ForeignKeysQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Statement-associated connection.
+ * @param primaryCatalog Primary key catalog name.
+ * @param primarySchema Primary key schema name.
+ * @param primaryTable Primary key table name.
+ * @param foreignCatalog Foreign key catalog name.
+ * @param foreignSchema Foreign key schema name.
+ * @param foreignTable Foreign key table name.
+ */
+ ForeignKeysQuery(diagnostic::Diagnosable& diag, Connection& connection,
+ const std::string& primaryCatalog, const std::string& primarySchema,
+ const std::string& primaryTable, const std::string& foreignCatalog,
+ const std::string& foreignSchema, const std::string& foreignTable);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ForeignKeysQuery();
+
+ /**
+ * 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);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * 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(ForeignKeysQuery);
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Primary key catalog name. */
+ std::string primaryCatalog;
+
+ /** Primary key schema name. */
+ std::string primarySchema;
+
+ /** Primary key table name. */
+ std::string primaryTable;
+
+ /** Foreign key catalog name. */
+ std::string foreignCatalog;
+
+ /** Foreign key schema name. */
+ std::string foreignSchema;
+
+ /** Foreign key table name. */
+ std::string foreignTable;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h
new file mode 100644
index 0000000..22e1359
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h
@@ -0,0 +1,137 @@
+/*
+ * 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_PRIMARY_KEYS_QUERY
+#define _IGNITE_ODBC_DRIVER_PRIMARY_KEYS_QUERY
+
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/meta/primary_key_meta.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Primary keys query.
+ */
+ class PrimaryKeysQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Statement-associated connection.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ */
+ PrimaryKeysQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& catalog,
+ const std::string& schema, const std::string& table);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PrimaryKeysQuery();
+
+ /**
+ * 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);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * 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(PrimaryKeysQuery);
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+
+ /** Primary keys metadata. */
+ meta::PrimaryKeyMetaVector meta;
+
+ /** Resultset cursor. */
+ meta::PrimaryKeyMetaVector::iterator cursor;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h
new file mode 100644
index 0000000..93da5c9
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h
@@ -0,0 +1,119 @@
+/*
+ * 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_QUERY
+#define _IGNITE_ODBC_DRIVER_QUERY
+
+#include <stdint.h>
+
+#include <map>
+
+#include "ignite/odbc/diagnostic/diagnosable.h"
+#include "ignite/odbc/meta/column_meta.h"
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/row.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class Query
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~Query()
+ {
+ // No-op.
+ }
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute() = 0;
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings) = 0;
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) = 0;
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close() = 0;
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const = 0;
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const = 0;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const = 0;
+
+ protected:
+ /**
+ * Constructor.
+ */
+ Query(diagnostic::Diagnosable& diag) :
+ diag(diag)
+ {
+ // No-op.
+ }
+
+ /** Diagnostics collector. */
+ diagnostic::Diagnosable& diag;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h
new file mode 100644
index 0000000..f5affad
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h
@@ -0,0 +1,142 @@
+/*
+ * 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_SPECIAL_COLUMNS_QUERY
+#define _IGNITE_ODBC_DRIVER_SPECIAL_COLUMNS_QUERY
+
+#include "ignite/odbc/query/query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Special columns query.
+ */
+ class SpecialColumnsQuery : public Query
+ {
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param scope Minimum required scope of the rowid.
+ * @param nullable Determines whether to return special columns
+ * that can have a NULL value.
+ */
+ SpecialColumnsQuery(diagnostic::Diagnosable& diag, int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable);
+
+ /**
+ * Destructor.
+ */
+ virtual ~SpecialColumnsQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * 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(SpecialColumnsQuery);
+
+ /** Query type. */
+ int16_t type;
+
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Minimum required scope of the rowid. */
+ int16_t scope;
+
+ /**
+ * Determines whether to return special columns that can have
+ * a NULL value.
+ */
+ int16_t nullable;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
[05/28] ignite git commit: IGNITE-2447: Moved all ODBC classes into
org.apache.ignite.internal.processors.odbc package.
Posted by vo...@apache.org.
IGNITE-2447: Moved all ODBC classes into
org.apache.ignite.internal.processors.odbc package.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2a756311
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2a756311
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2a756311
Branch: refs/heads/ignite-1786
Commit: 2a756311134e971fbfbc671f2b53090cae1085ad
Parents: 9baf266
Author: isapego <is...@gridgain.com>
Authored: Mon Jan 25 18:23:20 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Mon Jan 25 18:23:20 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/OdbcCommandHandler.java | 4 +-
.../internal/processors/odbc/OdbcParser.java | 341 ++++++++++++++++++
.../internal/processors/odbc/OdbcProcessor.java | 3 -
.../processors/odbc/OdbcProtocolHandler.java | 2 -
.../processors/odbc/OdbcQueryCloseRequest.java | 47 +++
.../processors/odbc/OdbcQueryCloseResult.java | 39 +++
.../odbc/OdbcQueryExecuteRequest.java | 85 +++++
.../processors/odbc/OdbcQueryExecuteResult.java | 55 +++
.../processors/odbc/OdbcQueryFetchRequest.java | 66 ++++
.../processors/odbc/OdbcQueryFetchResult.java | 75 ++++
.../odbc/OdbcQueryGetColumnsMetaRequest.java | 84 +++++
.../odbc/OdbcQueryGetColumnsMetaResult.java | 43 +++
.../odbc/OdbcQueryGetTablesMetaRequest.java | 105 ++++++
.../odbc/OdbcQueryGetTablesMetaResult.java | 43 +++
.../internal/processors/odbc/OdbcRequest.java | 61 ++++
.../internal/processors/odbc/OdbcResponse.java | 107 ++++++
.../processors/odbc/OdbcTcpNioListener.java | 99 ++++++
.../internal/processors/odbc/OdbcTcpServer.java | 189 ++++++++++
.../processors/odbc/protocol/OdbcParser.java | 345 -------------------
.../odbc/protocol/OdbcTcpNioListener.java | 102 ------
.../processors/odbc/protocol/OdbcTcpServer.java | 191 ----------
.../odbc/request/OdbcQueryCloseRequest.java | 47 ---
.../odbc/request/OdbcQueryExecuteRequest.java | 85 -----
.../odbc/request/OdbcQueryFetchRequest.java | 66 ----
.../request/OdbcQueryGetColumnsMetaRequest.java | 84 -----
.../request/OdbcQueryGetTablesMetaRequest.java | 105 ------
.../processors/odbc/request/OdbcRequest.java | 61 ----
.../odbc/response/OdbcQueryCloseResult.java | 39 ---
.../odbc/response/OdbcQueryExecuteResult.java | 55 ---
.../odbc/response/OdbcQueryFetchResult.java | 75 ----
.../response/OdbcQueryGetColumnsMetaResult.java | 43 ---
.../response/OdbcQueryGetTablesMetaResult.java | 43 ---
.../processors/odbc/response/OdbcResponse.java | 107 ------
33 files changed, 1440 insertions(+), 1456 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
index d8a05f7..9e56888 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
@@ -22,8 +22,6 @@ import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.odbc.request.*;
-import org.apache.ignite.internal.processors.odbc.response.*;
import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -32,7 +30,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import static org.apache.ignite.internal.processors.odbc.request.OdbcRequest.*;
+import static org.apache.ignite.internal.processors.odbc.OdbcRequest.*;
/**
* SQL query handler.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
new file mode 100644
index 0000000..ead6d3b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
@@ -0,0 +1,341 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.binary.*;
+import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.util.nio.GridNioParser;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+
+
+/**
+ * ODBC protocol parser.
+ */
+public class OdbcParser implements GridNioParser {
+ /** Initial output stream capacity. */
+ private static final int INIT_CAP = 1024;
+
+ /** Length in bytes of the remaining message part. */
+ int leftToReceive = 0;
+
+ /** Already received bytes of current message. */
+ ByteBuffer currentMessage = null;
+
+ /** Context. */
+ protected final GridKernalContext ctx;
+
+ /** Marshaller. */
+ private final GridBinaryMarshaller marsh;
+
+ OdbcParser(GridKernalContext context) {
+ ctx = context;
+
+ CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
+
+ marsh = cacheObjProc.marshaller();
+ }
+
+ /**
+ * Process data chunk and try to construct new message using stored and freshly received data.
+ * @param buf Fresh data buffer.
+ * @return Instance of the {@link BinaryReaderExImpl} positioned to read from the beginning of the message on
+ * success and null otherwise.
+ */
+ private BinaryRawReaderEx tryConstructMessage(ByteBuffer buf) {
+ if (leftToReceive != 0) {
+ // Still receiving message
+ int toConsume = Math.min(leftToReceive, buf.remaining());
+
+ currentMessage.put(buf.array(), buf.arrayOffset(), toConsume);
+ leftToReceive -= toConsume;
+
+ buf.position(buf.position() + toConsume);
+
+ if (leftToReceive != 0)
+ return null;
+
+ BinaryInputStream stream = new BinaryHeapInputStream(currentMessage.array());
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
+
+ currentMessage = null;
+
+ return reader;
+ }
+
+ // Receiving new message
+ // Getting message length. It's in the first four bytes of the message.
+ BinaryInputStream stream = new BinaryHeapInputStream(buf.array());
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
+
+ int messageLen = reader.readInt();
+ buf.getInt();
+
+ int remaining = buf.remaining();
+
+ if (messageLen > remaining) {
+ leftToReceive = messageLen - remaining;
+
+ currentMessage = ByteBuffer.allocate(messageLen);
+ currentMessage.put(buf);
+
+ return null;
+ }
+
+ buf.position(buf.position() + messageLen);
+
+ return reader;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public OdbcRequest decode(GridNioSession ses, ByteBuffer buf) throws IOException,
+ IgniteCheckedException {
+ BinaryRawReaderEx messageReader = tryConstructMessage(buf);
+
+ return messageReader == null ? null : readRequest(ses, messageReader);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
+ assert msg != null;
+ assert msg instanceof OdbcResponse;
+
+ System.out.println("Encoding query processing result");
+
+ BinaryRawWriterEx writer = marsh.writer(new BinaryHeapOutputStream(INIT_CAP));
+
+ // Reserving space for the message length.
+ int msgLenPos = writer.reserveInt();
+
+ writeResponse(ses, writer, (OdbcResponse)msg);
+
+ int msgLenWithHdr = writer.out().position() - msgLenPos;
+
+ int msgLen = msgLenWithHdr - 4;
+
+ writer.writeInt(msgLenPos, msgLen);
+
+ ByteBuffer buf = ByteBuffer.allocate(msgLenWithHdr);
+
+ buf.put(writer.out().array(), msgLenPos, msgLenWithHdr);
+
+ buf.flip();
+
+ return buf;
+ }
+
+ /**
+ * Read ODBC request from the raw data using provided {@link BinaryReaderExImpl} instance.
+ * @param ses Current session.
+ * @param reader Reader positioned to read the request.
+ * @return Instance of the {@link OdbcRequest}.
+ * @throws IOException if the type of the request is unknown to the parser.
+ */
+ private OdbcRequest readRequest(GridNioSession ses, BinaryRawReaderEx reader) throws IOException {
+ OdbcRequest res;
+
+ byte cmd = reader.readByte();
+
+ switch (cmd) {
+ case OdbcRequest.EXECUTE_SQL_QUERY: {
+ String cache = reader.readString();
+ String sql = reader.readString();
+ int argsNum = reader.readInt();
+
+ System.out.println("Message EXECUTE_SQL_QUERY:");
+ System.out.println("cache: " + cache);
+ System.out.println("query: " + sql);
+ System.out.println("argsNum: " + argsNum);
+
+ Object[] params = new Object[argsNum];
+
+ for (int i = 0; i < argsNum; ++i)
+ params[i] = reader.readObjectDetached();
+
+ res = new OdbcQueryExecuteRequest(cache, sql, params);
+ break;
+ }
+
+ case OdbcRequest.FETCH_SQL_QUERY: {
+ long queryId = reader.readLong();
+ int pageSize = reader.readInt();
+
+ System.out.println("Message FETCH_SQL_QUERY:");
+ System.out.println("queryId: " + queryId);
+ System.out.println("pageSize: " + pageSize);
+
+ res = new OdbcQueryFetchRequest(queryId, pageSize);
+ break;
+ }
+
+ case OdbcRequest.CLOSE_SQL_QUERY: {
+ long queryId = reader.readLong();
+
+ System.out.println("Message CLOSE_SQL_QUERY:");
+ System.out.println("queryId: " + queryId);
+
+ res = new OdbcQueryCloseRequest(queryId);
+ break;
+ }
+
+ case OdbcRequest.GET_COLUMNS_META: {
+ String cache = reader.readString();
+ String table = reader.readString();
+ String column = reader.readString();
+
+ System.out.println("Message GET_COLUMNS_META:");
+ System.out.println("cache: " + cache);
+ System.out.println("table: " + table);
+ System.out.println("column: " + column);
+
+ res = new OdbcQueryGetColumnsMetaRequest(cache, table, column);
+ break;
+ }
+
+ case OdbcRequest.GET_TABLES_META: {
+ String catalog = reader.readString();
+ String schema = reader.readString();
+ String table = reader.readString();
+ String tableType = reader.readString();
+
+ System.out.println("Message GET_COLUMNS_META:");
+ System.out.println("catalog: " + catalog);
+ System.out.println("schema: " + schema);
+ System.out.println("table: " + table);
+ System.out.println("tableType: " + tableType);
+
+ res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
+ break;
+ }
+
+ default:
+ throw new IOException("Failed to parse incoming packet (unknown command type) [ses=" + ses +
+ ", cmd=[" + Byte.toString(cmd) + ']');
+ }
+
+ return res;
+ }
+
+ /**
+ * Write ODBC response using provided {@link BinaryRawWriterEx} instance.
+ * @param ses Current session.
+ * @param writer Writer.
+ * @param rsp ODBC response that should be written.
+ * @throws IOException if the type of the response is unknown to the parser.
+ */
+ private void writeResponse(GridNioSession ses, BinaryRawWriterEx writer, OdbcResponse rsp) throws IOException {
+ // Writing status
+ writer.writeByte((byte)rsp.getSuccessStatus());
+
+ if (rsp.getSuccessStatus() != OdbcResponse.STATUS_SUCCESS) {
+ writer.writeString(rsp.getError());
+
+ return;
+ }
+
+ Object res0 = rsp.getResponse();
+
+ if (res0 instanceof OdbcQueryExecuteResult) {
+ OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0;
+
+ System.out.println("Resulting query ID: " + res.getQueryId());
+
+ writer.writeLong(res.getQueryId());
+
+ Collection<OdbcColumnMeta> metas = res.getColumnsMetadata();
+
+ assert metas != null;
+
+ writer.writeInt(metas.size());
+
+ for (OdbcColumnMeta meta : metas)
+ meta.writeBinary(writer, marsh.context());
+
+ } else if (res0 instanceof OdbcQueryFetchResult) {
+ OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0;
+
+ System.out.println("Resulting query ID: " + res.getQueryId());
+
+ writer.writeLong(res.getQueryId());
+
+ Collection<?> items0 = res.getItems();
+
+ assert items0 != null;
+
+ Collection<Collection<Object>> items = (Collection<Collection<Object>>)items0;
+
+ writer.writeBoolean(res.getLast());
+
+ writer.writeInt(items.size());
+
+ for (Collection<Object> row : items) {
+ if (row != null) {
+ writer.writeInt(row.size());
+
+ for (Object obj : row) {
+ if (obj != null)
+ writer.writeObjectDetached(obj);
+ }
+ }
+ }
+ } else if (res0 instanceof OdbcQueryCloseResult) {
+ OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0;
+
+ System.out.println("Resulting query ID: " + res.getQueryId());
+
+ writer.writeLong(res.getQueryId());
+
+ } else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
+ OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0;
+
+ Collection<OdbcColumnMeta> columnsMeta = res.getMeta();
+
+ assert columnsMeta != null;
+
+ writer.writeInt(columnsMeta.size());
+
+ for (OdbcColumnMeta columnMeta : columnsMeta)
+ columnMeta.writeBinary(writer, marsh.context());
+
+ } else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
+ OdbcQueryGetTablesMetaResult res = (OdbcQueryGetTablesMetaResult) res0;
+
+ Collection<OdbcTableMeta> tablesMeta = res.getMeta();
+
+ assert tablesMeta != null;
+
+ writer.writeInt(tablesMeta.size());
+
+ for (OdbcTableMeta tableMeta : tablesMeta)
+ tableMeta.writeBinary(writer);
+
+ } else {
+ throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
index a3f0b94..91b24a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
@@ -21,9 +21,6 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
-import org.apache.ignite.internal.processors.odbc.protocol.OdbcTcpServer;
-import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
-import org.apache.ignite.internal.processors.odbc.response.OdbcResponse;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.marshaller.Marshaller;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
index 9af002d..e1957d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
@@ -18,8 +18,6 @@ package org.apache.ignite.internal.processors.odbc;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
-import org.apache.ignite.internal.processors.odbc.response.OdbcResponse;
/**
* ODBC command protocol handler.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
new file mode 100644
index 0000000..e9b5698
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * ODBC query close request.
+ */
+public class OdbcQueryCloseRequest extends OdbcRequest {
+ /** Query ID. */
+ private long queryId;
+
+ /**
+ * @param queryId Query ID.
+ */
+ public OdbcQueryCloseRequest(long queryId) {
+ super(CLOSE_SQL_QUERY);
+ this.queryId = queryId;
+ }
+
+ /**
+ * @param queryId Query ID.
+ */
+ public void cacheName(long queryId) {
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long queryId() {
+ return queryId;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
new file mode 100644
index 0000000..cbc23c8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * Query result.
+ */
+public class OdbcQueryCloseResult {
+ /** Query ID. */
+ private long queryId;
+
+ /**
+ * @param queryId Query ID.
+ */
+ public OdbcQueryCloseResult(long queryId){
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long getQueryId() {
+ return queryId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
new file mode 100644
index 0000000..4628b52
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * ODBC query execute request.
+ */
+public class OdbcQueryExecuteRequest extends OdbcRequest {
+ /** Cache name. */
+ private String cacheName;
+
+ /** Sql query. */
+ private String sqlQry;
+
+ /** Sql query arguments. */
+ private Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param sqlQry SQL query.
+ * @param args Arguments list.
+ */
+ public OdbcQueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
+ super(EXECUTE_SQL_QUERY);
+ this.cacheName = cacheName;
+ this.sqlQry = sqlQry;
+ this.args = args;
+ }
+
+ /**
+ * @param sqlQry Sql query.
+ */
+ public void sqlQuery(String sqlQry) {
+ this.sqlQry = sqlQry;
+ }
+
+ /**
+ * @return Sql query.
+ */
+ public String sqlQuery() {
+ return sqlQry;
+ }
+
+ /**
+ * @param args Sql query arguments.
+ */
+ public void arguments(Object[] args) {
+ this.args = args;
+ }
+
+ /**
+ * @return Sql query arguments.
+ */
+ public Object[] arguments() {
+ return args;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public void cacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ public String cacheName() {
+ return cacheName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
new file mode 100644
index 0000000..a4dec54
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
+
+import java.util.Collection;
+
+/**
+ * Query execute result.
+ */
+public class OdbcQueryExecuteResult {
+ /** Query ID. */
+ private long queryId;
+
+ /** Fields metadata. */
+ private Collection<OdbcColumnMeta> columnsMeta;
+
+ /**
+ * @param queryId Query ID.
+ * @param columnsMeta Columns metadata.
+ */
+ public OdbcQueryExecuteResult(long queryId, Collection<OdbcColumnMeta> columnsMeta){
+ this.queryId = queryId;
+ this.columnsMeta = columnsMeta;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long getQueryId() {
+ return queryId;
+ }
+
+ /**
+ * @return Columns metadata.
+ */
+ public Collection<OdbcColumnMeta> getColumnsMetadata() {
+ return columnsMeta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
new file mode 100644
index 0000000..7609649
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * ODBC query fetch request.
+ */
+public class OdbcQueryFetchRequest extends OdbcRequest {
+ /** Query ID. */
+ private long queryId;
+
+ /** Page size - maximum number of rows to return. */
+ private Integer pageSize;
+
+ /**
+ * @param queryId Query ID.
+ * @param pageSize Page size.
+ */
+ public OdbcQueryFetchRequest(long queryId, int pageSize) {
+ super(FETCH_SQL_QUERY);
+ this.queryId = queryId;
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * @param pageSize Page size.
+ */
+ public void pageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * @return Page size.
+ */
+ public int pageSize() {
+ return pageSize;
+ }
+
+ /**
+ * @param queryId Query ID.
+ */
+ public void cacheName(long queryId) {
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long queryId() {
+ return queryId;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
new file mode 100644
index 0000000..b103914
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import java.util.Collection;
+
+/**
+ * Query fetch result.
+ */
+public class OdbcQueryFetchResult {
+ /** Query ID. */
+ private long queryId;
+
+ /** Query result rows. */
+ private Collection<?> items = null;
+
+ /** Flag indicating the query has no unfetched results. */
+ private boolean last = false;
+
+ /**
+ * @param queryId Query ID.
+ */
+ public OdbcQueryFetchResult(long queryId){
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long getQueryId() {
+ return queryId;
+ }
+
+ /**
+ * @param items Query result rows.
+ */
+ public void setItems(Collection<?> items) {
+ this.items = items;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public Collection<?> getItems() {
+ return items;
+ }
+
+ /**
+ * @param last Flag indicating the query has no unfetched results.
+ */
+ public void setLast(boolean last) {
+ this.last = last;
+ }
+
+ /**
+ * @return Flag indicating the query has no unfetched results.
+ */
+ public boolean getLast() {
+ return last;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
new file mode 100644
index 0000000..b0f1ba6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * ODBC query get columns meta request.
+ */
+public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
+ /** Cache name. */
+ private String cacheName;
+
+ /** Table name. */
+ private String tableName;
+
+ /** Column name. */
+ private String columnName;
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
+ super(GET_COLUMNS_META);
+
+ this.cacheName = cacheName;
+ this.tableName = tableName;
+ this.columnName = columnName;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public void cacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ public String cacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @param tableName Table name.
+ */
+ public void tableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ /**
+ * @return Table name.
+ */
+ public String tableName() {
+ return tableName;
+ }
+
+ /**
+ * @param columnName Column name.
+ */
+ public void columnName(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * @return Column name.
+ */
+ public String columnName() {
+ return columnName;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
new file mode 100644
index 0000000..f00176c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
+
+import java.util.Collection;
+
+/**
+ * Query get columns meta result.
+ */
+public class OdbcQueryGetColumnsMetaResult {
+ /** Query result rows. */
+ private Collection<OdbcColumnMeta> meta;
+
+ /**
+ * @param meta Column metadata.
+ */
+ public OdbcQueryGetColumnsMetaResult(Collection<OdbcColumnMeta> meta) {
+ this.meta = meta;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public Collection<OdbcColumnMeta> getMeta() {
+ return meta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
new file mode 100644
index 0000000..7d8194c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * ODBC query get tables meta request.
+ */
+public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
+ /** Catalog search pattern. */
+ private String catalog;
+
+ /** Schema search pattern. */
+ private String schema;
+
+ /** Table search pattern. */
+ private String table;
+
+ /** Table type search pattern. */
+ private String tableType;
+
+ /**
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableType Table type search pattern.
+ */
+ public OdbcQueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) {
+ super(GET_TABLES_META);
+
+ this.catalog = catalog;
+ this.schema = schema;
+ this.table = table;
+ this.tableType = tableType;
+ }
+
+ /**
+ * @param catalog Catalog search pattern.
+ */
+ public void catalog(String catalog) {
+ this.catalog = catalog;
+ }
+
+ /**
+ * @return catalog search pattern.
+ */
+ public String catalog() {
+ return catalog;
+ }
+
+ /**
+ * @param schema Schema search pattern.
+ */
+ public void schema(String schema) {
+ this.schema = schema;
+ }
+
+ /**
+ * @return Schema search pattern.
+ */
+ public String schema() {
+ return schema;
+ }
+
+ /**
+ * @param table Schema search pattern.
+ */
+ public void table(String table) {
+ this.table = table;
+ }
+
+ /**
+ * @return Table search pattern.
+ */
+ public String table() {
+ return table;
+ }
+
+ /**
+ * @param tableType Table type search pattern.
+ */
+ public void tableType(String tableType) {
+ this.tableType = tableType;
+ }
+
+ /**
+ * @return Table type search pattern.
+ */
+ public String tableType() {
+ return tableType;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
new file mode 100644
index 0000000..e737772
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.internal.processors.odbc.OdbcTableMeta;
+
+import java.util.Collection;
+
+/**
+ * Query get columns meta result.
+ */
+public class OdbcQueryGetTablesMetaResult {
+ /** Query result rows. */
+ private Collection<OdbcTableMeta> meta;
+
+ /**
+ * @param meta Column metadata.
+ */
+ public OdbcQueryGetTablesMetaResult(Collection<OdbcTableMeta> meta) {
+ this.meta = meta;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public Collection<OdbcTableMeta> getMeta() {
+ return meta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
new file mode 100644
index 0000000..1e8aecc
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+/**
+ * ODBC command request.
+ */
+public class OdbcRequest {
+ /** Execute sql query. */
+ public static final int EXECUTE_SQL_QUERY = 1;
+
+ /** Fetch query results. */
+ public static final int FETCH_SQL_QUERY = 2;
+
+ /** Close query. */
+ public static final int CLOSE_SQL_QUERY = 3;
+
+ /** Get columns meta query. */
+ public static final int GET_COLUMNS_META = 4;
+
+ /** Get columns meta query. */
+ public static final int GET_TABLES_META = 5;
+
+ /** Command. */
+ private int cmd;
+
+ /**
+ * @param cmd Command type.
+ */
+ public OdbcRequest(int cmd) {
+ this.cmd = cmd;
+ }
+
+ /**
+ * @return Command.
+ */
+ public int command() {
+ return cmd;
+ }
+
+ /**
+ * @param cmd Command.
+ */
+ public void command(int cmd) {
+ this.cmd = cmd;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
new file mode 100644
index 0000000..653e3f4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * ODBC protocol response.
+ */
+public class OdbcResponse {
+
+ /** Command succeeded. */
+ public static final int STATUS_SUCCESS = 0;
+
+ /** Command failed. */
+ public static final int STATUS_FAILED = 1;
+
+ /** Success status. */
+ @SuppressWarnings("RedundantFieldInitialization")
+ private int successStatus = STATUS_SUCCESS;
+
+ /** Error. */
+ private String err;
+
+ /** Response object. */
+ @GridToStringInclude
+ private Object obj;
+
+ /**
+ * Constructs successful rest response.
+ *
+ * @param obj Response object.
+ */
+ public OdbcResponse(Object obj) {
+ successStatus = STATUS_SUCCESS;
+ this.obj = obj;
+ }
+
+ /**
+ * Constructs failed rest response.
+ *
+ * @param status Response status.
+ * @param err Error, {@code null} if success is {@code true}.
+ */
+ public OdbcResponse(int status, @Nullable String err) {
+ assert status != STATUS_SUCCESS;
+
+ successStatus = status;
+ this.err = err;
+ }
+
+ /**
+ * @return Success flag.
+ */
+ public int getSuccessStatus() {
+ return successStatus;
+ }
+
+ /**
+ * @return Response object.
+ */
+ public Object getResponse() {
+ return obj;
+ }
+
+ /**
+ * @param obj Response object.
+ */
+ public void setResponse(@Nullable Object obj) {
+ this.obj = obj;
+ }
+
+ /**
+ * @return Error.
+ */
+ public String getError() {
+ return err;
+ }
+
+ /**
+ * @param err Error.
+ */
+ public void setError(String err) {
+ this.err = err;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(OdbcResponse.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
new file mode 100644
index 0000000..c30daff
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.util.nio.GridNioFuture;
+import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Listener for ODBC driver connection.
+ */
+public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest> {
+ /** Server. */
+ private OdbcTcpServer srv;
+
+ /** Logger. */
+ protected final IgniteLogger log;
+
+ /** Context. */
+ protected final GridKernalContext ctx;
+
+ /** Protocol handler. */
+ private OdbcProtocolHandler hnd;
+
+ OdbcTcpNioListener(IgniteLogger log, OdbcTcpServer srv, GridKernalContext ctx, OdbcProtocolHandler hnd) {
+ this.log = log;
+ this.srv = srv;
+ this.ctx = ctx;
+ this.hnd = hnd;
+ }
+
+ @Override
+ public void onConnected(GridNioSession ses) {
+ System.out.println("Driver connected");
+ }
+
+ @Override
+ public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
+ System.out.println("Driver disconnected");
+
+ if (e != null) {
+ if (e instanceof RuntimeException)
+ U.error(log, "Failed to process request from remote client: " + ses, e);
+ else
+ U.warn(log, "Closed client session due to exception [ses=" + ses + ", msg=" + e.getMessage() + ']');
+ }
+ }
+
+ @Override
+ public void onMessage(GridNioSession ses, OdbcRequest msg) {
+ assert msg != null;
+
+ System.out.println("Query: " + msg.command());
+
+ OdbcResponse res;
+
+ try {
+ res = hnd.handle(msg);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to process client request: " + msg, e);
+
+ res = new OdbcResponse(OdbcResponse.STATUS_FAILED,
+ "Failed to process client request: " + e.getMessage());
+ }
+
+ System.out.println("Resulting success status: " + res.getSuccessStatus());
+
+ GridNioFuture<?> sf = ses.send(res);
+
+ // Check if send failed.
+ if (sf.isDone()) {
+ try {
+ sf.get();
+ } catch (Exception e) {
+ U.error(log, "Failed to process client request [ses=" + ses + ", msg=" + msg + ']', e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
new file mode 100644
index 0000000..83adb1b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.OdbcConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.util.nio.*;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.IgnitePortProtocol;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.nio.ByteOrder;
+
+/**
+ * TCP server that handles communication with ODBC driver.
+ */
+public class OdbcTcpServer {
+
+ /** Server. */
+ private GridNioServer<OdbcRequest> srv;
+
+ /** NIO server listener. */
+ private GridNioServerListener<OdbcRequest> lsnr;
+
+ /** Logger. */
+ protected final IgniteLogger log;
+
+ /** Context. */
+ protected final GridKernalContext ctx;
+
+ /** Host used by this protocol. */
+ protected InetAddress host;
+
+ /** Port used by this protocol. */
+ protected int port;
+
+ /** */
+ public String name() {
+ return "ODBC server";
+ }
+
+ public OdbcTcpServer(GridKernalContext ctx) {
+ assert ctx != null;
+ assert ctx.config().getConnectorConfiguration() != null;
+
+ this.ctx = ctx;
+
+ log = ctx.log(getClass());
+ }
+
+ @SuppressWarnings("BusyWait")
+ public void start(final OdbcProtocolHandler hnd) throws IgniteCheckedException {
+ OdbcConfiguration cfg = ctx.config().getOdbcConfiguration();
+
+ assert cfg != null;
+
+ lsnr = new OdbcTcpNioListener(log, this, ctx, hnd);
+
+ GridNioParser parser = new OdbcParser(ctx);
+
+ try {
+ host = resolveOdbcTcpHost(ctx.config());
+
+ int odbcPort = cfg.getPort();
+
+ if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) {
+ port = odbcPort;
+
+ System.out.println("ODBC Server has started on TCP port " + port);
+
+ return;
+ }
+
+ U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " +
+ "[odbcPort=" + odbcPort + ", host=" + host + ']');
+ }
+ catch (IOException e) {
+ U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(),
+ "Failed to start " + name() + " on port " + port + ". " +
+ "Check restTcpHost configuration property.");
+ }
+ }
+
+ /** */
+ public void onKernalStart() {
+ }
+
+ /** */
+ public void stop() {
+ if (srv != null) {
+ ctx.ports().deregisterPorts(getClass());
+
+ srv.stop();
+ }
+ }
+
+ /**
+ * Resolves host for server using grid configuration.
+ *
+ * @param cfg Grid configuration.
+ * @return Host address.
+ * @throws IOException If failed to resolve host.
+ */
+ private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException {
+ String host = null;
+
+ ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration();
+
+ if (connectionCfg != null)
+ host = connectionCfg.getHost();
+
+ if (host == null)
+ host = cfg.getLocalHost();
+
+ return U.resolveLocalHost(host);
+ }
+
+ /**
+ * Tries to start server with given parameters.
+ *
+ * @param hostAddr Host on which server should be bound.
+ * @param port Port on which server should be bound.
+ * @param lsnr Server message listener.
+ * @param parser Server message parser.
+ * @param cfg Configuration for other parameters.
+ * @return {@code True} if server successfully started, {@code false} if port is used and
+ * server was unable to start.
+ */
+ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> lsnr,
+ GridNioParser parser, OdbcConfiguration cfg) {
+ try {
+ GridNioFilter codec = new GridNioCodecFilter(parser, log, false);
+
+ GridNioFilter[] filters;
+
+ filters = new GridNioFilter[] { codec };
+
+ srv = GridNioServer.<OdbcRequest>builder()
+ .address(hostAddr)
+ .port(port)
+ .listener(lsnr)
+ .logger(log)
+ .selectorCount(cfg.getSelectorCount())
+ .gridName(ctx.gridName())
+ .tcpNoDelay(cfg.isNoDelay())
+ .directBuffer(cfg.isDirectBuffer())
+ .byteOrder(ByteOrder.nativeOrder())
+ .socketSendBufferSize(cfg.getSendBufferSize())
+ .socketReceiveBufferSize(cfg.getReceiveBufferSize())
+ .sendQueueLimit(cfg.getSendQueueLimit())
+ .filters(filters)
+ .directMode(false)
+ .build();
+
+ srv.idleTimeout(cfg.getIdleTimeout());
+
+ srv.start();
+
+ ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage());
+
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java
deleted file mode 100644
index 602f859..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.protocol;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.binary.*;
-import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
-import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.binary.streams.BinaryInputStream;
-import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
-import org.apache.ignite.internal.processors.odbc.OdbcTableMeta;
-import org.apache.ignite.internal.processors.odbc.request.*;
-import org.apache.ignite.internal.processors.odbc.response.*;
-import org.apache.ignite.internal.util.nio.GridNioParser;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-
-
-/**
- * ODBC protocol parser.
- */
-public class OdbcParser implements GridNioParser {
- /** Initial output stream capacity. */
- private static final int INIT_CAP = 1024;
-
- /** Length in bytes of the remaining message part. */
- int leftToReceive = 0;
-
- /** Already received bytes of current message. */
- ByteBuffer currentMessage = null;
-
- /** Context. */
- protected final GridKernalContext ctx;
-
- /** Marshaller. */
- private final GridBinaryMarshaller marsh;
-
- OdbcParser(GridKernalContext context) {
- ctx = context;
-
- CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
-
- marsh = cacheObjProc.marshaller();
- }
-
- /**
- * Process data chunk and try to construct new message using stored and freshly received data.
- * @param buf Fresh data buffer.
- * @return Instance of the {@link BinaryReaderExImpl} positioned to read from the beginning of the message on
- * success and null otherwise.
- */
- private BinaryRawReaderEx tryConstructMessage(ByteBuffer buf) {
- if (leftToReceive != 0) {
- // Still receiving message
- int toConsume = Math.min(leftToReceive, buf.remaining());
-
- currentMessage.put(buf.array(), buf.arrayOffset(), toConsume);
- leftToReceive -= toConsume;
-
- buf.position(buf.position() + toConsume);
-
- if (leftToReceive != 0)
- return null;
-
- BinaryInputStream stream = new BinaryHeapInputStream(currentMessage.array());
-
- BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
-
- currentMessage = null;
-
- return reader;
- }
-
- // Receiving new message
- // Getting message length. It's in the first four bytes of the message.
- BinaryInputStream stream = new BinaryHeapInputStream(buf.array());
-
- BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
-
- int messageLen = reader.readInt();
- buf.getInt();
-
- int remaining = buf.remaining();
-
- if (messageLen > remaining) {
- leftToReceive = messageLen - remaining;
-
- currentMessage = ByteBuffer.allocate(messageLen);
- currentMessage.put(buf);
-
- return null;
- }
-
- buf.position(buf.position() + messageLen);
-
- return reader;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public OdbcRequest decode(GridNioSession ses, ByteBuffer buf) throws IOException,
- IgniteCheckedException {
- BinaryRawReaderEx messageReader = tryConstructMessage(buf);
-
- return messageReader == null ? null : readRequest(ses, messageReader);
- }
-
- /** {@inheritDoc} */
- @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
- assert msg != null;
- assert msg instanceof OdbcResponse;
-
- System.out.println("Encoding query processing result");
-
- BinaryRawWriterEx writer = marsh.writer(new BinaryHeapOutputStream(INIT_CAP));
-
- // Reserving space for the message length.
- int msgLenPos = writer.reserveInt();
-
- writeResponse(ses, writer, (OdbcResponse)msg);
-
- int msgLenWithHdr = writer.out().position() - msgLenPos;
-
- int msgLen = msgLenWithHdr - 4;
-
- writer.writeInt(msgLenPos, msgLen);
-
- ByteBuffer buf = ByteBuffer.allocate(msgLenWithHdr);
-
- buf.put(writer.out().array(), msgLenPos, msgLenWithHdr);
-
- buf.flip();
-
- return buf;
- }
-
- /**
- * Read ODBC request from the raw data using provided {@link BinaryReaderExImpl} instance.
- * @param ses Current session.
- * @param reader Reader positioned to read the request.
- * @return Instance of the {@link OdbcRequest}.
- * @throws IOException if the type of the request is unknown to the parser.
- */
- private OdbcRequest readRequest(GridNioSession ses, BinaryRawReaderEx reader) throws IOException {
- OdbcRequest res;
-
- byte cmd = reader.readByte();
-
- switch (cmd) {
- case OdbcRequest.EXECUTE_SQL_QUERY: {
- String cache = reader.readString();
- String sql = reader.readString();
- int argsNum = reader.readInt();
-
- System.out.println("Message EXECUTE_SQL_QUERY:");
- System.out.println("cache: " + cache);
- System.out.println("query: " + sql);
- System.out.println("argsNum: " + argsNum);
-
- Object[] params = new Object[argsNum];
-
- for (int i = 0; i < argsNum; ++i)
- params[i] = reader.readObjectDetached();
-
- res = new OdbcQueryExecuteRequest(cache, sql, params);
- break;
- }
-
- case OdbcRequest.FETCH_SQL_QUERY: {
- long queryId = reader.readLong();
- int pageSize = reader.readInt();
-
- System.out.println("Message FETCH_SQL_QUERY:");
- System.out.println("queryId: " + queryId);
- System.out.println("pageSize: " + pageSize);
-
- res = new OdbcQueryFetchRequest(queryId, pageSize);
- break;
- }
-
- case OdbcRequest.CLOSE_SQL_QUERY: {
- long queryId = reader.readLong();
-
- System.out.println("Message CLOSE_SQL_QUERY:");
- System.out.println("queryId: " + queryId);
-
- res = new OdbcQueryCloseRequest(queryId);
- break;
- }
-
- case OdbcRequest.GET_COLUMNS_META: {
- String cache = reader.readString();
- String table = reader.readString();
- String column = reader.readString();
-
- System.out.println("Message GET_COLUMNS_META:");
- System.out.println("cache: " + cache);
- System.out.println("table: " + table);
- System.out.println("column: " + column);
-
- res = new OdbcQueryGetColumnsMetaRequest(cache, table, column);
- break;
- }
-
- case OdbcRequest.GET_TABLES_META: {
- String catalog = reader.readString();
- String schema = reader.readString();
- String table = reader.readString();
- String tableType = reader.readString();
-
- System.out.println("Message GET_COLUMNS_META:");
- System.out.println("catalog: " + catalog);
- System.out.println("schema: " + schema);
- System.out.println("table: " + table);
- System.out.println("tableType: " + tableType);
-
- res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
- break;
- }
-
- default:
- throw new IOException("Failed to parse incoming packet (unknown command type) [ses=" + ses +
- ", cmd=[" + Byte.toString(cmd) + ']');
- }
-
- return res;
- }
-
- /**
- * Write ODBC response using provided {@link BinaryRawWriterEx} instance.
- * @param ses Current session.
- * @param writer Writer.
- * @param rsp ODBC response that should be written.
- * @throws IOException if the type of the response is unknown to the parser.
- */
- private void writeResponse(GridNioSession ses, BinaryRawWriterEx writer, OdbcResponse rsp) throws IOException {
- // Writing status
- writer.writeByte((byte)rsp.getSuccessStatus());
-
- if (rsp.getSuccessStatus() != OdbcResponse.STATUS_SUCCESS) {
- writer.writeString(rsp.getError());
-
- return;
- }
-
- Object res0 = rsp.getResponse();
-
- if (res0 instanceof OdbcQueryExecuteResult) {
- OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0;
-
- System.out.println("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- Collection<OdbcColumnMeta> metas = res.getColumnsMetadata();
-
- assert metas != null;
-
- writer.writeInt(metas.size());
-
- for (OdbcColumnMeta meta : metas)
- meta.writeBinary(writer, marsh.context());
-
- } else if (res0 instanceof OdbcQueryFetchResult) {
- OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0;
-
- System.out.println("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- Collection<?> items0 = res.getItems();
-
- assert items0 != null;
-
- Collection<Collection<Object>> items = (Collection<Collection<Object>>)items0;
-
- writer.writeBoolean(res.getLast());
-
- writer.writeInt(items.size());
-
- for (Collection<Object> row : items) {
- if (row != null) {
- writer.writeInt(row.size());
-
- for (Object obj : row) {
- if (obj != null)
- writer.writeObjectDetached(obj);
- }
- }
- }
- } else if (res0 instanceof OdbcQueryCloseResult) {
- OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0;
-
- System.out.println("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- } else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
- OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0;
-
- Collection<OdbcColumnMeta> columnsMeta = res.getMeta();
-
- assert columnsMeta != null;
-
- writer.writeInt(columnsMeta.size());
-
- for (OdbcColumnMeta columnMeta : columnsMeta)
- columnMeta.writeBinary(writer, marsh.context());
-
- } else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
- OdbcQueryGetTablesMetaResult res = (OdbcQueryGetTablesMetaResult) res0;
-
- Collection<OdbcTableMeta> tablesMeta = res.getMeta();
-
- assert tablesMeta != null;
-
- writer.writeInt(tablesMeta.size());
-
- for (OdbcTableMeta tableMeta : tablesMeta)
- tableMeta.writeBinary(writer);
-
- } else {
- throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java
deleted file mode 100644
index 656a477..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.protocol;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.odbc.OdbcProtocolHandler;
-import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
-import org.apache.ignite.internal.processors.odbc.response.OdbcResponse;
-import org.apache.ignite.internal.util.nio.GridNioFuture;
-import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Listener for ODBC driver connection.
- */
-public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest> {
- /** Server. */
- private OdbcTcpServer srv;
-
- /** Logger. */
- protected final IgniteLogger log;
-
- /** Context. */
- protected final GridKernalContext ctx;
-
- /** Protocol handler. */
- private OdbcProtocolHandler hnd;
-
- OdbcTcpNioListener(IgniteLogger log, OdbcTcpServer srv, GridKernalContext ctx, OdbcProtocolHandler hnd) {
- this.log = log;
- this.srv = srv;
- this.ctx = ctx;
- this.hnd = hnd;
- }
-
- @Override
- public void onConnected(GridNioSession ses) {
- System.out.println("Driver connected");
- }
-
- @Override
- public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
- System.out.println("Driver disconnected");
-
- if (e != null) {
- if (e instanceof RuntimeException)
- U.error(log, "Failed to process request from remote client: " + ses, e);
- else
- U.warn(log, "Closed client session due to exception [ses=" + ses + ", msg=" + e.getMessage() + ']');
- }
- }
-
- @Override
- public void onMessage(GridNioSession ses, OdbcRequest msg) {
- assert msg != null;
-
- System.out.println("Query: " + msg.command());
-
- OdbcResponse res;
-
- try {
- res = hnd.handle(msg);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to process client request: " + msg, e);
-
- res = new OdbcResponse(OdbcResponse.STATUS_FAILED,
- "Failed to process client request: " + e.getMessage());
- }
-
- System.out.println("Resulting success status: " + res.getSuccessStatus());
-
- GridNioFuture<?> sf = ses.send(res);
-
- // Check if send failed.
- if (sf.isDone()) {
- try {
- sf.get();
- } catch (Exception e) {
- U.error(log, "Failed to process client request [ses=" + ses + ", msg=" + msg + ']', e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java
deleted file mode 100644
index 4fbd326..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.protocol;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.configuration.ConnectorConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.odbc.OdbcProtocolHandler;
-import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
-import org.apache.ignite.internal.util.nio.*;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.IgnitePortProtocol;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.ByteOrder;
-
-/**
- * TCP server that handles communication with ODBC driver.
- */
-public class OdbcTcpServer {
-
- /** Server. */
- private GridNioServer<OdbcRequest> srv;
-
- /** NIO server listener. */
- private GridNioServerListener<OdbcRequest> lsnr;
-
- /** Logger. */
- protected final IgniteLogger log;
-
- /** Context. */
- protected final GridKernalContext ctx;
-
- /** Host used by this protocol. */
- protected InetAddress host;
-
- /** Port used by this protocol. */
- protected int port;
-
- /** */
- public String name() {
- return "ODBC server";
- }
-
- public OdbcTcpServer(GridKernalContext ctx) {
- assert ctx != null;
- assert ctx.config().getConnectorConfiguration() != null;
-
- this.ctx = ctx;
-
- log = ctx.log(getClass());
- }
-
- @SuppressWarnings("BusyWait")
- public void start(final OdbcProtocolHandler hnd) throws IgniteCheckedException {
- OdbcConfiguration cfg = ctx.config().getOdbcConfiguration();
-
- assert cfg != null;
-
- lsnr = new OdbcTcpNioListener(log, this, ctx, hnd);
-
- GridNioParser parser = new OdbcParser(ctx);
-
- try {
- host = resolveOdbcTcpHost(ctx.config());
-
- int odbcPort = cfg.getPort();
-
- if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) {
- port = odbcPort;
-
- System.out.println("ODBC Server has started on TCP port " + port);
-
- return;
- }
-
- U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " +
- "[odbcPort=" + odbcPort + ", host=" + host + ']');
- }
- catch (IOException e) {
- U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(),
- "Failed to start " + name() + " on port " + port + ". " +
- "Check restTcpHost configuration property.");
- }
- }
-
- /** */
- public void onKernalStart() {
- }
-
- /** */
- public void stop() {
- if (srv != null) {
- ctx.ports().deregisterPorts(getClass());
-
- srv.stop();
- }
- }
-
- /**
- * Resolves host for server using grid configuration.
- *
- * @param cfg Grid configuration.
- * @return Host address.
- * @throws IOException If failed to resolve host.
- */
- private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException {
- String host = null;
-
- ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration();
-
- if (connectionCfg != null)
- host = connectionCfg.getHost();
-
- if (host == null)
- host = cfg.getLocalHost();
-
- return U.resolveLocalHost(host);
- }
-
- /**
- * Tries to start server with given parameters.
- *
- * @param hostAddr Host on which server should be bound.
- * @param port Port on which server should be bound.
- * @param lsnr Server message listener.
- * @param parser Server message parser.
- * @param cfg Configuration for other parameters.
- * @return {@code True} if server successfully started, {@code false} if port is used and
- * server was unable to start.
- */
- private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> lsnr,
- GridNioParser parser, OdbcConfiguration cfg) {
- try {
- GridNioFilter codec = new GridNioCodecFilter(parser, log, false);
-
- GridNioFilter[] filters;
-
- filters = new GridNioFilter[] { codec };
-
- srv = GridNioServer.<OdbcRequest>builder()
- .address(hostAddr)
- .port(port)
- .listener(lsnr)
- .logger(log)
- .selectorCount(cfg.getSelectorCount())
- .gridName(ctx.gridName())
- .tcpNoDelay(cfg.isNoDelay())
- .directBuffer(cfg.isDirectBuffer())
- .byteOrder(ByteOrder.nativeOrder())
- .socketSendBufferSize(cfg.getSendBufferSize())
- .socketReceiveBufferSize(cfg.getReceiveBufferSize())
- .sendQueueLimit(cfg.getSendQueueLimit())
- .filters(filters)
- .directMode(false)
- .build();
-
- srv.idleTimeout(cfg.getIdleTimeout());
-
- srv.start();
-
- ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
-
- return true;
- }
- catch (IgniteCheckedException e) {
- if (log.isDebugEnabled())
- log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage());
-
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java
deleted file mode 100644
index 8ebcca1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query close request.
- */
-public class OdbcQueryCloseRequest extends OdbcRequest {
- /** Query ID. */
- private long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public OdbcQueryCloseRequest(long queryId) {
- super(CLOSE_SQL_QUERY);
- this.queryId = queryId;
- }
-
- /**
- * @param queryId Query ID.
- */
- public void cacheName(long queryId) {
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-}
\ No newline at end of file
[25/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp b/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp
new file mode 100644
index 0000000..45c666d
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp
@@ -0,0 +1,159 @@
+/* Copyright 2011 JetBrains s.r.o.
+ *
+ * Licensed 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.
+ *
+ * $Revision: 88625 $
+*/
+
+#define BOOST_TEST_MODULE IgniteCoreTest
+
+#include <sstream>
+
+#include <boost/test/unit_test_suite_impl.hpp>
+#include <boost/test/results_collector.hpp>
+#include <boost/test/utils/basic_cstring/io.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <boost/test/included/unit_test.hpp>
+
+#include "teamcity_messages.h"
+
+using namespace boost::unit_test;
+using namespace std;
+
+namespace JetBrains {
+
+// Custom formatter for TeamCity messages
+class TeamcityBoostLogFormatter: public boost::unit_test::unit_test_log_formatter {
+ TeamcityMessages messages;
+ std::string currentDetails;
+ std::string flowId;
+
+public:
+ TeamcityBoostLogFormatter(const std::string &_flowId);
+ TeamcityBoostLogFormatter();
+
+ void log_start(std::ostream&, boost::unit_test::counter_t test_cases_amount);
+ void log_finish(std::ostream&);
+ void log_build_info(std::ostream&);
+
+ void test_unit_start(std::ostream&, boost::unit_test::test_unit const& tu);
+ void test_unit_finish(std::ostream&,
+ boost::unit_test::test_unit const& tu,
+ unsigned long elapsed);
+ void test_unit_skipped(std::ostream&, boost::unit_test::test_unit const& tu);
+
+ void log_exception(std::ostream&,
+ boost::unit_test::log_checkpoint_data const&,
+ boost::unit_test::const_string explanation);
+
+ void log_entry_start(std::ostream&,
+ boost::unit_test::log_entry_data const&,
+ log_entry_types let);
+ void log_entry_value(std::ostream&, boost::unit_test::const_string value);
+ void log_entry_finish(std::ostream&);
+};
+
+// Fake fixture to register formatter
+struct TeamcityFormatterRegistrar {
+ TeamcityFormatterRegistrar() {
+ if (JetBrains::underTeamcity()) {
+ boost::unit_test::unit_test_log.set_formatter(new JetBrains::TeamcityBoostLogFormatter());
+ boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_successful_tests);
+ }
+ }
+};
+BOOST_GLOBAL_FIXTURE(TeamcityFormatterRegistrar);
+
+// Formatter implementation
+string toString(const_string bstr) {
+ stringstream ss;
+
+ ss << bstr;
+
+ return ss.str();
+}
+
+TeamcityBoostLogFormatter::TeamcityBoostLogFormatter(const std::string &_flowId)
+: flowId(_flowId)
+{}
+
+TeamcityBoostLogFormatter::TeamcityBoostLogFormatter()
+: flowId(getFlowIdFromEnvironment())
+{}
+
+void TeamcityBoostLogFormatter::log_start(ostream &out, counter_t test_cases_amount)
+{}
+
+void TeamcityBoostLogFormatter::log_finish(ostream &out)
+{}
+
+void TeamcityBoostLogFormatter::log_build_info(ostream &out)
+{}
+
+void TeamcityBoostLogFormatter::test_unit_start(ostream &out, test_unit const& tu) {
+ messages.setOutput(out);
+
+ if (tu.p_type == tut_case) {
+ messages.testStarted(tu.p_name, flowId);
+ } else {
+ messages.suiteStarted(tu.p_name, flowId);
+ }
+
+ currentDetails.clear();
+}
+
+void TeamcityBoostLogFormatter::test_unit_finish(ostream &out, test_unit const& tu, unsigned long elapsed) {
+ messages.setOutput(out);
+
+ test_results const& tr = results_collector.results(tu.p_id);
+ if (tu.p_type == tut_case) {
+ if(!tr.passed()) {
+ if(tr.p_skipped) {
+ messages.testIgnored(tu.p_name, "ignored", flowId);
+ } else if (tr.p_aborted) {
+ messages.testFailed(tu.p_name, "aborted", currentDetails, flowId);
+ } else {
+ messages.testFailed(tu.p_name, "failed", currentDetails, flowId);
+ }
+ }
+
+ messages.testFinished(tu.p_name, elapsed / 1000, flowId);
+ } else {
+ messages.suiteFinished(tu.p_name, flowId);
+ }
+}
+
+void TeamcityBoostLogFormatter::test_unit_skipped(ostream &out, test_unit const& tu)
+{}
+
+void TeamcityBoostLogFormatter::log_exception(ostream &out, log_checkpoint_data const&, const_string explanation) {
+ string what = toString(explanation);
+
+ out << what << endl;
+ currentDetails += what + "\n";
+}
+
+void TeamcityBoostLogFormatter::log_entry_start(ostream&, log_entry_data const&, log_entry_types let)
+{}
+
+void TeamcityBoostLogFormatter::log_entry_value(ostream &out, const_string value) {
+ out << value;
+ currentDetails += toString(value);
+}
+
+void TeamcityBoostLogFormatter::log_entry_finish(ostream &out) {
+ out << endl;
+ currentDetails += "\n";
+}
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp b/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp
new file mode 100644
index 0000000..087409e
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp
@@ -0,0 +1,150 @@
+/* Copyright 2011 JetBrains s.r.o.
+ *
+ * Licensed 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.
+ *
+ * $Revision: 88625 $
+*/
+
+#include <stdlib.h>
+#include <sstream>
+
+#include "teamcity_messages.h"
+
+using namespace std;
+
+namespace JetBrains {
+
+std::string getFlowIdFromEnvironment() {
+ const char *flowId = getenv("TEAMCITY_PROCESS_FLOW_ID");
+ return flowId == NULL ? "" : flowId;
+}
+
+bool underTeamcity() {
+ return getenv("TEAMCITY_PROJECT_NAME") != NULL;
+}
+
+TeamcityMessages::TeamcityMessages()
+: m_out(&cout)
+{}
+
+void TeamcityMessages::setOutput(ostream &out) {
+ m_out = &out;
+}
+
+string TeamcityMessages::escape(string s) {
+ string result;
+
+ for (size_t i = 0; i < s.length(); i++) {
+ char c = s[i];
+
+ switch (c) {
+ case '\n': result.append("|n"); break;
+ case '\r': result.append("|r"); break;
+ case '\'': result.append("|'"); break;
+ case '|': result.append("||"); break;
+ case ']': result.append("|]"); break;
+ default: result.append(&c, 1);
+ }
+ }
+
+ return result;
+}
+
+void TeamcityMessages::openMsg(const string &name) {
+ // endl for http://jetbrains.net/tracker/issue/TW-4412
+ *m_out << endl << "##teamcity[" << name;
+}
+
+void TeamcityMessages::closeMsg() {
+ *m_out << "]";
+ // endl for http://jetbrains.net/tracker/issue/TW-4412
+ *m_out << endl;
+ m_out->flush();
+}
+
+void TeamcityMessages::writeProperty(string name, string value) {
+ *m_out << " " << name << "='" << escape(value) << "'";
+}
+
+void TeamcityMessages::suiteStarted(string name, string flowid) {
+ openMsg("testSuiteStarted");
+ writeProperty("name", name);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::suiteFinished(string name, string flowid) {
+ openMsg("testSuiteFinished");
+ writeProperty("name", name);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testStarted(string name, string flowid) {
+ openMsg("testStarted");
+ writeProperty("name", name);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testFinished(string name, int durationMs, string flowid) {
+ openMsg("testFinished");
+
+ writeProperty("name", name);
+
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ if(durationMs >= 0) {
+ stringstream out;
+ out << durationMs;
+ writeProperty("duration", out.str());
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testFailed(string name, string message, string details, string flowid) {
+ openMsg("testFailed");
+ writeProperty("name", name);
+ writeProperty("message", message);
+ writeProperty("details", details);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testIgnored(std::string name, std::string message, string flowid) {
+ openMsg("testIgnored");
+ writeProperty("name", name);
+ writeProperty("message", message);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/utility_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/utility_test.cpp b/modules/platforms/cpp/odbc-test/src/utility_test.cpp
new file mode 100644
index 0000000..6c4d104
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/utility_test.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/impl/binary/binary_writer_impl.h>
+
+#include <ignite/odbc/utility.h>
+
+using namespace ignite::utility;
+
+BOOST_AUTO_TEST_SUITE(UtilityTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestUtilityRemoveSurroundingSpaces)
+{
+ std::string inStr(" \r \n \t some meaningfull data \n\n \t \r ");
+ std::string expectedOutStr("some meaningfull data");
+
+ std::string realOutStr(RemoveSurroundingSpaces(inStr.begin(), inStr.end()));
+
+ BOOST_REQUIRE(expectedOutStr == realOutStr);
+}
+
+BOOST_AUTO_TEST_CASE(TestUtilityCopyStringToBuffer)
+{
+ char buffer[1024];
+
+ std::string str("Some data. And some more data here.");
+
+ CopyStringToBuffer(str, buffer, sizeof(buffer));
+
+ BOOST_REQUIRE(!strcmp(buffer, str.c_str()));
+
+ CopyStringToBuffer(str, buffer, 11);
+
+ BOOST_REQUIRE(!strcmp(buffer, str.substr(0, 10).c_str()));
+}
+
+BOOST_AUTO_TEST_CASE(TestUtilityReadString)
+{
+ using namespace ignite::impl::binary;
+ using namespace ignite::impl::interop;
+
+ std::string inputStr("Hello World!");
+ std::string outputStr;
+
+ ignite::impl::interop::InteropUnpooledMemory mem(1024);
+ InteropOutputStream outStream(&mem);
+ BinaryWriterImpl writer(&outStream, 0);
+
+ writer.WriteString(inputStr.data(), static_cast<int32_t>(inputStr.size()));
+
+ outStream.Synchronize();
+
+ InteropInputStream inStream(&mem);
+ BinaryReaderImpl reader(&inStream);
+
+ ReadString(reader, outputStr);
+
+ BOOST_REQUIRE(inputStr == outputStr);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am
new file mode 100644
index 0000000..09f35fd
--- /dev/null
+++ b/modules/platforms/cpp/odbc/Makefile.am
@@ -0,0 +1,67 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+SUBDIRS = .
+DIST_SUBDIRS = .
+
+AM_CPPFLAGS = -I$(srcdir)/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
+AM_CXXFLAGS = -Wall -std=c++0x
+LIB_LDFLAGS = -no-undefined -version-info 1
+
+COMMON_SRC = os/linux/src/system/socket_client.cpp \
+ src/app/application_data_buffer.cpp \
+ src/app/parameter.cpp \
+ src/common_types.cpp \
+ src/config/configuration.cpp \
+ src/config/connection_info.cpp \
+ src/connection.cpp \
+ src/cursor.cpp \
+ src/decimal.cpp \
+ src/diagnostic/diagnosable_adapter.cpp \
+ src/diagnostic/diagnostic_record.cpp \
+ src/diagnostic/diagnostic_record_storage.cpp \
+ src/environment.cpp \
+ src/meta/column_meta.cpp \
+ src/meta/table_meta.cpp \
+ src/odbc.cpp \
+ src/query/column_metadata_query.cpp \
+ src/query/data_query.cpp \
+ src/query/foreign_keys_query.cpp \
+ src/query/primary_keys_query.cpp \
+ src/query/table_metadata_query.cpp \
+ src/query/type_info_query.cpp \
+ src/result_page.cpp \
+ src/row.cpp \
+ src/statement.cpp \
+ src/type_traits.cpp \
+ src/utility.cpp
+
+
+lib_LTLIBRARIES = libignite-odbc.la
+libignite_odbc_la_SOURCES = $(COMMON_SRC)
+libignite_odbc_la_LDFLAGS = $(LIB_LDFLAGS) -L/usr/local/lib -lignite-common -lignite-binary -ldl -version-info 0:0:0 -release $(PACKAGE_VERSION)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = ignite-odbc.pc
+
+clean-local:
+ $(RM) *.gcno *.gcda
+
+clean-docs:
+ $(RM) $(DX_CLEANFILES)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/configure.ac b/modules/platforms/cpp/odbc/configure.ac
new file mode 100644
index 0000000..e69d73c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/configure.ac
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([Apache Ignite ODBC driver], [1.5.1.7927], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_CONFIG_SRCDIR(src)
+
+AC_CANONICAL_SYSTEM
+AC_CONFIG_MACRO_DIR([m4])
+AC_LANG([C++])
+
+# Initialize automake
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_CONFIG_HEADER(config.h)
+
+AM_PROG_AR
+
+# Checks for programs.
+GXX="-g -O2"
+
+AC_PROG_CXX
+
+# Initialize Libtool
+LT_INIT
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_lock])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+
+AC_CONFIG_FILES(Makefile ignite-odbc.pc)
+
+AC_OUTPUT
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/ignite-odbc.pc.in
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/ignite-odbc.pc.in b/modules/platforms/cpp/odbc/ignite-odbc.pc.in
new file mode 100644
index 0000000..13cd7e9
--- /dev/null
+++ b/modules/platforms/cpp/odbc/ignite-odbc.pc.in
@@ -0,0 +1,9 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ignite-odbc
+Description: Apache Ignite ODBC driver.
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lignite-odbc
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h b/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
new file mode 100644
index 0000000..051f459
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
@@ -0,0 +1,342 @@
+/*
+ * 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_APPLICATION_DATA_BUFFER
+#define _IGNITE_ODBC_DRIVER_APPLICATION_DATA_BUFFER
+
+#include <stdint.h>
+
+#include <map>
+
+#include <ignite/guid.h>
+
+#include "ignite/odbc/decimal.h"
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/type_traits.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace app
+ {
+ /**
+ * User application data buffer.
+ */
+ class ApplicationDataBuffer
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ ApplicationDataBuffer();
+
+ /**
+ * Constructor.
+ *
+ * @param type Underlying data type.
+ * @param buffer Data buffer pointer.
+ * @param buflen Data buffer length.
+ * @param reslen Resulting data length.
+ * @param offset Pointer to buffer and reslen offset pointer.
+ */
+ ApplicationDataBuffer(type_traits::IgniteSqlType type, void* buffer, SqlLen buflen, SqlLen* reslen, size_t** offset = 0);
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Other instance.
+ */
+ ApplicationDataBuffer(const ApplicationDataBuffer& other);
+
+ /**
+ * Destructor.
+ */
+ ~ApplicationDataBuffer();
+
+ /**
+ * Copy assigment operator.
+ *
+ * @param other Other instance.
+ * @return This.
+ */
+ ApplicationDataBuffer& operator=(const ApplicationDataBuffer& other);
+
+ /**
+ * Set pointer to offset pointer.
+ *
+ * @param offset Pointer to offset pointer.
+ */
+ void SetPtrToOffsetPtr(size_t** offset)
+ {
+ this->offset = offset;
+ }
+
+ /**
+ * Put in buffer value of type int8_t.
+ *
+ * @param value Value.
+ */
+ void PutInt8(int8_t value);
+
+ /**
+ * Put in buffer value of type int16_t.
+ *
+ * @param value Value.
+ */
+ void PutInt16(int16_t value);
+
+ /**
+ * Put in buffer value of type int32_t.
+ *
+ * @param value Value.
+ */
+ void PutInt32(int32_t value);
+
+ /**
+ * Put in buffer value of type int64_t.
+ *
+ * @param value Value.
+ */
+ void PutInt64(int64_t value);
+
+ /**
+ * Put in buffer value of type float.
+ *
+ * @param value Value.
+ */
+ void PutFloat(float value);
+
+ /**
+ * Put in buffer value of type double.
+ *
+ * @param value Value.
+ */
+ void PutDouble(double value);
+
+ /**
+ * Put in buffer value of type string.
+ *
+ * @param value Value.
+ * @return Number of bytes that have been put in buffer.
+ */
+ int32_t PutString(const std::string& value);
+
+ /**
+ * Put in buffer value of type GUID.
+ *
+ * @param value Value.
+ */
+ void PutGuid(const Guid& value);
+
+ /**
+ * Put binary data in buffer.
+ *
+ * @param data Data pointer.
+ * @param len Data length.
+ * @return Number of bytes that have been put in buffer.
+ */
+ int32_t PutBinaryData(void* data, size_t len);
+
+ /**
+ * Put NULL.
+ */
+ void PutNull();
+
+ /**
+ * Put decimal value to buffer.
+ *
+ * @param value Value to put.
+ */
+ void PutDecimal(const Decimal& value);
+
+ /**
+ * Get string.
+ *
+ * @return String value of buffer.
+ */
+ std::string GetString(size_t maxLen) const;
+
+ /**
+ * Get value of type int8_t.
+ *
+ * @return Integer value of type int8_t.
+ */
+ int8_t GetInt8() const;
+
+ /**
+ * Get value of type int16_t.
+ *
+ * @return Integer value of type int16_t.
+ */
+ int16_t GetInt16() const;
+
+ /**
+ * Get value of type int32_t.
+ *
+ * @return Integer value of type int32_t.
+ */
+ int32_t GetInt32() const;
+
+ /**
+ * Get value of type int64_t.
+ *
+ * @return Integer value of type int64_t.
+ */
+ int64_t GetInt64() const;
+
+ /**
+ * Get value of type float.
+ *
+ * @return Integer value of type float.
+ */
+ float GetFloat() const;
+
+ /**
+ * Get value of type double.
+ *
+ * @return Integer value of type double.
+ */
+ double GetDouble() const;
+
+ /**
+ * Get raw data.
+ *
+ * @return Buffer data.
+ */
+ const void* GetData() const;
+
+ /**
+ * Get result data length.
+ *
+ * @return Data length pointer.
+ */
+ const SqlLen* GetResLen() const;
+
+ /**
+ * Get buffer size in bytes.
+ *
+ * @return Buffer size.
+ */
+ SqlLen GetSize() const
+ {
+ return buflen;
+ }
+
+ private:
+ /**
+ * Get raw data.
+ *
+ * @return Buffer data.
+ */
+ void* GetData();
+
+ /**
+ * Get result data length.
+ *
+ * @return Data length pointer.
+ */
+ SqlLen* GetResLen();
+
+ /**
+ * Put value of numeric type in the buffer.
+ *
+ * @param value Numeric value to put.
+ */
+ template<typename T>
+ void PutNum(T value);
+
+ /**
+ * Put numeric value to numeric buffer.
+ *
+ * @param value Numeric value.
+ */
+ template<typename Tbuf, typename Tin>
+ void PutNumToNumBuffer(Tin value);
+
+ /**
+ * Put value to string buffer.
+ *
+ * @param value Value that can be converted to string.
+ */
+ template<typename CharT, typename Tin>
+ void PutValToStrBuffer(const Tin& value);
+
+ /**
+ * Put value to string buffer.
+ * Specialisation for int8_t.
+ * @param value Value that can be converted to string.
+ */
+ template<typename CharT>
+ void PutValToStrBuffer(const int8_t & value);
+
+ /**
+ * Put string to string buffer.
+ *
+ * @param value String value.
+ */
+ template<typename OutCharT, typename InCharT>
+ void PutStrToStrBuffer(const std::basic_string<InCharT>& value);
+
+ /**
+ * Put raw data to any buffer.
+ *
+ * @param data Data pointer.
+ * @param len Data length.
+ */
+ void PutRawDataToBuffer(void *data, size_t len);
+
+ /**
+ * Get int of type T.
+ *
+ * @return Integer value of specified type.
+ */
+ template<typename T>
+ T GetNum() const;
+
+ /**
+ * Apply buffer offset to pointer.
+ * Adds offset to pointer if offset pointer is not null.
+ * @param ptr Pointer.
+ * @return Pointer with applied offset.
+ */
+ template<typename T>
+ T* ApplyOffset(T* ptr) const;
+
+ /** Underlying data type. */
+ type_traits::IgniteSqlType type;
+
+ /** Buffer pointer. */
+ void* buffer;
+
+ /** Buffer length. */
+ SqlLen buflen;
+
+ /** Result length. */
+ SqlLen* reslen;
+
+ /** Pointer to implementation pointer to application offset */
+ size_t** offset;
+ };
+
+ /** Column binging map type alias. */
+ typedef std::map<uint16_t, ApplicationDataBuffer> ColumnBindingMap;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/app/parameter.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/app/parameter.h b/modules/platforms/cpp/odbc/include/ignite/odbc/app/parameter.h
new file mode 100644
index 0000000..8756f48
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/app/parameter.h
@@ -0,0 +1,113 @@
+/*
+ * 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_APP_PARAMETER
+#define _IGNITE_ODBC_DRIVER_APP_PARAMETER
+
+#include <stdint.h>
+
+#include <map>
+
+#include <ignite/guid.h>
+#include <ignite/impl/binary/binary_writer_impl.h>
+#include <ignite/impl/binary/binary_reader_impl.h>
+
+#include "ignite/odbc/app/application_data_buffer.h"
+#include "ignite/odbc/type_traits.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace app
+ {
+ /**
+ * Statement parameter.
+ */
+ class Parameter
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Parameter();
+
+ /**
+ * Constructor.
+ *
+ * @param buffer Underlying data buffer.
+ * @param sqlType IPD type.
+ * @param columnSize IPD column size.
+ * @param decDigits IPD decimal digits.
+ */
+ Parameter(const ApplicationDataBuffer& buffer, int16_t sqlType,
+ size_t columnSize, int16_t decDigits);
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Other instance.
+ */
+ Parameter(const Parameter& other);
+
+ /**
+ * Destructor.
+ */
+ ~Parameter();
+
+ /**
+ * Copy assigment operator.
+ *
+ * @param other Other instance.
+ * @return This.
+ */
+ Parameter& operator=(const Parameter& other);
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const;
+
+ /**
+ * Get data buffer.
+ *
+ * @return underlying ApplicationDataBuffer instance.
+ */
+ ApplicationDataBuffer& GetBuffer();
+
+ private:
+ /** Underlying data buffer. */
+ ApplicationDataBuffer buffer;
+
+ /** IPD type. */
+ int16_t sqlType;
+
+ /** IPD column size. */
+ size_t columnSize;
+
+ /** IPD decimal digits. */
+ int16_t decDigits;
+ };
+
+ /** Parameter binging map type alias. */
+ typedef std::map<uint16_t, Parameter> ParameterBindingMap;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/column.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/column.h b/modules/platforms/cpp/odbc/include/ignite/odbc/column.h
new file mode 100644
index 0000000..dc0b6d9
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/column.h
@@ -0,0 +1,149 @@
+/*
+ * 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_COLUMN
+#define _IGNITE_ODBC_DRIVER_COLUMN
+
+#include <stdint.h>
+
+#include <ignite/impl/binary/binary_reader_impl.h>
+
+#include "ignite/odbc/app/application_data_buffer.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Result set column.
+ */
+ class Column
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Column();
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Another instance.
+ */
+ Column(const Column& other);
+
+ /**
+ * Copy operator.
+ *
+ * @param other Another instance.
+ * @return This.
+ */
+ Column& operator=(const Column& other);
+
+ /**
+ * Destructor.
+ */
+ ~Column();
+
+ /**
+ * Constructor.
+ *
+ * @param reader Reader to be used to retrieve column data.
+ */
+ Column(ignite::impl::binary::BinaryReaderImpl& reader);
+
+ /**
+ * Get column size in bytes.
+ *
+ * @return Column size.
+ */
+ int32_t GetSize() const
+ {
+ return size;
+ }
+
+ /**
+ * Read column data and store it in application data buffer.
+ *
+ * @param dataBuf Application data buffer.
+ * @return Operation result.
+ */
+ SqlResult ReadToBuffer(ignite::impl::binary::BinaryReaderImpl& reader,
+ app::ApplicationDataBuffer& dataBuf);
+
+ /**
+ * Check if the column is in valid state.
+ *
+ * @return True if valid.
+ */
+ bool IsValid() const
+ {
+ return startPos >= 0;
+ }
+
+ /**
+ * Get unread data length.
+ * Find out how many bytes of data are left unread.
+ *
+ * @return Lengh of unread data in bytes.
+ */
+ int32_t GetUnreadDataLength() const
+ {
+ return size - offset;
+ }
+
+ /**
+ * Get unread data length.
+ * Find out how many bytes of data are left unread.
+ *
+ * @return Lengh of unread data in bytes.
+ */
+ int32_t GetEndPosition() const
+ {
+ return endPos;
+ }
+
+ private:
+ /**
+ * Increase offset.
+ *
+ * Increases offset on specified value and makes sure resulting
+ * offset does not exceed column size.
+ *
+ * @param value Offset is incremented on this value.
+ */
+ void IncreaseOffset(int32_t value);
+
+ /** Column type */
+ int8_t type;
+
+ /** Column position in current row. */
+ int32_t startPos;
+
+ /** Column end position in current row. */
+ int32_t endPos;
+
+ /** Current offset in column. */
+ int32_t offset;
+
+ /** Column data size in bytes. */
+ int32_t size;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
new file mode 100644
index 0000000..8e1dbf2
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
@@ -0,0 +1,225 @@
+/*
+ * 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_COMMON_TYPES
+#define _IGNITE_ODBC_DRIVER_COMMON_TYPES
+
+#include <stdint.h>
+
+namespace ignite
+{
+ namespace odbc
+ {
+
+#ifdef _WIN64
+ typedef long long SqlLen;
+#else
+ typedef long SqlLen;
+#endif
+
+ /**
+ * SQL result.
+ */
+ enum SqlResult
+ {
+ /** Success. */
+ SQL_RESULT_SUCCESS,
+
+ /** Success with info. */
+ SQL_RESULT_SUCCESS_WITH_INFO,
+
+ /** Error. */
+ SQL_RESULT_ERROR,
+
+ /** No more data. */
+ SQL_RESULT_NO_DATA
+ };
+
+ /**
+ * Provides detailed information about the cause of a warning or error.
+ */
+ enum SqlState
+ {
+ /** Undefined state. Internal, should never be exposed to user. */
+ SQL_STATE_UNKNOWN,
+
+ /** Output data has been truncated. */
+ SQL_STATE_01004_DATA_TRUNCATED,
+
+ /** Error in row. */
+ SQL_STATE_01S01_ERROR_IN_ROW,
+
+ /**
+ * The driver did not support the specified value and
+ * substituted a similar value.
+ */
+ SQL_STATE_01S02_OPTION_VALUE_CHANGED,
+
+ /** Invalid cursor state. */
+ SQL_STATE_24000_INVALID_CURSOR_STATE,
+
+ /**
+ * The driver was unable to establish a connection with the data
+ * source.
+ */
+ SQL_STATE_08001_CANNOT_CONNECT,
+
+ /**
+ * The specified ConnectionHandle had already been used
+ * to establish a connection with a data source, and the connection
+ * was still open.
+ */
+ SQL_STATE_08002_ALREADY_CONNECTED,
+
+ /** The connection specified was not open. */
+ SQL_STATE_08003_NOT_CONNECTED,
+
+ /**
+ * An error occurred for which there was no specific SQLSTATE
+ * and for which no implementation-specific SQLSTATE was defined.
+ */
+ SQL_STATE_HY000_GENERAL_ERROR,
+
+ /**
+ * The driver was unable to allocate memory for the specified
+ * handle.
+ */
+ SQL_STATE_HY001_MEMORY_ALLOCATION,
+
+ /** Function sequence error. */
+ SQL_STATE_HY010_SEQUENCE_ERROR,
+
+ /** Column type out of range. */
+ SQL_STATE_HY097_COLUMN_TYPE_OUT_OF_RANGE,
+
+ /**
+ * The driver does not support the feature of ODBC behavior that
+ * the application requested.
+ */
+ SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+
+ /**
+ * The connection timeout period expired before the data source
+ * responded to the request.
+ */
+ SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT
+ };
+
+ /**
+ * Diagnostic field type.
+ */
+ enum DiagnosticField
+ {
+ /** Field type is unknown to the driver. */
+ IGNITE_SQL_DIAG_UNKNOWN,
+
+ /** Header record field: Count of rows in the cursor. */
+ IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT,
+
+ /**
+ * Header record field: String that describes the SQL statement
+ * that the underlying function executed.
+ */
+ IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION,
+
+ /**
+ * Header record field: Numeric code that describes the SQL
+ * statement that was executed by the underlying function.
+ */
+ IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE,
+
+ /** Header record field: Number of status records. */
+ IGNITE_SQL_DIAG_HEADER_NUMBER,
+
+ /** Header record field: Last operation return code. */
+ IGNITE_SQL_DIAG_HEADER_RETURNCODE,
+
+ /** Header record field: Row count. */
+ IGNITE_SQL_DIAG_HEADER_ROW_COUNT,
+
+ /** Status record field: Class origin. */
+ IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN,
+
+ /** Status record field: Column number. */
+ IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER,
+
+ /** Status record field: Connection name. */
+ IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME,
+
+ /** Status record field: Message text. */
+ IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT,
+
+ /** Status record field: Native result code. */
+ IGNITE_SQL_DIAG_STATUS_NATIVE,
+
+ /** Status record field: Row number. */
+ IGNITE_SQL_DIAG_STATUS_ROW_NUMBER,
+
+ /** Status record field: Server name. */
+ IGNITE_SQL_DIAG_STATUS_SERVER_NAME,
+
+ /** Status record field: SQLSTATE. */
+ IGNITE_SQL_DIAG_STATUS_SQLSTATE,
+
+ /** Status record field: Subclass origin. */
+ IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN
+ };
+
+ /**
+ * Environment attribute.
+ */
+ enum EnvironmentAttribute
+ {
+ /** ODBC attribute is unknown to the driver. */
+ IGNITE_SQL_ENV_ATTR_UNKNOWN,
+
+ /** ODBC version. */
+ IGNITE_SQL_ENV_ATTR_ODBC_VERSION,
+
+ /** Null-termination of strings. */
+ IGNITE_SQL_ENV_ATTR_OUTPUT_NTS
+ };
+
+ /**
+ * Convert internal Ignite type into ODBC SQL return code.
+ *
+ * @param result Internal result type.
+ * @return ODBC result type.
+ */
+ int SqlResultToReturnCode(SqlResult result);
+
+ /**
+ * Convert ODBC field type to internal DiagnosticField type value.
+ *
+ * @param field ODBC field type.
+ * @return Internal DiagnosticField type value.
+ */
+ DiagnosticField DiagnosticFieldToInternal(int16_t field);
+
+ /**
+ * Convert environment attribute to internal EnvironmentAttribute type value.
+ *
+ * @param attr Environment attribute.
+ * @return Internal EnvironmentAttribute type value.
+ */
+ EnvironmentAttribute EnvironmentAttributeToInternal(int32_t attr);
+
+
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
new file mode 100644
index 0000000..f85a5de
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
@@ -0,0 +1,164 @@
+/*
+ * 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_CONFIGURATION
+#define _IGNITE_ODBC_DRIVER_CONFIGURATION
+
+#include <stdint.h>
+#include <string>
+#include <map>
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace config
+ {
+ /**
+ * ODBC configuration abstraction.
+ */
+ class Configuration
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Configuration();
+
+ /**
+ * Destructor.
+ */
+ ~Configuration();
+
+ /**
+ * Fill configuration data using connection string.
+ *
+ * @param str Pointer to string data.
+ * @param len String length.
+ */
+ void FillFromConnectString(const char* str, size_t len);
+
+ /**
+ * Fill configuration data using connection string.
+ *
+ * @param str Connect string.
+ */
+ void FillFromConnectString(const std::string& str);
+
+ /**
+ * Convert configure to connect string.
+ *
+ * @return Connect string.
+ */
+ std::string ToConnectString() const;
+
+ /**
+ * Fill configuration data using config attributes string.
+ *
+ * @param str Pointer to list of zero-terminated strings.
+ * Terminated by two zero bytes.
+ */
+ void FillFromConfigAttributes(const char* attributes);
+
+ /**
+ * Get server port.
+ *
+ * @return Server port.
+ */
+ uint16_t GetPort() const
+ {
+ return port;
+ }
+
+ /**
+ * Get DSN.
+ *
+ * @return Data Source Name.
+ */
+ const std::string& GetDsn() const
+ {
+ return dsn;
+ }
+
+ /**
+ * Get Driver.
+ *
+ * @return Driver name.
+ */
+ const std::string& GetDriver() const
+ {
+ return driver;
+ }
+
+ /**
+ * Get server host.
+ *
+ * @return Server host.
+ */
+ const std::string& GetHost() const
+ {
+ return host;
+ }
+
+ /**
+ * Get cache.
+ *
+ * @return Cache name.
+ */
+ const std::string& GetCache() const
+ {
+ return cache;
+ }
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Configuration);
+
+ /** Map containing connect arguments. */
+ typedef std::map<std::string, std::string> ArgumentMap;
+
+ /**
+ * Parse connect string into key-value storage.
+ *
+ * @param str String to parse.
+ * @param len String length.
+ * @param params Parsing result.
+ */
+ void ParseAttributeList(const char* str, size_t len, char delimeter, ArgumentMap& args) const;
+
+ /** Data Source Name. */
+ std::string dsn;
+
+ /** Driver name. */
+ std::string driver;
+
+ /** Server hostname. */
+ std::string host;
+
+ /** Port of the server. */
+ uint16_t port;
+
+ /** Cache name. */
+ std::string cache;
+ };
+ }
+
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/config/connection_info.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/connection_info.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/connection_info.h
new file mode 100644
index 0000000..7f2738c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/connection_info.h
@@ -0,0 +1,98 @@
+/*
+ * 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_CONNECTION_INFO
+#define _IGNITE_ODBC_DRIVER_CONNECTION_INFO
+
+#include <stdint.h>
+
+#include <map>
+
+#include <ignite/common/common.h>
+#include <ignite/odbc/common_types.h>
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace config
+ {
+ /**
+ * Connection info.
+ */
+ class ConnectionInfo
+ {
+ public:
+ /** Info type. */
+ typedef unsigned short InfoType;
+
+#ifdef ODBC_DEBUG
+ /**
+ * Convert type to string containing its name.
+ * Debug function.
+ * @param type Info type.
+ * @return Null-terminated string containing types name.
+ */
+ static const char* InfoTypeToString(InfoType type);
+#endif
+
+ /**
+ * Constructor.
+ */
+ ConnectionInfo();
+
+ /**
+ * Destructor.
+ */
+ ~ConnectionInfo();
+
+ /**
+ * Get info of any type.
+ * @param type Info type.
+ * @param buf Result buffer pointer.
+ * @param buflen Result buffer length.
+ * @param reslen Result value length pointer.
+ * @return True on success.
+ */
+ SqlResult GetInfo(InfoType type, void* buf, short buflen, short* reslen) const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(ConnectionInfo);
+
+ /** Associative array of string parameters. */
+ typedef std::map<InfoType, std::string> StringInfoMap;
+
+ /** Associative array of unsigned integer parameters. */
+ typedef std::map<InfoType, unsigned int> UintInfoMap;
+
+ /** Associative array of unsigned short parameters. */
+ typedef std::map<InfoType, unsigned short> UshortInfoMap;
+
+ /** String parameters. */
+ StringInfoMap strParams;
+
+ /** Integer parameters. */
+ UintInfoMap intParams;
+
+ /** Short parameters. */
+ UshortInfoMap shortParams;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
new file mode 100644
index 0000000..56037f5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
@@ -0,0 +1,258 @@
+/*
+ * 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_CONNECTION
+#define _IGNITE_ODBC_DRIVER_CONNECTION
+
+#include <stdint.h>
+
+#include <vector>
+
+#include "ignite/odbc/parser.h"
+#include "ignite/odbc/system/socket_client.h"
+#include "ignite/odbc/config/connection_info.h"
+#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ class Statement;
+
+ /**
+ * ODBC node connection.
+ */
+ class Connection : public diagnostic::DiagnosableAdapter
+ {
+ friend class Environment;
+ public:
+ /**
+ * Destructor.
+ */
+ ~Connection();
+
+ /**
+ * Get connection info.
+ *
+ * @return Connection info.
+ */
+ const config::ConnectionInfo& GetInfo() const;
+
+ /**
+ * Get info of any type.
+ *
+ * @param type Info type.
+ * @param buf Result buffer pointer.
+ * @param buflen Result buffer length.
+ * @param reslen Result value length pointer.
+ */
+ void GetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen);
+
+ /**
+ * Establish connection to ODBC server.
+ *
+ * @param server Server (DSN).
+ */
+ void Establish(const std::string& server);
+
+ /**
+ * Establish connection to ODBC server.
+ *
+ * @param host Host.
+ * @param port Port.
+ * @param cache Cache name to connect to.
+ */
+ void Establish(const std::string& host, uint16_t port, const std::string& cache);
+
+ /**
+ * Release established connection.
+ *
+ * @return Operation result.
+ */
+ void Release();
+
+ /**
+ * Create statement associated with the connection.
+ *
+ * @return Pointer to valid instance on success and NULL on failure.
+ */
+ Statement* CreateStatement();
+
+ /**
+ * Send data by established connection.
+ *
+ * @param data Data buffer.
+ * @param len Data length.
+ * @return True on success.
+ */
+ bool Send(const int8_t* data, size_t len);
+
+ /**
+ * Receive next message.
+ *
+ * @param msg Buffer for message.
+ * @return True on success.
+ */
+ bool Receive(std::vector<int8_t>& msg);
+
+ /**
+ * Get name of the assotiated cache.
+ *
+ * @return Cache name.
+ */
+ const std::string& GetCache() const;
+
+ /**
+ * Create diagnostic record associated with the Connection instance.
+ *
+ * @param sqlState SQL state.
+ * @param message Message.
+ * @param rowNum Associated row number.
+ * @param columnNum Associated column number.
+ * @return DiagnosticRecord associated with the instance.
+ */
+ diagnostic::DiagnosticRecord CreateStatusRecord(SqlState sqlState,
+ const std::string& message, int32_t rowNum = 0, int32_t columnNum = 0) const;
+
+ /**
+ * Synchronously send request message and receive response.
+ *
+ * @param req Request message.
+ * @param rsp Response message.
+ * @return True on success.
+ */
+ template<typename ReqT, typename RspT>
+ bool SyncMessage(const ReqT& req, RspT& rsp)
+ {
+ std::vector<int8_t> tempBuffer;
+
+ parser.Encode(req, tempBuffer);
+
+ bool requestSent = Send(tempBuffer.data(), tempBuffer.size());
+
+ if (!requestSent)
+ return false;
+
+ bool responseReceived = Receive(tempBuffer);
+
+ if (!responseReceived)
+ return false;
+
+ parser.Decode(rsp, tempBuffer);
+
+ return true;
+ }
+
+ /**
+ * Perform transaction commit.
+ */
+ void TransactionCommit();
+
+ /**
+ * Perform transaction rollback.
+ */
+ void TransactionRollback();
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Connection);
+
+ /**
+ * Establish connection to ODBC server.
+ * Internal call.
+ *
+ * @param server Server (DNS).
+ * @return Operation result.
+ */
+ SqlResult InternalEstablish(const std::string& server);
+
+ /**
+ * Establish connection to ODBC server.
+ * Internal call.
+ *
+ * @param host Host.
+ * @param port Port.
+ * @param cache Cache name to connect to.
+ * @return Operation result.
+ */
+ SqlResult InternalEstablish(const std::string& host, uint16_t port, const std::string& cache);
+
+ /**
+ * Release established connection.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalRelease();
+
+ /**
+ * Get info of any type.
+ * Internal call.
+ *
+ * @param type Info type.
+ * @param buf Result buffer pointer.
+ * @param buflen Result buffer length.
+ * @param reslen Result value length pointer.
+ * @return Operation result.
+ */
+ SqlResult InternalGetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen);
+
+ /**
+ * Create statement associated with the connection.
+ * Internal call.
+ *
+ * @param Pointer to valid instance on success and NULL on failure.
+ * @return Operation result.
+ */
+ SqlResult InternalCreateStatement(Statement*& statement);
+
+ /**
+ * Perform transaction commit on all the associated connections.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalTransactionCommit();
+
+ /**
+ * Perform transaction rollback on all the associated connections.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalTransactionRollback();
+
+ /**
+ * Constructor.
+ */
+ Connection();
+
+ /** Socket. */
+ tcp::SocketClient socket;
+
+ /** State flag. */
+ bool connected;
+
+ /** Cache name. */
+ std::string cache;
+
+ /** Message parser. */
+ Parser parser;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h b/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
new file mode 100644
index 0000000..7d4c925
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/cursor.h
@@ -0,0 +1,108 @@
+/*
+ * 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_CURSOR
+#define _IGNITE_ODBC_DRIVER_CURSOR
+
+#include <stdint.h>
+
+#include <map>
+#include <memory>
+
+#include "ignite/odbc/result_page.h"
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/row.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Query result cursor.
+ */
+ class Cursor
+ {
+ public:
+ /**
+ * Constructor.
+ * @param queryId ID of the executed query.
+ */
+ Cursor(int64_t queryId);
+
+ /**
+ * Destructor.
+ */
+ ~Cursor();
+
+ /**
+ * Move cursor to the next result row.
+ * @return False if data update required or no more data.
+ */
+ bool Increment();
+
+ /**
+ * Check if the cursor needs data update.
+ * @return True if the cursor needs data update.
+ */
+ bool NeedDataUpdate() const;
+
+ /**
+ * Check if the cursor has next row row.
+ * @return True if the cursor has next row row.
+ */
+ bool HasNext() const;
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ /**
+ * Update current cursor page data.
+ * @param newPage New result page.
+ */
+ void UpdateData(std::auto_ptr<ResultPage>& newPage);
+
+ /**
+ * Get current row.
+ * @return Current row.
+ */
+ Row* GetRow();
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Cursor);
+
+ /** Cursor id. */
+ int64_t queryId;
+
+ /** Current page. */
+ std::auto_ptr<ResultPage> currentPage;
+
+ /** Row position in current page. */
+ int32_t currentPagePos;
+
+ /** Current row. */
+ std::auto_ptr<Row> currentRow;
+ };
+ }
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h b/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
new file mode 100644
index 0000000..abf7f34
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
@@ -0,0 +1,126 @@
+/*
+ * 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_DECIMAL
+#define _IGNITE_DECIMAL
+
+#include <stdint.h>
+
+namespace ignite
+{
+ //TODO: move to binary or common library.
+ class Decimal
+ {
+ friend void swap(Decimal& first, Decimal& second);
+ public:
+ /**
+ * Default constructor.
+ */
+ Decimal();
+
+ /**
+ * Constructor.
+ *
+ * @param scale Scale.
+ * @param mag Magnitude. Value is copied.
+ * @param len Magnitude length in bytes.
+ */
+ Decimal(int32_t scale, const int8_t* mag, int32_t len);
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Other instance.
+ */
+ Decimal(const Decimal& other);
+
+ /**
+ * Destructor.
+ */
+ ~Decimal();
+
+ /**
+ * Copy operator.
+ *
+ * @param other Other instance.
+ * @return This.
+ */
+ Decimal& operator=(const Decimal& other);
+
+ /**
+ * Convert to double.
+ */
+ operator double() const;
+
+ /**
+ * Get scale.
+ *
+ * @return Scale.
+ */
+ int32_t GetScale() const;
+
+ /**
+ * Get sign.
+ *
+ * @return Sign: -1 if negative and 1 if positive.
+ */
+ int32_t GetSign() const;
+
+ /**
+ * Check if the value is negative.
+ *
+ * @return True if negative and false otherwise.
+ */
+ bool IsNegative() const;
+
+ /**
+ * Get magnitude length.
+ *
+ * @return Magnitude length.
+ */
+ int32_t GetLength() const;
+
+ /**
+ * Get magnitude pointer.
+ *
+ * @return Magnitude pointer.
+ */
+ const int8_t* GetMagnitude() const;
+
+ private:
+ /** Scale. */
+ int32_t scale;
+
+ /** Magnitude lenght. */
+ int32_t len;
+
+ /** Magnitude. */
+ int8_t* magnitude;
+ };
+
+ /**
+ * Swap function for the Decimal type.
+ *
+ * @param first First instance.
+ * @param second Second instance.
+ */
+ void swap(Decimal& first, Decimal& second);
+}
+
+
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable.h
new file mode 100644
index 0000000..2afd819
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable.h
@@ -0,0 +1,82 @@
+/*
+ * 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_DIAGNOSABLE
+#define _IGNITE_ODBC_DRIVER_DIAGNOSABLE
+
+#include "ignite/odbc/diagnostic/diagnostic_record_storage.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ /**
+ * Diagnosable interface.
+ */
+ class Diagnosable
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~Diagnosable()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get diagnostic record.
+ *
+ * @return Diagnostic record.
+ */
+ virtual const diagnostic::DiagnosticRecordStorage& GetDiagnosticRecords() const = 0;
+
+ /**
+ * Add new status record.
+ *
+ * @param sqlState SQL state.
+ * @param message Message.
+ * @param rowNum Associated row number.
+ * @param columnNum Associated column number.
+ */
+ virtual void AddStatusRecord(SqlState sqlState, const std::string& message,
+ int32_t rowNum, int32_t columnNum) = 0;
+
+ /**
+ * Add new status record.
+ *
+ * @param sqlState SQL state.
+ * @param message Message.
+ */
+ virtual void AddStatusRecord(SqlState sqlState, const std::string& message) = 0;
+
+ protected:
+ /**
+ * Default constructor.
+ */
+ Diagnosable()
+ {
+ // No-op.
+ }
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable_adapter.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable_adapter.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable_adapter.h
new file mode 100644
index 0000000..5b01f49
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnosable_adapter.h
@@ -0,0 +1,107 @@
+/*
+ * 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_DIAGNOSABLE_ADAPTER
+#define _IGNITE_ODBC_DRIVER_DIAGNOSABLE_ADAPTER
+
+#include "ignite/odbc/diagnostic/diagnosable.h"
+
+#define IGNITE_ODBC_API_CALL(...) \
+ diagnosticRecords.Reset(); \
+ SqlResult result = (__VA_ARGS__); \
+ diagnosticRecords.SetHeaderRecord(result)
+
+#define IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS \
+ diagnosticRecords.Reset(); \
+ diagnosticRecords.SetHeaderRecord(SQL_RESULT_SUCCESS)
+
+namespace ignite
+{
+ namespace odbc
+ {
+ class Connection;
+
+ namespace diagnostic
+ {
+ /**
+ * Diagnosable interface.
+ */
+ class DiagnosableAdapter : public Diagnosable
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~DiagnosableAdapter()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get diagnostic record.
+ *
+ * @return Diagnostic record.
+ */
+ virtual const diagnostic::DiagnosticRecordStorage& GetDiagnosticRecords() const
+ {
+ return diagnosticRecords;
+ }
+
+ /**
+ * Add new status record.
+ *
+ * @param sqlState SQL state.
+ * @param message Message.
+ * @param rowNum Associated row number.
+ * @param columnNum Associated column number.
+ */
+ virtual void AddStatusRecord(SqlState sqlState, const std::string& message,
+ int32_t rowNum, int32_t columnNum);
+
+ /**
+ * Add new status record.
+ *
+ * @param sqlState SQL state.
+ * @param message Message.
+ */
+ virtual void AddStatusRecord(SqlState sqlState, const std::string& message);
+
+ protected:
+ /**
+ * Constructor.
+ *
+ * @param connection Pointer to connection. Used to create
+ * diagnostic records with connection info.
+ */
+ DiagnosableAdapter(const Connection* connection = 0) :
+ connection(connection)
+ {
+ // No-op.
+ }
+
+ /** Diagnostic records. */
+ diagnostic::DiagnosticRecordStorage diagnosticRecords;
+
+ private:
+ /** Connection. */
+ const Connection* connection;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
new file mode 100644
index 0000000..87d29c1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
@@ -0,0 +1,165 @@
+/*
+ * 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_DIAGNOSTIC_RECORD
+#define _IGNITE_ODBC_DRIVER_DIAGNOSTIC_RECORD
+
+#include <stdint.h>
+
+#include <vector>
+
+#include <ignite/common/common.h>
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/app/application_data_buffer.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ /**
+ * Status diagnostic record.
+ */
+ class DiagnosticRecord
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ DiagnosticRecord();
+
+ /**
+ * Constructor.
+ *
+ * @param sqlState SQL state code.
+ * @param message Message.
+ * @param connectionName Connection name.
+ * @param serverName Server name.
+ * @param rowNum Associated row number.
+ * @param columnNum Associated column number.
+ */
+ DiagnosticRecord(SqlState sqlState, const std::string& message,
+ const std::string& connectionName, const std::string& serverName,
+ int32_t rowNum = 0, int32_t columnNum = 0);
+
+ /**
+ * Destructor.
+ */
+ ~DiagnosticRecord();
+
+ /**
+ * Get class origin.
+ *
+ * @return A string that indicates the document that defines the
+ * class portion of the SQLSTATE value in this record.
+ */
+ const std::string& GetClassOrigin() const;
+
+ /**
+ * Get subclass origin.
+ *
+ * @return A string with the same format and valid values as origin,
+ * that identifies the defining portion of the subclass
+ * portion of the SQLSTATE code.
+ */
+ const std::string& GetSubclassOrigin() const;
+
+ /**
+ * Get record message text.
+ *
+ * @return An informational message on the error or warning.
+ */
+ const std::string& GetMessage() const;
+
+ /**
+ * Get connection name.
+ *
+ * @return A string that indicates the name of the connection that
+ * the diagnostic record relates to.
+ */
+ const std::string& GetConnectionName() const;
+
+ /**
+ * Get server name.
+ *
+ * @return A string that indicates the server name that the
+ * diagnostic record relates to.
+ */
+ const std::string& GetServerName() const;
+
+ /**
+ * Get SQL state of the record.
+ *
+ * @return A five-character SQLSTATE diagnostic code.
+ */
+ const std::string& GetSqlState() const;
+
+ /**
+ * Get row number.
+ *
+ * @return The row number in the rowset, or the parameter number in
+ * the set of parameters, with which the status record is
+ * associated.
+ */
+ int32_t GetRowNumber() const;
+
+ /**
+ * Get column number.
+ *
+ * @return Contains the value that represents the column number
+ * in the result set or the parameter number in the set
+ * of parameters.
+ */
+ int32_t GetColumnNumber() const;
+
+ private:
+ /** SQL state diagnostic code. */
+ SqlState sqlState;
+
+ /** An informational message on the error or warning. */
+ std::string message;
+
+ /**
+ * A string that indicates the name of the connection that
+ * the diagnostic record relates to.
+ */
+ std::string connectionName;
+
+ /**
+ * A string that indicates the server name that the
+ * diagnostic record relates to.
+ */
+ std::string serverName;
+
+ /**
+ * The row number in the rowset, or the parameter number in the
+ * set of parameters, with which the status record is associated.
+ */
+ int32_t rowNum;
+
+ /**
+ * Contains the value that represents the column number in the
+ * result set or the parameter number in the set of parameters.
+ */
+ int32_t columnNum;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
[09/28] ignite git commit: IGNITE-2444: Removed mentions of the
VS-2014 from odbc.sln.
Posted by vo...@apache.org.
IGNITE-2444: Removed mentions of the VS-2014 from odbc.sln.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9abee12f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9abee12f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9abee12f
Branch: refs/heads/ignite-1786
Commit: 9abee12f0ffd98ac4137337664a066572509ed60
Parents: ebc6b57
Author: isapego <is...@gridgain.com>
Authored: Tue Jan 26 13:17:34 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Jan 26 13:17:34 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc/project/vs/odbc.sln | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9abee12f/modules/platforms/cpp/odbc/project/vs/odbc.sln
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.sln b/modules/platforms/cpp/odbc/project/vs/odbc.sln
index ecaafe0..89144a3 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.sln
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.sln
@@ -1,8 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc-driver", "..\..\odbc-driver\project\vs\odbc-driver.vcxproj", "{12F77E12-38FE-42D3-B1DA-7E5979362961}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc-test", "..\..\odbc-test\project\vs\odbc-test.vcxproj", "{309BEA40-495D-463F-98D5-4657F03F6D8F}"
[06/28] ignite git commit: IGNTIE-1786: Refactored according to
review findings.
Posted by vo...@apache.org.
IGNTIE-1786: Refactored according to review findings.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/73127efb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/73127efb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/73127efb
Branch: refs/heads/ignite-1786
Commit: 73127efb6af2f27d75193d1a911e806ab356db94
Parents: 2a75631
Author: isapego <is...@gridgain.com>
Authored: Mon Jan 25 20:46:37 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Mon Jan 25 20:46:37 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/OdbcColumnMeta.java | 21 +++--
.../processors/odbc/OdbcCommandHandler.java | 36 ++++----
.../internal/processors/odbc/OdbcParser.java | 87 ++++++++++++--------
.../internal/processors/odbc/OdbcProcessor.java | 10 ++-
.../processors/odbc/OdbcProtocolHandler.java | 8 +-
.../processors/odbc/OdbcQueryCloseRequest.java | 8 +-
.../processors/odbc/OdbcQueryCloseResult.java | 4 +-
.../odbc/OdbcQueryExecuteRequest.java | 28 +------
.../processors/odbc/OdbcQueryExecuteResult.java | 8 +-
.../processors/odbc/OdbcQueryFetchRequest.java | 19 +----
.../processors/odbc/OdbcQueryFetchResult.java | 32 +++----
.../odbc/OdbcQueryGetColumnsMetaRequest.java | 29 ++-----
.../odbc/OdbcQueryGetColumnsMetaResult.java | 6 +-
.../odbc/OdbcQueryGetTablesMetaRequest.java | 36 +-------
.../odbc/OdbcQueryGetTablesMetaResult.java | 6 +-
.../internal/processors/odbc/OdbcRequest.java | 9 +-
.../internal/processors/odbc/OdbcResponse.java | 38 +++------
.../internal/processors/odbc/OdbcTableMeta.java | 14 ++--
.../processors/odbc/OdbcTcpNioListener.java | 36 ++++----
.../internal/processors/odbc/OdbcTcpServer.java | 64 ++++++--------
20 files changed, 203 insertions(+), 296 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
index 0c2eed2..8b47a06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
@@ -30,19 +30,20 @@ import static org.apache.ignite.internal.binary.GridBinaryMarshaller.UNREGISTERE
*/
public class OdbcColumnMeta {
/** Cache name. */
- private String schemaName;
+ private final String schemaName;
/** Table name. */
- private String tableName;
+ private final String tableName;
/** Column name. */
- private String columnName;
+ private final String columnName;
/** Data type. */
- private Class<?> dataType;
+ private final Class<?> dataType;
/**
* Add quotation marks at the beginning and end of the string.
+ *
* @param str Input string.
* @return String surrounded with quotation marks.
*/
@@ -74,16 +75,19 @@ public class OdbcColumnMeta {
this.tableName = info.typeName();
this.columnName = info.fieldName();
+ Class<?> type;
try {
- this.dataType = Class.forName(info.fieldTypeName());
+ type = Class.forName(info.fieldTypeName());
}
catch (Exception ignored) {
- this.dataType = Object.class;
+ type = Object.class;
}
+
+ this.dataType = type;
}
- @Override
- public boolean equals(Object o)
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o)
{
if (!(o instanceof OdbcColumnMeta))
return false;
@@ -98,6 +102,7 @@ public class OdbcColumnMeta {
/**
* Write in a binary format.
+ *
* @param writer Binary writer.
* @param ctx Portable context.
* @throws IOException
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
index 9e56888..73858d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
@@ -90,32 +90,27 @@ public class OdbcCommandHandler {
}
/**
- * @param qryCurs Query cursors.
* @param cur Current cursor.
* @param req Sql fetch request.
* @param qryId Query id.
* @return Query result with items.
*/
- private static OdbcQueryFetchResult createQueryResult(
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
- Iterator cur, OdbcQueryFetchRequest req, Long qryId) {
- OdbcQueryFetchResult res = new OdbcQueryFetchResult(qryId);
+ private static OdbcQueryFetchResult createQueryResult(Iterator cur, OdbcQueryFetchRequest req, Long qryId) {
List<Object> items = new ArrayList<>();
for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
items.add(cur.next());
- res.setItems(items);
-
- res.setLast(!cur.hasNext());
-
- return res;
+ return new OdbcQueryFetchResult(qryId, items, !cur.hasNext());
}
/**
+ * Convert metadata in collection from {@link GridQueryFieldMetadata} to
+ * {@link OdbcColumnMeta}.
+ *
* @param meta Internal query field metadata.
- * @return Rest query field metadata.
+ * @return Odbc query field metadata.
*/
private static Collection<OdbcColumnMeta> convertMetadata(Collection<GridQueryFieldMetadata> meta) {
List<OdbcColumnMeta> res = new ArrayList<>();
@@ -142,6 +137,7 @@ public class OdbcCommandHandler {
/**
* Remove quotation marks at the beginning and end of the string if present.
+ *
* @param str Input string.
* @return String without leading and trailing quotation marks.
*/
@@ -153,12 +149,14 @@ public class OdbcCommandHandler {
}
/**
+ * {@link OdbcQueryExecuteRequest} command handler.
+ *
* @param req Execute query request.
* @param qryCurs Queries cursors.
* @return Response.
*/
private OdbcResponse executeQuery(OdbcQueryExecuteRequest req,
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
long qryId = qryIdGen.getAndIncrement();
try {
@@ -194,12 +192,14 @@ public class OdbcCommandHandler {
}
/**
+ * {@link OdbcQueryCloseRequest} command handler.
+ *
* @param req Execute query request.
* @param qryCurs Queries cursors.
* @return Response.
*/
private OdbcResponse closeQuery(OdbcQueryCloseRequest req,
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
try {
QueryCursor cur = qryCurs.get(req.queryId()).get1();
@@ -223,12 +223,14 @@ public class OdbcCommandHandler {
}
/**
+ * {@link OdbcQueryFetchRequest} command handler.
+ *
* @param req Execute query request.
* @param qryCurs Queries cursors.
* @return Response.
*/
private OdbcResponse fetchQuery(OdbcQueryFetchRequest req,
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
try {
Iterator cur = qryCurs.get(req.queryId()).get2();
@@ -236,7 +238,7 @@ public class OdbcCommandHandler {
return new OdbcResponse(OdbcResponse.STATUS_FAILED,
"Failed to find query with ID: " + req.queryId());
- OdbcQueryFetchResult res = createQueryResult(qryCurs, cur, req, req.queryId());
+ OdbcQueryFetchResult res = createQueryResult(cur, req, req.queryId());
return new OdbcResponse(res);
}
@@ -248,6 +250,8 @@ public class OdbcCommandHandler {
}
/**
+ * {@link OdbcQueryGetColumnsMetaRequest} command handler.
+ *
* @param req Get columns metadata request.
* @return Response.
*/
@@ -299,6 +303,8 @@ public class OdbcCommandHandler {
}
/**
+ * {@link OdbcQueryGetTablesMetaRequest} command handler.
+ *
* @param req Get tables metadata request.
* @return Response.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
index ead6d3b..222293a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Collection;
-
/**
* ODBC protocol parser.
*/
@@ -40,30 +39,30 @@ public class OdbcParser implements GridNioParser {
private static final int INIT_CAP = 1024;
/** Length in bytes of the remaining message part. */
- int leftToReceive = 0;
+ private int leftToReceive = 0;
/** Already received bytes of current message. */
- ByteBuffer currentMessage = null;
-
- /** Context. */
- protected final GridKernalContext ctx;
+ private ByteBuffer currentMessage = null;
/** Marshaller. */
private final GridBinaryMarshaller marsh;
- OdbcParser(GridKernalContext context) {
- ctx = context;
-
- CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
+ /**
+ * @param context Kernel context.
+ */
+ public OdbcParser(GridKernalContext context) {
+ CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)context.cacheObjects();
marsh = cacheObjProc.marshaller();
}
/**
- * Process data chunk and try to construct new message using stored and freshly received data.
+ * Process data chunk and try to construct new message using stored and
+ * freshly received data.
+ *
* @param buf Fresh data buffer.
- * @return Instance of the {@link BinaryReaderExImpl} positioned to read from the beginning of the message on
- * success and null otherwise.
+ * @return Instance of the {@link BinaryReaderExImpl} positioned to read
+ * from the beginning of the message on success and null otherwise.
*/
private BinaryRawReaderEx tryConstructMessage(ByteBuffer buf) {
if (leftToReceive != 0) {
@@ -88,16 +87,19 @@ public class OdbcParser implements GridNioParser {
}
// Receiving new message
- // Getting message length. It's in the first four bytes of the message.
BinaryInputStream stream = new BinaryHeapInputStream(buf.array());
BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
+ // Getting message length. It's in the first four bytes of the message.
int messageLen = reader.readInt();
+
+ // Just skipping int here to sync position.
buf.getInt();
int remaining = buf.remaining();
+ // Checking if we have not entire message in buffer.
if (messageLen > remaining) {
leftToReceive = messageLen - remaining;
@@ -151,6 +153,7 @@ public class OdbcParser implements GridNioParser {
/**
* Read ODBC request from the raw data using provided {@link BinaryReaderExImpl} instance.
+ *
* @param ses Current session.
* @param reader Reader positioned to read the request.
* @return Instance of the {@link OdbcRequest}.
@@ -163,6 +166,7 @@ public class OdbcParser implements GridNioParser {
switch (cmd) {
case OdbcRequest.EXECUTE_SQL_QUERY: {
+
String cache = reader.readString();
String sql = reader.readString();
int argsNum = reader.readInt();
@@ -178,10 +182,12 @@ public class OdbcParser implements GridNioParser {
params[i] = reader.readObjectDetached();
res = new OdbcQueryExecuteRequest(cache, sql, params);
+
break;
}
case OdbcRequest.FETCH_SQL_QUERY: {
+
long queryId = reader.readLong();
int pageSize = reader.readInt();
@@ -190,20 +196,24 @@ public class OdbcParser implements GridNioParser {
System.out.println("pageSize: " + pageSize);
res = new OdbcQueryFetchRequest(queryId, pageSize);
+
break;
}
case OdbcRequest.CLOSE_SQL_QUERY: {
+
long queryId = reader.readLong();
System.out.println("Message CLOSE_SQL_QUERY:");
System.out.println("queryId: " + queryId);
res = new OdbcQueryCloseRequest(queryId);
+
break;
}
case OdbcRequest.GET_COLUMNS_META: {
+
String cache = reader.readString();
String table = reader.readString();
String column = reader.readString();
@@ -214,10 +224,12 @@ public class OdbcParser implements GridNioParser {
System.out.println("column: " + column);
res = new OdbcQueryGetColumnsMetaRequest(cache, table, column);
+
break;
}
case OdbcRequest.GET_TABLES_META: {
+
String catalog = reader.readString();
String schema = reader.readString();
String table = reader.readString();
@@ -230,6 +242,7 @@ public class OdbcParser implements GridNioParser {
System.out.println("tableType: " + tableType);
res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
+
break;
}
@@ -243,6 +256,7 @@ public class OdbcParser implements GridNioParser {
/**
* Write ODBC response using provided {@link BinaryRawWriterEx} instance.
+ *
* @param ses Current session.
* @param writer Writer.
* @param rsp ODBC response that should be written.
@@ -250,15 +264,15 @@ public class OdbcParser implements GridNioParser {
*/
private void writeResponse(GridNioSession ses, BinaryRawWriterEx writer, OdbcResponse rsp) throws IOException {
// Writing status
- writer.writeByte((byte)rsp.getSuccessStatus());
+ writer.writeByte((byte)rsp.status());
- if (rsp.getSuccessStatus() != OdbcResponse.STATUS_SUCCESS) {
- writer.writeString(rsp.getError());
+ if (rsp.status() != OdbcResponse.STATUS_SUCCESS) {
+ writer.writeString(rsp.error());
return;
}
- Object res0 = rsp.getResponse();
+ Object res0 = rsp.response();
if (res0 instanceof OdbcQueryExecuteResult) {
OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0;
@@ -276,25 +290,27 @@ public class OdbcParser implements GridNioParser {
for (OdbcColumnMeta meta : metas)
meta.writeBinary(writer, marsh.context());
- } else if (res0 instanceof OdbcQueryFetchResult) {
+ }
+ else if (res0 instanceof OdbcQueryFetchResult) {
OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0;
- System.out.println("Resulting query ID: " + res.getQueryId());
+ System.out.println("Resulting query ID: " + res.queryId());
- writer.writeLong(res.getQueryId());
+ writer.writeLong(res.queryId());
- Collection<?> items0 = res.getItems();
+ Collection<?> items0 = res.items();
assert items0 != null;
- Collection<Collection<Object>> items = (Collection<Collection<Object>>)items0;
+ writer.writeBoolean(res.last());
- writer.writeBoolean(res.getLast());
+ writer.writeInt(items0.size());
- writer.writeInt(items.size());
+ for (Object row0 : items0) {
+ if (row0 != null) {
+
+ Collection<?> row = (Collection<?>)row0;
- for (Collection<Object> row : items) {
- if (row != null) {
writer.writeInt(row.size());
for (Object obj : row) {
@@ -303,17 +319,19 @@ public class OdbcParser implements GridNioParser {
}
}
}
- } else if (res0 instanceof OdbcQueryCloseResult) {
+ }
+ else if (res0 instanceof OdbcQueryCloseResult) {
OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0;
System.out.println("Resulting query ID: " + res.getQueryId());
writer.writeLong(res.getQueryId());
- } else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
+ }
+ else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0;
- Collection<OdbcColumnMeta> columnsMeta = res.getMeta();
+ Collection<OdbcColumnMeta> columnsMeta = res.meta();
assert columnsMeta != null;
@@ -322,10 +340,11 @@ public class OdbcParser implements GridNioParser {
for (OdbcColumnMeta columnMeta : columnsMeta)
columnMeta.writeBinary(writer, marsh.context());
- } else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
+ }
+ else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
OdbcQueryGetTablesMetaResult res = (OdbcQueryGetTablesMetaResult) res0;
- Collection<OdbcTableMeta> tablesMeta = res.getMeta();
+ Collection<OdbcTableMeta> tablesMeta = res.meta();
assert tablesMeta != null;
@@ -334,8 +353,8 @@ public class OdbcParser implements GridNioParser {
for (OdbcTableMeta tableMeta : tablesMeta)
tableMeta.writeBinary(writer);
- } else {
- throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]");
}
+ else
+ throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]");
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
index 91b24a4..39652c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
@@ -40,10 +40,12 @@ public class OdbcProcessor extends GridProcessorAdapter {
/** Protocol handler. */
private final OdbcProtocolHandler protoHnd = new OdbcProtocolHandler() {
+ /** {@inheritDoc} */
@Override public OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException {
return handle0(req);
}
+ /** {@inheritDoc} */
@Override public IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req) {
return new GridFinishedFuture<>(
new IgniteCheckedException("Failed to handle request (asynchronous handling is not implemented)."));
@@ -51,6 +53,8 @@ public class OdbcProcessor extends GridProcessorAdapter {
};
/**
+ * Handle request.
+ *
* @param req Request.
* @return Response.
*/
@@ -71,8 +75,10 @@ public class OdbcProcessor extends GridProcessorAdapter {
}
/**
+ * Handle request.
+ *
* @param req Request.
- * @return Future.
+ * @return Response.
*/
private OdbcResponse handleRequest(final OdbcRequest req) throws IgniteCheckedException {
if (log.isDebugEnabled())
@@ -149,6 +155,8 @@ public class OdbcProcessor extends GridProcessorAdapter {
}
/**
+ * Check if the ODBC is enabled.
+ *
* @return Whether or not ODBC is enabled.
*/
public boolean isOdbcEnabled() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
index e1957d7..2b80e95 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
@@ -24,15 +24,19 @@ import org.apache.ignite.internal.IgniteInternalFuture;
*/
public interface OdbcProtocolHandler {
/**
+ * Handle request.
+ *
* @param req Request.
* @return Response.
* @throws IgniteCheckedException In case of error.
*/
- public OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException;
+ OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException;
/**
+ * Handle request asynchronously.
+ *
* @param req Request.
* @return Future.
*/
- public IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req);
+ IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
index e9b5698..eb644e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseRequest.java
@@ -21,20 +21,14 @@ package org.apache.ignite.internal.processors.odbc;
*/
public class OdbcQueryCloseRequest extends OdbcRequest {
/** Query ID. */
- private long queryId;
+ private final long queryId;
/**
* @param queryId Query ID.
*/
public OdbcQueryCloseRequest(long queryId) {
super(CLOSE_SQL_QUERY);
- this.queryId = queryId;
- }
- /**
- * @param queryId Query ID.
- */
- public void cacheName(long queryId) {
this.queryId = queryId;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
index cbc23c8..92c433a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryCloseResult.java
@@ -17,11 +17,11 @@
package org.apache.ignite.internal.processors.odbc;
/**
- * Query result.
+ * ODBC query result.
*/
public class OdbcQueryCloseResult {
/** Query ID. */
- private long queryId;
+ private final long queryId;
/**
* @param queryId Query ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
index 4628b52..d01a0c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteRequest.java
@@ -21,13 +21,13 @@ package org.apache.ignite.internal.processors.odbc;
*/
public class OdbcQueryExecuteRequest extends OdbcRequest {
/** Cache name. */
- private String cacheName;
+ private final String cacheName;
/** Sql query. */
- private String sqlQry;
+ private final String sqlQry;
/** Sql query arguments. */
- private Object[] args;
+ private final Object[] args;
/**
* @param cacheName Cache name.
@@ -36,19 +36,13 @@ public class OdbcQueryExecuteRequest extends OdbcRequest {
*/
public OdbcQueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
super(EXECUTE_SQL_QUERY);
+
this.cacheName = cacheName;
this.sqlQry = sqlQry;
this.args = args;
}
/**
- * @param sqlQry Sql query.
- */
- public void sqlQuery(String sqlQry) {
- this.sqlQry = sqlQry;
- }
-
- /**
* @return Sql query.
*/
public String sqlQuery() {
@@ -56,13 +50,6 @@ public class OdbcQueryExecuteRequest extends OdbcRequest {
}
/**
- * @param args Sql query arguments.
- */
- public void arguments(Object[] args) {
- this.args = args;
- }
-
- /**
* @return Sql query arguments.
*/
public Object[] arguments() {
@@ -70,13 +57,6 @@ public class OdbcQueryExecuteRequest extends OdbcRequest {
}
/**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
* @return Cache name.
*/
public String cacheName() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
index a4dec54..be8da07 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryExecuteResult.java
@@ -16,8 +16,6 @@
*/
package org.apache.ignite.internal.processors.odbc;
-import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
-
import java.util.Collection;
/**
@@ -25,16 +23,16 @@ import java.util.Collection;
*/
public class OdbcQueryExecuteResult {
/** Query ID. */
- private long queryId;
+ private final long queryId;
/** Fields metadata. */
- private Collection<OdbcColumnMeta> columnsMeta;
+ private final Collection<OdbcColumnMeta> columnsMeta;
/**
* @param queryId Query ID.
* @param columnsMeta Columns metadata.
*/
- public OdbcQueryExecuteResult(long queryId, Collection<OdbcColumnMeta> columnsMeta){
+ public OdbcQueryExecuteResult(long queryId, Collection<OdbcColumnMeta> columnsMeta) {
this.queryId = queryId;
this.columnsMeta = columnsMeta;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
index 7609649..3da0824 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchRequest.java
@@ -21,10 +21,10 @@ package org.apache.ignite.internal.processors.odbc;
*/
public class OdbcQueryFetchRequest extends OdbcRequest {
/** Query ID. */
- private long queryId;
+ private final long queryId;
/** Page size - maximum number of rows to return. */
- private Integer pageSize;
+ private final int pageSize;
/**
* @param queryId Query ID.
@@ -32,14 +32,8 @@ public class OdbcQueryFetchRequest extends OdbcRequest {
*/
public OdbcQueryFetchRequest(long queryId, int pageSize) {
super(FETCH_SQL_QUERY);
- this.queryId = queryId;
- this.pageSize = pageSize;
- }
- /**
- * @param pageSize Page size.
- */
- public void pageSize(Integer pageSize) {
+ this.queryId = queryId;
this.pageSize = pageSize;
}
@@ -51,13 +45,6 @@ public class OdbcQueryFetchRequest extends OdbcRequest {
}
/**
- * @param queryId Query ID.
- */
- public void cacheName(long queryId) {
- this.queryId = queryId;
- }
-
- /**
* @return Query ID.
*/
public long queryId() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
index b103914..9278a40 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryFetchResult.java
@@ -23,53 +23,43 @@ import java.util.Collection;
*/
public class OdbcQueryFetchResult {
/** Query ID. */
- private long queryId;
+ private final long queryId;
/** Query result rows. */
- private Collection<?> items = null;
+ private final Collection<?> items;
/** Flag indicating the query has no unfetched results. */
- private boolean last = false;
+ private final boolean last;
/**
* @param queryId Query ID.
+ * @param items Query result rows.
+ * @param last Flag indicating the query has no unfetched results.
*/
- public OdbcQueryFetchResult(long queryId){
+ public OdbcQueryFetchResult(long queryId, Collection<?> items, boolean last){
this.queryId = queryId;
+ this.items = items;
+ this.last = last;
}
/**
* @return Query ID.
*/
- public long getQueryId() {
+ public long queryId() {
return queryId;
}
/**
- * @param items Query result rows.
- */
- public void setItems(Collection<?> items) {
- this.items = items;
- }
-
- /**
* @return Query result rows.
*/
- public Collection<?> getItems() {
+ public Collection<?> items() {
return items;
}
/**
- * @param last Flag indicating the query has no unfetched results.
- */
- public void setLast(boolean last) {
- this.last = last;
- }
-
- /**
* @return Flag indicating the query has no unfetched results.
*/
- public boolean getLast() {
+ public boolean last() {
return last;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
index b0f1ba6..00b1ab0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaRequest.java
@@ -21,16 +21,18 @@ package org.apache.ignite.internal.processors.odbc;
*/
public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
/** Cache name. */
- private String cacheName;
+ private final String cacheName;
/** Table name. */
- private String tableName;
+ private final String tableName;
/** Column name. */
- private String columnName;
+ private final String columnName;
/**
* @param cacheName Cache name.
+ * @param tableName Table name.
+ * @param columnName Column name.
*/
public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
super(GET_COLUMNS_META);
@@ -41,13 +43,6 @@ public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
}
/**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
* @return Cache name.
*/
public String cacheName() {
@@ -55,13 +50,6 @@ public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
}
/**
- * @param tableName Table name.
- */
- public void tableName(String tableName) {
- this.tableName = tableName;
- }
-
- /**
* @return Table name.
*/
public String tableName() {
@@ -69,13 +57,6 @@ public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
}
/**
- * @param columnName Column name.
- */
- public void columnName(String columnName) {
- this.columnName = columnName;
- }
-
- /**
* @return Column name.
*/
public String columnName() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
index f00176c..c4f63b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetColumnsMetaResult.java
@@ -16,8 +16,6 @@
*/
package org.apache.ignite.internal.processors.odbc;
-import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
-
import java.util.Collection;
/**
@@ -25,7 +23,7 @@ import java.util.Collection;
*/
public class OdbcQueryGetColumnsMetaResult {
/** Query result rows. */
- private Collection<OdbcColumnMeta> meta;
+ private final Collection<OdbcColumnMeta> meta;
/**
* @param meta Column metadata.
@@ -37,7 +35,7 @@ public class OdbcQueryGetColumnsMetaResult {
/**
* @return Query result rows.
*/
- public Collection<OdbcColumnMeta> getMeta() {
+ public Collection<OdbcColumnMeta> meta() {
return meta;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
index 7d8194c..097cfe2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaRequest.java
@@ -21,16 +21,16 @@ package org.apache.ignite.internal.processors.odbc;
*/
public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
/** Catalog search pattern. */
- private String catalog;
+ private final String catalog;
/** Schema search pattern. */
- private String schema;
+ private final String schema;
/** Table search pattern. */
- private String table;
+ private final String table;
/** Table type search pattern. */
- private String tableType;
+ private final String tableType;
/**
* @param catalog Catalog search pattern.
@@ -48,13 +48,6 @@ public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
}
/**
- * @param catalog Catalog search pattern.
- */
- public void catalog(String catalog) {
- this.catalog = catalog;
- }
-
- /**
* @return catalog search pattern.
*/
public String catalog() {
@@ -62,13 +55,6 @@ public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
}
/**
- * @param schema Schema search pattern.
- */
- public void schema(String schema) {
- this.schema = schema;
- }
-
- /**
* @return Schema search pattern.
*/
public String schema() {
@@ -76,13 +62,6 @@ public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
}
/**
- * @param table Schema search pattern.
- */
- public void table(String table) {
- this.table = table;
- }
-
- /**
* @return Table search pattern.
*/
public String table() {
@@ -90,13 +69,6 @@ public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
}
/**
- * @param tableType Table type search pattern.
- */
- public void tableType(String tableType) {
- this.tableType = tableType;
- }
-
- /**
* @return Table type search pattern.
*/
public String tableType() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
index e737772..5a92759 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcQueryGetTablesMetaResult.java
@@ -16,8 +16,6 @@
*/
package org.apache.ignite.internal.processors.odbc;
-import org.apache.ignite.internal.processors.odbc.OdbcTableMeta;
-
import java.util.Collection;
/**
@@ -25,7 +23,7 @@ import java.util.Collection;
*/
public class OdbcQueryGetTablesMetaResult {
/** Query result rows. */
- private Collection<OdbcTableMeta> meta;
+ private final Collection<OdbcTableMeta> meta;
/**
* @param meta Column metadata.
@@ -37,7 +35,7 @@ public class OdbcQueryGetTablesMetaResult {
/**
* @return Query result rows.
*/
- public Collection<OdbcTableMeta> getMeta() {
+ public Collection<OdbcTableMeta> meta() {
return meta;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
index 1e8aecc..5d74843 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequest.java
@@ -36,7 +36,7 @@ public class OdbcRequest {
public static final int GET_TABLES_META = 5;
/** Command. */
- private int cmd;
+ private final int cmd;
/**
* @param cmd Command type.
@@ -51,11 +51,4 @@ public class OdbcRequest {
public int command() {
return cmd;
}
-
- /**
- * @param cmd Command.
- */
- public void command(int cmd) {
- this.cmd = cmd;
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
index 653e3f4..e532499 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcResponse.java
@@ -24,7 +24,6 @@ import org.jetbrains.annotations.Nullable;
* ODBC protocol response.
*/
public class OdbcResponse {
-
/** Command succeeded. */
public static final int STATUS_SUCCESS = 0;
@@ -32,15 +31,14 @@ public class OdbcResponse {
public static final int STATUS_FAILED = 1;
/** Success status. */
- @SuppressWarnings("RedundantFieldInitialization")
- private int successStatus = STATUS_SUCCESS;
+ private final int status;
/** Error. */
- private String err;
+ private final String err;
/** Response object. */
@GridToStringInclude
- private Object obj;
+ private final Object obj;
/**
* Constructs successful rest response.
@@ -48,8 +46,10 @@ public class OdbcResponse {
* @param obj Response object.
*/
public OdbcResponse(Object obj) {
- successStatus = STATUS_SUCCESS;
+ this.status = STATUS_SUCCESS;
+
this.obj = obj;
+ this.err = null;
}
/**
@@ -61,45 +61,33 @@ public class OdbcResponse {
public OdbcResponse(int status, @Nullable String err) {
assert status != STATUS_SUCCESS;
- successStatus = status;
+ this.status = status;
+
+ this.obj = null;
this.err = err;
}
/**
* @return Success flag.
*/
- public int getSuccessStatus() {
- return successStatus;
+ public int status() {
+ return status;
}
/**
* @return Response object.
*/
- public Object getResponse() {
+ public Object response() {
return obj;
}
/**
- * @param obj Response object.
- */
- public void setResponse(@Nullable Object obj) {
- this.obj = obj;
- }
-
- /**
* @return Error.
*/
- public String getError() {
+ public String error() {
return err;
}
- /**
- * @param err Error.
- */
- public void setError(String err) {
- this.err = err;
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(OdbcResponse.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
index b1eea71..4b8bf23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
@@ -25,19 +25,20 @@ import java.io.IOException;
*/
public class OdbcTableMeta {
/** Catalog name. */
- private String catalog;
+ private final String catalog;
/** Schema name. */
- private String schema;
+ private final String schema;
/** Table name. */
- private String table;
+ private final String table;
/** Table type. */
- private String tableType;
+ private final String tableType;
/**
* Add quotation marks at the beginning and end of the string.
+ *
* @param str Input string.
* @return String surrounded with quotation marks.
*/
@@ -61,8 +62,8 @@ public class OdbcTableMeta {
this.tableType = tableType;
}
- @Override
- public boolean equals(Object o)
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o)
{
if (!(o instanceof OdbcTableMeta))
return false;
@@ -77,6 +78,7 @@ public class OdbcTableMeta {
/**
* Write in a binary format.
+ *
* @param writer Binary writer.
* @throws IOException
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
index c30daff..ffd425a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
@@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.odbc;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.util.nio.GridNioFuture;
import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
import org.apache.ignite.internal.util.nio.GridNioSession;
@@ -29,32 +28,28 @@ import org.jetbrains.annotations.Nullable;
* Listener for ODBC driver connection.
*/
public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest> {
- /** Server. */
- private OdbcTcpServer srv;
-
/** Logger. */
- protected final IgniteLogger log;
-
- /** Context. */
- protected final GridKernalContext ctx;
+ private final IgniteLogger log;
/** Protocol handler. */
- private OdbcProtocolHandler hnd;
+ private final OdbcProtocolHandler hnd;
- OdbcTcpNioListener(IgniteLogger log, OdbcTcpServer srv, GridKernalContext ctx, OdbcProtocolHandler hnd) {
+ /**
+ * @param log Logger.
+ * @param hnd Protocol handler.
+ */
+ OdbcTcpNioListener(IgniteLogger log, OdbcProtocolHandler hnd) {
this.log = log;
- this.srv = srv;
- this.ctx = ctx;
this.hnd = hnd;
}
- @Override
- public void onConnected(GridNioSession ses) {
+ /** {@inheritDoc} */
+ @Override public void onConnected(GridNioSession ses) {
System.out.println("Driver connected");
}
- @Override
- public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
+ /** {@inheritDoc} */
+ @Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
System.out.println("Driver disconnected");
if (e != null) {
@@ -65,8 +60,8 @@ public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest
}
}
- @Override
- public void onMessage(GridNioSession ses, OdbcRequest msg) {
+ /** {@inheritDoc} */
+ @Override public void onMessage(GridNioSession ses, OdbcRequest msg) {
assert msg != null;
System.out.println("Query: " + msg.command());
@@ -83,7 +78,7 @@ public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest
"Failed to process client request: " + e.getMessage());
}
- System.out.println("Resulting success status: " + res.getSuccessStatus());
+ System.out.println("Resulting success status: " + res.status());
GridNioFuture<?> sf = ses.send(res);
@@ -91,7 +86,8 @@ public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest
if (sf.isDone()) {
try {
sf.get();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
U.error(log, "Failed to process client request [ses=" + ses + ", msg=" + msg + ']', e);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/73127efb/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
index 83adb1b..8c69e3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
@@ -34,30 +34,18 @@ import java.nio.ByteOrder;
* TCP server that handles communication with ODBC driver.
*/
public class OdbcTcpServer {
-
/** Server. */
private GridNioServer<OdbcRequest> srv;
- /** NIO server listener. */
- private GridNioServerListener<OdbcRequest> lsnr;
-
/** Logger. */
- protected final IgniteLogger log;
+ private final IgniteLogger log;
/** Context. */
- protected final GridKernalContext ctx;
-
- /** Host used by this protocol. */
- protected InetAddress host;
-
- /** Port used by this protocol. */
- protected int port;
-
- /** */
- public String name() {
- return "ODBC server";
- }
+ private final GridKernalContext ctx;
+ /**
+ * @param ctx Kernel context.
+ */
public OdbcTcpServer(GridKernalContext ctx) {
assert ctx != null;
assert ctx.config().getConnectorConfiguration() != null;
@@ -67,44 +55,44 @@ public class OdbcTcpServer {
log = ctx.log(getClass());
}
- @SuppressWarnings("BusyWait")
+ /**
+ * Start ODBC TCP server.
+ *
+ * @param hnd ODBC protocol handler.
+ * @throws IgniteCheckedException
+ */
public void start(final OdbcProtocolHandler hnd) throws IgniteCheckedException {
OdbcConfiguration cfg = ctx.config().getOdbcConfiguration();
assert cfg != null;
- lsnr = new OdbcTcpNioListener(log, this, ctx, hnd);
+ GridNioServerListener<OdbcRequest> listener = new OdbcTcpNioListener(log, hnd);
GridNioParser parser = new OdbcParser(ctx);
try {
- host = resolveOdbcTcpHost(ctx.config());
-
- int odbcPort = cfg.getPort();
+ InetAddress host = resolveOdbcTcpHost(ctx.config());
- if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) {
- port = odbcPort;
+ int port = cfg.getPort();
+ if (startTcpServer(host, port, listener, parser, cfg)) {
System.out.println("ODBC Server has started on TCP port " + port);
return;
}
- U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " +
- "[odbcPort=" + odbcPort + ", host=" + host + ']');
+ U.warn(log, "Failed to start ODBC server (possibly all ports in range are in use) " +
+ "[port=" + port + ", host=" + host + ']');
}
catch (IOException e) {
- U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(),
- "Failed to start " + name() + " on port " + port + ". " +
- "Check restTcpHost configuration property.");
+ U.warn(log, "Failed to start ODBC server: " + e.getMessage(),
+ "Failed to start ODBC server. Check odbcTcpHost configuration property.");
}
}
- /** */
- public void onKernalStart() {
- }
-
- /** */
+ /**
+ * Stop ODBC TCP server.
+ */
public void stop() {
if (srv != null) {
ctx.ports().deregisterPorts(getClass());
@@ -139,13 +127,13 @@ public class OdbcTcpServer {
*
* @param hostAddr Host on which server should be bound.
* @param port Port on which server should be bound.
- * @param lsnr Server message listener.
+ * @param listener Server message listener.
* @param parser Server message parser.
* @param cfg Configuration for other parameters.
* @return {@code True} if server successfully started, {@code false} if port is used and
* server was unable to start.
*/
- private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> lsnr,
+ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> listener,
GridNioParser parser, OdbcConfiguration cfg) {
try {
GridNioFilter codec = new GridNioCodecFilter(parser, log, false);
@@ -157,7 +145,7 @@ public class OdbcTcpServer {
srv = GridNioServer.<OdbcRequest>builder()
.address(hostAddr)
.port(port)
- .listener(lsnr)
+ .listener(listener)
.logger(log)
.selectorCount(cfg.getSelectorCount())
.gridName(ctx.gridName())
@@ -181,7 +169,7 @@ public class OdbcTcpServer {
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
- log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage());
+ log.debug("Failed to start ODBC server on port " + port + ": " + e.getMessage());
return false;
}
[03/28] ignite git commit: IGNITE-2447: Renamed ODBC classes to
follow naming convention.
Posted by vo...@apache.org.
IGNITE-2447: Renamed ODBC classes to follow naming convention.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9baf2668
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9baf2668
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9baf2668
Branch: refs/heads/ignite-1786
Commit: 9baf2668e00ed879e7f777d0b21d58aa81c900c3
Parents: a622561
Author: isapego <is...@gridgain.com>
Authored: Mon Jan 25 18:17:07 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Mon Jan 25 18:17:07 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/GridKernalContext.java | 4 +-
.../ignite/internal/GridKernalContextImpl.java | 10 +-
.../apache/ignite/internal/IgniteKernal.java | 4 +-
.../processors/odbc/GridOdbcColumnMeta.java | 125 -------
.../processors/odbc/GridOdbcCommandHandler.java | 337 ------------------
.../processors/odbc/GridOdbcProcessor.java | 160 ---------
.../odbc/GridOdbcProtocolHandler.java | 40 ---
.../processors/odbc/GridOdbcTableMeta.java | 89 -----
.../processors/odbc/OdbcColumnMeta.java | 125 +++++++
.../processors/odbc/OdbcCommandHandler.java | 337 ++++++++++++++++++
.../internal/processors/odbc/OdbcProcessor.java | 160 +++++++++
.../processors/odbc/OdbcProtocolHandler.java | 40 +++
.../internal/processors/odbc/OdbcTableMeta.java | 89 +++++
.../odbc/protocol/GridOdbcParser.java | 345 -------------------
.../odbc/protocol/GridTcpOdbcNioListener.java | 102 ------
.../odbc/protocol/GridTcpOdbcServer.java | 191 ----------
.../processors/odbc/protocol/OdbcParser.java | 345 +++++++++++++++++++
.../odbc/protocol/OdbcTcpNioListener.java | 102 ++++++
.../processors/odbc/protocol/OdbcTcpServer.java | 191 ++++++++++
.../odbc/request/GridOdbcRequest.java | 61 ----
.../odbc/request/OdbcQueryCloseRequest.java | 47 +++
.../odbc/request/OdbcQueryExecuteRequest.java | 85 +++++
.../odbc/request/OdbcQueryFetchRequest.java | 66 ++++
.../request/OdbcQueryGetColumnsMetaRequest.java | 84 +++++
.../request/OdbcQueryGetTablesMetaRequest.java | 105 ++++++
.../processors/odbc/request/OdbcRequest.java | 61 ++++
.../odbc/request/QueryCloseRequest.java | 47 ---
.../odbc/request/QueryExecuteRequest.java | 85 -----
.../odbc/request/QueryFetchRequest.java | 66 ----
.../request/QueryGetColumnsMetaRequest.java | 84 -----
.../odbc/request/QueryGetTablesMetaRequest.java | 105 ------
.../odbc/response/GridOdbcResponse.java | 107 ------
.../odbc/response/OdbcQueryCloseResult.java | 39 +++
.../odbc/response/OdbcQueryExecuteResult.java | 55 +++
.../odbc/response/OdbcQueryFetchResult.java | 75 ++++
.../response/OdbcQueryGetColumnsMetaResult.java | 43 +++
.../response/OdbcQueryGetTablesMetaResult.java | 43 +++
.../processors/odbc/response/OdbcResponse.java | 107 ++++++
.../odbc/response/QueryCloseResult.java | 39 ---
.../odbc/response/QueryExecuteResult.java | 55 ---
.../odbc/response/QueryFetchResult.java | 75 ----
.../response/QueryGetColumnsMetaResult.java | 43 ---
.../odbc/response/QueryGetTablesMetaResult.java | 43 ---
43 files changed, 2208 insertions(+), 2208 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index e563478..b95d595 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -48,7 +48,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsHelper;
import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
-import org.apache.ignite.internal.processors.odbc.GridOdbcProcessor;
+import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
@@ -316,7 +316,7 @@ public interface GridKernalContext extends Iterable<GridComponent> {
*
* @return ODBC processor.
*/
- public GridOdbcProcessor odbc();
+ public OdbcProcessor odbc();
/**
* @return Plugin processor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 81088b4..753dbe8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -65,7 +65,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
-import org.apache.ignite.internal.processors.odbc.GridOdbcProcessor;
+import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
@@ -161,7 +161,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
/** */
@GridToStringInclude
- private GridOdbcProcessor odbcProc;
+ private OdbcProcessor odbcProc;
/** */
@GridToStringInclude
@@ -511,8 +511,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
pluginProc = (IgnitePluginProcessor)comp;
else if (comp instanceof GridQueryProcessor)
qryProc = (GridQueryProcessor)comp;
- else if (comp instanceof GridOdbcProcessor)
- odbcProc = (GridOdbcProcessor)comp;
+ else if (comp instanceof OdbcProcessor)
+ odbcProc = (OdbcProcessor)comp;
else if (comp instanceof DataStructuresProcessor)
dataStructuresProc = (DataStructuresProcessor)comp;
else if (comp instanceof ClusterProcessor)
@@ -756,7 +756,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
}
/** {@inheritDoc} */
- @Override public GridOdbcProcessor odbc() {
+ @Override public OdbcProcessor odbc() {
return odbcProc;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 22afe01..cd27995 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -117,7 +117,7 @@ import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
import org.apache.ignite.internal.processors.nodevalidation.OsDiscoveryNodeValidationProcessor;
-import org.apache.ignite.internal.processors.odbc.GridOdbcProcessor;
+import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformNoopProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
@@ -850,7 +850,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
startProcessor(createComponent(IgniteCacheObjectProcessor.class, ctx));
startProcessor(new GridCacheProcessor(ctx));
startProcessor(new GridQueryProcessor(ctx));
- startProcessor(new GridOdbcProcessor(ctx));
+ startProcessor(new OdbcProcessor(ctx));
startProcessor(new GridTaskSessionProcessor(ctx));
startProcessor(new GridJobProcessor(ctx));
startProcessor(new GridTaskProcessor(ctx));
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcColumnMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcColumnMeta.java
deleted file mode 100644
index 03a5dd8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcColumnMeta.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc;
-
-import org.apache.ignite.internal.binary.BinaryClassDescriptor;
-import org.apache.ignite.internal.binary.BinaryContext;
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
-import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
-
-import java.io.IOException;
-
-import static org.apache.ignite.internal.binary.GridBinaryMarshaller.UNREGISTERED_TYPE_ID;
-
-/**
- * ODBC column-related metadata.
- */
-public class GridOdbcColumnMeta {
- /** Cache name. */
- private String schemaName;
-
- /** Table name. */
- private String tableName;
-
- /** Column name. */
- private String columnName;
-
- /** Data type. */
- private Class<?> dataType;
-
- /**
- * Add quotation marks at the beginning and end of the string.
- * @param str Input string.
- * @return String surrounded with quotation marks.
- */
- private String AddQuotationMarksIfNeeded(String str) {
- if (!str.startsWith("\"") && !str.isEmpty())
- return "\"" + str + "\"";
-
- return str;
- }
-
- /**
- * @param schemaName Cache name.
- * @param tableName Table name.
- * @param columnName Column name.
- * @param dataType Data type.
- */
- public GridOdbcColumnMeta(String schemaName, String tableName, String columnName, Class<?> dataType) {
- this.schemaName = AddQuotationMarksIfNeeded(schemaName);
- this.tableName = tableName;
- this.columnName = columnName;
- this.dataType = dataType;
- }
-
- /**
- * @param info Field metadata.
- */
- public GridOdbcColumnMeta(GridQueryFieldMetadata info) {
- this.schemaName = AddQuotationMarksIfNeeded(info.schemaName());
- this.tableName = info.typeName();
- this.columnName = info.fieldName();
-
- try {
- this.dataType = Class.forName(info.fieldTypeName());
- }
- catch (Exception ignored) {
- this.dataType = Object.class;
- }
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (!(o instanceof GridOdbcColumnMeta))
- return false;
-
- GridOdbcColumnMeta another = (GridOdbcColumnMeta)o;
-
- return schemaName.equals(another.schemaName) &&
- tableName.equals(another.tableName) &&
- columnName.equals(another.columnName) &&
- dataType.equals(another.dataType);
- }
-
- /**
- * Write in a binary format.
- * @param writer Binary writer.
- * @param ctx Portable context.
- * @throws IOException
- */
- public void writeBinary(BinaryRawWriterEx writer, BinaryContext ctx) throws IOException {
- writer.writeString(schemaName);
- writer.writeString(tableName);
- writer.writeString(columnName);
- writer.writeString(dataType.getName());
-
- byte typeId;
-
- BinaryClassDescriptor desc = ctx.descriptorForClass(dataType, false);
-
- if (desc == null)
- throw new IOException("Object is not portable: [class=" + dataType + ']');
-
- if (desc.registered())
- typeId = (byte)desc.typeId();
- else
- typeId = (byte)UNREGISTERED_TYPE_ID;
-
- writer.writeByte(typeId);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcCommandHandler.java
deleted file mode 100644
index 2b19880..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcCommandHandler.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc;
-
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.odbc.request.*;
-import org.apache.ignite.internal.processors.odbc.response.*;
-import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
-import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
-import org.apache.ignite.lang.IgniteBiTuple;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.apache.ignite.internal.processors.odbc.request.GridOdbcRequest.*;
-
-/**
- * SQL query handler.
- */
-public class GridOdbcCommandHandler {
- /** Kernal context. */
- protected final GridKernalContext ctx;
-
- /** Log. */
- protected final IgniteLogger log;
-
- /** Query ID sequence. */
- private static final AtomicLong qryIdGen = new AtomicLong();
-
- /** Current queries cursors. */
- private final ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs = new ConcurrentHashMap<>();
-
- /**
- * @param ctx Context.
- */
- public GridOdbcCommandHandler(GridKernalContext ctx) {
- this.ctx = ctx;
-
- log = ctx.log(getClass());
- }
-
- /**
- * @param req Request.
- * @return Response.
- */
- public GridOdbcResponse handle(GridOdbcRequest req) {
- assert req != null;
-
- switch (req.command()) {
- case EXECUTE_SQL_QUERY: {
- return executeQuery((QueryExecuteRequest)req, qryCurs);
- }
-
- case FETCH_SQL_QUERY: {
- return fetchQuery((QueryFetchRequest)req, qryCurs);
- }
-
- case CLOSE_SQL_QUERY: {
- return closeQuery((QueryCloseRequest)req, qryCurs);
- }
-
- case GET_COLUMNS_META: {
- return getColumnsMeta((QueryGetColumnsMetaRequest) req);
- }
-
- case GET_TABLES_META: {
- return getTablesMeta((QueryGetTablesMetaRequest) req);
- }
- }
-
- return null;
- }
-
- /**
- * @param qryCurs Query cursors.
- * @param cur Current cursor.
- * @param req Sql fetch request.
- * @param qryId Query id.
- * @return Query result with items.
- */
- private static QueryFetchResult createQueryResult(
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
- Iterator cur, QueryFetchRequest req, Long qryId) {
- QueryFetchResult res = new QueryFetchResult(qryId);
-
- List<Object> items = new ArrayList<>();
-
- for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
- items.add(cur.next());
-
- res.setItems(items);
-
- res.setLast(!cur.hasNext());
-
- return res;
- }
-
- /**
- * @param meta Internal query field metadata.
- * @return Rest query field metadata.
- */
- private static Collection<GridOdbcColumnMeta> convertMetadata(Collection<GridQueryFieldMetadata> meta) {
- List<GridOdbcColumnMeta> res = new ArrayList<>();
-
- if (meta != null) {
- for (GridQueryFieldMetadata info : meta)
- res.add(new GridOdbcColumnMeta(info));
- }
-
- return res;
- }
-
- /**
- * Checks whether string matches SQL pattern.
- *
- * @param str String.
- * @param ptrn Pattern.
- * @return Whether string matches pattern.
- */
- private boolean matches(String str, String ptrn) {
- return str != null && (ptrn == null || ptrn.isEmpty() ||
- str.toUpperCase().matches(ptrn.toUpperCase().replace("%", ".*").replace("_", ".")));
- }
-
- /**
- * Remove quotation marks at the beginning and end of the string if present.
- * @param str Input string.
- * @return String without leading and trailing quotation marks.
- */
- private String RemoveQuotationMarksIfNeeded(String str) {
- if (str.startsWith("\"") && str.endsWith("\""))
- return str.substring(1, str.length() - 1);
-
- return str;
- }
-
- /**
- * @param req Execute query request.
- * @param qryCurs Queries cursors.
- * @return Response.
- */
- private GridOdbcResponse executeQuery(QueryExecuteRequest req,
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
- long qryId = qryIdGen.getAndIncrement();
-
- try {
- SqlFieldsQuery qry = new SqlFieldsQuery(req.sqlQuery());
-
- qry.setArgs(req.arguments());
-
- IgniteCache<Object, Object> cache = ctx.grid().cache(req.cacheName());
-
- if (cache == null)
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED,
- "Failed to find cache with name: " + req.cacheName());
-
- QueryCursor qryCur = cache.query(qry);
-
- Iterator cur = qryCur.iterator();
-
- qryCurs.put(qryId, new IgniteBiTuple<>(qryCur, cur));
-
- List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
-
- System.out.println("Field meta: " + fieldsMeta);
-
- QueryExecuteResult res = new QueryExecuteResult(qryId, convertMetadata(fieldsMeta));
-
- return new GridOdbcResponse(res);
- }
- catch (Exception e) {
- qryCurs.remove(qryId);
-
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED, e.getMessage());
- }
- }
-
- /**
- * @param req Execute query request.
- * @param qryCurs Queries cursors.
- * @return Response.
- */
- private GridOdbcResponse closeQuery(QueryCloseRequest req,
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
- try {
- QueryCursor cur = qryCurs.get(req.queryId()).get1();
-
- if (cur == null)
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED,
- "Failed to find query with ID: " + req.queryId());
-
- cur.close();
-
- qryCurs.remove(req.queryId());
-
- QueryCloseResult res = new QueryCloseResult(req.queryId());
-
- return new GridOdbcResponse(res);
- }
- catch (Exception e) {
- qryCurs.remove(req.queryId());
-
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED, e.getMessage());
- }
- }
-
- /**
- * @param req Execute query request.
- * @param qryCurs Queries cursors.
- * @return Response.
- */
- private GridOdbcResponse fetchQuery(QueryFetchRequest req,
- ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
- try {
- Iterator cur = qryCurs.get(req.queryId()).get2();
-
- if (cur == null)
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED,
- "Failed to find query with ID: " + req.queryId());
-
- QueryFetchResult res = createQueryResult(qryCurs, cur, req, req.queryId());
-
- return new GridOdbcResponse(res);
- }
- catch (Exception e) {
- qryCurs.remove(req.queryId());
-
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED, e.getMessage());
- }
- }
-
- /**
- * @param req Get columns metadata request.
- * @return Response.
- */
- private GridOdbcResponse getColumnsMeta(QueryGetColumnsMetaRequest req) {
- try {
- List<GridOdbcColumnMeta> meta = new ArrayList<>();
-
- String cacheName;
- String tableName;
-
- if (req.tableName().contains(".")) {
- // Parsing two-part table name.
- String[] parts = req.tableName().split("\\.");
-
- cacheName = RemoveQuotationMarksIfNeeded(parts[0]);
-
- tableName = parts[1];
- }
- else {
- cacheName = RemoveQuotationMarksIfNeeded(req.cacheName());
-
- tableName = req.tableName();
- }
-
- Collection<GridQueryTypeDescriptor> tablesMeta = ctx.query().types(cacheName);
-
- for (GridQueryTypeDescriptor table : tablesMeta) {
- if (!matches(table.name(), tableName))
- continue;
-
- for (Map.Entry<String, Class<?>> field : table.fields().entrySet()) {
- if (!matches(field.getKey(), req.columnName()))
- continue;
-
- GridOdbcColumnMeta columnMeta = new GridOdbcColumnMeta(req.cacheName(),
- table.name(), field.getKey(), field.getValue());
-
- if (!meta.contains(columnMeta))
- meta.add(columnMeta);
- }
- }
- QueryGetColumnsMetaResult res = new QueryGetColumnsMetaResult(meta);
-
- return new GridOdbcResponse(res);
- }
- catch (Exception e) {
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED, e.getMessage());
- }
- }
-
- /**
- * @param req Get tables metadata request.
- * @return Response.
- */
- private GridOdbcResponse getTablesMeta(QueryGetTablesMetaRequest req) {
- try {
- List<GridOdbcTableMeta> meta = new ArrayList<>();
-
- String realSchema = RemoveQuotationMarksIfNeeded(req.schema());
-
- Collection<GridQueryTypeDescriptor> tablesMeta = ctx.query().types(realSchema);
-
- for (GridQueryTypeDescriptor table : tablesMeta) {
- if (!matches(table.name(), req.table()))
- continue;
-
- if (!matches("TABLE", req.tableType()))
- continue;
-
- GridOdbcTableMeta tableMeta = new GridOdbcTableMeta(req.catalog(), req.schema(),
- table.name(), "TABLE");
-
- if (!meta.contains(tableMeta))
- meta.add(tableMeta);
- }
-
- QueryGetTablesMetaResult res = new QueryGetTablesMetaResult(meta);
-
- return new GridOdbcResponse(res);
- }
- catch (Exception e) {
- return new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED, e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProcessor.java
deleted file mode 100644
index a78b032..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProcessor.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.internal.processors.GridProcessorAdapter;
-import org.apache.ignite.internal.processors.odbc.protocol.GridTcpOdbcServer;
-import org.apache.ignite.internal.processors.odbc.request.GridOdbcRequest;
-import org.apache.ignite.internal.processors.odbc.response.GridOdbcResponse;
-import org.apache.ignite.internal.util.GridSpinReadWriteLock;
-import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.marshaller.Marshaller;
-
-/**
- * ODBC processor.
- */
-public class GridOdbcProcessor extends GridProcessorAdapter {
- /** OBCD TCP Server. */
- private GridTcpOdbcServer srv;
-
- /** Busy lock. */
- private final GridSpinReadWriteLock busyLock = new GridSpinReadWriteLock();
-
- /** Command handler. */
- private GridOdbcCommandHandler handler;
-
- /** Protocol handler. */
- private final GridOdbcProtocolHandler protoHnd = new GridOdbcProtocolHandler() {
- @Override public GridOdbcResponse handle(GridOdbcRequest req) throws IgniteCheckedException {
- return handle0(req);
- }
-
- @Override public IgniteInternalFuture<GridOdbcResponse> handleAsync(GridOdbcRequest req) {
- return new GridFinishedFuture<>(
- new IgniteCheckedException("Failed to handle request (asynchronous handling is not implemented)."));
- }
- };
-
- /**
- * @param req Request.
- * @return Response.
- */
- private GridOdbcResponse handle0(final GridOdbcRequest req) throws IgniteCheckedException {
- if (!busyLock.tryReadLock())
- throw new IgniteCheckedException("Failed to handle request (received request while stopping grid).");
-
- GridOdbcResponse rsp = null;
-
- try {
- rsp = handleRequest(req);
- }
- finally {
- busyLock.readUnlock();
- }
-
- return rsp;
- }
-
- /**
- * @param req Request.
- * @return Future.
- */
- private GridOdbcResponse handleRequest(final GridOdbcRequest req) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Received request from client: " + req);
-
- GridOdbcResponse rsp;
-
- try {
- rsp = handler == null ? null : handler.handle(req);
-
- if (rsp == null)
- throw new IgniteCheckedException("Failed to find registered handler for command: " + req.command());
- }
- catch (Exception e) {
- if (log.isDebugEnabled())
- log.debug("Failed to handle request [req=" + req + ", e=" + e + "]");
-
- rsp = new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED, e.getMessage());
- }
-
- return rsp;
- }
-
- /**
- * @param ctx Kernal context.
- */
- public GridOdbcProcessor(GridKernalContext ctx) {
- super(ctx);
-
- srv = new GridTcpOdbcServer(ctx);
- }
-
- /** {@inheritDoc} */
- @Override public void start() throws IgniteCheckedException {
- if (isOdbcEnabled()) {
-
- Marshaller marsh = ctx.config().getMarshaller();
-
- if (marsh != null && !(marsh instanceof BinaryMarshaller))
- throw new IgniteCheckedException("Failed to start processor " +
- "(ODBC may only be used with BinaryMarshaller).");
-
- // Register handler.
- handler = new GridOdbcCommandHandler(ctx);
-
- srv.start(protoHnd);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void stop(boolean cancel) throws IgniteCheckedException {
- if (isOdbcEnabled()) {
- srv.stop();
- }
- }
-
- /** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
- if (isOdbcEnabled()) {
-
- if (log.isDebugEnabled())
- log.debug("ODBC processor started.");
- }
- }
-
- /** {@inheritDoc} */
- @Override public void onKernalStop(boolean cancel) {
- if (isOdbcEnabled()) {
- busyLock.writeLock();
-
- if (log.isDebugEnabled())
- log.debug("ODBC processor stopped.");
- }
- }
-
- /**
- * @return Whether or not ODBC is enabled.
- */
- public boolean isOdbcEnabled() {
- return ctx.config().getOdbcConfiguration() != null;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProtocolHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProtocolHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProtocolHandler.java
deleted file mode 100644
index 033f067..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcProtocolHandler.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.odbc.request.GridOdbcRequest;
-import org.apache.ignite.internal.processors.odbc.response.GridOdbcResponse;
-
-/**
- * ODBC command protocol handler.
- */
-public interface GridOdbcProtocolHandler {
- /**
- * @param req Request.
- * @return Response.
- * @throws IgniteCheckedException In case of error.
- */
- public GridOdbcResponse handle(GridOdbcRequest req) throws IgniteCheckedException;
-
- /**
- * @param req Request.
- * @return Future.
- */
- public IgniteInternalFuture<GridOdbcResponse> handleAsync(GridOdbcRequest req);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcTableMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcTableMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcTableMeta.java
deleted file mode 100644
index 1dd11b8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/GridOdbcTableMeta.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc;
-
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
-
-import java.io.IOException;
-
-/**
- * ODBC table-related metadata.
- */
-public class GridOdbcTableMeta {
- /** Catalog name. */
- private String catalog;
-
- /** Schema name. */
- private String schema;
-
- /** Table name. */
- private String table;
-
- /** Table type. */
- private String tableType;
-
- /**
- * Add quotation marks at the beginning and end of the string.
- * @param str Input string.
- * @return String surrounded with quotation marks.
- */
- private String AddQuotationMarksIfNeeded(String str) {
- if (!str.startsWith("\"") && !str.isEmpty())
- return "\"" + str + "\"";
-
- return str;
- }
-
- /**
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @param tableType Table type.
- */
- public GridOdbcTableMeta(String catalog, String schema, String table, String tableType) {
- this.catalog = catalog;
- this.schema = AddQuotationMarksIfNeeded(schema);
- this.table = table;
- this.tableType = tableType;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (!(o instanceof GridOdbcTableMeta))
- return false;
-
- GridOdbcTableMeta another = (GridOdbcTableMeta)o;
-
- return catalog.equals(another.catalog) &&
- schema.equals(another.schema) &&
- table.equals(another.table) &&
- tableType.equals(another.tableType);
- }
-
- /**
- * Write in a binary format.
- * @param writer Binary writer.
- * @throws IOException
- */
- public void writeBinary(BinaryRawWriterEx writer) throws IOException {
- writer.writeString(catalog);
- writer.writeString(schema);
- writer.writeString(table);
- writer.writeString(tableType);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
new file mode 100644
index 0000000..0c2eed2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcColumnMeta.java
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.internal.binary.BinaryClassDescriptor;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
+
+import java.io.IOException;
+
+import static org.apache.ignite.internal.binary.GridBinaryMarshaller.UNREGISTERED_TYPE_ID;
+
+/**
+ * ODBC column-related metadata.
+ */
+public class OdbcColumnMeta {
+ /** Cache name. */
+ private String schemaName;
+
+ /** Table name. */
+ private String tableName;
+
+ /** Column name. */
+ private String columnName;
+
+ /** Data type. */
+ private Class<?> dataType;
+
+ /**
+ * Add quotation marks at the beginning and end of the string.
+ * @param str Input string.
+ * @return String surrounded with quotation marks.
+ */
+ private String AddQuotationMarksIfNeeded(String str) {
+ if (!str.startsWith("\"") && !str.isEmpty())
+ return "\"" + str + "\"";
+
+ return str;
+ }
+
+ /**
+ * @param schemaName Cache name.
+ * @param tableName Table name.
+ * @param columnName Column name.
+ * @param dataType Data type.
+ */
+ public OdbcColumnMeta(String schemaName, String tableName, String columnName, Class<?> dataType) {
+ this.schemaName = AddQuotationMarksIfNeeded(schemaName);
+ this.tableName = tableName;
+ this.columnName = columnName;
+ this.dataType = dataType;
+ }
+
+ /**
+ * @param info Field metadata.
+ */
+ public OdbcColumnMeta(GridQueryFieldMetadata info) {
+ this.schemaName = AddQuotationMarksIfNeeded(info.schemaName());
+ this.tableName = info.typeName();
+ this.columnName = info.fieldName();
+
+ try {
+ this.dataType = Class.forName(info.fieldTypeName());
+ }
+ catch (Exception ignored) {
+ this.dataType = Object.class;
+ }
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof OdbcColumnMeta))
+ return false;
+
+ OdbcColumnMeta another = (OdbcColumnMeta)o;
+
+ return schemaName.equals(another.schemaName) &&
+ tableName.equals(another.tableName) &&
+ columnName.equals(another.columnName) &&
+ dataType.equals(another.dataType);
+ }
+
+ /**
+ * Write in a binary format.
+ * @param writer Binary writer.
+ * @param ctx Portable context.
+ * @throws IOException
+ */
+ public void writeBinary(BinaryRawWriterEx writer, BinaryContext ctx) throws IOException {
+ writer.writeString(schemaName);
+ writer.writeString(tableName);
+ writer.writeString(columnName);
+ writer.writeString(dataType.getName());
+
+ byte typeId;
+
+ BinaryClassDescriptor desc = ctx.descriptorForClass(dataType, false);
+
+ if (desc == null)
+ throw new IOException("Object is not portable: [class=" + dataType + ']');
+
+ if (desc.registered())
+ typeId = (byte)desc.typeId();
+ else
+ typeId = (byte)UNREGISTERED_TYPE_ID;
+
+ writer.writeByte(typeId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
new file mode 100644
index 0000000..d8a05f7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
@@ -0,0 +1,337 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
+import org.apache.ignite.internal.processors.odbc.request.*;
+import org.apache.ignite.internal.processors.odbc.response.*;
+import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
+import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
+import org.apache.ignite.lang.IgniteBiTuple;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import static org.apache.ignite.internal.processors.odbc.request.OdbcRequest.*;
+
+/**
+ * SQL query handler.
+ */
+public class OdbcCommandHandler {
+ /** Kernal context. */
+ protected final GridKernalContext ctx;
+
+ /** Log. */
+ protected final IgniteLogger log;
+
+ /** Query ID sequence. */
+ private static final AtomicLong qryIdGen = new AtomicLong();
+
+ /** Current queries cursors. */
+ private final ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs = new ConcurrentHashMap<>();
+
+ /**
+ * @param ctx Context.
+ */
+ public OdbcCommandHandler(GridKernalContext ctx) {
+ this.ctx = ctx;
+
+ log = ctx.log(getClass());
+ }
+
+ /**
+ * @param req Request.
+ * @return Response.
+ */
+ public OdbcResponse handle(OdbcRequest req) {
+ assert req != null;
+
+ switch (req.command()) {
+ case EXECUTE_SQL_QUERY: {
+ return executeQuery((OdbcQueryExecuteRequest)req, qryCurs);
+ }
+
+ case FETCH_SQL_QUERY: {
+ return fetchQuery((OdbcQueryFetchRequest)req, qryCurs);
+ }
+
+ case CLOSE_SQL_QUERY: {
+ return closeQuery((OdbcQueryCloseRequest)req, qryCurs);
+ }
+
+ case GET_COLUMNS_META: {
+ return getColumnsMeta((OdbcQueryGetColumnsMetaRequest) req);
+ }
+
+ case GET_TABLES_META: {
+ return getTablesMeta((OdbcQueryGetTablesMetaRequest) req);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param qryCurs Query cursors.
+ * @param cur Current cursor.
+ * @param req Sql fetch request.
+ * @param qryId Query id.
+ * @return Query result with items.
+ */
+ private static OdbcQueryFetchResult createQueryResult(
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs,
+ Iterator cur, OdbcQueryFetchRequest req, Long qryId) {
+ OdbcQueryFetchResult res = new OdbcQueryFetchResult(qryId);
+
+ List<Object> items = new ArrayList<>();
+
+ for (int i = 0; i < req.pageSize() && cur.hasNext(); ++i)
+ items.add(cur.next());
+
+ res.setItems(items);
+
+ res.setLast(!cur.hasNext());
+
+ return res;
+ }
+
+ /**
+ * @param meta Internal query field metadata.
+ * @return Rest query field metadata.
+ */
+ private static Collection<OdbcColumnMeta> convertMetadata(Collection<GridQueryFieldMetadata> meta) {
+ List<OdbcColumnMeta> res = new ArrayList<>();
+
+ if (meta != null) {
+ for (GridQueryFieldMetadata info : meta)
+ res.add(new OdbcColumnMeta(info));
+ }
+
+ return res;
+ }
+
+ /**
+ * Checks whether string matches SQL pattern.
+ *
+ * @param str String.
+ * @param ptrn Pattern.
+ * @return Whether string matches pattern.
+ */
+ private boolean matches(String str, String ptrn) {
+ return str != null && (ptrn == null || ptrn.isEmpty() ||
+ str.toUpperCase().matches(ptrn.toUpperCase().replace("%", ".*").replace("_", ".")));
+ }
+
+ /**
+ * Remove quotation marks at the beginning and end of the string if present.
+ * @param str Input string.
+ * @return String without leading and trailing quotation marks.
+ */
+ private String RemoveQuotationMarksIfNeeded(String str) {
+ if (str.startsWith("\"") && str.endsWith("\""))
+ return str.substring(1, str.length() - 1);
+
+ return str;
+ }
+
+ /**
+ * @param req Execute query request.
+ * @param qryCurs Queries cursors.
+ * @return Response.
+ */
+ private OdbcResponse executeQuery(OdbcQueryExecuteRequest req,
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ long qryId = qryIdGen.getAndIncrement();
+
+ try {
+ SqlFieldsQuery qry = new SqlFieldsQuery(req.sqlQuery());
+
+ qry.setArgs(req.arguments());
+
+ IgniteCache<Object, Object> cache = ctx.grid().cache(req.cacheName());
+
+ if (cache == null)
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED,
+ "Failed to find cache with name: " + req.cacheName());
+
+ QueryCursor qryCur = cache.query(qry);
+
+ Iterator cur = qryCur.iterator();
+
+ qryCurs.put(qryId, new IgniteBiTuple<>(qryCur, cur));
+
+ List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
+
+ System.out.println("Field meta: " + fieldsMeta);
+
+ OdbcQueryExecuteResult res = new OdbcQueryExecuteResult(qryId, convertMetadata(fieldsMeta));
+
+ return new OdbcResponse(res);
+ }
+ catch (Exception e) {
+ qryCurs.remove(qryId);
+
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage());
+ }
+ }
+
+ /**
+ * @param req Execute query request.
+ * @param qryCurs Queries cursors.
+ * @return Response.
+ */
+ private OdbcResponse closeQuery(OdbcQueryCloseRequest req,
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ try {
+ QueryCursor cur = qryCurs.get(req.queryId()).get1();
+
+ if (cur == null)
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED,
+ "Failed to find query with ID: " + req.queryId());
+
+ cur.close();
+
+ qryCurs.remove(req.queryId());
+
+ OdbcQueryCloseResult res = new OdbcQueryCloseResult(req.queryId());
+
+ return new OdbcResponse(res);
+ }
+ catch (Exception e) {
+ qryCurs.remove(req.queryId());
+
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage());
+ }
+ }
+
+ /**
+ * @param req Execute query request.
+ * @param qryCurs Queries cursors.
+ * @return Response.
+ */
+ private OdbcResponse fetchQuery(OdbcQueryFetchRequest req,
+ ConcurrentHashMap<Long, IgniteBiTuple<QueryCursor, Iterator>> qryCurs) {
+ try {
+ Iterator cur = qryCurs.get(req.queryId()).get2();
+
+ if (cur == null)
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED,
+ "Failed to find query with ID: " + req.queryId());
+
+ OdbcQueryFetchResult res = createQueryResult(qryCurs, cur, req, req.queryId());
+
+ return new OdbcResponse(res);
+ }
+ catch (Exception e) {
+ qryCurs.remove(req.queryId());
+
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage());
+ }
+ }
+
+ /**
+ * @param req Get columns metadata request.
+ * @return Response.
+ */
+ private OdbcResponse getColumnsMeta(OdbcQueryGetColumnsMetaRequest req) {
+ try {
+ List<OdbcColumnMeta> meta = new ArrayList<>();
+
+ String cacheName;
+ String tableName;
+
+ if (req.tableName().contains(".")) {
+ // Parsing two-part table name.
+ String[] parts = req.tableName().split("\\.");
+
+ cacheName = RemoveQuotationMarksIfNeeded(parts[0]);
+
+ tableName = parts[1];
+ }
+ else {
+ cacheName = RemoveQuotationMarksIfNeeded(req.cacheName());
+
+ tableName = req.tableName();
+ }
+
+ Collection<GridQueryTypeDescriptor> tablesMeta = ctx.query().types(cacheName);
+
+ for (GridQueryTypeDescriptor table : tablesMeta) {
+ if (!matches(table.name(), tableName))
+ continue;
+
+ for (Map.Entry<String, Class<?>> field : table.fields().entrySet()) {
+ if (!matches(field.getKey(), req.columnName()))
+ continue;
+
+ OdbcColumnMeta columnMeta = new OdbcColumnMeta(req.cacheName(),
+ table.name(), field.getKey(), field.getValue());
+
+ if (!meta.contains(columnMeta))
+ meta.add(columnMeta);
+ }
+ }
+ OdbcQueryGetColumnsMetaResult res = new OdbcQueryGetColumnsMetaResult(meta);
+
+ return new OdbcResponse(res);
+ }
+ catch (Exception e) {
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage());
+ }
+ }
+
+ /**
+ * @param req Get tables metadata request.
+ * @return Response.
+ */
+ private OdbcResponse getTablesMeta(OdbcQueryGetTablesMetaRequest req) {
+ try {
+ List<OdbcTableMeta> meta = new ArrayList<>();
+
+ String realSchema = RemoveQuotationMarksIfNeeded(req.schema());
+
+ Collection<GridQueryTypeDescriptor> tablesMeta = ctx.query().types(realSchema);
+
+ for (GridQueryTypeDescriptor table : tablesMeta) {
+ if (!matches(table.name(), req.table()))
+ continue;
+
+ if (!matches("TABLE", req.tableType()))
+ continue;
+
+ OdbcTableMeta tableMeta = new OdbcTableMeta(req.catalog(), req.schema(),
+ table.name(), "TABLE");
+
+ if (!meta.contains(tableMeta))
+ meta.add(tableMeta);
+ }
+
+ OdbcQueryGetTablesMetaResult res = new OdbcQueryGetTablesMetaResult(meta);
+
+ return new OdbcResponse(res);
+ }
+ catch (Exception e) {
+ return new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
new file mode 100644
index 0000000..a3f0b94
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProcessor.java
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.GridProcessorAdapter;
+import org.apache.ignite.internal.processors.odbc.protocol.OdbcTcpServer;
+import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
+import org.apache.ignite.internal.processors.odbc.response.OdbcResponse;
+import org.apache.ignite.internal.util.GridSpinReadWriteLock;
+import org.apache.ignite.internal.util.future.GridFinishedFuture;
+import org.apache.ignite.marshaller.Marshaller;
+
+/**
+ * ODBC processor.
+ */
+public class OdbcProcessor extends GridProcessorAdapter {
+ /** OBCD TCP Server. */
+ private OdbcTcpServer srv;
+
+ /** Busy lock. */
+ private final GridSpinReadWriteLock busyLock = new GridSpinReadWriteLock();
+
+ /** Command handler. */
+ private OdbcCommandHandler handler;
+
+ /** Protocol handler. */
+ private final OdbcProtocolHandler protoHnd = new OdbcProtocolHandler() {
+ @Override public OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException {
+ return handle0(req);
+ }
+
+ @Override public IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req) {
+ return new GridFinishedFuture<>(
+ new IgniteCheckedException("Failed to handle request (asynchronous handling is not implemented)."));
+ }
+ };
+
+ /**
+ * @param req Request.
+ * @return Response.
+ */
+ private OdbcResponse handle0(final OdbcRequest req) throws IgniteCheckedException {
+ if (!busyLock.tryReadLock())
+ throw new IgniteCheckedException("Failed to handle request (received request while stopping grid).");
+
+ OdbcResponse rsp = null;
+
+ try {
+ rsp = handleRequest(req);
+ }
+ finally {
+ busyLock.readUnlock();
+ }
+
+ return rsp;
+ }
+
+ /**
+ * @param req Request.
+ * @return Future.
+ */
+ private OdbcResponse handleRequest(final OdbcRequest req) throws IgniteCheckedException {
+ if (log.isDebugEnabled())
+ log.debug("Received request from client: " + req);
+
+ OdbcResponse rsp;
+
+ try {
+ rsp = handler == null ? null : handler.handle(req);
+
+ if (rsp == null)
+ throw new IgniteCheckedException("Failed to find registered handler for command: " + req.command());
+ }
+ catch (Exception e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to handle request [req=" + req + ", e=" + e + "]");
+
+ rsp = new OdbcResponse(OdbcResponse.STATUS_FAILED, e.getMessage());
+ }
+
+ return rsp;
+ }
+
+ /**
+ * @param ctx Kernal context.
+ */
+ public OdbcProcessor(GridKernalContext ctx) {
+ super(ctx);
+
+ srv = new OdbcTcpServer(ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteCheckedException {
+ if (isOdbcEnabled()) {
+
+ Marshaller marsh = ctx.config().getMarshaller();
+
+ if (marsh != null && !(marsh instanceof BinaryMarshaller))
+ throw new IgniteCheckedException("Failed to start processor " +
+ "(ODBC may only be used with BinaryMarshaller).");
+
+ // Register handler.
+ handler = new OdbcCommandHandler(ctx);
+
+ srv.start(protoHnd);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop(boolean cancel) throws IgniteCheckedException {
+ if (isOdbcEnabled()) {
+ srv.stop();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onKernalStart() throws IgniteCheckedException {
+ if (isOdbcEnabled()) {
+
+ if (log.isDebugEnabled())
+ log.debug("ODBC processor started.");
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onKernalStop(boolean cancel) {
+ if (isOdbcEnabled()) {
+ busyLock.writeLock();
+
+ if (log.isDebugEnabled())
+ log.debug("ODBC processor stopped.");
+ }
+ }
+
+ /**
+ * @return Whether or not ODBC is enabled.
+ */
+ public boolean isOdbcEnabled() {
+ return ctx.config().getOdbcConfiguration() != null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
new file mode 100644
index 0000000..9af002d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolHandler.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
+import org.apache.ignite.internal.processors.odbc.response.OdbcResponse;
+
+/**
+ * ODBC command protocol handler.
+ */
+public interface OdbcProtocolHandler {
+ /**
+ * @param req Request.
+ * @return Response.
+ * @throws IgniteCheckedException In case of error.
+ */
+ public OdbcResponse handle(OdbcRequest req) throws IgniteCheckedException;
+
+ /**
+ * @param req Request.
+ * @return Future.
+ */
+ public IgniteInternalFuture<OdbcResponse> handleAsync(OdbcRequest req);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
new file mode 100644
index 0000000..b1eea71
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTableMeta.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc;
+
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+
+import java.io.IOException;
+
+/**
+ * ODBC table-related metadata.
+ */
+public class OdbcTableMeta {
+ /** Catalog name. */
+ private String catalog;
+
+ /** Schema name. */
+ private String schema;
+
+ /** Table name. */
+ private String table;
+
+ /** Table type. */
+ private String tableType;
+
+ /**
+ * Add quotation marks at the beginning and end of the string.
+ * @param str Input string.
+ * @return String surrounded with quotation marks.
+ */
+ private String AddQuotationMarksIfNeeded(String str) {
+ if (!str.startsWith("\"") && !str.isEmpty())
+ return "\"" + str + "\"";
+
+ return str;
+ }
+
+ /**
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param tableType Table type.
+ */
+ public OdbcTableMeta(String catalog, String schema, String table, String tableType) {
+ this.catalog = catalog;
+ this.schema = AddQuotationMarksIfNeeded(schema);
+ this.table = table;
+ this.tableType = tableType;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof OdbcTableMeta))
+ return false;
+
+ OdbcTableMeta another = (OdbcTableMeta)o;
+
+ return catalog.equals(another.catalog) &&
+ schema.equals(another.schema) &&
+ table.equals(another.table) &&
+ tableType.equals(another.tableType);
+ }
+
+ /**
+ * Write in a binary format.
+ * @param writer Binary writer.
+ * @throws IOException
+ */
+ public void writeBinary(BinaryRawWriterEx writer) throws IOException {
+ writer.writeString(catalog);
+ writer.writeString(schema);
+ writer.writeString(table);
+ writer.writeString(tableType);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridOdbcParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridOdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridOdbcParser.java
deleted file mode 100644
index 3cd2fad..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridOdbcParser.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.protocol;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.binary.*;
-import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
-import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.binary.streams.BinaryInputStream;
-import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.odbc.GridOdbcColumnMeta;
-import org.apache.ignite.internal.processors.odbc.GridOdbcTableMeta;
-import org.apache.ignite.internal.processors.odbc.request.*;
-import org.apache.ignite.internal.processors.odbc.response.*;
-import org.apache.ignite.internal.util.nio.GridNioParser;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-
-
-/**
- * ODBC protocol parser.
- */
-public class GridOdbcParser implements GridNioParser {
- /** Initial output stream capacity. */
- private static final int INIT_CAP = 1024;
-
- /** Length in bytes of the remaining message part. */
- int leftToReceive = 0;
-
- /** Already received bytes of current message. */
- ByteBuffer currentMessage = null;
-
- /** Context. */
- protected final GridKernalContext ctx;
-
- /** Marshaller. */
- private final GridBinaryMarshaller marsh;
-
- GridOdbcParser(GridKernalContext context) {
- ctx = context;
-
- CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
-
- marsh = cacheObjProc.marshaller();
- }
-
- /**
- * Process data chunk and try to construct new message using stored and freshly received data.
- * @param buf Fresh data buffer.
- * @return Instance of the {@link BinaryReaderExImpl} positioned to read from the beginning of the message on
- * success and null otherwise.
- */
- private BinaryRawReaderEx tryConstructMessage(ByteBuffer buf) {
- if (leftToReceive != 0) {
- // Still receiving message
- int toConsume = Math.min(leftToReceive, buf.remaining());
-
- currentMessage.put(buf.array(), buf.arrayOffset(), toConsume);
- leftToReceive -= toConsume;
-
- buf.position(buf.position() + toConsume);
-
- if (leftToReceive != 0)
- return null;
-
- BinaryInputStream stream = new BinaryHeapInputStream(currentMessage.array());
-
- BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
-
- currentMessage = null;
-
- return reader;
- }
-
- // Receiving new message
- // Getting message length. It's in the first four bytes of the message.
- BinaryInputStream stream = new BinaryHeapInputStream(buf.array());
-
- BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
-
- int messageLen = reader.readInt();
- buf.getInt();
-
- int remaining = buf.remaining();
-
- if (messageLen > remaining) {
- leftToReceive = messageLen - remaining;
-
- currentMessage = ByteBuffer.allocate(messageLen);
- currentMessage.put(buf);
-
- return null;
- }
-
- buf.position(buf.position() + messageLen);
-
- return reader;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public GridOdbcRequest decode(GridNioSession ses, ByteBuffer buf) throws IOException,
- IgniteCheckedException {
- BinaryRawReaderEx messageReader = tryConstructMessage(buf);
-
- return messageReader == null ? null : readRequest(ses, messageReader);
- }
-
- /** {@inheritDoc} */
- @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
- assert msg != null;
- assert msg instanceof GridOdbcResponse;
-
- System.out.println("Encoding query processing result");
-
- BinaryRawWriterEx writer = marsh.writer(new BinaryHeapOutputStream(INIT_CAP));
-
- // Reserving space for the message length.
- int msgLenPos = writer.reserveInt();
-
- writeResponse(ses, writer, (GridOdbcResponse)msg);
-
- int msgLenWithHdr = writer.out().position() - msgLenPos;
-
- int msgLen = msgLenWithHdr - 4;
-
- writer.writeInt(msgLenPos, msgLen);
-
- ByteBuffer buf = ByteBuffer.allocate(msgLenWithHdr);
-
- buf.put(writer.out().array(), msgLenPos, msgLenWithHdr);
-
- buf.flip();
-
- return buf;
- }
-
- /**
- * Read ODBC request from the raw data using provided {@link BinaryReaderExImpl} instance.
- * @param ses Current session.
- * @param reader Reader positioned to read the request.
- * @return Instance of the {@link GridOdbcRequest}.
- * @throws IOException if the type of the request is unknown to the parser.
- */
- private GridOdbcRequest readRequest(GridNioSession ses, BinaryRawReaderEx reader) throws IOException {
- GridOdbcRequest res;
-
- byte cmd = reader.readByte();
-
- switch (cmd) {
- case GridOdbcRequest.EXECUTE_SQL_QUERY: {
- String cache = reader.readString();
- String sql = reader.readString();
- int argsNum = reader.readInt();
-
- System.out.println("Message EXECUTE_SQL_QUERY:");
- System.out.println("cache: " + cache);
- System.out.println("query: " + sql);
- System.out.println("argsNum: " + argsNum);
-
- Object[] params = new Object[argsNum];
-
- for (int i = 0; i < argsNum; ++i)
- params[i] = reader.readObjectDetached();
-
- res = new QueryExecuteRequest(cache, sql, params);
- break;
- }
-
- case GridOdbcRequest.FETCH_SQL_QUERY: {
- long queryId = reader.readLong();
- int pageSize = reader.readInt();
-
- System.out.println("Message FETCH_SQL_QUERY:");
- System.out.println("queryId: " + queryId);
- System.out.println("pageSize: " + pageSize);
-
- res = new QueryFetchRequest(queryId, pageSize);
- break;
- }
-
- case GridOdbcRequest.CLOSE_SQL_QUERY: {
- long queryId = reader.readLong();
-
- System.out.println("Message CLOSE_SQL_QUERY:");
- System.out.println("queryId: " + queryId);
-
- res = new QueryCloseRequest(queryId);
- break;
- }
-
- case GridOdbcRequest.GET_COLUMNS_META: {
- String cache = reader.readString();
- String table = reader.readString();
- String column = reader.readString();
-
- System.out.println("Message GET_COLUMNS_META:");
- System.out.println("cache: " + cache);
- System.out.println("table: " + table);
- System.out.println("column: " + column);
-
- res = new QueryGetColumnsMetaRequest(cache, table, column);
- break;
- }
-
- case GridOdbcRequest.GET_TABLES_META: {
- String catalog = reader.readString();
- String schema = reader.readString();
- String table = reader.readString();
- String tableType = reader.readString();
-
- System.out.println("Message GET_COLUMNS_META:");
- System.out.println("catalog: " + catalog);
- System.out.println("schema: " + schema);
- System.out.println("table: " + table);
- System.out.println("tableType: " + tableType);
-
- res = new QueryGetTablesMetaRequest(catalog, schema, table, tableType);
- break;
- }
-
- default:
- throw new IOException("Failed to parse incoming packet (unknown command type) [ses=" + ses +
- ", cmd=[" + Byte.toString(cmd) + ']');
- }
-
- return res;
- }
-
- /**
- * Write ODBC response using provided {@link BinaryRawWriterEx} instance.
- * @param ses Current session.
- * @param writer Writer.
- * @param rsp ODBC response that should be written.
- * @throws IOException if the type of the response is unknown to the parser.
- */
- private void writeResponse(GridNioSession ses, BinaryRawWriterEx writer, GridOdbcResponse rsp) throws IOException {
- // Writing status
- writer.writeByte((byte)rsp.getSuccessStatus());
-
- if (rsp.getSuccessStatus() != GridOdbcResponse.STATUS_SUCCESS) {
- writer.writeString(rsp.getError());
-
- return;
- }
-
- Object res0 = rsp.getResponse();
-
- if (res0 instanceof QueryExecuteResult) {
- QueryExecuteResult res = (QueryExecuteResult) res0;
-
- System.out.println("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- Collection<GridOdbcColumnMeta> metas = res.getColumnsMetadata();
-
- assert metas != null;
-
- writer.writeInt(metas.size());
-
- for (GridOdbcColumnMeta meta : metas)
- meta.writeBinary(writer, marsh.context());
-
- } else if (res0 instanceof QueryFetchResult) {
- QueryFetchResult res = (QueryFetchResult) res0;
-
- System.out.println("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- Collection<?> items0 = res.getItems();
-
- assert items0 != null;
-
- Collection<Collection<Object>> items = (Collection<Collection<Object>>)items0;
-
- writer.writeBoolean(res.getLast());
-
- writer.writeInt(items.size());
-
- for (Collection<Object> row : items) {
- if (row != null) {
- writer.writeInt(row.size());
-
- for (Object obj : row) {
- if (obj != null)
- writer.writeObjectDetached(obj);
- }
- }
- }
- } else if (res0 instanceof QueryCloseResult) {
- QueryCloseResult res = (QueryCloseResult) res0;
-
- System.out.println("Resulting query ID: " + res.getQueryId());
-
- writer.writeLong(res.getQueryId());
-
- } else if (res0 instanceof QueryGetColumnsMetaResult) {
- QueryGetColumnsMetaResult res = (QueryGetColumnsMetaResult) res0;
-
- Collection<GridOdbcColumnMeta> columnsMeta = res.getMeta();
-
- assert columnsMeta != null;
-
- writer.writeInt(columnsMeta.size());
-
- for (GridOdbcColumnMeta columnMeta : columnsMeta)
- columnMeta.writeBinary(writer, marsh.context());
-
- } else if (res0 instanceof QueryGetTablesMetaResult) {
- QueryGetTablesMetaResult res = (QueryGetTablesMetaResult) res0;
-
- Collection<GridOdbcTableMeta> tablesMeta = res.getMeta();
-
- assert tablesMeta != null;
-
- writer.writeInt(tablesMeta.size());
-
- for (GridOdbcTableMeta tableMeta : tablesMeta)
- tableMeta.writeBinary(writer);
-
- } else {
- throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcNioListener.java
deleted file mode 100644
index c53c2c0..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcNioListener.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.protocol;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.odbc.GridOdbcProtocolHandler;
-import org.apache.ignite.internal.processors.odbc.request.GridOdbcRequest;
-import org.apache.ignite.internal.processors.odbc.response.GridOdbcResponse;
-import org.apache.ignite.internal.util.nio.GridNioFuture;
-import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
-import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Listener for ODBC driver connection.
- */
-public class GridTcpOdbcNioListener extends GridNioServerListenerAdapter<GridOdbcRequest> {
- /** Server. */
- private GridTcpOdbcServer srv;
-
- /** Logger. */
- protected final IgniteLogger log;
-
- /** Context. */
- protected final GridKernalContext ctx;
-
- /** Protocol handler. */
- private GridOdbcProtocolHandler hnd;
-
- GridTcpOdbcNioListener(IgniteLogger log, GridTcpOdbcServer srv, GridKernalContext ctx, GridOdbcProtocolHandler hnd) {
- this.log = log;
- this.srv = srv;
- this.ctx = ctx;
- this.hnd = hnd;
- }
-
- @Override
- public void onConnected(GridNioSession ses) {
- System.out.println("Driver connected");
- }
-
- @Override
- public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
- System.out.println("Driver disconnected");
-
- if (e != null) {
- if (e instanceof RuntimeException)
- U.error(log, "Failed to process request from remote client: " + ses, e);
- else
- U.warn(log, "Closed client session due to exception [ses=" + ses + ", msg=" + e.getMessage() + ']');
- }
- }
-
- @Override
- public void onMessage(GridNioSession ses, GridOdbcRequest msg) {
- assert msg != null;
-
- System.out.println("Query: " + msg.command());
-
- GridOdbcResponse res;
-
- try {
- res = hnd.handle(msg);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to process client request: " + msg, e);
-
- res = new GridOdbcResponse(GridOdbcResponse.STATUS_FAILED,
- "Failed to process client request: " + e.getMessage());
- }
-
- System.out.println("Resulting success status: " + res.getSuccessStatus());
-
- GridNioFuture<?> sf = ses.send(res);
-
- // Check if send failed.
- if (sf.isDone()) {
- try {
- sf.get();
- } catch (Exception e) {
- U.error(log, "Failed to process client request [ses=" + ses + ", msg=" + msg + ']', e);
- }
- }
- }
-}
[11/28] ignite git commit: IGNITE-2445: Fixed JavaDocs for ODBC.
Posted by vo...@apache.org.
IGNITE-2445: Fixed JavaDocs for ODBC.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/57822b61
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/57822b61
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/57822b61
Branch: refs/heads/ignite-1786
Commit: 57822b6118a2c22ee17794f32bb55e3370eb4490
Parents: f58ceb6
Author: isapego <is...@gridgain.com>
Authored: Tue Jan 26 16:09:42 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Jan 26 16:09:42 2016 +0300
----------------------------------------------------------------------
.../ignite/configuration/IgniteConfiguration.java | 8 ++++++--
.../ignite/configuration/OdbcConfiguration.java | 14 +++++++++++---
2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/57822b61/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 656e36c..6a2efcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -2284,14 +2284,18 @@ public class IgniteConfiguration {
}
/**
- * @return Odbc configuration.
+ * Gets configuration for ODBC.
+ *
+ * @return ODBC configuration.
*/
public OdbcConfiguration getOdbcConfiguration() {
return odbcCfg;
}
/**
- * @param odbcCfg Odbc configuration.
+ * Sets configuration for ODBC.
+ *
+ * @param odbcCfg ODBC configuration.
* @return {@code this} for chaining.
*/
public IgniteConfiguration setOdbcConfiguration(OdbcConfiguration odbcCfg) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/57822b61/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
index 74fe29f..bf4122a 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
@@ -151,7 +151,7 @@ public class OdbcConfiguration {
}
/**
- * Sets whether {@code TCP_NODELAY} option should be set for all accepted client connections.
+ * Sets whether {@code TCP_NODELAY} option should be set for all accepted ODBC client connections.
*
* @param noDelay {@code True} if option should be enabled.
* @see #isNoDelay()
@@ -165,6 +165,8 @@ public class OdbcConfiguration {
* that is allocated and accessed using native system calls, without using JVM heap. Enabling direct
* buffer <em>may</em> improve performance and avoid memory issues (long GC pauses due to huge buffer
* size).
+ * <p/>
+ * If not specified, default value is {@link #DFLT_TCP_DIRECT_BUF}.
*
* @return Whether direct buffer should be used.
*/
@@ -184,6 +186,8 @@ public class OdbcConfiguration {
/**
* Gets ODBC TCP server send buffer size.
+ * <p/>
+ * If not specified, default value is {@link #DFLT_SOCK_BUF_SIZE}.
*
* @return ODBC TCP server send buffer size (0 for default).
*/
@@ -203,6 +207,8 @@ public class OdbcConfiguration {
/**
* Gets ODBC TCP server receive buffer size.
+ * <p/>
+ * If not specified, default value is {@link #DFLT_SOCK_BUF_SIZE}.
*
* @return ODBC TCP server receive buffer size (0 for default).
*/
@@ -261,10 +267,12 @@ public class OdbcConfiguration {
}
/**
- * Gets idle timeout for ODBC server.
+ * Gets idle timeout for ODBC TCP server.
* <p>
* This setting is used to reject half-opened sockets. If no packets
* come within idle timeout, the connection is closed.
+ * <p/>
+ * If not specified, default value is {@link #DFLT_IDLE_TIMEOUT}.
*
* @return Idle timeout in milliseconds.
*/
@@ -273,7 +281,7 @@ public class OdbcConfiguration {
}
/**
- * Sets idle timeout for ODBC server.
+ * Sets idle timeout for ODBC TCP server.
*
* @param idleTimeout Idle timeout in milliseconds.
* @see #getIdleTimeout()
[18/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/meta/column_meta.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/meta/column_meta.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/meta/column_meta.cpp
deleted file mode 100644
index 114dd03..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/meta/column_meta.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * 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 "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/meta/column_meta.h"
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/common_types.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace meta
- {
-
-#ifdef ODBC_DEBUG
-
-#define DBG_STR_CASE(x) case x: return #x
-
- const char* ColumnMeta::AttrIdToString(uint16_t id)
- {
- switch (id)
- {
- DBG_STR_CASE(SQL_DESC_LABEL);
- DBG_STR_CASE(SQL_DESC_BASE_COLUMN_NAME);
- DBG_STR_CASE(SQL_DESC_NAME);
- DBG_STR_CASE(SQL_DESC_TABLE_NAME);
- DBG_STR_CASE(SQL_DESC_BASE_TABLE_NAME);
- DBG_STR_CASE(SQL_DESC_SCHEMA_NAME);
- DBG_STR_CASE(SQL_DESC_CATALOG_NAME);
- DBG_STR_CASE(SQL_DESC_LITERAL_PREFIX);
- DBG_STR_CASE(SQL_DESC_LITERAL_SUFFIX);
- DBG_STR_CASE(SQL_DESC_TYPE_NAME);
- DBG_STR_CASE(SQL_DESC_LOCAL_TYPE_NAME);
- DBG_STR_CASE(SQL_DESC_FIXED_PREC_SCALE);
- DBG_STR_CASE(SQL_DESC_AUTO_UNIQUE_VALUE);
- DBG_STR_CASE(SQL_DESC_CASE_SENSITIVE);
- DBG_STR_CASE(SQL_DESC_CONCISE_TYPE);
- DBG_STR_CASE(SQL_DESC_TYPE);
- DBG_STR_CASE(SQL_DESC_DISPLAY_SIZE);
- DBG_STR_CASE(SQL_DESC_LENGTH);
- DBG_STR_CASE(SQL_DESC_OCTET_LENGTH);
- DBG_STR_CASE(SQL_DESC_NULLABLE);
- DBG_STR_CASE(SQL_DESC_NUM_PREC_RADIX);
- DBG_STR_CASE(SQL_DESC_PRECISION);
- DBG_STR_CASE(SQL_DESC_SCALE);
- DBG_STR_CASE(SQL_DESC_SEARCHABLE);
- DBG_STR_CASE(SQL_DESC_UNNAMED);
- DBG_STR_CASE(SQL_DESC_UNSIGNED);
- DBG_STR_CASE(SQL_DESC_UPDATABLE);
- default:
- break;
- }
- return "<< UNKNOWN ID >>";
- }
-
-#undef DBG_STR_CASE
-
-#endif
-
- void ColumnMeta::Read(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- utility::ReadString(reader, schemaName);
- utility::ReadString(reader, tableName);
- utility::ReadString(reader, columnName);
- utility::ReadString(reader, typeName);
-
- dataType = reader.ReadInt8();
- }
-
- bool ColumnMeta::GetAttribute(uint16_t fieldId, std::string& value) const
- {
- using namespace ignite::impl::binary;
-
- switch (fieldId)
- {
- case SQL_DESC_LABEL:
- case SQL_DESC_BASE_COLUMN_NAME:
- case SQL_DESC_NAME:
- {
- value = columnName;
-
- return true;
- }
-
- case SQL_DESC_TABLE_NAME:
- case SQL_DESC_BASE_TABLE_NAME:
- {
- value = tableName;
-
- return true;
- }
-
- case SQL_DESC_SCHEMA_NAME:
- {
- value = schemaName;
-
- return true;
- }
-
- case SQL_DESC_CATALOG_NAME:
- {
- value.clear();
-
- return true;
- }
-
- case SQL_DESC_LITERAL_PREFIX:
- case SQL_DESC_LITERAL_SUFFIX:
- {
- if (dataType == IGNITE_TYPE_STRING)
- value = "'";
- else
- value.clear();
-
- return true;
- }
-
- case SQL_DESC_TYPE_NAME:
- case SQL_DESC_LOCAL_TYPE_NAME:
- {
- value = type_traits::BinaryTypeToSqlTypeName(dataType);
-
- return true;
- }
-
- default:
- return false;
- }
- }
-
- bool ColumnMeta::GetAttribute(uint16_t fieldId, SqlLen& value) const
- {
- using namespace ignite::impl::binary;
-
- switch (fieldId)
- {
- case SQL_DESC_FIXED_PREC_SCALE:
- case SQL_DESC_AUTO_UNIQUE_VALUE:
- {
- value = SQL_FALSE;
-
- return true;
- }
-
- case SQL_DESC_CASE_SENSITIVE:
- {
- if (dataType == IGNITE_TYPE_STRING)
- value = SQL_TRUE;
- else
- value = SQL_FALSE;
-
- return true;
- }
-
- case SQL_DESC_CONCISE_TYPE:
- case SQL_DESC_TYPE:
- {
- value = type_traits::BinaryToSqlType(dataType);
-
- return true;
- }
-
- case SQL_DESC_DISPLAY_SIZE:
- {
- value = type_traits::BinaryTypeDisplaySize(dataType);
-
- return true;
- }
-
- case SQL_DESC_LENGTH:
- case SQL_DESC_OCTET_LENGTH:
- {
- value = type_traits::BinaryTypeTransferLength(dataType);
-
- return true;
- }
-
- case SQL_DESC_NULLABLE:
- {
- value = type_traits::BinaryTypeNullability(dataType);
-
- return true;
- }
-
- case SQL_DESC_NUM_PREC_RADIX:
- {
- value = type_traits::BinaryTypeNumPrecRadix(dataType);
-
- return true;
- }
-
- case SQL_DESC_PRECISION:
- {
- value = type_traits::BinaryTypeColumnSize(dataType);
-
- return true;
- }
-
- case SQL_DESC_SCALE:
- {
- value = type_traits::BinaryTypeDecimalDigits(dataType);
-
- if (value < 0)
- value = 0;
-
- return true;
- }
-
- case SQL_DESC_SEARCHABLE:
- {
- value = SQL_PRED_BASIC;
-
- return true;
- }
-
- case SQL_DESC_UNNAMED:
- {
- value = columnName.empty() ? SQL_UNNAMED : SQL_NAMED;
-
- return true;
- }
-
- case SQL_DESC_UNSIGNED:
- {
- value = type_traits::BinaryTypeUnsigned(dataType) ? SQL_TRUE : SQL_FALSE;
-
- return true;
- }
-
- case SQL_DESC_UPDATABLE:
- {
- // We do not support update for now so just set all
- // columns to readonly.
- value = SQL_ATTR_READONLY;
-
- return true;
- }
-
- default:
- return false;
- }
- }
-
- void ReadColumnMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, ColumnMetaVector& meta)
- {
- int32_t metaNum = reader.ReadInt32();
-
- meta.clear();
- meta.reserve(static_cast<size_t>(metaNum));
-
- for (int32_t i = 0; i < metaNum; ++i)
- {
- meta.push_back(ColumnMeta());
-
- meta.back().Read(reader);
- }
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/meta/table_meta.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/meta/table_meta.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/meta/table_meta.cpp
deleted file mode 100644
index 71ced8f..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/meta/table_meta.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 "ignite/odbc/meta/table_meta.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace meta
- {
- void TableMeta::Read(ignite::impl::binary::BinaryReaderImpl & reader)
- {
- utility::ReadString(reader, catalogName);
- utility::ReadString(reader, schemaName);
- utility::ReadString(reader, tableName);
- utility::ReadString(reader, tableType);
- }
-
- void ReadTableMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, TableMetaVector& meta)
- {
- int32_t metaNum = reader.ReadInt32();
-
- meta.clear();
- meta.reserve(static_cast<size_t>(metaNum));
-
- for (int32_t i = 0; i < metaNum; ++i)
- {
- meta.push_back(TableMeta());
-
- meta.back().Read(reader);
- }
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
deleted file mode 100644
index 84e312a..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
+++ /dev/null
@@ -1,1687 +0,0 @@
-/*
- * 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 <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <algorithm>
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/system/odbc_constants.h"
-
-#include "ignite/odbc/config/configuration.h"
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/environment.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/statement.h"
-
-#ifdef ODBC_DEBUG
-
-FILE* log_file = NULL;
-
-void logInit(const char* path)
-{
- if (!log_file)
- {
- log_file = fopen(path, "w");
- }
-}
-
-#endif //ODBC_DEBUG
-
-BOOL INSTAPI ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
-{
- LOG_MSG("ConfigDSN called\n");
-
- ignite::odbc::config::Configuration config;
-
- config.FillFromConfigAttributes(attributes);
-
- if (!SQLValidDSN(config.GetDsn().c_str()))
- return SQL_FALSE;
-
- LOG_MSG("Driver: %s\n", driver);
- LOG_MSG("Attributes: %s\n", attributes);
-
- LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
-
- switch (req)
- {
- case ODBC_ADD_DSN:
- {
- LOG_MSG("ODBC_ADD_DSN\n");
-
- return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
- }
-
- case ODBC_CONFIG_DSN:
- {
- LOG_MSG("ODBC_CONFIG_DSN\n");
- break;
- }
-
- case ODBC_REMOVE_DSN:
- {
- LOG_MSG("ODBC_REMOVE_DSN\n");
-
- return SQLRemoveDSNFromIni(config.GetDsn().c_str());
- }
-
- default:
- {
- return SQL_FALSE;
- }
- }
-
- return SQL_TRUE;
-}
-
-SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
- SQLUSMALLINT infoType,
- SQLPOINTER infoValue,
- SQLSMALLINT infoValueMax,
- SQLSMALLINT* length)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::config::ConnectionInfo;
-
- LOG_MSG("SQLGetInfo called: %d (%s)\n", infoType, ConnectionInfo::InfoTypeToString(infoType));
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- connection->GetInfo(infoType, infoValue, infoValueMax, length);
-
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result)
-{
- //LOG_MSG("SQLAllocHandle called\n");
- switch (type)
- {
- case SQL_HANDLE_ENV:
- return SQLAllocEnv(result);
-
- case SQL_HANDLE_DBC:
- return SQLAllocConnect(parent, result);
-
- case SQL_HANDLE_STMT:
- return SQLAllocStmt(parent, result);
-
- case SQL_HANDLE_DESC:
- default:
- break;
- }
-
- *result = 0;
- return SQL_ERROR;
-}
-
-SQLRETURN SQL_API SQLAllocEnv(SQLHENV* env)
-{
- using ignite::odbc::Environment;
-
- LOG_MSG("SQLAllocEnv called\n");
-
- *env = reinterpret_cast<SQLHENV>(new Environment());
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC* conn)
-{
- using ignite::odbc::Environment;
- using ignite::odbc::Connection;
-
- LOG_MSG("SQLAllocConnect called\n");
-
- *conn = SQL_NULL_HDBC;
-
- Environment *environment = reinterpret_cast<Environment*>(env);
-
- if (!environment)
- return SQL_INVALID_HANDLE;
-
- Connection *connection = environment->CreateConnection();
-
- if (!connection)
- return environment->GetDiagnosticRecords().GetReturnCode();
-
- *conn = reinterpret_cast<SQLHDBC>(connection);
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLAllocStmt called\n");
-
- *stmt = SQL_NULL_HDBC;
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- Statement *statement = connection->CreateStatement();
-
- *stmt = reinterpret_cast<SQLHSTMT>(statement);
-
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle)
-{
- switch (type)
- {
- case SQL_HANDLE_ENV:
- return SQLFreeEnv(handle);
-
- case SQL_HANDLE_DBC:
- return SQLFreeConnect(handle);
-
- case SQL_HANDLE_STMT:
- return SQLFreeStmt(handle, SQL_DROP);
-
- case SQL_HANDLE_DESC:
- default:
- break;
- }
-
- return SQL_ERROR;
-}
-
-SQLRETURN SQL_API SQLFreeEnv(SQLHENV env)
-{
- using ignite::odbc::Environment;
-
- LOG_MSG("SQLFreeEnv called\n");
-
- Environment *environment = reinterpret_cast<Environment*>(env);
-
- if (!environment)
- return SQL_INVALID_HANDLE;
-
- delete environment;
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLFreeConnect(SQLHDBC conn)
-{
- using ignite::odbc::Connection;
-
- LOG_MSG("SQLFreeConnect called\n");
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- delete connection;
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLFreeStmt called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- switch (option)
- {
- case SQL_DROP:
- {
- delete statement;
-
- break;
- }
-
- case SQL_CLOSE:
- {
- return SQLCloseCursor(stmt);
- }
-
- case SQL_UNBIND:
- {
- statement->UnbindAllColumns();
-
- break;
- }
-
- case SQL_RESET_PARAMS:
- {
- statement->UnbindAllParameters();
-
- break;
- }
-
- default:
- return SQL_ERROR;
- }
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLCloseCursor called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- statement->Close();
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLDriverConnect(SQLHDBC conn,
- SQLHWND windowHandle,
- SQLCHAR* inConnectionString,
- SQLSMALLINT inConnectionStringLen,
- SQLCHAR* outConnectionString,
- SQLSMALLINT outConnectionStringBufferLen,
- SQLSMALLINT* outConnectionStringLen,
- SQLUSMALLINT driverCompletion)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
- using ignite::utility::CopyStringToBuffer;
-
- UNREFERENCED_PARAMETER(windowHandle);
-
- LOG_MSG("SQLDriverConnect called\n");
- LOG_MSG("Connection String: [%s]\n", inConnectionString);
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
-
- ignite::odbc::config::Configuration config;
-
- config.FillFromConnectString(connectStr);
-
- connection->Establish(config.GetHost(), config.GetPort(), config.GetCache());
-
- const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
-
- if (!diag.IsSuccessful())
- return diag.GetReturnCode();
-
- std::string outConnectStr = config.ToConnectString();
-
- size_t reslen = CopyStringToBuffer(outConnectStr,
- reinterpret_cast<char*>(outConnectionString),
- static_cast<size_t>(outConnectionStringBufferLen));
-
- if (outConnectionStringLen)
- *outConnectionStringLen = static_cast<SQLSMALLINT>(reslen);
-
- LOG_MSG("%s\n", outConnectionString);
-
- return diag.GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLConnect(SQLHDBC conn,
- SQLCHAR* serverName,
- SQLSMALLINT serverNameLen,
- SQLCHAR* userName,
- SQLSMALLINT userNameLen,
- SQLCHAR* auth,
- SQLSMALLINT authLen)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLConnect called\n");
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- std::string server = SqlStringToString(serverName, serverNameLen);
-
- connection->Establish(server);
-
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLDisconnect(SQLHDBC conn)
-{
- using ignite::odbc::Connection;
-
- LOG_MSG("SQLDisconnect called\n");
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- connection->Release();
-
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLPrepare called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string sql = SqlStringToString(query, queryLen);
-
- LOG_MSG("SQL: %s\n", sql.c_str());
-
- statement->PrepareSqlQuery(sql);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLExecute called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- statement->ExecuteSqlQuery();
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLExecDirect called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string sql = SqlStringToString(query, queryLen);
-
- LOG_MSG("SQL: %s\n", sql.c_str());
-
- statement->ExecuteSqlQuery(sql);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt,
- SQLUSMALLINT colNum,
- SQLSMALLINT targetType,
- SQLPOINTER targetValue,
- SQLLEN bufferLength,
- SQLLEN* strLengthOrIndicator)
-{
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
-
- LOG_MSG("SQLBindCol called: index=%d, type=%d\n", colNum, targetType);
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- IgniteSqlType driverType = ToDriverType(targetType);
-
- if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
- return SQL_ERROR;
-
- if (bufferLength < 0)
- return SQL_ERROR;
-
- if (targetValue || strLengthOrIndicator)
- {
- ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
-
- statement->BindColumn(colNum, dataBuffer);
- }
- else
- statement->UnbindColumn(colNum);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLFetch called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- statement->FetchRow();
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt,
- SQLSMALLINT orientation,
- SQLLEN offset)
-{
- LOG_MSG("SQLFetchScroll called\n");
- LOG_MSG("Orientation: %d, Offset: %d\n", orientation, offset);
-
- if (orientation != SQL_FETCH_NEXT)
- return SQL_ERROR;
-
- return SQLFetch(stmt);
-}
-
-SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt,
- SQLUSMALLINT orientation,
- SQLLEN offset,
- SQLULEN* rowCount,
- SQLUSMALLINT* rowStatusArray)
-{
- LOG_MSG("SQLExtendedFetch called\n");
-
- SQLRETURN res = SQLFetchScroll(stmt, orientation, offset);
-
- if (res == SQL_SUCCESS || res == SQL_NO_DATA)
- {
- if (rowCount)
- *rowCount = 1;
-
- if (rowStatusArray)
- rowStatusArray[0] = SQL_ROW_SUCCESS;
- }
-
- return res;
-}
-
-SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *columnNum)
-{
- using ignite::odbc::Statement;
- using ignite::odbc::meta::ColumnMetaVector;
-
- LOG_MSG("SQLNumResultCols called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- int32_t res = statement->GetColumnNumber();
-
- *columnNum = static_cast<SQLSMALLINT>(res);
-
- LOG_MSG("columnNum: %d\n", *columnNum);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLTables(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLCHAR* tableType,
- SQLSMALLINT tableTypeLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLTables called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
- std::string tableTypeStr = SqlStringToString(tableType, tableTypeLen);
-
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
- LOG_MSG("tableType: %s\n", tableTypeStr.c_str());
-
- statement->ExecuteGetTablesMetaQuery(catalog, schema, table, tableTypeStr);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLCHAR* columnName,
- SQLSMALLINT columnNameLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLColumns called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
- std::string column = SqlStringToString(columnName, columnNameLen);
-
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
- LOG_MSG("column: %s\n", column.c_str());
-
- statement->ExecuteGetColumnsMetaQuery(schema, table, column);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLMoreResults called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- //TODO: reset diagnostic here.
- return statement->DataAvailable() ? SQL_SUCCESS : SQL_NO_DATA;
-}
-
-SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt,
- SQLUSMALLINT paramIdx,
- SQLSMALLINT ioType,
- SQLSMALLINT bufferType,
- SQLSMALLINT paramSqlType,
- SQLULEN columnSize,
- SQLSMALLINT decDigits,
- SQLPOINTER buffer,
- SQLLEN bufferLen,
- SQLLEN* resLen)
-{
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
- using ignite::odbc::app::Parameter;
- using ignite::odbc::type_traits::IsSqlTypeSupported;
-
- LOG_MSG("SQLBindParameter called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- if (ioType != SQL_PARAM_INPUT)
- return SQL_ERROR;
-
- if (*resLen == SQL_DATA_AT_EXEC || *resLen <= SQL_LEN_DATA_AT_EXEC_OFFSET)
- return SQL_ERROR;
-
- if (!IsSqlTypeSupported(paramSqlType))
- return SQL_ERROR;
-
- IgniteSqlType driverType = ToDriverType(bufferType);
-
- if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
- return SQL_ERROR;
-
- if (buffer)
- {
- ApplicationDataBuffer dataBuffer(driverType, buffer, bufferLen, resLen);
-
- Parameter param(dataBuffer, paramSqlType, columnSize, decDigits);
-
- statement->BindParameter(paramIdx, param);
- }
- else
- statement->UnbindParameter(paramIdx);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLNativeSql(SQLHDBC conn,
- SQLCHAR* inQuery,
- SQLINTEGER inQueryLen,
- SQLCHAR* outQueryBuffer,
- SQLINTEGER outQueryBufferLen,
- SQLINTEGER* outQueryLen)
-{
- using namespace ignite::utility;
-
- LOG_MSG("SQLNativeSql called\n");
-
- std::string in = SqlStringToString(inQuery, inQueryLen);
-
- CopyStringToBuffer(in, reinterpret_cast<char*>(outQueryBuffer),
- static_cast<size_t>(outQueryBufferLen));
-
- *outQueryLen = std::min(outQueryBufferLen, static_cast<SQLINTEGER>(in.size()));
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt,
- SQLUSMALLINT columnNum,
- SQLUSMALLINT fieldId,
- SQLPOINTER strAttr,
- SQLSMALLINT bufferLen,
- SQLSMALLINT* strAttrLen,
- SQLLEN* numericAttr)
-{
- using ignite::odbc::Statement;
- using ignite::odbc::meta::ColumnMetaVector;
- using ignite::odbc::meta::ColumnMeta;
-
- LOG_MSG("SQLColAttribute called: %d (%s)\n", fieldId, ColumnMeta::AttrIdToString(fieldId));
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- // This is a special case
- if (fieldId == SQL_DESC_COUNT)
- {
- SQLSMALLINT val = 0;
-
- SQLRETURN res = SQLNumResultCols(stmt, &val);
-
- if (res == SQL_SUCCESS)
- *numericAttr = val;
-
- return res;
- }
-
- statement->GetColumnAttribute(columnNum, fieldId, reinterpret_cast<char*>(strAttr),
- bufferLen, strAttrLen, numericAttr);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt,
- SQLUSMALLINT columnNum,
- SQLCHAR* columnNameBuf,
- SQLSMALLINT columnNameBufLen,
- SQLSMALLINT* columnNameLen,
- SQLSMALLINT* dataType,
- SQLULEN* columnSize,
- SQLSMALLINT* decimalDigits,
- SQLSMALLINT* nullable)
-{
- using ignite::odbc::Statement;
- using ignite::odbc::SqlLen;
-
- LOG_MSG("SQLDescribeCol called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- statement->GetColumnAttribute(columnNum, SQL_DESC_NAME,
- reinterpret_cast<char*>(columnNameBuf), columnNameBufLen, columnNameLen, 0);
-
- SqlLen dataTypeRes;
- SqlLen columnSizeRes;
- SqlLen decimalDigitsRes;
- SqlLen nullableRes;
-
- statement->GetColumnAttribute(columnNum, SQL_DESC_TYPE, 0, 0, 0, &dataTypeRes);
- statement->GetColumnAttribute(columnNum, SQL_DESC_PRECISION, 0, 0, 0, &columnSizeRes);
- statement->GetColumnAttribute(columnNum, SQL_DESC_SCALE, 0, 0, 0, &decimalDigitsRes);
- statement->GetColumnAttribute(columnNum, SQL_DESC_NULLABLE, 0, 0, 0, &nullableRes);
-
- LOG_MSG("columnNum: %lld\n", columnNum);
- LOG_MSG("dataTypeRes: %lld\n", dataTypeRes);
- LOG_MSG("columnSizeRes: %lld\n", columnSizeRes);
- LOG_MSG("decimalDigitsRes: %lld\n", decimalDigitsRes);
- LOG_MSG("nullableRes: %lld\n", nullableRes);
- LOG_MSG("columnNameBuf: %s\n", columnNameBuf);
- LOG_MSG("columnNameLen: %d\n", *columnNameLen);
-
- *dataType = static_cast<SQLSMALLINT>(dataTypeRes);
- *columnSize = static_cast<SQLULEN>(columnSizeRes);
- *decimalDigits = static_cast<SQLSMALLINT>(decimalDigitsRes);
- *nullable = static_cast<SQLSMALLINT>(nullableRes);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-
-SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCnt)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLRowCount called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- int64_t res = statement->AffectedRows();
-
- *rowCnt = static_cast<SQLLEN>(res);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt,
- SQLCHAR* primaryCatalogName,
- SQLSMALLINT primaryCatalogNameLen,
- SQLCHAR* primarySchemaName,
- SQLSMALLINT primarySchemaNameLen,
- SQLCHAR* primaryTableName,
- SQLSMALLINT primaryTableNameLen,
- SQLCHAR* foreignCatalogName,
- SQLSMALLINT foreignCatalogNameLen,
- SQLCHAR* foreignSchemaName,
- SQLSMALLINT foreignSchemaNameLen,
- SQLCHAR* foreignTableName,
- SQLSMALLINT foreignTableNameLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLForeignKeys called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string primaryCatalog = SqlStringToString(primaryCatalogName, primaryCatalogNameLen);
- std::string primarySchema = SqlStringToString(primarySchemaName, primarySchemaNameLen);
- std::string primaryTable = SqlStringToString(primaryTableName, primaryTableNameLen);
- std::string foreignCatalog = SqlStringToString(foreignCatalogName, foreignCatalogNameLen);
- std::string foreignSchema = SqlStringToString(foreignSchemaName, foreignSchemaNameLen);
- std::string foreignTable = SqlStringToString(foreignTableName, foreignTableNameLen);
-
- LOG_MSG("primaryCatalog: %s\n", primaryCatalog.c_str());
- LOG_MSG("primarySchema: %s\n", primarySchema.c_str());
- LOG_MSG("primaryTable: %s\n", primaryTable.c_str());
- LOG_MSG("foreignCatalog: %s\n", foreignCatalog.c_str());
- LOG_MSG("foreignSchema: %s\n", foreignSchema.c_str());
- LOG_MSG("foreignTable: %s\n", foreignTable.c_str());
-
- statement->ExecuteGetForeignKeysQuery(primaryCatalog, primarySchema,
- primaryTable, foreignCatalog, foreignSchema, foreignTable);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt,
- SQLINTEGER attr,
- SQLPOINTER valueBuf,
- SQLINTEGER valueBufLen,
- SQLINTEGER* valueResLen)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLGetStmtAttr called");
-
-#ifdef ODBC_DEBUG
- using ignite::odbc::type_traits::StatementAttrIdToString;
-
- LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
-#endif //ODBC_DEBUG
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- //TODO: move this logic into Statement.
- switch (attr)
- {
- case SQL_ATTR_APP_ROW_DESC:
- case SQL_ATTR_APP_PARAM_DESC:
- case SQL_ATTR_IMP_ROW_DESC:
- case SQL_ATTR_IMP_PARAM_DESC:
- {
- SQLPOINTER *val = reinterpret_cast<SQLPOINTER*>(valueBuf);
-
- *val = static_cast<SQLPOINTER>(stmt);
-
- break;
- }
-
- case SQL_ATTR_ROW_ARRAY_SIZE:
- {
- SQLINTEGER *val = reinterpret_cast<SQLINTEGER*>(valueBuf);
-
- *val = static_cast<SQLINTEGER>(1);
-
- break;
- }
-
- case SQL_ATTR_ROWS_FETCHED_PTR:
- {
- SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
-
- *val = reinterpret_cast<SQLULEN*>(statement->GetRowsFetchedPtr());
-
- break;
- }
-
- case SQL_ATTR_ROW_STATUS_PTR:
- {
- SQLUSMALLINT** val = reinterpret_cast<SQLUSMALLINT**>(valueBuf);
-
- *val = reinterpret_cast<SQLUSMALLINT*>(statement->GetRowStatusesPtr());
-
- break;
- }
-
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- {
- SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
-
- *val = reinterpret_cast<SQLULEN*>(statement->GetParamBindOffsetPtr());
-
- break;
- }
-
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- {
- SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
-
- *val = reinterpret_cast<SQLULEN*>(statement->GetColumnBindOffsetPtr());
-
- break;
- }
-
- default:
- return SQL_ERROR;
- }
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt,
- SQLINTEGER attr,
- SQLPOINTER value,
- SQLINTEGER valueLen)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLSetStmtAttr called");
-
-#ifdef ODBC_DEBUG
- using ignite::odbc::type_traits::StatementAttrIdToString;
-
- LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
-#endif //ODBC_DEBUG
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- //TODO: move this logic into Statement.
- switch (attr)
- {
- case SQL_ATTR_ROW_ARRAY_SIZE:
- {
- SQLULEN val = reinterpret_cast<SQLULEN>(value);
-
- LOG_MSG("Value: %d\n", val);
-
- if (val != 1)
- return SQL_ERROR;
-
- break;
- }
-
- case SQL_ATTR_ROWS_FETCHED_PTR:
- {
- statement->SetRowsFetchedPtr(reinterpret_cast<size_t*>(value));
-
- break;
- }
-
- case SQL_ATTR_ROW_STATUS_PTR:
- {
- statement->SetRowStatusesPtr(reinterpret_cast<uint16_t*>(value));
-
- break;
- }
-
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- {
- statement->SetParamBindOffsetPtr(reinterpret_cast<size_t*>(value));
-
- break;
- }
-
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- {
- statement->SetColumnBindOffsetPtr(reinterpret_cast<size_t*>(value));
-
- break;
- }
-
- default:
- return SQL_ERROR;
- }
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLPrimaryKeys called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
-
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
-
- statement->ExecuteGetPrimaryKeysQuery(catalog, schema, table);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLNumParams called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- *paramCnt = static_cast<SQLSMALLINT>(statement->GetParametersNumber());
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT handleType,
- SQLHANDLE handle,
- SQLSMALLINT recNum,
- SQLSMALLINT diagId,
- SQLPOINTER buffer,
- SQLSMALLINT bufferLen,
- SQLSMALLINT* resLen)
-{
- using namespace ignite::odbc;
- using namespace ignite::odbc::diagnostic;
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::app::ApplicationDataBuffer;
-
- LOG_MSG("SQLGetDiagField called: %d\n", recNum);
-
- SqlLen outResLen;
- ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, buffer, bufferLen, &outResLen);
-
- SqlResult result;
-
- DiagnosticField field = DiagnosticFieldToInternal(diagId);
-
- switch (handleType)
- {
- case SQL_HANDLE_ENV:
- case SQL_HANDLE_DBC:
- case SQL_HANDLE_STMT:
- {
- Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
-
- result = diag->GetDiagnosticRecords().GetField(recNum, field, outBuffer);
-
- break;
- }
-
- default:
- {
- result = SQL_RESULT_NO_DATA;
- break;
- }
- }
-
- if (result == SQL_RESULT_SUCCESS)
- *resLen = static_cast<SQLSMALLINT>(outResLen);
-
- return SqlResultToReturnCode(result);
-}
-
-SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT handleType,
- SQLHANDLE handle,
- SQLSMALLINT recNum,
- SQLCHAR* sqlState,
- SQLINTEGER* nativeError,
- SQLCHAR* msgBuffer,
- SQLSMALLINT msgBufferLen,
- SQLSMALLINT* msgLen)
-{
- using namespace ignite::utility;
- using namespace ignite::odbc;
- using namespace ignite::odbc::diagnostic;
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::app::ApplicationDataBuffer;
-
- LOG_MSG("SQLGetDiagRec called\n");
-
- const DiagnosticRecordStorage* records = 0;
-
- switch (handleType)
- {
- case SQL_HANDLE_ENV:
- case SQL_HANDLE_DBC:
- case SQL_HANDLE_STMT:
- {
- Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
-
- records = &diag->GetDiagnosticRecords();
-
- break;
- }
-
- default:
- break;
- }
-
- if (!records || recNum < 1 || recNum > records->GetStatusRecordsNumber())
- return SQL_NO_DATA;
-
- const DiagnosticRecord& record = records->GetStatusRecord(recNum);
-
- if (sqlState)
- CopyStringToBuffer(record.GetSqlState(), reinterpret_cast<char*>(sqlState), 6);
-
- if (nativeError)
- *nativeError = 0;
-
- SqlLen outResLen;
- ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
-
- outBuffer.PutString(record.GetMessage());
-
- *msgLen = static_cast<SQLSMALLINT>(outResLen);
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt,
- SQLSMALLINT type)
-{
- using ignite::odbc::Statement;
-
- LOG_MSG("SQLGetTypeInfo called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- statement->ExecuteGetTypeInfoQuery(static_cast<int16_t>(type));
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType,
- SQLHANDLE handle,
- SQLSMALLINT completionType)
-{
- using namespace ignite::odbc;
-
- LOG_MSG("SQLEndTran called\n");
-
- SQLRETURN result;
-
- switch (handleType)
- {
- case SQL_HANDLE_ENV:
- {
- Environment *env = reinterpret_cast<Environment*>(handle);
-
- if (!env)
- return SQL_INVALID_HANDLE;
-
- if (completionType == SQL_COMMIT)
- env->TransactionCommit();
- else
- env->TransactionRollback();
-
- result = env->GetDiagnosticRecords().GetReturnCode();
-
- break;
- }
-
- case SQL_HANDLE_DBC:
- {
- Connection *conn = reinterpret_cast<Connection*>(handle);
-
- if (!conn)
- return SQL_INVALID_HANDLE;
-
- if (completionType == SQL_COMMIT)
- conn->TransactionCommit();
- else
- conn->TransactionRollback();
-
- result = conn->GetDiagnosticRecords().GetReturnCode();
-
- break;
- }
-
- default:
- {
- result = SQL_INVALID_HANDLE;
-
- break;
- }
- }
-
- return result;
-}
-
-SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt,
- SQLUSMALLINT colNum,
- SQLSMALLINT targetType,
- SQLPOINTER targetValue,
- SQLLEN bufferLength,
- SQLLEN* strLengthOrIndicator)
-{
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
-
- LOG_MSG("SQLGetData called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- IgniteSqlType driverType = ToDriverType(targetType);
-
- ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
-
- statement->GetColumnData(colNum, dataBuffer);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env,
- SQLINTEGER attr,
- SQLPOINTER value,
- SQLINTEGER valueLen)
-{
- using ignite::odbc::Environment;
-
- LOG_MSG("SQLSetEnvAttr called\n");
-
- Environment *environment = reinterpret_cast<Environment*>(env);
-
- if (!environment)
- return SQL_INVALID_HANDLE;
-
- environment->SetAttribute(attr, value, valueLen);
-
- return environment->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env,
- SQLINTEGER attr,
- SQLPOINTER valueBuf,
- SQLINTEGER valueBufLen,
- SQLINTEGER* valueResLen)
-{
- using namespace ignite::odbc;
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::app::ApplicationDataBuffer;
-
- LOG_MSG("SQLGetEnvAttr called\n");
-
- Environment *environment = reinterpret_cast<Environment*>(env);
-
- if (!environment)
- return SQL_INVALID_HANDLE;
-
- SqlLen outResLen;
- ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, valueBuf,
- static_cast<int32_t>(valueBufLen), &outResLen);
-
- environment->GetAttribute(attr, outBuffer);
-
- *valueResLen = static_cast<SQLSMALLINT>(outResLen);
-
- return environment->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt,
- SQLSMALLINT idType,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLSMALLINT scope,
- SQLSMALLINT nullable)
-{
- using namespace ignite::odbc;
-
- using ignite::utility::SqlStringToString;
-
- LOG_MSG("SQLSpecialColumns called\n");
-
- Statement *statement = reinterpret_cast<Statement*>(stmt);
-
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
-
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
-
- statement->ExecuteSpecialColumnsQuery(idType, catalog, schema, table, scope, nullable);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-//
-// ==== Not implemented ====
-//
-
-SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt)
-{
- LOG_MSG("SQLCancel called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt,
- SQLUSMALLINT colNum,
- SQLUSMALLINT fieldId,
- SQLPOINTER strAttrBuf,
- SQLSMALLINT strAttrBufLen,
- SQLSMALLINT* strAttrResLen,
- SQLLEN* numAttrBuf)
-{
- LOG_MSG("SQLColAttributes called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLError(SQLHENV env,
- SQLHDBC conn,
- SQLHSTMT stmt,
- SQLCHAR* state,
- SQLINTEGER* error,
- SQLCHAR* msgBuf,
- SQLSMALLINT msgBufLen,
- SQLSMALLINT* msgResLen)
-{
- LOG_MSG("SQLError called\n");
- return(SQL_NO_DATA_FOUND);
-}
-
-SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt,
- SQLCHAR* nameBuf,
- SQLSMALLINT nameBufLen,
- SQLSMALLINT* nameResLen)
-{
- LOG_MSG("SQLGetCursorName called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt,
- SQLCHAR* name,
- SQLSMALLINT nameLen)
-{
- LOG_MSG("SQLSetCursorName called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC conn,
- SQLUSMALLINT option,
- SQLPOINTER value)
-{
- LOG_MSG("SQLGetConnectOption called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetFunctions(SQLHDBC conn,
- SQLUSMALLINT funcId,
- SQLUSMALLINT* supported)
-{
- LOG_MSG("SQLGetFunctions called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt,
- SQLUSMALLINT option,
- SQLPOINTER value)
-{
- LOG_MSG("SQLGetStmtOption called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt,
- SQLPOINTER* value)
-{
- LOG_MSG("SQLParamData called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt,
- SQLPOINTER data,
- SQLLEN strLengthOrIndicator)
-{
- LOG_MSG("SQLPutData called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC conn,
- SQLUSMALLINT option,
- SQLULEN value)
-{
- LOG_MSG("SQLSetConnectOption called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt,
- SQLUSMALLINT option,
- SQLULEN value)
-{
- LOG_MSG("SQLSetStmtOption called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLUSMALLINT unique,
- SQLUSMALLINT reserved)
-{
- LOG_MSG("SQLStatistics called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC conn,
- SQLCHAR* inConnectionStr,
- SQLSMALLINT inConnectionStrLen,
- SQLCHAR* outConnectionStrBuf,
- SQLSMALLINT outConnectionStrBufLen,
- SQLSMALLINT* outConnectionStrResLen)
-{
- LOG_MSG("SQLBrowseConnect called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt,
- SQLCHAR * catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR * schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR * procName,
- SQLSMALLINT procNameLen,
- SQLCHAR * columnName,
- SQLSMALLINT columnNameLen)
-{
- LOG_MSG("SQLProcedureColumns called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt,
- SQLSETPOSIROW rowNum,
- SQLUSMALLINT operation,
- SQLUSMALLINT lockType)
-{
- LOG_MSG("SQLSetPos called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt,
- SQLUSMALLINT concurrency,
- SQLLEN crowKeyset,
- SQLUSMALLINT crowRowset)
-{
- LOG_MSG("SQLSetScrollOptions called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC conn,
- SQLINTEGER attr,
- SQLPOINTER valueBuf,
- SQLINTEGER valueBufLen,
- SQLINTEGER* valueResLen)
-{
- LOG_MSG("SQLGetConnectAttr called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC conn,
- SQLINTEGER attr,
- SQLPOINTER value,
- SQLINTEGER valueLen)
-{
- using ignite::odbc::Connection;
-
- LOG_MSG("SQLSetConnectAttr called\n");
-
- Connection *connection = reinterpret_cast<Connection*>(conn);
-
- if (!connection)
- return SQL_INVALID_HANDLE;
-
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt,
- SQLUSMALLINT operation)
-{
- LOG_MSG("SQLBulkOperations called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen)
-{
- LOG_MSG("SQLTablePrivileges called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLCopyDesc(SQLHDESC src, SQLHDESC dst)
-{
- LOG_MSG("SQLCopyDesc called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetDescField(SQLHDESC descr,
- SQLSMALLINT recNum,
- SQLSMALLINT fieldId,
- SQLPOINTER buffer,
- SQLINTEGER bufferLen,
- SQLINTEGER* resLen)
-{
- LOG_MSG("SQLGetDescField called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle,
- SQLSMALLINT RecNumber,
- SQLCHAR* nameBuffer,
- SQLSMALLINT nameBufferLen,
- SQLSMALLINT* strLen,
- SQLSMALLINT* type,
- SQLSMALLINT* subType,
- SQLLEN* len,
- SQLSMALLINT* precision,
- SQLSMALLINT* scale,
- SQLSMALLINT* nullable)
-{
- LOG_MSG("SQLGetDescRec called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetDescField(SQLHDESC descr,
- SQLSMALLINT recNum,
- SQLSMALLINT fieldId,
- SQLPOINTER buffer,
- SQLINTEGER bufferLen)
-{
- LOG_MSG("SQLSetDescField called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetDescRec(SQLHDESC descr,
- SQLSMALLINT recNum,
- SQLSMALLINT type,
- SQLSMALLINT subType,
- SQLLEN len,
- SQLSMALLINT precision,
- SQLSMALLINT scale,
- SQLPOINTER buffer,
- SQLLEN* resLen,
- SQLLEN* id)
-{
- LOG_MSG("SQLSetDescRec called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLCHAR* columnName,
- SQLSMALLINT columnNameLen)
-{
- LOG_MSG("SQLColumnPrivileges called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT stmt,
- SQLUSMALLINT paramNum,
- SQLSMALLINT* dataType,
- SQLULEN* paramSize,
- SQLSMALLINT* decimalDigits,
- SQLSMALLINT* nullable)
-{
- LOG_MSG("SQLDescribeParam called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLParamOptions(SQLHSTMT stmt,
- SQLULEN paramSetSize,
- SQLULEN* paramsProcessed)
-{
- LOG_MSG("SQLParamOptions called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLProcedures(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen)
-{
- LOG_MSG("SQLProcedures called\n");
- return SQL_SUCCESS;
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/query/column_metadata_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/column_metadata_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/column_metadata_query.cpp
deleted file mode 100644
index 69a08b1..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/column_metadata_query.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/message.h"
-#include "ignite/odbc/query/column_metadata_query.h"
-
-namespace
-{
- enum ResultColumn
- {
- /** Catalog name. NULL if not applicable to the data source. */
- TABLE_CAT = 1,
-
- /** Schema name. NULL if not applicable to the data source. */
- TABLE_SCHEM,
-
- /** Table name. */
- TABLE_NAME,
-
- /** Column name. */
- COLUMN_NAME,
-
- /** SQL data type. */
- DATA_TYPE,
-
- /** Data source�dependent data type name. */
- TYPE_NAME,
-
- /** Column size. */
- COLUMN_SIZE,
-
- /** The length in bytes of data transferred on fetch. */
- BUFFER_LENGTH,
-
- /** The total number of significant digits to the right of the decimal point. */
- DECIMAL_DIGITS,
-
- /** Precision. */
- NUM_PREC_RADIX,
-
- /** Nullability of the data in column. */
- NULLABLE,
-
- /** A description of the column. */
- REMARKS
- };
-}
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- ColumnMetadataQuery::ColumnMetadataQuery(diagnostic::Diagnosable& diag,
- Connection& connection, const std::string& schema,
- const std::string& table, const std::string& column) :
- Query(diag),
- connection(connection),
- schema(schema),
- table(table),
- column(column),
- executed(false),
- meta(),
- columnsMeta()
- {
- using namespace ignite::impl::binary;
- using namespace ignite::odbc::type_traits;
-
- using meta::ColumnMeta;
-
- columnsMeta.reserve(12);
-
- const std::string sch("");
- const std::string tbl("");
-
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_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, "TYPE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_SIZE", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "BUFFER_LENGTH", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "DECIMAL_DIGITS", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "NUM_PREC_RADIX", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "NULLABLE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "REMARKS", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- }
-
- ColumnMetadataQuery::~ColumnMetadataQuery()
- {
- // No-op.
- }
-
- SqlResult ColumnMetadataQuery::Execute()
- {
- if (executed)
- Close();
-
- SqlResult result = MakeRequestGetColumnsMeta();
-
- if (result == SQL_RESULT_SUCCESS)
- {
- executed = true;
-
- cursor = meta.begin();
- }
-
- return result;
- }
-
- const meta::ColumnMetaVector& ColumnMetadataQuery::GetMeta() const
- {
- return columnsMeta;
- }
-
- SqlResult ColumnMetadataQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cursor == meta.end())
- return SQL_RESULT_NO_DATA;
-
- app::ColumnBindingMap::iterator it;
-
- for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
- GetColumn(it->first, it->second);
-
- ++cursor;
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult ColumnMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cursor == meta.end())
- return SQL_RESULT_NO_DATA;
-
- const meta::ColumnMeta& currentColumn = *cursor;
- uint8_t columnType = currentColumn.GetDataType();
-
- switch (columnIdx)
- {
- case TABLE_CAT:
- {
- buffer.PutNull();
- break;
- }
-
- case TABLE_SCHEM:
- {
- buffer.PutString(currentColumn.GetSchemaName());
- break;
- }
-
- case TABLE_NAME:
- {
- buffer.PutString(currentColumn.GetTableName());
- break;
- }
-
- case COLUMN_NAME:
- {
- buffer.PutString(currentColumn.GetColumnName());
- break;
- }
-
- case DATA_TYPE:
- {
- buffer.PutInt16(type_traits::BinaryToSqlType(columnType));
- break;
- }
-
- case TYPE_NAME:
- {
- buffer.PutString(currentColumn.GetColumnTypeName());
- break;
- }
-
- case COLUMN_SIZE:
- {
- buffer.PutInt16(type_traits::BinaryTypeColumnSize(columnType));
- break;
- }
-
- case BUFFER_LENGTH:
- {
- buffer.PutInt16(type_traits::BinaryTypeTransferLength(columnType));
- break;
- }
-
- case DECIMAL_DIGITS:
- {
- int32_t decDigits = type_traits::BinaryTypeDecimalDigits(columnType);
- if (decDigits < 0)
- buffer.PutNull();
- else
- buffer.PutInt16(static_cast<int16_t>(decDigits));
- break;
- }
-
- case NUM_PREC_RADIX:
- {
- buffer.PutInt16(type_traits::BinaryTypeNumPrecRadix(columnType));
- break;
- }
-
- case NULLABLE:
- {
- buffer.PutInt16(type_traits::BinaryTypeNullability(columnType));
- break;
- }
-
- case REMARKS:
- {
- buffer.PutNull();
- break;
- }
-
- default:
- break;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult ColumnMetadataQuery::Close()
- {
- meta.clear();
-
- executed = false;
-
- return SQL_RESULT_SUCCESS;
- }
-
- bool ColumnMetadataQuery::DataAvailable() const
- {
- return cursor != meta.end();
- }
-
- int64_t ColumnMetadataQuery::AffectedRows() const
- {
- return 0;
- }
-
- SqlResult ColumnMetadataQuery::MakeRequestGetColumnsMeta()
- {
- QueryGetColumnsMetaRequest req(schema, table, column);
- QueryGetColumnsMetaResponse rsp;
-
- bool success = connection.SyncMessage(req, rsp);
-
- if (!success)
- {
- diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
- {
- LOG_MSG("Error: %s\n", rsp.GetError().c_str());
-
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
-
- return SQL_RESULT_ERROR;
- }
-
- meta = rsp.GetMeta();
-
- for (size_t i = 0; i < meta.size(); ++i)
- {
- LOG_MSG("[%d] SchemaName: %s\n", i, meta[i].GetSchemaName().c_str());
- LOG_MSG("[%d] TableName: %s\n", i, meta[i].GetTableName().c_str());
- LOG_MSG("[%d] ColumnName: %s\n", i, meta[i].GetColumnName().c_str());
- LOG_MSG("[%d] ColumnTypeName: %s\n", i, meta[i].GetColumnTypeName().c_str());
- LOG_MSG("[%d] ColumnType: %d\n", i, meta[i].GetDataType());
- LOG_MSG("\n");
- }
-
- return SQL_RESULT_SUCCESS;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/query/data_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/data_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/data_query.cpp
deleted file mode 100644
index 4e9239b..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/data_query.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * 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 "ignite/odbc/connection.h"
-#include "ignite/odbc/message.h"
-#include "ignite/odbc/query/data_query.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- DataQuery::DataQuery(diagnostic::Diagnosable& diag,
- Connection& connection, const std::string& sql,
- const app::ParameterBindingMap& params) :
- Query(diag),
- connection(connection),
- sql(sql),
- params(params)
- {
- // No-op.
- }
-
- DataQuery::~DataQuery()
- {
- Close();
- }
-
- SqlResult DataQuery::Execute()
- {
- if (cursor.get())
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query cursor is in open state already.");
-
- return SQL_RESULT_ERROR;
- }
-
- return MakeRequestExecute();
- }
-
- const meta::ColumnMetaVector & DataQuery::GetMeta() const
- {
- return resultMeta;
- }
-
- SqlResult DataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings)
- {
- if (!cursor.get())
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (!cursor->HasNext())
- return SQL_RESULT_NO_DATA;
-
- if (cursor->NeedDataUpdate())
- {
- SqlResult result = MakeRequestFetch();
-
- if (result != SQL_RESULT_SUCCESS)
- return result;
-
- if (!cursor->HasNext())
- return SQL_RESULT_NO_DATA;
- }
- else
- cursor->Increment();
-
- Row* row = cursor->GetRow();
-
- if (!row)
- {
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown error.");
-
- return SQL_RESULT_ERROR;
- }
-
- for (int32_t i = 1; i < row->GetSize() + 1; ++i)
- {
- app::ColumnBindingMap::iterator it = columnBindings.find(i);
-
- SqlResult result;
-
- if (it != columnBindings.end())
- result = row->ReadColumnToBuffer(i, it->second);
-
- if (result == SQL_RESULT_ERROR)
- {
- diag.AddStatusRecord(SQL_STATE_01S01_ERROR_IN_ROW, "Can not retrieve row column.", 0, i);
-
- return SQL_RESULT_ERROR;
- }
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult DataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
- {
- if (!cursor.get())
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- Row* row = cursor->GetRow();
-
- if (!row)
- return SQL_RESULT_NO_DATA;
-
- SqlResult result = row->ReadColumnToBuffer(columnIdx, buffer);
-
- if (result == SQL_RESULT_ERROR)
- {
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown column type.");
-
- return SQL_RESULT_ERROR;
- }
-
- return result;
- }
-
- SqlResult DataQuery::Close()
- {
- if (!cursor.get())
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query cursor is not in open state.");
-
- return SQL_RESULT_ERROR;
- }
-
- SqlResult result = MakeRequestClose();
-
- if (result == SQL_RESULT_SUCCESS)
- cursor.reset();
-
- return result;
- }
-
- bool DataQuery::DataAvailable() const
- {
- return cursor.get() && cursor->HasNext();
- }
-
- int64_t DataQuery::AffectedRows() const
- {
- // We are only support SELECT statements so we should not
- // return anything particullar.
- return 0;
- }
-
- SqlResult DataQuery::MakeRequestExecute()
- {
- const std::string& cacheName = connection.GetCache();
-
- QueryExecuteRequest req(cacheName, sql, params);
- QueryExecuteResponse rsp;
-
- bool success = connection.SyncMessage(req, rsp);
-
- if (!success)
- {
- diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
- {
- LOG_MSG("Error: %s\n", rsp.GetError().c_str());
-
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
-
- return SQL_RESULT_ERROR;
- }
-
- cursor.reset(new Cursor(rsp.GetQueryId()));
-
- resultMeta.assign(rsp.GetMeta().begin(), rsp.GetMeta().end());
-
- LOG_MSG("Query id: %lld\n", cursor->GetQueryId());
-
- for (size_t i = 0; i < rsp.GetMeta().size(); ++i)
- {
- LOG_MSG("[%d] SchemaName: %s\n", i, rsp.GetMeta()[i].GetSchemaName().c_str());
- LOG_MSG("[%d] TypeName: %s\n", i, rsp.GetMeta()[i].GetTableName().c_str());
- LOG_MSG("[%d] ColumnName: %s\n", i, rsp.GetMeta()[i].GetColumnName().c_str());
- LOG_MSG("[%d] ColumnTypeName: %s\n", i, rsp.GetMeta()[i].GetColumnTypeName().c_str());
- LOG_MSG("[%d] ColumnType: %d\n", i, rsp.GetMeta()[i].GetDataType());
- LOG_MSG("\n");
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult DataQuery::MakeRequestClose()
- {
- QueryCloseRequest req(cursor->GetQueryId());
- QueryCloseResponse rsp;
-
- bool success = connection.SyncMessage(req, rsp);
-
- if (!success)
- {
- diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
-
- return SQL_RESULT_ERROR;
- }
-
- LOG_MSG("Query id: %lld\n", rsp.GetQueryId());
-
- if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
- {
- LOG_MSG("Error: %s\n", rsp.GetError().c_str());
-
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult DataQuery::MakeRequestFetch()
- {
- std::auto_ptr<ResultPage> resultPage(new ResultPage());
-
- QueryFetchRequest req(cursor->GetQueryId(), ResultPage::DEFAULT_SIZE);
- QueryFetchResponse rsp(*resultPage);
-
- bool success = connection.SyncMessage(req, rsp);
-
- LOG_MSG("Query id: %lld\n", rsp.GetQueryId());
- LOG_MSG("Request status: %s\n", success ? "Success" : "Failure");
-
- if (!success)
- {
- diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
- {
- LOG_MSG("Error: %s\n", rsp.GetError().c_str());
-
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
-
- return SQL_RESULT_ERROR;
- }
-
- cursor->UpdateData(resultPage);
-
- return SQL_RESULT_SUCCESS;
- }
- }
- }
-}
-
[16/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/Makefile.am b/modules/platforms/cpp/odbc/odbc-test/Makefile.am
deleted file mode 100644
index 32ca6b2..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/Makefile.am
+++ /dev/null
@@ -1,55 +0,0 @@
-##
-## 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.
-##
-
-ACLOCAL_AMFLAGS = "-Im4"
-
-SUBDIRS = .
-DIST_SUBDIRS = .
-
-AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/../odbc-driver/include -DIGNITE_IMPL
-AM_CXXFLAGS = -Wall -std=c++0x
-
-noinst_PROGRAMS = ignite-odbc-tests
-
-ignite_odbc_tests_SOURCES = src/teamcity_boost.cpp \
- src/teamcity_messages.cpp \
- src/parser_test.cpp \
- src/cursor_test.cpp \
- src/connection_info_test.cpp \
- src/application_data_buffer_test.cpp \
- src/configuration_test.cpp \
- src/row_test.cpp \
- src/utility_test.cpp \
- ../odbc-driver/src/cursor.cpp \
- ../odbc-driver/src/config/connection_info.cpp \
- ../odbc-driver/src/app/application_data_buffer.cpp \
- ../odbc-driver/src/config/configuration.cpp \
- ../odbc-driver/src/row.cpp \
- ../odbc-driver/src/decimal.cpp \
- ../odbc-driver/src/utility.cpp \
- ../odbc-driver/src/result_page.cpp
-
-ignite_odbc_tests_LDFLAGS = -static-libtool-libs -L/usr/local/lib -lignite-binary -ldl
-
-run-check: check
- ./ignite-odbc-tests -p
-
-clean-local: clean-check
- $(RM) *.gcno *.gcda
-
-clean-docs:
- $(RM) $(ignite_odbc_tests_OBJECTS)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/README.TXT b/modules/platforms/cpp/odbc/odbc-test/README.TXT
deleted file mode 100644
index 97f4c64..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/README.TXT
+++ /dev/null
@@ -1 +0,0 @@
-Contains IDE projects artifacts.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/configure.ac b/modules/platforms/cpp/odbc/odbc-test/configure.ac
deleted file mode 100644
index abb7adc..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/configure.ac
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# 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.
-#
-
-# -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ([2.69])
-AC_INIT([Apache Ignite ODBC Test], [1.5.1.7927], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
-AC_CONFIG_SRCDIR(src)
-
-AC_CANONICAL_SYSTEM
-AC_CONFIG_MACRO_DIR([m4])
-AC_LANG([C++])
-
-# Initialize automake
-AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
-AC_CONFIG_HEADER(config.h)
-
-AM_PROG_AR
-
-# Checks for programs.
-GXX="-g -O2"
-
-AC_PROG_CXX
-
-# Initialize Libtool
-LT_INIT
-
-# Checks for libraries.
-AC_CHECK_LIB([pthread], [pthread_mutex_lock])
-
-# Checks for header files.
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_INLINE
-AC_TYPE_INT16_T
-AC_TYPE_INT32_T
-AC_TYPE_INT64_T
-AC_TYPE_INT8_T
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-
-# Checks for library functions.
-AC_FUNC_ERROR_AT_LINE
-
-AC_CONFIG_FILES(Makefile)
-
-AC_OUTPUT
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/include/teamcity_messages.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/include/teamcity_messages.h b/modules/platforms/cpp/odbc/odbc-test/include/teamcity_messages.h
deleted file mode 100644
index 8cf23d0..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/include/teamcity_messages.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright 2011 JetBrains s.r.o.
- *
- * Licensed 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.
- *
- * $Revision: 88625 $
-*/
-
-#ifndef H_TEAMCITY_MESSAGES
-#define H_TEAMCITY_MESSAGES
-
-#include <string>
-#include <iostream>
-
-namespace JetBrains {
-
-std::string getFlowIdFromEnvironment();
-bool underTeamcity();
-
-class TeamcityMessages {
- std::ostream *m_out;
-
-protected:
- std::string escape(std::string s);
-
- void openMsg(const std::string &name);
- void writeProperty(std::string name, std::string value);
- void closeMsg();
-
-public:
- TeamcityMessages();
-
- void setOutput(std::ostream &);
-
- void suiteStarted(std::string name, std::string flowid = "");
- void suiteFinished(std::string name, std::string flowid = "");
-
- void testStarted(std::string name, std::string flowid = "");
- void testFailed(std::string name, std::string message, std::string details, std::string flowid = "");
- void testIgnored(std::string name, std::string message, std::string flowid = "");
- void testFinished(std::string name, int durationMs = -1, std::string flowid = "");
-};
-
-}
-
-#endif /* H_TEAMCITY_MESSAGES */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj
deleted file mode 100644
index a6a2ae3..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj
+++ /dev/null
@@ -1,189 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{309BEA40-495D-463F-98D5-4657F03F6D8F}</ProjectGuid>
- <RootNamespace>odbctest</RootNamespace>
- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v100</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="Shared">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
- <IntDir>$(Platform)\$(Configuration)\</IntDir>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc-driver\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ExceptionHandling>Async</ExceptionHandling>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc-driver\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ExceptionHandling>Async</ExceptionHandling>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <SubSystem>Console</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc-driver\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ExceptionHandling>Async</ExceptionHandling>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\..\common\include;$(ProjectDir)\..\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\..\binary\include;$(ProjectDir)\..\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc-driver\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ExceptionHandling>Async</ExceptionHandling>
- </ClCompile>
- <Link>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\odbc-driver\src\app\application_data_buffer.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\column.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\config\configuration.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\config\connection_info.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\cursor.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\decimal.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\result_page.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\row.cpp" />
- <ClCompile Include="..\..\..\odbc-driver\src\utility.cpp" />
- <ClCompile Include="..\..\src\application_data_buffer_test.cpp" />
- <ClCompile Include="..\..\src\column_test.cpp" />
- <ClCompile Include="..\..\src\configuration_test.cpp" />
- <ClCompile Include="..\..\src\connection_info_test.cpp" />
- <ClCompile Include="..\..\src\cursor_test.cpp" />
- <ClCompile Include="..\..\src\parser_test.cpp" />
- <ClCompile Include="..\..\src\row_test.cpp" />
- <ClCompile Include="..\..\src\teamcity_boost.cpp" />
- <ClCompile Include="..\..\src\teamcity_messages.cpp" />
- <ClCompile Include="..\..\src\utility_test.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\include\teamcity_messages.h" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\..\binary\project\vs\binary.vcxproj">
- <Project>{4f15669b-92eb-49f0-b774-8f19bae0b960}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\..\common\project\vs\common.vcxproj">
- <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj.filters
deleted file mode 100644
index cf44ba9..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Code">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Externals">
- <UniqueIdentifier>{cc75fc86-c08d-428a-8ae3-f9979e4588ab}</UniqueIdentifier>
- </Filter>
- <Filter Include="Code\teamcity">
- <UniqueIdentifier>{5438a56d-1009-412a-86e3-ceb1112af275}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\configuration_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\utility.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\connection_info_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\parser_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\teamcity_boost.cpp">
- <Filter>Code\teamcity</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\teamcity_messages.cpp">
- <Filter>Code\teamcity</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\application_data_buffer_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\row_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\row.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\result_page.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\cursor_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\cursor.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\utility_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\config\configuration.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\config\connection_info.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\app\application_data_buffer.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\decimal.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\odbc-driver\src\column.cpp">
- <Filter>Externals</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\column_test.cpp">
- <Filter>Code</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\include\teamcity_messages.h">
- <Filter>Code\teamcity</Filter>
- </ClInclude>
- </ItemGroup>
-</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/application_data_buffer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/application_data_buffer_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/application_data_buffer_test.cpp
deleted file mode 100644
index 632f05f..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/application_data_buffer_test.cpp
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/guid.h>
-#include <ignite/odbc/decimal.h>
-#include <ignite/odbc/app/application_data_buffer.h>
-
-#define FLOAT_PRECISION 0.0000001f
-
-using namespace ignite;
-using namespace ignite::odbc;
-using namespace ignite::odbc::app;
-using namespace ignite::odbc::type_traits;
-
-BOOST_AUTO_TEST_SUITE(ApplicationDataBufferTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestPutIntToString)
-{
- char buffer[1024];
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
-
- appBuf.PutInt8(12);
- BOOST_REQUIRE(!strcmp(buffer, "12"));
- BOOST_REQUIRE(reslen == strlen("12"));
-
- appBuf.PutInt8(-12);
- BOOST_REQUIRE(!strcmp(buffer, "-12"));
- BOOST_REQUIRE(reslen == strlen("-12"));
-
- appBuf.PutInt16(9876);
- BOOST_REQUIRE(!strcmp(buffer, "9876"));
- BOOST_REQUIRE(reslen == strlen("9876"));
-
- appBuf.PutInt16(-9876);
- BOOST_REQUIRE(!strcmp(buffer, "-9876"));
- BOOST_REQUIRE(reslen == strlen("-9876"));
-
- appBuf.PutInt32(1234567);
- BOOST_REQUIRE(!strcmp(buffer, "1234567"));
- BOOST_REQUIRE(reslen == strlen("1234567"));
-
- appBuf.PutInt32(-1234567);
- BOOST_REQUIRE(!strcmp(buffer, "-1234567"));
- BOOST_REQUIRE(reslen == strlen("-1234567"));
-}
-
-BOOST_AUTO_TEST_CASE(TestPutFloatToString)
-{
- char buffer[1024];
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
-
- appBuf.PutFloat(12.42f);
- BOOST_REQUIRE(!strcmp(buffer, "12.42"));
- BOOST_REQUIRE(reslen == strlen("12.42"));
-
- appBuf.PutFloat(-12.42f);
- BOOST_REQUIRE(!strcmp(buffer, "-12.42"));
- BOOST_REQUIRE(reslen == strlen("-12.42"));
-
- appBuf.PutDouble(1000.21);
- BOOST_REQUIRE(!strcmp(buffer, "1000.21"));
- BOOST_REQUIRE(reslen == strlen("1000.21"));
-
- appBuf.PutDouble(-1000.21);
- BOOST_REQUIRE(!strcmp(buffer, "-1000.21"));
- BOOST_REQUIRE(reslen == strlen("-1000.21"));
-}
-
-BOOST_AUTO_TEST_CASE(TestPutGuidToString)
-{
- char buffer[1024];
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
-
- ignite::Guid guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL);
-
- appBuf.PutGuid(guid);
-
- BOOST_REQUIRE(!strcmp(buffer, "1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
- BOOST_REQUIRE(reslen == strlen("1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
-}
-
-BOOST_AUTO_TEST_CASE(TestPutBinaryToString)
-{
- char buffer[1024];
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
-
- uint8_t binary[] = { 0x21, 0x84, 0xF4, 0xDC, 0x01, 0x00, 0xFF, 0xF0 };
-
- appBuf.PutBinaryData(binary, sizeof(binary));
-
- BOOST_REQUIRE(!strcmp(buffer, "2184f4dc0100fff0"));
- BOOST_REQUIRE(reslen == strlen("2184f4dc0100fff0"));
-}
-
-BOOST_AUTO_TEST_CASE(TestPutStringToString)
-{
- char buffer[1024];
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
-
- std::string testString("Test string");
-
- appBuf.PutString(testString);
-
- BOOST_REQUIRE(!strcmp(buffer, testString.c_str()));
- BOOST_REQUIRE(reslen == testString.size());
-}
-
-BOOST_AUTO_TEST_CASE(TestPutStringToWstring)
-{
- wchar_t buffer[1024];
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_WCHAR, buffer, sizeof(buffer), &reslen, &offset);
-
- std::string testString("Test string");
-
- appBuf.PutString(testString);
- BOOST_REQUIRE(!wcscmp(buffer, L"Test string"));
-}
-
-BOOST_AUTO_TEST_CASE(TestPutStringToLong)
-{
- long numBuf;
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, &offset);
-
- appBuf.PutString("424242424");
- BOOST_REQUIRE(numBuf == 424242424L);
-
- appBuf.PutString("-424242424");
- BOOST_REQUIRE(numBuf == -424242424L);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutStringToTiny)
-{
- int8_t numBuf;
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_TINYINT, &numBuf, sizeof(numBuf), &reslen, &offset);
-
- appBuf.PutString("12");
- BOOST_REQUIRE(numBuf == 12);
-
- appBuf.PutString("-12");
- BOOST_REQUIRE(numBuf == -12);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutStringToFloat)
-{
- float numBuf;
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset);
-
- appBuf.PutString("12.21");
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 12.21, FLOAT_PRECISION);
-
- appBuf.PutString("-12.21");
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -12.21, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutIntToFloat)
-{
- float numBuf;
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset);
-
- appBuf.PutInt8(5);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 5.0, FLOAT_PRECISION);
-
- appBuf.PutInt8(-5);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -5.0, FLOAT_PRECISION);
-
- appBuf.PutInt16(4242);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 4242.0, FLOAT_PRECISION);
-
- appBuf.PutInt16(-4242);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -4242.0, FLOAT_PRECISION);
-
- appBuf.PutInt32(1234567);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 1234567.0, FLOAT_PRECISION);
-
- appBuf.PutInt32(-1234567);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -1234567.0, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutFloatToShort)
-{
- short numBuf;
- SqlLen reslen;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &numBuf, sizeof(numBuf), &reslen, &offset);
-
- appBuf.PutDouble(5.42);
- BOOST_REQUIRE(numBuf == 5);
-
- appBuf.PutDouble(-5.42);
- BOOST_REQUIRE(numBuf == -5.0);
-
- appBuf.PutFloat(42.99f);
- BOOST_REQUIRE(numBuf == 42);
-
- appBuf.PutFloat(-42.99f);
- BOOST_REQUIRE(numBuf == -42);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutDecimalToDouble)
-{
- double numBuf;
- SqlLen reslen;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &numBuf, sizeof(numBuf), &reslen, 0);
-
- Decimal decimal;
-
- BOOST_REQUIRE_CLOSE_FRACTION(static_cast<double>(decimal), 0.0, FLOAT_PRECISION);
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 0.0, FLOAT_PRECISION);
-
- int8_t mag1[] = { 1, 0 };
-
- decimal = Decimal(0, mag1, sizeof(mag1));
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 256.0, FLOAT_PRECISION);
-
- int8_t mag2[] = { 2, 23 };
-
- decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -53.5, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutDecimalToLong)
-{
- long numBuf;
- SqlLen reslen;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, 0);
-
- Decimal decimal;
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(numBuf == 0);
-
- int8_t mag1[] = { 1, 0 };
-
- decimal = Decimal(0, mag1, sizeof(mag1));
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(numBuf == 256);
-
- int8_t mag2[] = { 2, 23 };
-
- decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(numBuf == -53);
-}
-
-BOOST_AUTO_TEST_CASE(TestPutDecimalToString)
-{
- char strBuf[64];
- SqlLen reslen;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
-
- Decimal decimal;
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(std::string(strBuf, reslen) == "0");
-
- int8_t mag1[] = { 1, 0 };
-
- decimal = Decimal(0, mag1, sizeof(mag1));
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(std::string(strBuf, reslen) == "256");
-
- int8_t mag2[] = { 2, 23 };
-
- decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
-
- appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(std::string(strBuf, reslen) == "-53.5");
-}
-
-BOOST_AUTO_TEST_CASE(TestGetStringFromLong)
-{
- long numBuf = 42;
- SqlLen reslen = sizeof(numBuf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, reslen, &reslen, &offset);
-
- std::string res = appBuf.GetString(32);
-
- BOOST_REQUIRE(res == "42");
-
- numBuf = -77;
-
- res = appBuf.GetString(32);
-
- BOOST_REQUIRE(res == "-77");
-}
-
-BOOST_AUTO_TEST_CASE(TestGetStringFromDouble)
-{
- double numBuf = 43.36;
- SqlLen reslen = sizeof(numBuf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &numBuf, reslen, &reslen, &offset);
-
- std::string res = appBuf.GetString(32);
-
- BOOST_REQUIRE(res == "43.36");
-
- numBuf = -58.91;
-
- res = appBuf.GetString(32);
-
- BOOST_REQUIRE(res == "-58.91");
-}
-
-BOOST_AUTO_TEST_CASE(TestGetStringFromString)
-{
- char buf[] = "Some data 32d2d5hs";
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset);
-
- std::string res = appBuf.GetString(reslen);
-
- BOOST_REQUIRE(res.compare(buf));
-}
-
-BOOST_AUTO_TEST_CASE(TestGetFloatFromUshort)
-{
- unsigned short numBuf = 7162;
- SqlLen reslen = sizeof(numBuf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT, &numBuf, reslen, &reslen, &offset);
-
- float resFloat = appBuf.GetFloat();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 7162.0f, FLOAT_PRECISION);
-
- double resDouble = appBuf.GetDouble();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 7162.0, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetFloatFromString)
-{
- char buf[] = "28.562";
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset);
-
- float resFloat = appBuf.GetFloat();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 28.562f, FLOAT_PRECISION);
-
- double resDouble = appBuf.GetDouble();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 28.562, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetFloatFromFloat)
-{
- float buf = 207.49f;
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &buf, reslen, &reslen, &offset);
-
- float resFloat = appBuf.GetFloat();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 207.49f, FLOAT_PRECISION);
-
- double resDouble = appBuf.GetDouble();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 207.49, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetFloatFromDouble)
-{
- double buf = 893.162;
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &buf, reslen, &reslen, &offset);
-
- float resFloat = appBuf.GetFloat();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 893.162f, FLOAT_PRECISION);
-
- double resDouble = appBuf.GetDouble();
-
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 893.162, FLOAT_PRECISION);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetIntFromString)
-{
- char buf[] = "39";
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset);
-
- int64_t resInt64 = appBuf.GetInt64();
-
- BOOST_REQUIRE(resInt64 == 39);
-
- int32_t resInt32 = appBuf.GetInt32();
-
- BOOST_REQUIRE(resInt32 == 39);
-
- int16_t resInt16 = appBuf.GetInt16();
-
- BOOST_REQUIRE(resInt16 == 39);
-
- int8_t resInt8 = appBuf.GetInt8();
-
- BOOST_REQUIRE(resInt8 == 39);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetIntFromFloat)
-{
- float buf = -107.49f;
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &buf, reslen, &reslen, &offset);
-
- int64_t resInt64 = appBuf.GetInt64();
-
- BOOST_REQUIRE(resInt64 == -107);
-
- int32_t resInt32 = appBuf.GetInt32();
-
- BOOST_REQUIRE(resInt32 == -107);
-
- int16_t resInt16 = appBuf.GetInt16();
-
- BOOST_REQUIRE(resInt16 == -107);
-
- int8_t resInt8 = appBuf.GetInt8();
-
- BOOST_REQUIRE(resInt8 == -107);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetIntFromDouble)
-{
- double buf = 42.97f;
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &buf, reslen, &reslen, &offset);
-
- int64_t resInt64 = appBuf.GetInt64();
-
- BOOST_REQUIRE(resInt64 == 42);
-
- int32_t resInt32 = appBuf.GetInt32();
-
- BOOST_REQUIRE(resInt32 == 42);
-
- int16_t resInt16 = appBuf.GetInt16();
-
- BOOST_REQUIRE(resInt16 == 42);
-
- int8_t resInt8 = appBuf.GetInt8();
-
- BOOST_REQUIRE(resInt8 == 42);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetIntFromBigint)
-{
- uint64_t buf = 19;
- SqlLen reslen = sizeof(buf);
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT, &buf, reslen, &reslen, &offset);
-
- int64_t resInt64 = appBuf.GetInt64();
-
- BOOST_REQUIRE(resInt64 == 19);
-
- int32_t resInt32 = appBuf.GetInt32();
-
- BOOST_REQUIRE(resInt32 == 19);
-
- int16_t resInt16 = appBuf.GetInt16();
-
- BOOST_REQUIRE(resInt16 == 19);
-
- int8_t resInt8 = appBuf.GetInt8();
-
- BOOST_REQUIRE(resInt8 == 19);
-}
-
-BOOST_AUTO_TEST_CASE(TestGetIntWithOffset)
-{
- struct TestStruct
- {
- uint64_t val;
- SqlLen reslen;
- };
-
- TestStruct buf[2] = {
- { 12, sizeof(uint64_t) },
- { 42, sizeof(uint64_t) }
- };
-
- size_t offset = 0;
- size_t* offsetPtr = &offset;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT, &buf[0].val, sizeof(buf[0].val), &buf[0].reslen, &offsetPtr);
-
- int64_t val = appBuf.GetInt64();
-
- BOOST_REQUIRE(val == 12);
-
- offset += sizeof(TestStruct);
-
- val = appBuf.GetInt64();
-
- BOOST_REQUIRE(val == 42);
-
- offsetPtr = 0;
-
- val = appBuf.GetInt64();
-
- BOOST_REQUIRE(val == 12);
-}
-
-BOOST_AUTO_TEST_CASE(TestSetStringWithOffset)
-{
- struct TestStruct
- {
- char val[64];
- SqlLen reslen;
- };
-
- TestStruct buf[2] = {
- { "", 0 },
- { "", 0 }
- };
-
- size_t offset = 0;
- size_t* offsetPtr = &offset;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf[0].val, sizeof(buf[0].val), &buf[0].reslen, &offsetPtr);
-
- appBuf.PutString("Hello Ignite!");
-
- std::string res(buf[0].val, buf[0].reslen);
-
- BOOST_REQUIRE(buf[0].reslen == strlen("Hello Ignite!"));
- BOOST_REQUIRE(res == "Hello Ignite!");
- BOOST_REQUIRE(res.size() == strlen("Hello Ignite!"));
-
- offset += sizeof(TestStruct);
-
- appBuf.PutString("Hello with offset!");
-
- res.assign(buf[0].val, buf[0].reslen);
-
- BOOST_REQUIRE(res == "Hello Ignite!");
- BOOST_REQUIRE(res.size() == strlen("Hello Ignite!"));
- BOOST_REQUIRE(buf[0].reslen == strlen("Hello Ignite!"));
-
- res.assign(buf[1].val, buf[1].reslen);
-
- BOOST_REQUIRE(res == "Hello with offset!");
- BOOST_REQUIRE(res.size() == strlen("Hello with offset!"));
- BOOST_REQUIRE(buf[1].reslen == strlen("Hello with offset!"));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/column_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/column_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/column_test.cpp
deleted file mode 100644
index 4864a6a..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/column_test.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/impl/binary/binary_common.h>
-#include <ignite/impl/binary/binary_writer_impl.h>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/column.h"
-
-using namespace ignite::impl::binary;
-using namespace ignite::odbc::app;
-using namespace ignite::odbc;
-
-BOOST_AUTO_TEST_SUITE(ColumnTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestColumnDefaultConstruction)
-{
- Column column;
-
- BOOST_REQUIRE(!column.IsValid());
-}
-
-BOOST_AUTO_TEST_CASE(TestColumnShort)
-{
- ignite::impl::interop::InteropUnpooledMemory mem(4096);
- ignite::impl::interop::InteropOutputStream outStream(&mem);
- ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
-
- int16_t data = 42;
-
- writer.WriteInt8(IGNITE_TYPE_SHORT);
- writer.WriteInt16(data);
-
- outStream.Synchronize();
-
- ignite::impl::interop::InteropInputStream inStream(&mem);
- ignite::impl::binary::BinaryReaderImpl reader(&inStream);
-
- Column column(reader);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == 2);
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 2);
-
- short shortBuf = 0;
- SqlLen reslen = 0;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &shortBuf, sizeof(shortBuf), &reslen, &offset);
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == 2);
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
-
- BOOST_REQUIRE(shortBuf == data);
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == 2);
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
-}
-
-BOOST_AUTO_TEST_CASE(TestColumnString)
-{
- ignite::impl::interop::InteropUnpooledMemory mem(4096);
- ignite::impl::interop::InteropOutputStream outStream(&mem);
- ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
-
- std::string data("Some test data.");
-
- writer.WriteString(data.data(), static_cast<int32_t>(data.size()));
-
- outStream.Synchronize();
-
- ignite::impl::interop::InteropInputStream inStream(&mem);
- ignite::impl::binary::BinaryReaderImpl reader(&inStream);
-
- Column column(reader);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == data.size());
-
- char strBuf[1024] = {};
- SqlLen reslen = 0;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset);
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
-
- BOOST_REQUIRE(std::string(strBuf) == data);
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
-}
-
-BOOST_AUTO_TEST_CASE(TestColumnStringSeveral)
-{
- ignite::impl::interop::InteropUnpooledMemory mem(4096);
- ignite::impl::interop::InteropOutputStream outStream(&mem);
- ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
-
- std::string data("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
-
- writer.WriteString(data.data(), static_cast<int32_t>(data.size()));
-
- outStream.Synchronize();
-
- ignite::impl::interop::InteropInputStream inStream(&mem);
- ignite::impl::binary::BinaryReaderImpl reader(&inStream);
-
- Column column(reader);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == data.size());
-
- std::string res;
-
- std::string strBuf(data.size() / 3 + 2, 0);
- SqlLen reslen = 0;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf[0], strBuf.size(), &reslen, &offset);
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - (strBuf.size() - 1));
-
- res.append(strBuf.c_str());
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - 2 * (strBuf.size() - 1));
-
- res.append(strBuf.c_str());
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
-
- res.append(strBuf.c_str());
-
- BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
-
- BOOST_REQUIRE(column.IsValid());
-
- BOOST_REQUIRE(column.GetSize() == data.size());
-
- BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
-
- BOOST_REQUIRE(res == data);
-}
-
-BOOST_AUTO_TEST_CASE(TestColumnMultiString)
-{
- ignite::impl::interop::InteropUnpooledMemory mem(4096);
- ignite::impl::interop::InteropOutputStream outStream(&mem);
- ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
-
- std::string data1("Some test data.");
- std::string data2("Other TEST DATA.");
-
- writer.WriteString(data1.data(), static_cast<int32_t>(data1.size()));
- writer.WriteString(data2.data(), static_cast<int32_t>(data2.size()));
-
- outStream.Synchronize();
-
- ignite::impl::interop::InteropInputStream inStream(&mem);
- ignite::impl::binary::BinaryReaderImpl reader(&inStream);
-
- Column column1(reader);
-
- inStream.Position(column1.GetEndPosition());
-
- Column column2(reader);
-
- BOOST_REQUIRE(column1.IsValid());
-
- BOOST_REQUIRE(column1.GetSize() == data1.size());
-
- BOOST_REQUIRE(column1.GetUnreadDataLength() == data1.size());
-
- BOOST_REQUIRE(column2.IsValid());
-
- BOOST_REQUIRE(column2.GetSize() == data2.size());
-
- BOOST_REQUIRE(column2.GetUnreadDataLength() == data2.size());
-
- char strBuf[1024] = {};
- SqlLen reslen = 0;
- size_t* offset = 0;
-
- ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset);
-
- BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column1.IsValid());
-
- BOOST_REQUIRE(column1.GetSize() == data1.size());
-
- BOOST_REQUIRE(column1.GetUnreadDataLength() == 0);
-
- BOOST_REQUIRE(std::string(strBuf) == data1);
-
- BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
-
- BOOST_REQUIRE(column1.IsValid());
-
- BOOST_REQUIRE(column1.GetSize() == data1.size());
-
- BOOST_REQUIRE(column1.GetUnreadDataLength() == 0);
-
- BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(column2.IsValid());
-
- BOOST_REQUIRE(column2.GetSize() == data2.size());
-
- BOOST_REQUIRE(column2.GetUnreadDataLength() == 0);
-
- BOOST_REQUIRE(std::string(strBuf) == data2);
-
- BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
-
- BOOST_REQUIRE(column2.IsValid());
-
- BOOST_REQUIRE(column2.GetSize() == data2.size());
-
- BOOST_REQUIRE(column2.GetUnreadDataLength() == 0);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/configuration_test.cpp
deleted file mode 100644
index fba46cc..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/configuration_test.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <iostream>
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/odbc/config/configuration.h>
-
-using namespace ignite::odbc::config;
-
-namespace
-{
- const char* testDriverName = "Ignite";
- const char* testServerHost = "testhost.com";
- const uint16_t testServerPort = 4242;
- const char* testCacheName = "TestCache";
- const char* testDsn = "Ignite DSN";
-}
-
-BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
-
-void CheckConnectionConfig(const Configuration& cfg)
-{
- BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
- BOOST_REQUIRE(cfg.GetHost() == testServerHost);
- BOOST_REQUIRE(cfg.GetPort() == testServerPort);
- BOOST_REQUIRE(cfg.GetCache() == testCacheName);
- BOOST_REQUIRE(cfg.GetDsn().empty());
-
- std::stringstream constructor;
-
- constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName << ";";
-
- const std::string& expectedStr = constructor.str();
-
- BOOST_REQUIRE(cfg.ToConnectString() == expectedStr);
-}
-
-void CheckDsnConfig(const Configuration& cfg)
-{
- BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
- BOOST_REQUIRE(cfg.GetDsn() == testDsn);
- BOOST_REQUIRE(cfg.GetHost().empty());
- BOOST_REQUIRE(cfg.GetCache().empty());
- BOOST_REQUIRE(cfg.GetPort() == 0);
-}
-
-BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "DRIVER={" << testDriverName << "};"
- << "SERVER=" << testServerHost <<";"
- << "PORT=" << testServerPort << ";"
- << "CACHE=" << testCacheName;
-
- const std::string& connectStr = constructor.str();
-
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
-
- CheckConnectionConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestConnectStringLowercase)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName;
-
- const std::string& connectStr = constructor.str();
-
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
-
- CheckConnectionConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestConnectStringMixed)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "Driver={" << testDriverName << "};"
- << "Server=" << testServerHost << ";"
- << "Port=" << testServerPort << ";"
- << "Cache=" << testCacheName;
-
- const std::string& connectStr = constructor.str();
-
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
-
- CheckConnectionConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "DRIVER = {" << testDriverName << "} ;\n"
- << " SERVER =" << testServerHost << " ; \n"
- << "PORT= " << testServerPort << "; "
- << "CACHE = \n\r" << testCacheName;
-
- const std::string& connectStr = constructor.str();
-
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
-
- CheckConnectionConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestDsnStringUppercase)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "DRIVER=" << testDriverName << '\0'
- << "DSN={" << testDsn << "}" << '\0' << '\0';
-
- const std::string& configStr = constructor.str();
-
- cfg.FillFromConfigAttributes(configStr.data());
-
- CheckDsnConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "driver=" << testDriverName << '\0'
- << "dsn={" << testDsn << "}" << '\0' << '\0';
-
- const std::string& configStr = constructor.str();
-
- cfg.FillFromConfigAttributes(configStr.data());
-
- CheckDsnConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestDsnStrinMixed)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << "Driver=" << testDriverName << '\0'
- << "Dsn={" << testDsn << "}" << '\0' << '\0';
-
- const std::string& configStr = constructor.str();
-
- cfg.FillFromConfigAttributes(configStr.data());
-
- CheckDsnConfig(cfg);
-}
-
-BOOST_AUTO_TEST_CASE(TestDsnStrinWhitespaces)
-{
- Configuration cfg;
-
- std::stringstream constructor;
-
- constructor << " DRIVER = " << testDriverName << "\r\n" << '\0'
- << "DSN= {" << testDsn << "} \n" << '\0' << '\0';
-
- const std::string& configStr = constructor.str();
-
- cfg.FillFromConfigAttributes(configStr.data());
-
- CheckDsnConfig(cfg);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/connection_info_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/connection_info_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/connection_info_test.cpp
deleted file mode 100644
index dd8d1f6..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/connection_info_test.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <iostream>
-
-#include <boost/test/unit_test.hpp>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/config/connection_info.h"
-
-using namespace ignite::odbc;
-using namespace ignite::odbc::config;
-
-BOOST_AUTO_TEST_SUITE(ConnectionInfoTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestConnectionInfoSupportedInfo)
-{
- char buffer[4096];
- short reslen = 0;
-
- ConnectionInfo info;
-
- SqlResult result;
-
-#ifdef SQL_DRIVER_NAME
- result = info.GetInfo(SQL_DRIVER_NAME, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_DRIVER_NAME
-
-#ifdef SQL_DBMS_NAME
- result = info.GetInfo(SQL_DBMS_NAME, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_DBMS_NAME
-
-#ifdef SQL_DRIVER_ODBC_VER
- result = info.GetInfo(SQL_DRIVER_ODBC_VER, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_DRIVER_ODBC_VER
-
-#ifdef SQL_DBMS_VER
- result = info.GetInfo(SQL_DBMS_VER, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_DBMS_VER
-
-#ifdef SQL_DRIVER_VER
- result = info.GetInfo(SQL_DRIVER_VER, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_DRIVER_VER
-
-#ifdef SQL_COLUMN_ALIAS
- result = info.GetInfo(SQL_COLUMN_ALIAS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_COLUMN_ALIAS
-
-#ifdef SQL_IDENTIFIER_QUOTE_CHAR
- result = info.GetInfo(SQL_IDENTIFIER_QUOTE_CHAR, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_IDENTIFIER_QUOTE_CHAR
-
-#ifdef SQL_CATALOG_NAME_SEPARATOR
- result = info.GetInfo(SQL_CATALOG_NAME_SEPARATOR, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_CATALOG_NAME_SEPARATOR
-
-#ifdef SQL_SPECIAL_CHARACTERS
- result = info.GetInfo(SQL_SPECIAL_CHARACTERS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_SPECIAL_CHARACTERS
-
-#ifdef SQL_CATALOG_TERM
- result = info.GetInfo(SQL_CATALOG_TERM, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_CATALOG_TERM
-
-#ifdef SQL_TABLE_TERM
- result = info.GetInfo(SQL_TABLE_TERM, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_TABLE_TERM
-
-#ifdef SQL_SCHEMA_TERM
- result = info.GetInfo(SQL_SCHEMA_TERM, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_SCHEMA_TERM
-
-#ifdef SQL_ASYNC_DBC_FUNCTIONS
- result = info.GetInfo(SQL_ASYNC_DBC_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_ASYNC_DBC_FUNCTIONS
-
-#ifdef SQL_GETDATA_EXTENSIONS
- result = info.GetInfo(SQL_GETDATA_EXTENSIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_GETDATA_EXTENSIONS
-
-#ifdef SQL_ODBC_INTERFACE_CONFORMANCE
- result = info.GetInfo(SQL_ODBC_INTERFACE_CONFORMANCE, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_ODBC_INTERFACE_CONFORMANCE
-
-#ifdef SQL_SQL_CONFORMANCE
- result = info.GetInfo(SQL_SQL_CONFORMANCE, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_SQL_CONFORMANCE
-
-#ifdef SQL_CATALOG_USAGE
- result = info.GetInfo(SQL_CATALOG_USAGE, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_CATALOG_USAGE
-
-#ifdef SQL_SCHEMA_USAGE
- result = info.GetInfo(SQL_SCHEMA_USAGE, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_SCHEMA_USAGE
-
-#ifdef SQL_MAX_IDENTIFIER_LEN
- result = info.GetInfo(SQL_MAX_IDENTIFIER_LEN, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_MAX_IDENTIFIER_LEN
-
-#ifdef SQL_AGGREGATE_FUNCTIONS
- result = info.GetInfo(SQL_AGGREGATE_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_AGGREGATE_FUNCTIONS
-
-#ifdef SQL_AGGREGATE_FUNCTIONS
- result = info.GetInfo(SQL_NUMERIC_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_AGGREGATE_FUNCTIONS
-
-#ifdef SQL_STRING_FUNCTIONS
- result = info.GetInfo(SQL_STRING_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_STRING_FUNCTIONS
-
-#ifdef SQL_TIMEDATE_FUNCTIONS
- result = info.GetInfo(SQL_TIMEDATE_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_TIMEDATE_FUNCTIONS
-
-#ifdef SQL_TIMEDATE_ADD_INTERVALS
- result = info.GetInfo(SQL_TIMEDATE_ADD_INTERVALS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_TIMEDATE_ADD_INTERVALS
-
-#ifdef SQL_TIMEDATE_DIFF_INTERVALS
- result = info.GetInfo(SQL_TIMEDATE_DIFF_INTERVALS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_TIMEDATE_DIFF_INTERVALS
-
-#ifdef SQL_DATETIME_LITERALS
- result = info.GetInfo(SQL_DATETIME_LITERALS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_DATETIME_LITERALS
-
-#ifdef SQL_SYSTEM_FUNCTIONS
- result = info.GetInfo(SQL_SYSTEM_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_SYSTEM_FUNCTIONS
-
-#ifdef SQL_CONVERT_FUNCTIONS
- result = info.GetInfo(SQL_CONVERT_FUNCTIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_CONVERT_FUNCTIONS
-
-#ifdef SQL_OJ_CAPABILITIES
- result = info.GetInfo(SQL_OJ_CAPABILITIES, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_OJ_CAPABILITIES
-
-#ifdef SQL_POS_OPERATIONS
- result = info.GetInfo(SQL_POS_OPERATIONS, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_POS_OPERATIONS
-
-#ifdef SQL_MAX_CONCURRENT_ACTIVITIES
- result = info.GetInfo(SQL_MAX_CONCURRENT_ACTIVITIES, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_MAX_CONCURRENT_ACTIVITIES
-
-#ifdef SQL_CURSOR_COMMIT_BEHAVIOR
- result = info.GetInfo(SQL_CURSOR_COMMIT_BEHAVIOR, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_CURSOR_COMMIT_BEHAVIOR
-
-#ifdef SQL_CURSOR_ROLLBACK_BEHAVIOR
- result = info.GetInfo(SQL_CURSOR_ROLLBACK_BEHAVIOR, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_CURSOR_ROLLBACK_BEHAVIOR
-
-#ifdef SQL_TXN_CAPABLE
- result = info.GetInfo(SQL_TXN_CAPABLE, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_TXN_CAPABLE
-
-#ifdef SQL_QUOTED_IDENTIFIER_CASE
- result = info.GetInfo(SQL_QUOTED_IDENTIFIER_CASE, buffer, sizeof(buffer), &reslen);
- BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
-#endif //SQL_QUOTED_IDENTIFIER_CASE
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/cursor_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/cursor_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/cursor_test.cpp
deleted file mode 100644
index af841e7..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/cursor_test.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/impl/binary/binary_writer_impl.h>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/cursor.h"
-
-using namespace ignite::odbc;
-
-const int64_t testQueryId = 42;
-
-std::auto_ptr<ResultPage> CreateTestPage(bool last, int32_t size)
-{
- using namespace ignite::impl::binary;
- using namespace ignite::impl::interop;
-
- ignite::impl::interop::InteropUnpooledMemory mem(1024);
- InteropOutputStream outStream(&mem);
- BinaryWriterImpl writer(&outStream, 0);
-
- // Last page flag.
- writer.WriteBool(last);
-
- //Page size.
- writer.WriteInt32(size);
-
- for (int32_t i = 0; i < size; ++i)
- {
- // Writing row size = 1 column.
- writer.WriteInt32(1);
-
- // Writing column type.
- writer.WriteInt8(IGNITE_TYPE_INT);
-
- // Column value.
- writer.WriteInt32(i);
- }
-
- outStream.Synchronize();
-
- std::auto_ptr<ResultPage> res(new ResultPage());
-
- InteropInputStream inStream(&mem);
- BinaryReaderImpl reader(&inStream);
-
- res->Read(reader);
-
- BOOST_REQUIRE(res->GetSize() == size);
- BOOST_REQUIRE(res->IsLast() == last);
-
- return res;
-}
-
-void CheckCursorNeedUpdate(Cursor& cursor)
-{
- BOOST_REQUIRE(cursor.NeedDataUpdate());
-
- BOOST_REQUIRE(cursor.HasNext());
-
- BOOST_REQUIRE(!cursor.Increment());
-}
-
-void CheckCursorReady(Cursor& cursor)
-{
- BOOST_REQUIRE(!cursor.NeedDataUpdate());
-
- BOOST_REQUIRE(cursor.HasNext());
-
- BOOST_REQUIRE(cursor.GetRow());
-}
-
-void CheckCursorEnd(Cursor& cursor)
-{
- BOOST_REQUIRE(!cursor.NeedDataUpdate());
-
- BOOST_REQUIRE(!cursor.HasNext());
-
- BOOST_REQUIRE(!cursor.Increment());
-
- BOOST_REQUIRE(cursor.GetRow());
-}
-
-BOOST_AUTO_TEST_SUITE(CursorTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestCursorEmpty)
-{
- Cursor cursor(testQueryId);
-
- BOOST_REQUIRE(cursor.GetQueryId() == testQueryId);
-
- CheckCursorNeedUpdate(cursor);
-}
-
-BOOST_AUTO_TEST_CASE(TestCursorLast)
-{
- const int32_t pageSize = 16;
-
- Cursor cursor(testQueryId);
-
- std::auto_ptr<ResultPage> resultPage = CreateTestPage(true, pageSize);
-
- cursor.UpdateData(resultPage);
-
- BOOST_REQUIRE(cursor.GetQueryId() == testQueryId);
-
- CheckCursorReady(cursor);
-
- for (int32_t i = 0; i < pageSize - 1; ++i)
- BOOST_REQUIRE(cursor.Increment());
-
- CheckCursorEnd(cursor);
-}
-
-BOOST_AUTO_TEST_CASE(TestCursorUpdate)
-{
- const int32_t pageSize = 16;
-
- Cursor cursor(testQueryId);
-
- std::auto_ptr<ResultPage> resultPage = CreateTestPage(false, pageSize);
-
- cursor.UpdateData(resultPage);
-
- BOOST_REQUIRE(cursor.GetQueryId() == testQueryId);
-
- CheckCursorReady(cursor);
-
- for (int32_t i = 0; i < pageSize - 1; ++i)
- BOOST_REQUIRE(cursor.Increment());
-
- CheckCursorNeedUpdate(cursor);
-
- resultPage = CreateTestPage(true, pageSize);
-
- cursor.UpdateData(resultPage);
-
- CheckCursorReady(cursor);
-
- for (int32_t i = 0; i < pageSize - 1; ++i)
- BOOST_REQUIRE(cursor.Increment());
-
- CheckCursorEnd(cursor);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/parser_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/parser_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/parser_test.cpp
deleted file mode 100644
index ad8a5b4..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/parser_test.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/odbc/parser.h>
-
-using namespace ignite::odbc;
-
-struct TestMessage
-{
- TestMessage()
- {
- // No-op.
- }
-
- TestMessage(int32_t a, const std::string& b) : a(a), b(b)
- {
- // No-op.
- }
-
- ~TestMessage()
- {
- // No-op.
- }
-
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- writer.WriteInt32(a);
- writer.WriteString(b.data(), static_cast<int32_t>(b.size()));
- }
-
- void Read(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- a = reader.ReadInt32();
-
- b.resize(reader.ReadString(0, 0));
- reader.ReadString(&b[0], static_cast<int32_t>(b.size()));
- }
-
- int32_t a;
- std::string b;
-};
-
-bool operator==(const TestMessage& lhs, const TestMessage& rhs)
-{
- return lhs.a == rhs.a &&
- lhs.b == rhs.b;
-}
-
-BOOST_AUTO_TEST_SUITE(ParserTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestParserEncodeDecode)
-{
- Parser parser;
-
- std::vector<int8_t> outBuffer;
- std::vector<int8_t> inBuffer;
-
- TestMessage outMsg(42, "Test message");
- TestMessage inMsg;
-
- parser.Encode(outMsg, outBuffer);
-
- inBuffer.reserve(outBuffer.size());
-
- // First 4 bytes contain message size after encoding but are not expected
- // during decoding.
- std::copy(outBuffer.begin() + 4, outBuffer.end(), std::back_inserter(inBuffer));
-
- parser.Decode(inMsg, inBuffer);
-
- BOOST_REQUIRE(outMsg == inMsg);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/row_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/row_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/row_test.cpp
deleted file mode 100644
index e655cf7..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/row_test.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/impl/binary/binary_writer_impl.h>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/row.h"
-
-using namespace ignite::odbc::app;
-using namespace ignite::odbc;
-
-
-std::string GetStrColumnValue(size_t rowIdx)
-{
- std::stringstream generator("Column 2 test string, row num: ");
- generator << rowIdx << ". Some trailing bytes";
-
- return generator.str();
-}
-
-void FillMemWithData(ignite::impl::interop::InteropUnpooledMemory& mem, size_t rowNum)
-{
- using namespace ignite::impl::binary;
- using namespace ignite::impl::interop;
-
- InteropOutputStream stream(&mem);
- BinaryWriterImpl writer(&stream, 0);
-
- for (size_t i = 0; i < rowNum; ++i)
- {
- // Number of columns in page.
- writer.WriteInt32(4);
-
- // First column is int.
- writer.WriteInt8(IGNITE_TYPE_LONG);
- writer.WriteInt64(static_cast<int64_t>(i * 10));
-
- // Second column is string.
- const std::string& str(GetStrColumnValue(i));
-
- writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
-
- // Third column is GUID.
- ignite::Guid guid(0x2b218f63642a4a64ULL, 0x9674098f388ac298ULL + i);
-
- writer.WriteGuid(guid);
-
- // The last column is bool.
- writer.WriteInt8(IGNITE_TYPE_BOOL);
- writer.WriteBool(i % 2 == 1);
- }
-
- stream.Synchronize();
-}
-
-void CheckRowData(Row& row, size_t rowIdx)
-{
- SqlLen reslen;
-
- long longBuf;
- char strBuf[1024];
- SQLGUID guidBuf;
- char bitBuf;
- size_t* offset = 0;
-
- ApplicationDataBuffer appLongBuf(type_traits::IGNITE_ODBC_C_TYPE_SIGNED_LONG, &longBuf, sizeof(longBuf), &reslen, &offset);
- ApplicationDataBuffer appStrBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset);
- ApplicationDataBuffer appGuidBuf(type_traits::IGNITE_ODBC_C_TYPE_GUID, &guidBuf, sizeof(guidBuf), &reslen, &offset);
- ApplicationDataBuffer appBitBuf(type_traits::IGNITE_ODBC_C_TYPE_BIT, &bitBuf, sizeof(bitBuf), &reslen, &offset);
-
- // Checking size.
- BOOST_REQUIRE(row.GetSize() == 4);
-
- // Checking 1st column.
- BOOST_REQUIRE(row.ReadColumnToBuffer(1, appLongBuf) == SQL_RESULT_SUCCESS);
- BOOST_REQUIRE(longBuf == rowIdx * 10);
-
- // Checking 2nd column.
- BOOST_REQUIRE(row.ReadColumnToBuffer(2, appStrBuf) == SQL_RESULT_SUCCESS);
-
- std::string strReal(strBuf, static_cast<size_t>(reslen));
- std::string strExpected(GetStrColumnValue(rowIdx));
-
- BOOST_REQUIRE(strReal == strExpected);
-
- // Checking 3rd column.
- BOOST_REQUIRE(row.ReadColumnToBuffer(3, appGuidBuf) == SQL_RESULT_SUCCESS);
-
- BOOST_REQUIRE(guidBuf.Data1 == 0x2b218f63UL);
- BOOST_REQUIRE(guidBuf.Data2 == 0x642aU);
- BOOST_REQUIRE(guidBuf.Data3 == 0x4a64U);
-
- BOOST_REQUIRE(guidBuf.Data4[0] == 0x96);
- BOOST_REQUIRE(guidBuf.Data4[1] == 0x74);
- BOOST_REQUIRE(guidBuf.Data4[2] == 0x09);
- BOOST_REQUIRE(guidBuf.Data4[3] == 0x8f);
- BOOST_REQUIRE(guidBuf.Data4[4] == 0x38);
- BOOST_REQUIRE(guidBuf.Data4[5] == 0x8a);
- BOOST_REQUIRE(guidBuf.Data4[6] == 0xc2);
- BOOST_REQUIRE(guidBuf.Data4[7] == 0x98 + rowIdx);
-
- // Checking 4th column.
- BOOST_REQUIRE(row.ReadColumnToBuffer(4, appBitBuf) == SQL_RESULT_SUCCESS);
- BOOST_REQUIRE(bitBuf == rowIdx % 2);
-}
-
-
-BOOST_AUTO_TEST_SUITE(RowTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestRowMoveToNext)
-{
- ignite::impl::interop::InteropUnpooledMemory mem(4096);
-
- const size_t rowNum = 32;
-
- FillMemWithData(mem, rowNum);
-
- Row row(mem);
-
- for (size_t i = 0; i < rowNum - 1; ++i)
- {
- BOOST_REQUIRE(row.GetSize() == 4);
- BOOST_REQUIRE(row.MoveToNext());
- }
-}
-
-BOOST_AUTO_TEST_CASE(TestRowRead)
-{
- ignite::impl::interop::InteropUnpooledMemory mem(4096);
-
- const size_t rowNum = 8;
-
- FillMemWithData(mem, rowNum);
-
- Row row(mem);
-
- BOOST_REQUIRE(row.GetSize() == 4);
-
- for (size_t i = 0; i < rowNum - 1; ++i)
- {
- CheckRowData(row, i);
-
- BOOST_REQUIRE(row.MoveToNext());
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/teamcity_boost.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/teamcity_boost.cpp b/modules/platforms/cpp/odbc/odbc-test/src/teamcity_boost.cpp
deleted file mode 100644
index 45c666d..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/teamcity_boost.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright 2011 JetBrains s.r.o.
- *
- * Licensed 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.
- *
- * $Revision: 88625 $
-*/
-
-#define BOOST_TEST_MODULE IgniteCoreTest
-
-#include <sstream>
-
-#include <boost/test/unit_test_suite_impl.hpp>
-#include <boost/test/results_collector.hpp>
-#include <boost/test/utils/basic_cstring/io.hpp>
-#include <boost/test/unit_test_log.hpp>
-#include <boost/test/included/unit_test.hpp>
-
-#include "teamcity_messages.h"
-
-using namespace boost::unit_test;
-using namespace std;
-
-namespace JetBrains {
-
-// Custom formatter for TeamCity messages
-class TeamcityBoostLogFormatter: public boost::unit_test::unit_test_log_formatter {
- TeamcityMessages messages;
- std::string currentDetails;
- std::string flowId;
-
-public:
- TeamcityBoostLogFormatter(const std::string &_flowId);
- TeamcityBoostLogFormatter();
-
- void log_start(std::ostream&, boost::unit_test::counter_t test_cases_amount);
- void log_finish(std::ostream&);
- void log_build_info(std::ostream&);
-
- void test_unit_start(std::ostream&, boost::unit_test::test_unit const& tu);
- void test_unit_finish(std::ostream&,
- boost::unit_test::test_unit const& tu,
- unsigned long elapsed);
- void test_unit_skipped(std::ostream&, boost::unit_test::test_unit const& tu);
-
- void log_exception(std::ostream&,
- boost::unit_test::log_checkpoint_data const&,
- boost::unit_test::const_string explanation);
-
- void log_entry_start(std::ostream&,
- boost::unit_test::log_entry_data const&,
- log_entry_types let);
- void log_entry_value(std::ostream&, boost::unit_test::const_string value);
- void log_entry_finish(std::ostream&);
-};
-
-// Fake fixture to register formatter
-struct TeamcityFormatterRegistrar {
- TeamcityFormatterRegistrar() {
- if (JetBrains::underTeamcity()) {
- boost::unit_test::unit_test_log.set_formatter(new JetBrains::TeamcityBoostLogFormatter());
- boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_successful_tests);
- }
- }
-};
-BOOST_GLOBAL_FIXTURE(TeamcityFormatterRegistrar);
-
-// Formatter implementation
-string toString(const_string bstr) {
- stringstream ss;
-
- ss << bstr;
-
- return ss.str();
-}
-
-TeamcityBoostLogFormatter::TeamcityBoostLogFormatter(const std::string &_flowId)
-: flowId(_flowId)
-{}
-
-TeamcityBoostLogFormatter::TeamcityBoostLogFormatter()
-: flowId(getFlowIdFromEnvironment())
-{}
-
-void TeamcityBoostLogFormatter::log_start(ostream &out, counter_t test_cases_amount)
-{}
-
-void TeamcityBoostLogFormatter::log_finish(ostream &out)
-{}
-
-void TeamcityBoostLogFormatter::log_build_info(ostream &out)
-{}
-
-void TeamcityBoostLogFormatter::test_unit_start(ostream &out, test_unit const& tu) {
- messages.setOutput(out);
-
- if (tu.p_type == tut_case) {
- messages.testStarted(tu.p_name, flowId);
- } else {
- messages.suiteStarted(tu.p_name, flowId);
- }
-
- currentDetails.clear();
-}
-
-void TeamcityBoostLogFormatter::test_unit_finish(ostream &out, test_unit const& tu, unsigned long elapsed) {
- messages.setOutput(out);
-
- test_results const& tr = results_collector.results(tu.p_id);
- if (tu.p_type == tut_case) {
- if(!tr.passed()) {
- if(tr.p_skipped) {
- messages.testIgnored(tu.p_name, "ignored", flowId);
- } else if (tr.p_aborted) {
- messages.testFailed(tu.p_name, "aborted", currentDetails, flowId);
- } else {
- messages.testFailed(tu.p_name, "failed", currentDetails, flowId);
- }
- }
-
- messages.testFinished(tu.p_name, elapsed / 1000, flowId);
- } else {
- messages.suiteFinished(tu.p_name, flowId);
- }
-}
-
-void TeamcityBoostLogFormatter::test_unit_skipped(ostream &out, test_unit const& tu)
-{}
-
-void TeamcityBoostLogFormatter::log_exception(ostream &out, log_checkpoint_data const&, const_string explanation) {
- string what = toString(explanation);
-
- out << what << endl;
- currentDetails += what + "\n";
-}
-
-void TeamcityBoostLogFormatter::log_entry_start(ostream&, log_entry_data const&, log_entry_types let)
-{}
-
-void TeamcityBoostLogFormatter::log_entry_value(ostream &out, const_string value) {
- out << value;
- currentDetails += toString(value);
-}
-
-void TeamcityBoostLogFormatter::log_entry_finish(ostream &out) {
- out << endl;
- currentDetails += "\n";
-}
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/teamcity_messages.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/teamcity_messages.cpp b/modules/platforms/cpp/odbc/odbc-test/src/teamcity_messages.cpp
deleted file mode 100644
index 087409e..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/teamcity_messages.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Copyright 2011 JetBrains s.r.o.
- *
- * Licensed 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.
- *
- * $Revision: 88625 $
-*/
-
-#include <stdlib.h>
-#include <sstream>
-
-#include "teamcity_messages.h"
-
-using namespace std;
-
-namespace JetBrains {
-
-std::string getFlowIdFromEnvironment() {
- const char *flowId = getenv("TEAMCITY_PROCESS_FLOW_ID");
- return flowId == NULL ? "" : flowId;
-}
-
-bool underTeamcity() {
- return getenv("TEAMCITY_PROJECT_NAME") != NULL;
-}
-
-TeamcityMessages::TeamcityMessages()
-: m_out(&cout)
-{}
-
-void TeamcityMessages::setOutput(ostream &out) {
- m_out = &out;
-}
-
-string TeamcityMessages::escape(string s) {
- string result;
-
- for (size_t i = 0; i < s.length(); i++) {
- char c = s[i];
-
- switch (c) {
- case '\n': result.append("|n"); break;
- case '\r': result.append("|r"); break;
- case '\'': result.append("|'"); break;
- case '|': result.append("||"); break;
- case ']': result.append("|]"); break;
- default: result.append(&c, 1);
- }
- }
-
- return result;
-}
-
-void TeamcityMessages::openMsg(const string &name) {
- // endl for http://jetbrains.net/tracker/issue/TW-4412
- *m_out << endl << "##teamcity[" << name;
-}
-
-void TeamcityMessages::closeMsg() {
- *m_out << "]";
- // endl for http://jetbrains.net/tracker/issue/TW-4412
- *m_out << endl;
- m_out->flush();
-}
-
-void TeamcityMessages::writeProperty(string name, string value) {
- *m_out << " " << name << "='" << escape(value) << "'";
-}
-
-void TeamcityMessages::suiteStarted(string name, string flowid) {
- openMsg("testSuiteStarted");
- writeProperty("name", name);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::suiteFinished(string name, string flowid) {
- openMsg("testSuiteFinished");
- writeProperty("name", name);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testStarted(string name, string flowid) {
- openMsg("testStarted");
- writeProperty("name", name);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testFinished(string name, int durationMs, string flowid) {
- openMsg("testFinished");
-
- writeProperty("name", name);
-
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- if(durationMs >= 0) {
- stringstream out;
- out << durationMs;
- writeProperty("duration", out.str());
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testFailed(string name, string message, string details, string flowid) {
- openMsg("testFailed");
- writeProperty("name", name);
- writeProperty("message", message);
- writeProperty("details", details);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testIgnored(std::string name, std::string message, string flowid) {
- openMsg("testIgnored");
- writeProperty("name", name);
- writeProperty("message", message);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-}
[08/28] ignite git commit: IGNITE-2446: Added host property for
OdbcConfiguration.
Posted by vo...@apache.org.
IGNITE-2446: Added host property for OdbcConfiguration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ebc6b571
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ebc6b571
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ebc6b571
Branch: refs/heads/ignite-1786
Commit: ebc6b57161ca381eeb0ed2dd97c82b5ec09c0590
Parents: e200771
Author: isapego <is...@gridgain.com>
Authored: Tue Jan 26 12:34:11 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Jan 26 12:34:11 2016 +0300
----------------------------------------------------------------------
.../ignite/configuration/OdbcConfiguration.java | 29 ++++++++++++++++++++
.../internal/processors/odbc/OdbcTcpServer.java | 6 ++--
2 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebc6b571/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
index fbc064b..74fe29f 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
@@ -41,6 +41,9 @@ public class OdbcConfiguration {
/** TCP port. */
private int port = DFLT_TCP_PORT;
+ /** TCP host. */
+ private String host;
+
/** TCP no delay flag. */
private boolean noDelay = DFLT_TCP_NODELAY;
@@ -82,6 +85,7 @@ public class OdbcConfiguration {
idleTimeout = cfg.getIdleTimeout();
noDelay = cfg.isNoDelay();
port = cfg.getPort();
+ host = cfg.getHost();
rcvBufSize = cfg.getReceiveBufferSize();
selectorCnt = cfg.getSelectorCount();
sndBufSize = cfg.getSendBufferSize();
@@ -109,6 +113,31 @@ public class OdbcConfiguration {
}
/**
+ * Gets host for TCP ODBC server. This can be either an
+ * IP address or a domain name.
+ * <p>
+ * If not defined, system-wide local address will be used
+ * (see {@link IgniteConfiguration#getLocalHost()}.
+ * <p>
+ * You can also use {@code 0.0.0.0} value to bind to all
+ * locally-available IP addresses.
+ *
+ * @return TCP host.
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * Sets host for TCP ODBC server.
+ *
+ * @param host TCP host.
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ /**
* Gets flag indicating whether {@code TCP_NODELAY} option should be set for accepted client connections.
* Setting this option reduces network latency and should be set to {@code true} in majority of cases.
* For more information, see {@link Socket#setTcpNoDelay(boolean)}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ebc6b571/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
index 648be56..88e4bdb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
@@ -111,10 +111,10 @@ public class OdbcTcpServer {
private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException {
String host = null;
- ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration();
+ OdbcConfiguration odbcCfg = cfg.getOdbcConfiguration();
- if (connectionCfg != null)
- host = connectionCfg.getHost();
+ if (odbcCfg != null)
+ host = odbcCfg.getHost();
if (host == null)
host = cfg.getLocalHost();
[21/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/primary_key_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/primary_key_meta.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/primary_key_meta.h
deleted file mode 100644
index e479e10..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/primary_key_meta.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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_PRIMARY_KEY_META
-#define _IGNITE_ODBC_PRIMARY_KEY_META
-
-#include <stdint.h>
-#include <string>
-
-#include "ignite/impl/binary/binary_reader_impl.h"
-
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace meta
- {
- /**
- * Primary key metadata.
- */
- class PrimaryKeyMeta
- {
- public:
- /**
- * Default constructor.
- */
- PrimaryKeyMeta()
- {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @param column Column name.
- * @param keySeq Column sequence number in key (starting with 1).
- * @param keyName Key name.
- */
- PrimaryKeyMeta(const std::string& catalog, const std::string& schema,
- const std::string& table, const std::string& column, int16_t keySeq,
- const std::string& keyName) :
- catalog(catalog),
- schema(schema),
- table(table),
- column(column),
- keySeq(keySeq),
- keyName(keyName)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~PrimaryKeyMeta()
- {
- // No-op.
- }
-
- /**
- * Copy constructor.
- */
- PrimaryKeyMeta(const PrimaryKeyMeta& other) :
- catalog(other.catalog),
- schema(other.schema),
- table(other.table),
- column(other.column),
- keySeq(other.keySeq),
- keyName(other.keyName)
- {
- // No-op.
- }
-
- /**
- * Copy operator.
- */
- PrimaryKeyMeta& operator=(const PrimaryKeyMeta& other)
- {
- catalog = other.catalog;
- schema = other.schema;
- table = other.table;
- column = other.column;
- keySeq = other.keySeq;
- keyName = other.keyName;
-
- return *this;
- }
-
- /**
- * Get catalog name.
- * @return Catalog name.
- */
- const std::string& GetCatalogName() const
- {
- return catalog;
- }
-
- /**
- * Get schema name.
- * @return Schema name.
- */
- const std::string& GetSchemaName() const
- {
- return schema;
- }
-
- /**
- * Get table name.
- * @return Table name.
- */
- const std::string& GetTableName() const
- {
- return table;
- }
-
- /**
- * Get column name.
- * @return Column name.
- */
- const std::string& GetColumnName() const
- {
- return table;
- }
-
- /**
- * Get column sequence number in key.
- * @return Sequence number in key.
- */
- int16_t GetKeySeq() const
- {
- return keySeq;
- }
-
- /**
- * Get key name.
- * @return Key name.
- */
- const std::string& GetKeyName() const
- {
- return keyName;
- }
-
- private:
- /** Catalog name. */
- std::string catalog;
-
- /** Schema name. */
- std::string schema;
-
- /** Table name. */
- std::string table;
-
- /** Collumn name. */
- std::string column;
-
- /** Column sequence number in key. */
- int16_t keySeq;
-
- /** Key name. */
- std::string keyName;
- };
-
- /** Table metadata vector alias. */
- typedef std::vector<PrimaryKeyMeta> PrimaryKeyMetaVector;
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/table_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/table_meta.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/table_meta.h
deleted file mode 100644
index 0618217..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/table_meta.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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_TABLE_META
-#define _IGNITE_ODBC_TABLE_META
-
-#include <stdint.h>
-#include <string>
-
-#include "ignite/impl/binary/binary_reader_impl.h"
-
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace meta
- {
- /**
- * Table metadata.
- */
- class TableMeta
- {
- public:
- /**
- * Default constructor.
- */
- TableMeta()
- {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param catalogName Catalog name.
- * @param schemaName Schema name.
- * @param tableName Table name.
- * @param tableType Table type.
- */
- TableMeta(const std::string& catalogName, const std::string& schemaName,
- const std::string& tableName, const std::string& tableType) :
- catalogName(catalogName), schemaName(schemaName), tableName(tableName),
- tableType(tableType)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~TableMeta()
- {
- // No-op.
- }
-
- /**
- * Copy constructor.
- */
- TableMeta(const TableMeta& other) :
- catalogName(other.catalogName),
- schemaName(other.schemaName),
- tableName(other.tableName),
- tableType(other.tableType)
- {
- // No-op.
- }
-
- /**
- * Copy operator.
- */
- TableMeta& operator=(const TableMeta& other)
- {
- catalogName = other.catalogName;
- schemaName = other.schemaName;
- tableName = other.tableName;
- tableType = other.tableType;
-
- return *this;
- }
-
- /**
- * Read using reader.
- * @param reader Reader.
- */
- void Read(ignite::impl::binary::BinaryReaderImpl& reader);
-
- /**
- * Get catalog name.
- * @return Catalog name.
- */
- const std::string& GetCatalogName() const
- {
- return catalogName;
- }
-
- /**
- * Get schema name.
- * @return Schema name.
- */
- const std::string& GetSchemaName() const
- {
- return schemaName;
- }
-
- /**
- * Get table name.
- * @return Table name.
- */
- const std::string& GetTableName() const
- {
- return tableName;
- }
-
- /**
- * Get table type.
- * @return Table type.
- */
- const std::string& GetTableType() const
- {
- return tableType;
- }
-
- private:
- /** Catalog name. */
- std::string catalogName;
-
- /** Schema name. */
- std::string schemaName;
-
- /** Table name. */
- std::string tableName;
-
- /** Table type. */
- std::string tableType;
- };
-
- /** Table metadata vector alias. */
- typedef std::vector<TableMeta> TableMetaVector;
-
- /**
- * Read tables metadata collection.
- * @param reader Reader.
- * @param meta Collection.
- */
- void ReadTableMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, TableMetaVector& meta);
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/parser.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/parser.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/parser.h
deleted file mode 100644
index 8b8f277..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/parser.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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_PARSER
-#define _IGNITE_ODBC_DRIVER_PARSER
-
-#include <stdint.h>
-
-#include <vector>
-
-#include <ignite/impl/interop/interop_output_stream.h>
-#include <ignite/impl/interop/interop_input_stream.h>
-#include <ignite/impl/binary/binary_writer_impl.h>
-#include <ignite/impl/binary/binary_reader_impl.h>
-
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /**
- * Message parser.
- */
- class Parser
- {
- public:
- /** Default initial size of operational memory. */
- enum { DEFAULT_MEM_ALLOCATION = 4096 };
-
- /**
- * Constructor.
- */
- Parser(int32_t cap = DEFAULT_MEM_ALLOCATION) : inMem(cap), outMem(cap), outStream(&outMem)
- {
- //No-op.
- }
-
- /**
- * Destructor.
- */
- ~Parser()
- {
- //No-op.
- }
-
- /**
- * Encode message and place encoded data in buffer.
- *
- * @param msg Message to encode.
- * @param buf Data buffer.
- */
- template<typename MsgT>
- void Encode(const MsgT& msg, std::vector<int8_t>& buf)
- {
- using namespace ignite::impl::binary;
-
- ResetState();
-
- BinaryWriterImpl writer(&outStream, 0);
-
- int32_t msgLenPos = outStream.Reserve(4);
-
- msg.Write(writer);
-
- outStream.WriteInt32(msgLenPos, outStream.Position() - 4);
-
- buf.resize(outStream.Position());
-
- memcpy(&buf[0], outMem.Data(), outStream.Position());
- }
-
- /**
- * Decode message from data in buffer.
- *
- * @param msg Message to decode.
- * @param buf Data buffer.
- * @note Can be optimized after InteropMemory refactoring.
- */
- template<typename MsgT>
- void Decode(MsgT& msg, const std::vector<int8_t>& buf)
- {
- using namespace ignite::impl::binary;
-
- //for (size_t i = 0; i < buf.size(); ++i)
- // LOG_MSG("Data[%0.4d] : %0.3d, %c\n", i, (int)buf[i], buf[i] > 64 && buf[i] < 128 ? buf[i] : '.');
-
- if (inMem.Capacity() < static_cast<int32_t>(buf.size()))
- inMem.Reallocate(static_cast<int32_t>(buf.size()));
-
- memcpy(inMem.Data(), buf.data(), buf.size());
-
- inMem.Length(static_cast<int32_t>(buf.size()));
-
- ignite::impl::interop::InteropInputStream inStream(&inMem);
-
- BinaryReaderImpl reader(&inStream);
-
- msg.Read(reader);
- }
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Parser);
-
- /**
- * Reset internal state of the parser.
- */
- void ResetState()
- {
- outMem.Length(0);
-
- outStream.Position(0);
- }
-
- /** Input operational memory. */
- ignite::impl::interop::InteropUnpooledMemory inMem;
-
- /** Output operational memory. */
- ignite::impl::interop::InteropUnpooledMemory outMem;
-
- /** Output stream. */
- ignite::impl::interop::InteropOutputStream outStream;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/column_metadata_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/column_metadata_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/column_metadata_query.h
deleted file mode 100644
index 378e95c..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/column_metadata_query.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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_COLUMN_METADATA_QUERY
-#define _IGNITE_ODBC_DRIVER_COLUMN_METADATA_QUERY
-
-#include "ignite/odbc/query/query.h"
-#include "ignite/odbc/meta/column_meta.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /** Connection forward-declaration. */
- class Connection;
-
- namespace query
- {
- /**
- * Query.
- */
- class ColumnMetadataQuery : public Query
- {
- public:
- /**
- * Constructor.
- *
- * @param diag Diagnostics collector.
- * @param connection Associated connection.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param column Column search pattern.
- */
- ColumnMetadataQuery(diagnostic::Diagnosable& diag,
- Connection& connection, const std::string& schema,
- const std::string& table, const std::string& column);
-
- /**
- * Destructor.
- */
- virtual ~ColumnMetadataQuery();
-
- /**
- * 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);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * 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(ColumnMetadataQuery);
-
- /**
- * Make get columns metadata requets and use response to set internal state.
- *
- * @return Operation result.
- */
- SqlResult MakeRequestGetColumnsMeta();
-
- /** Connection associated with the statement. */
- Connection& connection;
-
- /** Schema search pattern. */
- std::string schema;
-
- /** Table search pattern. */
- std::string table;
-
- /** Column search pattern. */
- std::string column;
-
- /** Query executed. */
- bool executed;
-
- /** Fetched metadata. */
- meta::ColumnMetaVector meta;
-
- /** Metadata cursor. */
- meta::ColumnMetaVector::iterator cursor;
-
- /** Columns metadata. */
- meta::ColumnMetaVector columnsMeta;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/data_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/data_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/data_query.h
deleted file mode 100644
index 88550d0..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/data_query.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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_DATA_QUERY
-#define _IGNITE_ODBC_DRIVER_DATA_QUERY
-
-#include "ignite/odbc/query/query.h"
-#include "ignite/odbc/app/parameter.h"
-#include "ignite/odbc/cursor.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /** Connection forward-declaration. */
- class Connection;
-
- namespace query
- {
- /**
- * Query.
- */
- class DataQuery : public Query
- {
- public:
- /**
- * Constructor.
- *
- * @param diag Diagnostics collector.
- * @param connection Associated connection.
- * @param sql SQL query string.
- * @param params SQL params.
- */
- DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
- const std::string& sql, const app::ParameterBindingMap& params);
-
- /**
- * Destructor.
- */
- virtual ~DataQuery();
-
- /**
- * 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.
- *
- * @param columnBindings Application buffers to put data to.
- * @return Operation result.
- */
- virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * 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(DataQuery);
-
- /**
- * Make query execute request and use response to set internal
- * state.
- *
- * @return True on success.
- */
- SqlResult MakeRequestExecute();
-
- /**
- * Make query close request.
- *
- * @return True on success.
- */
- SqlResult MakeRequestClose();
-
- /**
- * Make data fetch request and use response to set internal state.
- *
- * @return True on success.
- */
- SqlResult MakeRequestFetch();
-
- /** Connection associated with the statement. */
- Connection& connection;
-
- /** SQL Query. */
- std::string sql;
-
- /** Parameter bindings. */
- const app::ParameterBindingMap& params;
-
- /** Columns metadata. */
- meta::ColumnMetaVector resultMeta;
-
- /** Cursor. */
- std::auto_ptr<Cursor> cursor;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/foreign_keys_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/foreign_keys_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/foreign_keys_query.h
deleted file mode 100644
index abd13bc..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/foreign_keys_query.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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_FOREIGN_KEYS_QUERY
-#define _IGNITE_ODBC_DRIVER_FOREIGN_KEYS_QUERY
-
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/query/query.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- /**
- * Foreign keys query.
- */
- class ForeignKeysQuery : public Query
- {
- public:
- /**
- * Constructor.
- *
- * @param diag Diagnostics collector.
- * @param connection Statement-associated connection.
- * @param primaryCatalog Primary key catalog name.
- * @param primarySchema Primary key schema name.
- * @param primaryTable Primary key table name.
- * @param foreignCatalog Foreign key catalog name.
- * @param foreignSchema Foreign key schema name.
- * @param foreignTable Foreign key table name.
- */
- ForeignKeysQuery(diagnostic::Diagnosable& diag, Connection& connection,
- const std::string& primaryCatalog, const std::string& primarySchema,
- const std::string& primaryTable, const std::string& foreignCatalog,
- const std::string& foreignSchema, const std::string& foreignTable);
-
- /**
- * Destructor.
- */
- virtual ~ForeignKeysQuery();
-
- /**
- * 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);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * 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(ForeignKeysQuery);
-
- /** Connection associated with the statement. */
- Connection& connection;
-
- /** Primary key catalog name. */
- std::string primaryCatalog;
-
- /** Primary key schema name. */
- std::string primarySchema;
-
- /** Primary key table name. */
- std::string primaryTable;
-
- /** Foreign key catalog name. */
- std::string foreignCatalog;
-
- /** Foreign key schema name. */
- std::string foreignSchema;
-
- /** Foreign key table name. */
- std::string foreignTable;
-
- /** Query executed. */
- bool executed;
-
- /** Columns metadata. */
- meta::ColumnMetaVector columnsMeta;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/primary_keys_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/primary_keys_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/primary_keys_query.h
deleted file mode 100644
index 22e1359..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/primary_keys_query.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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_PRIMARY_KEYS_QUERY
-#define _IGNITE_ODBC_DRIVER_PRIMARY_KEYS_QUERY
-
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/query/query.h"
-#include "ignite/odbc/meta/primary_key_meta.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- /**
- * Primary keys query.
- */
- class PrimaryKeysQuery : public Query
- {
- public:
- /**
- * Constructor.
- *
- * @param diag Diagnostics collector.
- * @param connection Statement-associated connection.
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- */
- PrimaryKeysQuery(diagnostic::Diagnosable& diag,
- Connection& connection, const std::string& catalog,
- const std::string& schema, const std::string& table);
-
- /**
- * Destructor.
- */
- virtual ~PrimaryKeysQuery();
-
- /**
- * 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);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * 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(PrimaryKeysQuery);
-
- /** Connection associated with the statement. */
- Connection& connection;
-
- /** Catalog name. */
- std::string catalog;
-
- /** Schema name. */
- std::string schema;
-
- /** Table name. */
- std::string table;
-
- /** Query executed. */
- bool executed;
-
- /** Columns metadata. */
- meta::ColumnMetaVector columnsMeta;
-
- /** Primary keys metadata. */
- meta::PrimaryKeyMetaVector meta;
-
- /** Resultset cursor. */
- meta::PrimaryKeyMetaVector::iterator cursor;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/query.h
deleted file mode 100644
index 93da5c9..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/query.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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_QUERY
-#define _IGNITE_ODBC_DRIVER_QUERY
-
-#include <stdint.h>
-
-#include <map>
-
-#include "ignite/odbc/diagnostic/diagnosable.h"
-#include "ignite/odbc/meta/column_meta.h"
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/row.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- /**
- * Query.
- */
- class Query
- {
- public:
- /**
- * Destructor.
- */
- virtual ~Query()
- {
- // No-op.
- }
-
- /**
- * Execute query.
- *
- * @return True on success.
- */
- virtual SqlResult Execute() = 0;
-
- /**
- * Fetch next result row to application buffers.
- *
- * @param columnBindings Application buffers to put data to.
- * @return Operation result.
- */
- virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings) = 0;
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) = 0;
-
- /**
- * Close query.
- *
- * @return True on success.
- */
- virtual SqlResult Close() = 0;
-
- /**
- * Get column metadata.
- *
- * @return Column metadata.
- */
- virtual const meta::ColumnMetaVector& GetMeta() const = 0;
-
- /**
- * Check if data is available.
- *
- * @return True if data is available.
- */
- virtual bool DataAvailable() const = 0;
-
- /**
- * Get number of rows affected by the statement.
- *
- * @return Number of rows affected by the statement.
- */
- virtual int64_t AffectedRows() const = 0;
-
- protected:
- /**
- * Constructor.
- */
- Query(diagnostic::Diagnosable& diag) :
- diag(diag)
- {
- // No-op.
- }
-
- /** Diagnostics collector. */
- diagnostic::Diagnosable& diag;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h
deleted file mode 100644
index f5affad..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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_SPECIAL_COLUMNS_QUERY
-#define _IGNITE_ODBC_DRIVER_SPECIAL_COLUMNS_QUERY
-
-#include "ignite/odbc/query/query.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- /**
- * Special columns query.
- */
- class SpecialColumnsQuery : public Query
- {
- public:
-
- /**
- * Constructor.
- *
- * @param diag Diagnostics collector.
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @param scope Minimum required scope of the rowid.
- * @param nullable Determines whether to return special columns
- * that can have a NULL value.
- */
- SpecialColumnsQuery(diagnostic::Diagnosable& diag, int16_t type,
- const std::string& catalog, const std::string& schema,
- const std::string& table, int16_t scope, int16_t nullable);
-
- /**
- * Destructor.
- */
- virtual ~SpecialColumnsQuery();
-
- /**
- * Execute query.
- *
- * @return True on success.
- */
- virtual SqlResult Execute();
-
- /**
- * Fetch next result row to application buffers.
- *
- * @param columnBindings Application buffers to put data to.
- * @return Operation result.
- */
- virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * Close query.
- *
- * @return True on success.
- */
- virtual SqlResult Close();
-
- /**
- * Get column metadata.
- *
- * @return Column metadata.
- */
- virtual const meta::ColumnMetaVector& GetMeta() const;
-
- /**
- * 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(SpecialColumnsQuery);
-
- /** Query type. */
- int16_t type;
-
- /** Catalog name. */
- std::string catalog;
-
- /** Schema name. */
- std::string schema;
-
- /** Table name. */
- std::string table;
-
- /** Minimum required scope of the rowid. */
- int16_t scope;
-
- /**
- * Determines whether to return special columns that can have
- * a NULL value.
- */
- int16_t nullable;
-
- /** Query executed. */
- bool executed;
-
- /** Columns metadata. */
- meta::ColumnMetaVector columnsMeta;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/table_metadata_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/table_metadata_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/table_metadata_query.h
deleted file mode 100644
index 1b05377..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/table_metadata_query.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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_TABLE_METADATA_QUERY
-#define _IGNITE_ODBC_DRIVER_TABLE_METADATA_QUERY
-
-#include "ignite/odbc/query/query.h"
-#include "ignite/odbc/meta/table_meta.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /** Connection forward-declaration. */
- class Connection;
-
- namespace query
- {
- /**
- * Query.
- */
- class TableMetadataQuery : public Query
- {
- public:
- /**
- * Constructor.
- *
- * @param diag Diagnostics collector.
- * @param connection Associated connection.
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableType Table type search pattern.
- */
- TableMetadataQuery(diagnostic::Diagnosable& diag, Connection& connection,
- const std::string& catalog, const std::string& schema,
- const std::string& table, const std::string& tableType);
-
- /**
- * Destructor.
- */
- virtual ~TableMetadataQuery();
-
- /**
- * 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);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * 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(TableMetadataQuery);
-
- /**
- * Make get columns metadata requets and use response to set internal state.
- *
- * @return True on success.
- */
- SqlResult MakeRequestGetTablesMeta();
-
- /** Connection associated with the statement. */
- Connection& connection;
-
- /** Catalog search pattern. */
- std::string catalog;
-
- /** Schema search pattern. */
- std::string schema;
-
- /** Table search pattern. */
- std::string table;
-
- /** Table type search pattern. */
- std::string tableType;
-
- /** Query executed. */
- bool executed;
-
- /** Fetched metadata. */
- meta::TableMetaVector meta;
-
- /** Metadata cursor. */
- meta::TableMetaVector::iterator cursor;
-
- /** Columns metadata. */
- meta::ColumnMetaVector columnsMeta;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index ffef3e4..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/type_info_query.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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);
-
- /**
- * Get data of the specified column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * 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/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/result_page.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/result_page.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/result_page.h
deleted file mode 100644
index 5c8cac3..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/result_page.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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_RESULT_PAGE
-#define _IGNITE_ODBC_DRIVER_RESULT_PAGE
-
-#include <stdint.h>
-
-#include <ignite/impl/binary/binary_reader_impl.h>
-
-#include "ignite/odbc/app/application_data_buffer.h"
-#include "ignite/odbc/common_types.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /**
- * Query result page.
- */
- class ResultPage
- {
- enum { DEFAULT_ALLOCATED_MEMORY = 1024 };
-
- public:
- // Default result page size.
- enum { DEFAULT_SIZE = 32 };
-
- /**
- * Constructor.
- */
- ResultPage();
-
- /**
- * Destructor.
- */
- ~ResultPage();
-
- /**
- * Read result page using provided reader.
- * @param reader Reader.
- */
- void Read(ignite::impl::binary::BinaryReaderImpl& reader);
-
- /**
- * Get page size.
- * @return Page size.
- */
- int32_t GetSize() const
- {
- return size;
- }
-
- /**
- * Check if the page is last.
- * @return True if the page is last.
- */
- bool IsLast() const
- {
- return last;
- }
-
- /**
- * Get page data.
- * @return Page data.
- */
- ignite::impl::interop::InteropUnpooledMemory& GetData()
- {
- return data;
- }
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(ResultPage);
-
- /** Last page flag. */
- bool last;
-
- /** Page size in rows. */
- int32_t size;
-
- /** Memory that contains current row page data. */
- ignite::impl::interop::InteropUnpooledMemory data;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/row.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/row.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/row.h
deleted file mode 100644
index 7673555..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/row.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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_ROW
-#define _IGNITE_ODBC_DRIVER_ROW
-
-#include <stdint.h>
-#include <vector>
-
-#include "ignite/odbc/column.h"
-#include "ignite/odbc/app/application_data_buffer.h"
-
-
-namespace ignite
-{
- namespace odbc
- {
- /**
- * Query result row.
- */
- class Row
- {
- public:
- /**
- * Constructor.
- */
- Row(ignite::impl::interop::InteropUnpooledMemory& pageData);
-
- /**
- * Destructor.
- */
- ~Row();
-
- /**
- * Get row size in columns.
- *
- * @return Row size.
- */
- int32_t GetSize() const
- {
- return size;
- }
-
- /**
- * Read column data and store it in application data buffer.
- *
- * @param dataBuf Application data buffer.
- * @return True on success.
- */
- SqlResult ReadColumnToBuffer(uint16_t columnIdx, app::ApplicationDataBuffer& dataBuf);
-
- /**
- * Move to next row.
- *
- * @return True on success.
- */
- bool MoveToNext();
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Row);
-
- /**
- * Reinitialize row state using stream data.
- * @note Stream must be positioned at the beginning of the row.
- */
- void Reinit();
-
- /**
- * Get columns by its index.
- *
- * Column indexing starts at 1.
- *
- * @note This operation is private because it's unsafe to use:
- * It is neccessary to ensure that column is discovered prior
- * to calling this method using EnsureColumnDiscovered().
- *
- * @param columnIdx Column index.
- * @return Reference to specified column.
- */
- Column& GetColumn(uint16_t columnIdx)
- {
- return columns[columnIdx - 1];
- }
-
- /**
- * Ensure that column data is discovered.
- *
- * @param columnIdx Column index.
- * @return True if the column is discovered and false if it can not
- * be discovered.
- */
- bool EnsureColumnDiscovered(uint16_t columnIdx);
-
- /** Row position in current page. */
- int32_t rowBeginPos;
-
- /** Current position in row. */
- int32_t pos;
-
- /** Row size in columns. */
- int32_t size;
-
- /** Memory that contains current row data. */
- ignite::impl::interop::InteropUnpooledMemory& pageData;
-
- /** Page data input stream. */
- ignite::impl::interop::InteropInputStream stream;
-
- /** Data reader. */
- ignite::impl::binary::BinaryReaderImpl reader;
-
- /** Columns. */
- std::vector<Column> columns;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
deleted file mode 100644
index bbe5da5..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * 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_STATEMENT
-#define _IGNITE_ODBC_DRIVER_STATEMENT
-
-#include <stdint.h>
-
-#include <map>
-#include <memory>
-
-#include <ignite/impl/interop/interop_output_stream.h>
-#include <ignite/impl/interop/interop_input_stream.h>
-#include <ignite/impl/binary/binary_writer_impl.h>
-
-#include "ignite/odbc/meta/column_meta.h"
-#include "ignite/odbc/meta/table_meta.h"
-#include "ignite/odbc/query/query.h"
-#include "ignite/odbc/app/application_data_buffer.h"
-#include "ignite/odbc/app/parameter.h"
-#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/cursor.h"
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- class Connection;
-
- /**
- * SQL-statement abstraction. Holds SQL query user buffers data and
- * call result.
- */
- class Statement : public diagnostic::DiagnosableAdapter
- {
- friend class Connection;
- public:
- /**
- * Destructor.
- */
- ~Statement();
-
- /**
- * Bind result column to specified data buffer.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- */
- void BindColumn(uint16_t columnIdx, const app::ApplicationDataBuffer& buffer);
-
- /**
- * Unbind specified column buffer.
- *
- * @param columnIdx Column index.
- */
- void UnbindColumn(uint16_t columnIdx);
-
- /**
- * Unbind all column buffers.
- */
- void UnbindAllColumns();
-
- /**
- * Set column binding offset pointer.
- *
- * @param ptr Column binding offset pointer.
- */
- void SetColumnBindOffsetPtr(size_t* ptr);
-
- /**
- * Get column binding offset pointer.
- *
- * @return Column binding offset pointer.
- */
- size_t* GetColumnBindOffsetPtr();
-
- /**
- * Get number of columns in the result set.
- *
- * @return Columns number.
- */
- int32_t GetColumnNumber();
-
- /**
- * Bind parameter.
- *
- * @param paramIdx Parameter index.
- * @param param Parameter.
- */
- void BindParameter(uint16_t paramIdx, const app::Parameter& param);
-
- /**
- * Unbind specified parameter.
- *
- * @param paramIdx Parameter index.
- */
- void UnbindParameter(uint16_t paramIdx);
-
- /**
- * Unbind all parameters.
- */
- void UnbindAllParameters();
-
- /**
- * Get number of binded parameters.
- *
- * @return Number of binded parameters.
- */
- uint16_t GetParametersNumber();
-
- /**
- * Set parameter binding offset pointer.
- *
- * @param ptr Parameter binding offset pointer.
- */
- void SetParamBindOffsetPtr(size_t* ptr);
-
- /**
- * Get parameter binding offset pointer.
- *
- * @return Parameter binding offset pointer.
- */
- size_t* GetParamBindOffsetPtr();
-
- /**
- * Get value of the column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- */
- void GetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * Prepare SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @param query SQL query.
- */
- void PrepareSqlQuery(const std::string& query);
-
- /**
- * Prepare SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @param query SQL query.
- * @param len Query length.
- */
- void PrepareSqlQuery(const char* query, size_t len);
-
- /**
- * Execute SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @param query SQL query.
- */
- void ExecuteSqlQuery(const std::string& query);
-
- /**
- * Execute SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @param query SQL query.
- * @param len Query length.
- */
- void ExecuteSqlQuery(const char* query, size_t len);
-
- /**
- * Execute SQL query.
- *
- * @note Only SELECT queries are supported currently.
- */
- void ExecuteSqlQuery();
-
- /**
- * Get columns metadata.
- *
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param column Column search pattern.
- */
- void ExecuteGetColumnsMetaQuery(const std::string& schema,
- const std::string& table, const std::string& column);
-
- /**
- * Get tables metadata.
- *
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableType Table type search pattern.
- */
- void ExecuteGetTablesMetaQuery(const std::string& catalog,
- const std::string& schema, const std::string& table,
- const std::string& tableType);
-
- /**
- * Get foreign keys.
- *
- * @param primaryCatalog Primary key catalog name.
- * @param primarySchema Primary key schema name.
- * @param primaryTable Primary key table name.
- * @param foreignCatalog Foreign key catalog name.
- * @param foreignSchema Foreign key schema name.
- * @param foreignTable Foreign key table name.
- */
- void ExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
- const std::string& primarySchema, const std::string& primaryTable,
- const std::string& foreignCatalog, const std::string& foreignSchema,
- const std::string& foreignTable);
-
- /**
- * Get primary keys.
- *
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- */
- void ExecuteGetPrimaryKeysQuery(const std::string& catalog,
- const std::string& schema, const std::string& table);
-
- /**
- * Get special columns.
- *
- * @param type Special column type.
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @param scope Minimum required scope of the rowid.
- * @param type Determines whether to return special columns that
- * can have a NULL value.
- */
- void ExecuteSpecialColumnsQuery(int16_t type,
- const std::string& catalog, const std::string& schema,
- const std::string& table, int16_t scope, int16_t nullable);
-
- /**
- * Get type info.
- *
- * @param sqlType SQL type for which to return info or SQL_ALL_TYPES.
- */
- void ExecuteGetTypeInfoQuery(int16_t sqlType);
-
- /**
- * Close statement.
- */
- void Close();
-
- /**
- * Fetch query result row.
- */
- void FetchRow();
-
- /**
- * Get column metadata.
- *
- * @return Column metadata.
- */
- const meta::ColumnMetaVector* GetMeta() const;
-
- /**
- * Check if data is available.
- *
- * @return True if data is available.
- */
- bool DataAvailable() const;
-
- /**
- * Get column attribute.
- *
- * @param colIdx Column index.
- * @param attrId Attribute ID.
- * @param strbuf Buffer for string attribute value.
- * @param buflen String buffer size.
- * @param reslen Buffer to put resulting string length to.
- * @param numbuf Numeric value buffer.
- */
- void GetColumnAttribute(uint16_t colIdx, uint16_t attrId, char* strbuf,
- int16_t buflen, int16_t* reslen, SqlLen* numbuf);
-
- /**
- * Get number of rows affected by the statement.
- *
- * @return Number of rows affected by the statement.
- */
- int64_t AffectedRows();
-
- /**
- * Set rows fetched buffer pointer.
- *
- * @param ptr Rows fetched buffer pointer.
- */
- void SetRowsFetchedPtr(size_t* ptr);
-
- /**
- * Get rows fetched buffer pointer.
- *
- * @return Rows fetched buffer pointer.
- */
- size_t* GetRowsFetchedPtr();
-
- /**
- * Set row statuses array pointer.
- *
- * @param ptr Row statuses array pointer.
- */
- void SetRowStatusesPtr(uint16_t* ptr);
-
- /**
- * Get row statuses array pointer.
- *
- * @return Row statuses array pointer.
- */
- uint16_t* GetRowStatusesPtr();
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Statement);
-
- /**
- * Get value of the column in the result set.
- *
- * @param columnIdx Column index.
- * @param buffer Buffer to put column data to.
- * @return Operation result.
- */
- SqlResult InternalGetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
-
- /**
- * Close statement.
- * Internal call.
- *
- * @return Operation result.
- */
- SqlResult InternalClose();
-
- /**
- * Prepare SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @param query SQL query.
- * @param len Query length.
- * @return Operation result.
- */
- SqlResult InternalPrepareSqlQuery(const char* query, size_t len);
-
- /**
- * Execute SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @param query SQL query.
- * @param len Query length.
- * @return Operation result.
- */
- SqlResult InternalExecuteSqlQuery(const char* query, size_t len);
-
- /**
- * Execute SQL query.
- *
- * @note Only SELECT queries are supported currently.
- * @return Operation result.
- */
- SqlResult InternalExecuteSqlQuery();
-
- /**
- * Fetch query result row.
- *
- * @return Operation result.
- */
- SqlResult InternalFetchRow();
-
- /**
- * Get number of columns in the result set.
- *
- * @param res Columns number.
- * @return Operation result.
- */
- SqlResult InternalGetColumnNumber(int32_t &res);
-
- /**
- * Get columns metadata.
- *
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param column Column search pattern.
- * @return Operation result.
- */
- SqlResult InternalExecuteGetColumnsMetaQuery(const std::string& schema,
- const std::string& table, const std::string& column);
-
- /**
- * Get tables metadata.
- *
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableType Table type search pattern.
- * @return Operation result.
- */
- SqlResult InternalExecuteGetTablesMetaQuery(const std::string& catalog,
- const std::string& schema, const std::string& table,
- const std::string& tableType);
-
- /**
- * Get foreign keys.
- *
- * @param primaryCatalog Primary key catalog name.
- * @param primarySchema Primary key schema name.
- * @param primaryTable Primary key table name.
- * @param foreignCatalog Foreign key catalog name.
- * @param foreignSchema Foreign key schema name.
- * @param foreignTable Foreign key table name.
- * @return Operation result.
- */
- SqlResult InternalExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
- const std::string& primarySchema, const std::string& primaryTable,
- const std::string& foreignCatalog, const std::string& foreignSchema,
- const std::string& foreignTable);
-
- /**
- * Get primary keys.
- *
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @return Operation result.
- */
- SqlResult InternalExecuteGetPrimaryKeysQuery(const std::string& catalog,
- const std::string& schema, const std::string& table);
-
- /**
- * Get special columns.
- *
- * @param type Special column type.
- * @param catalog Catalog name.
- * @param schema Schema name.
- * @param table Table name.
- * @param scope Minimum required scope of the rowid.
- * @param nullable Determines whether to return special columns
- * that can have a NULL value.
- * @return Operation result.
- */
- SqlResult InternalExecuteSpecialColumnsQuery(int16_t type,
- const std::string& catalog, const std::string& schema,
- const std::string& table, int16_t scope, int16_t nullable);
-
- /**
- * Get type info.
- *
- * @param sqlType SQL type for which to return info or SQL_ALL_TYPES.
- */
- SqlResult InternalExecuteGetTypeInfoQuery(int16_t sqlType);
-
- /**
- * Get column attribute.
- *
- * @param colIdx Column index.
- * @param attrId Attribute ID.
- * @param strbuf Buffer for string attribute value.
- * @param buflen String buffer size.
- * @param reslen Buffer to put resulting string length to.
- * @param numbuf Numeric value buffer.
- * @return Operation result.
- */
- SqlResult InternalGetColumnAttribute(uint16_t colIdx, uint16_t attrId,
- char* strbuf, int16_t buflen, int16_t* reslen, SqlLen* numbuf);
-
- /**
- * Get number of rows affected by the statement.
- *
- * @param rowCnt Number of rows affected by the statement.
- * @return Operation result.
- */
- SqlResult InternalAffectedRows(int64_t& rowCnt);
-
- /**
- * Constructor.
- * Called by friend classes.
- *
- * @param parent Connection associated with the statement.
- */
- Statement(Connection& parent);
-
- /** Connection associated with the statement. */
- Connection& connection;
-
- /** Column bindings. */
- app::ColumnBindingMap columnBindings;
-
- /** Parameter bindings. */
- app::ParameterBindingMap paramBindings;
-
- /** Underlying query. */
- std::auto_ptr<query::Query> currentQuery;
-
- /** Buffer to store number of rows fetched by the last fetch. */
- size_t* rowsFetched;
-
- /** Array to store statuses of rows fetched by the last fetch. */
- uint16_t* rowStatuses;
-
- /** Offset added to pointers to change binding of parameters. */
- size_t* paramBindOffset;
-
- /* Offset added to pointers to change binding of column data. */
- size_t* columnBindOffset;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/odbc_constants.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/odbc_constants.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/odbc_constants.h
deleted file mode 100644
index 0262be5..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/system/odbc_constants.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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_ODBC_CONSTANTS
-#define _IGNITE_ODBC_DRIVER_ODBC_CONSTANTS
-
-#ifdef _WIN32
-
-#define _WINSOCKAPI_
-#include <windows.h>
-
-#ifdef min
-# undef min
-#endif // min
-
-#ifdef GetMessage
-# undef GetMessage
-#endif // GetMessage
-
-#endif //_WIN32
-
-#define ODBCVER 0x0380
-
-#include <sqlext.h>
-#include <odbcinst.h>
-
-#ifndef UNREFERENCED_PARAMETER
-#define UNREFERENCED_PARAMETER(x) (void)(x)
-#endif // UNREFERENCED_PARAMETER
-
-#endif //_IGNITE_ODBC_DRIVER_ODBC_CONSTANTS
[22/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h
deleted file mode 100644
index 8e1dbf2..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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_COMMON_TYPES
-#define _IGNITE_ODBC_DRIVER_COMMON_TYPES
-
-#include <stdint.h>
-
-namespace ignite
-{
- namespace odbc
- {
-
-#ifdef _WIN64
- typedef long long SqlLen;
-#else
- typedef long SqlLen;
-#endif
-
- /**
- * SQL result.
- */
- enum SqlResult
- {
- /** Success. */
- SQL_RESULT_SUCCESS,
-
- /** Success with info. */
- SQL_RESULT_SUCCESS_WITH_INFO,
-
- /** Error. */
- SQL_RESULT_ERROR,
-
- /** No more data. */
- SQL_RESULT_NO_DATA
- };
-
- /**
- * Provides detailed information about the cause of a warning or error.
- */
- enum SqlState
- {
- /** Undefined state. Internal, should never be exposed to user. */
- SQL_STATE_UNKNOWN,
-
- /** Output data has been truncated. */
- SQL_STATE_01004_DATA_TRUNCATED,
-
- /** Error in row. */
- SQL_STATE_01S01_ERROR_IN_ROW,
-
- /**
- * The driver did not support the specified value and
- * substituted a similar value.
- */
- SQL_STATE_01S02_OPTION_VALUE_CHANGED,
-
- /** Invalid cursor state. */
- SQL_STATE_24000_INVALID_CURSOR_STATE,
-
- /**
- * The driver was unable to establish a connection with the data
- * source.
- */
- SQL_STATE_08001_CANNOT_CONNECT,
-
- /**
- * The specified ConnectionHandle had already been used
- * to establish a connection with a data source, and the connection
- * was still open.
- */
- SQL_STATE_08002_ALREADY_CONNECTED,
-
- /** The connection specified was not open. */
- SQL_STATE_08003_NOT_CONNECTED,
-
- /**
- * An error occurred for which there was no specific SQLSTATE
- * and for which no implementation-specific SQLSTATE was defined.
- */
- SQL_STATE_HY000_GENERAL_ERROR,
-
- /**
- * The driver was unable to allocate memory for the specified
- * handle.
- */
- SQL_STATE_HY001_MEMORY_ALLOCATION,
-
- /** Function sequence error. */
- SQL_STATE_HY010_SEQUENCE_ERROR,
-
- /** Column type out of range. */
- SQL_STATE_HY097_COLUMN_TYPE_OUT_OF_RANGE,
-
- /**
- * The driver does not support the feature of ODBC behavior that
- * the application requested.
- */
- SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
-
- /**
- * The connection timeout period expired before the data source
- * responded to the request.
- */
- SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT
- };
-
- /**
- * Diagnostic field type.
- */
- enum DiagnosticField
- {
- /** Field type is unknown to the driver. */
- IGNITE_SQL_DIAG_UNKNOWN,
-
- /** Header record field: Count of rows in the cursor. */
- IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT,
-
- /**
- * Header record field: String that describes the SQL statement
- * that the underlying function executed.
- */
- IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION,
-
- /**
- * Header record field: Numeric code that describes the SQL
- * statement that was executed by the underlying function.
- */
- IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE,
-
- /** Header record field: Number of status records. */
- IGNITE_SQL_DIAG_HEADER_NUMBER,
-
- /** Header record field: Last operation return code. */
- IGNITE_SQL_DIAG_HEADER_RETURNCODE,
-
- /** Header record field: Row count. */
- IGNITE_SQL_DIAG_HEADER_ROW_COUNT,
-
- /** Status record field: Class origin. */
- IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN,
-
- /** Status record field: Column number. */
- IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER,
-
- /** Status record field: Connection name. */
- IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME,
-
- /** Status record field: Message text. */
- IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT,
-
- /** Status record field: Native result code. */
- IGNITE_SQL_DIAG_STATUS_NATIVE,
-
- /** Status record field: Row number. */
- IGNITE_SQL_DIAG_STATUS_ROW_NUMBER,
-
- /** Status record field: Server name. */
- IGNITE_SQL_DIAG_STATUS_SERVER_NAME,
-
- /** Status record field: SQLSTATE. */
- IGNITE_SQL_DIAG_STATUS_SQLSTATE,
-
- /** Status record field: Subclass origin. */
- IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN
- };
-
- /**
- * Environment attribute.
- */
- enum EnvironmentAttribute
- {
- /** ODBC attribute is unknown to the driver. */
- IGNITE_SQL_ENV_ATTR_UNKNOWN,
-
- /** ODBC version. */
- IGNITE_SQL_ENV_ATTR_ODBC_VERSION,
-
- /** Null-termination of strings. */
- IGNITE_SQL_ENV_ATTR_OUTPUT_NTS
- };
-
- /**
- * Convert internal Ignite type into ODBC SQL return code.
- *
- * @param result Internal result type.
- * @return ODBC result type.
- */
- int SqlResultToReturnCode(SqlResult result);
-
- /**
- * Convert ODBC field type to internal DiagnosticField type value.
- *
- * @param field ODBC field type.
- * @return Internal DiagnosticField type value.
- */
- DiagnosticField DiagnosticFieldToInternal(int16_t field);
-
- /**
- * Convert environment attribute to internal EnvironmentAttribute type value.
- *
- * @param attr Environment attribute.
- * @return Internal EnvironmentAttribute type value.
- */
- EnvironmentAttribute EnvironmentAttributeToInternal(int32_t attr);
-
-
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/configuration.h
deleted file mode 100644
index f85a5de..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/configuration.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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_CONFIGURATION
-#define _IGNITE_ODBC_DRIVER_CONFIGURATION
-
-#include <stdint.h>
-#include <string>
-#include <map>
-
-#include <ignite/common/common.h>
-
-namespace ignite
-{
- namespace odbc
- {
- namespace config
- {
- /**
- * ODBC configuration abstraction.
- */
- class Configuration
- {
- public:
- /**
- * Default constructor.
- */
- Configuration();
-
- /**
- * Destructor.
- */
- ~Configuration();
-
- /**
- * Fill configuration data using connection string.
- *
- * @param str Pointer to string data.
- * @param len String length.
- */
- void FillFromConnectString(const char* str, size_t len);
-
- /**
- * Fill configuration data using connection string.
- *
- * @param str Connect string.
- */
- void FillFromConnectString(const std::string& str);
-
- /**
- * Convert configure to connect string.
- *
- * @return Connect string.
- */
- std::string ToConnectString() const;
-
- /**
- * Fill configuration data using config attributes string.
- *
- * @param str Pointer to list of zero-terminated strings.
- * Terminated by two zero bytes.
- */
- void FillFromConfigAttributes(const char* attributes);
-
- /**
- * Get server port.
- *
- * @return Server port.
- */
- uint16_t GetPort() const
- {
- return port;
- }
-
- /**
- * Get DSN.
- *
- * @return Data Source Name.
- */
- const std::string& GetDsn() const
- {
- return dsn;
- }
-
- /**
- * Get Driver.
- *
- * @return Driver name.
- */
- const std::string& GetDriver() const
- {
- return driver;
- }
-
- /**
- * Get server host.
- *
- * @return Server host.
- */
- const std::string& GetHost() const
- {
- return host;
- }
-
- /**
- * Get cache.
- *
- * @return Cache name.
- */
- const std::string& GetCache() const
- {
- return cache;
- }
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Configuration);
-
- /** Map containing connect arguments. */
- typedef std::map<std::string, std::string> ArgumentMap;
-
- /**
- * Parse connect string into key-value storage.
- *
- * @param str String to parse.
- * @param len String length.
- * @param params Parsing result.
- */
- void ParseAttributeList(const char* str, size_t len, char delimeter, ArgumentMap& args) const;
-
- /** Data Source Name. */
- std::string dsn;
-
- /** Driver name. */
- std::string driver;
-
- /** Server hostname. */
- std::string host;
-
- /** Port of the server. */
- uint16_t port;
-
- /** Cache name. */
- std::string cache;
- };
- }
-
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/connection_info.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/connection_info.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/connection_info.h
deleted file mode 100644
index 7f2738c..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/config/connection_info.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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_CONNECTION_INFO
-#define _IGNITE_ODBC_DRIVER_CONNECTION_INFO
-
-#include <stdint.h>
-
-#include <map>
-
-#include <ignite/common/common.h>
-#include <ignite/odbc/common_types.h>
-
-namespace ignite
-{
- namespace odbc
- {
- namespace config
- {
- /**
- * Connection info.
- */
- class ConnectionInfo
- {
- public:
- /** Info type. */
- typedef unsigned short InfoType;
-
-#ifdef ODBC_DEBUG
- /**
- * Convert type to string containing its name.
- * Debug function.
- * @param type Info type.
- * @return Null-terminated string containing types name.
- */
- static const char* InfoTypeToString(InfoType type);
-#endif
-
- /**
- * Constructor.
- */
- ConnectionInfo();
-
- /**
- * Destructor.
- */
- ~ConnectionInfo();
-
- /**
- * Get info of any type.
- * @param type Info type.
- * @param buf Result buffer pointer.
- * @param buflen Result buffer length.
- * @param reslen Result value length pointer.
- * @return True on success.
- */
- SqlResult GetInfo(InfoType type, void* buf, short buflen, short* reslen) const;
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(ConnectionInfo);
-
- /** Associative array of string parameters. */
- typedef std::map<InfoType, std::string> StringInfoMap;
-
- /** Associative array of unsigned integer parameters. */
- typedef std::map<InfoType, unsigned int> UintInfoMap;
-
- /** Associative array of unsigned short parameters. */
- typedef std::map<InfoType, unsigned short> UshortInfoMap;
-
- /** String parameters. */
- StringInfoMap strParams;
-
- /** Integer parameters. */
- UintInfoMap intParams;
-
- /** Short parameters. */
- UshortInfoMap shortParams;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h
deleted file mode 100644
index 56037f5..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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_CONNECTION
-#define _IGNITE_ODBC_DRIVER_CONNECTION
-
-#include <stdint.h>
-
-#include <vector>
-
-#include "ignite/odbc/parser.h"
-#include "ignite/odbc/system/socket_client.h"
-#include "ignite/odbc/config/connection_info.h"
-#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
-
-namespace ignite
-{
- namespace odbc
- {
- class Statement;
-
- /**
- * ODBC node connection.
- */
- class Connection : public diagnostic::DiagnosableAdapter
- {
- friend class Environment;
- public:
- /**
- * Destructor.
- */
- ~Connection();
-
- /**
- * Get connection info.
- *
- * @return Connection info.
- */
- const config::ConnectionInfo& GetInfo() const;
-
- /**
- * Get info of any type.
- *
- * @param type Info type.
- * @param buf Result buffer pointer.
- * @param buflen Result buffer length.
- * @param reslen Result value length pointer.
- */
- void GetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen);
-
- /**
- * Establish connection to ODBC server.
- *
- * @param server Server (DSN).
- */
- void Establish(const std::string& server);
-
- /**
- * Establish connection to ODBC server.
- *
- * @param host Host.
- * @param port Port.
- * @param cache Cache name to connect to.
- */
- void Establish(const std::string& host, uint16_t port, const std::string& cache);
-
- /**
- * Release established connection.
- *
- * @return Operation result.
- */
- void Release();
-
- /**
- * Create statement associated with the connection.
- *
- * @return Pointer to valid instance on success and NULL on failure.
- */
- Statement* CreateStatement();
-
- /**
- * Send data by established connection.
- *
- * @param data Data buffer.
- * @param len Data length.
- * @return True on success.
- */
- bool Send(const int8_t* data, size_t len);
-
- /**
- * Receive next message.
- *
- * @param msg Buffer for message.
- * @return True on success.
- */
- bool Receive(std::vector<int8_t>& msg);
-
- /**
- * Get name of the assotiated cache.
- *
- * @return Cache name.
- */
- const std::string& GetCache() const;
-
- /**
- * Create diagnostic record associated with the Connection instance.
- *
- * @param sqlState SQL state.
- * @param message Message.
- * @param rowNum Associated row number.
- * @param columnNum Associated column number.
- * @return DiagnosticRecord associated with the instance.
- */
- diagnostic::DiagnosticRecord CreateStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum = 0, int32_t columnNum = 0) const;
-
- /**
- * Synchronously send request message and receive response.
- *
- * @param req Request message.
- * @param rsp Response message.
- * @return True on success.
- */
- template<typename ReqT, typename RspT>
- bool SyncMessage(const ReqT& req, RspT& rsp)
- {
- std::vector<int8_t> tempBuffer;
-
- parser.Encode(req, tempBuffer);
-
- bool requestSent = Send(tempBuffer.data(), tempBuffer.size());
-
- if (!requestSent)
- return false;
-
- bool responseReceived = Receive(tempBuffer);
-
- if (!responseReceived)
- return false;
-
- parser.Decode(rsp, tempBuffer);
-
- return true;
- }
-
- /**
- * Perform transaction commit.
- */
- void TransactionCommit();
-
- /**
- * Perform transaction rollback.
- */
- void TransactionRollback();
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Connection);
-
- /**
- * Establish connection to ODBC server.
- * Internal call.
- *
- * @param server Server (DNS).
- * @return Operation result.
- */
- SqlResult InternalEstablish(const std::string& server);
-
- /**
- * Establish connection to ODBC server.
- * Internal call.
- *
- * @param host Host.
- * @param port Port.
- * @param cache Cache name to connect to.
- * @return Operation result.
- */
- SqlResult InternalEstablish(const std::string& host, uint16_t port, const std::string& cache);
-
- /**
- * Release established connection.
- * Internal call.
- *
- * @return Operation result.
- */
- SqlResult InternalRelease();
-
- /**
- * Get info of any type.
- * Internal call.
- *
- * @param type Info type.
- * @param buf Result buffer pointer.
- * @param buflen Result buffer length.
- * @param reslen Result value length pointer.
- * @return Operation result.
- */
- SqlResult InternalGetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen);
-
- /**
- * Create statement associated with the connection.
- * Internal call.
- *
- * @param Pointer to valid instance on success and NULL on failure.
- * @return Operation result.
- */
- SqlResult InternalCreateStatement(Statement*& statement);
-
- /**
- * Perform transaction commit on all the associated connections.
- * Internal call.
- *
- * @return Operation result.
- */
- SqlResult InternalTransactionCommit();
-
- /**
- * Perform transaction rollback on all the associated connections.
- * Internal call.
- *
- * @return Operation result.
- */
- SqlResult InternalTransactionRollback();
-
- /**
- * Constructor.
- */
- Connection();
-
- /** Socket. */
- tcp::SocketClient socket;
-
- /** State flag. */
- bool connected;
-
- /** Cache name. */
- std::string cache;
-
- /** Message parser. */
- Parser parser;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/cursor.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/cursor.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/cursor.h
deleted file mode 100644
index 7d4c925..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/cursor.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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_CURSOR
-#define _IGNITE_ODBC_DRIVER_CURSOR
-
-#include <stdint.h>
-
-#include <map>
-#include <memory>
-
-#include "ignite/odbc/result_page.h"
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/row.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /**
- * Query result cursor.
- */
- class Cursor
- {
- public:
- /**
- * Constructor.
- * @param queryId ID of the executed query.
- */
- Cursor(int64_t queryId);
-
- /**
- * Destructor.
- */
- ~Cursor();
-
- /**
- * Move cursor to the next result row.
- * @return False if data update required or no more data.
- */
- bool Increment();
-
- /**
- * Check if the cursor needs data update.
- * @return True if the cursor needs data update.
- */
- bool NeedDataUpdate() const;
-
- /**
- * Check if the cursor has next row row.
- * @return True if the cursor has next row row.
- */
- bool HasNext() const;
-
- /**
- * Get query ID.
- * @return Query ID.
- */
- int64_t GetQueryId() const
- {
- return queryId;
- }
-
- /**
- * Update current cursor page data.
- * @param newPage New result page.
- */
- void UpdateData(std::auto_ptr<ResultPage>& newPage);
-
- /**
- * Get current row.
- * @return Current row.
- */
- Row* GetRow();
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Cursor);
-
- /** Cursor id. */
- int64_t queryId;
-
- /** Current page. */
- std::auto_ptr<ResultPage> currentPage;
-
- /** Row position in current page. */
- int32_t currentPagePos;
-
- /** Current row. */
- std::auto_ptr<Row> currentRow;
- };
- }
-}
-
-#endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/decimal.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/decimal.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/decimal.h
deleted file mode 100644
index abf7f34..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/decimal.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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_DECIMAL
-#define _IGNITE_DECIMAL
-
-#include <stdint.h>
-
-namespace ignite
-{
- //TODO: move to binary or common library.
- class Decimal
- {
- friend void swap(Decimal& first, Decimal& second);
- public:
- /**
- * Default constructor.
- */
- Decimal();
-
- /**
- * Constructor.
- *
- * @param scale Scale.
- * @param mag Magnitude. Value is copied.
- * @param len Magnitude length in bytes.
- */
- Decimal(int32_t scale, const int8_t* mag, int32_t len);
-
- /**
- * Copy constructor.
- *
- * @param other Other instance.
- */
- Decimal(const Decimal& other);
-
- /**
- * Destructor.
- */
- ~Decimal();
-
- /**
- * Copy operator.
- *
- * @param other Other instance.
- * @return This.
- */
- Decimal& operator=(const Decimal& other);
-
- /**
- * Convert to double.
- */
- operator double() const;
-
- /**
- * Get scale.
- *
- * @return Scale.
- */
- int32_t GetScale() const;
-
- /**
- * Get sign.
- *
- * @return Sign: -1 if negative and 1 if positive.
- */
- int32_t GetSign() const;
-
- /**
- * Check if the value is negative.
- *
- * @return True if negative and false otherwise.
- */
- bool IsNegative() const;
-
- /**
- * Get magnitude length.
- *
- * @return Magnitude length.
- */
- int32_t GetLength() const;
-
- /**
- * Get magnitude pointer.
- *
- * @return Magnitude pointer.
- */
- const int8_t* GetMagnitude() const;
-
- private:
- /** Scale. */
- int32_t scale;
-
- /** Magnitude lenght. */
- int32_t len;
-
- /** Magnitude. */
- int8_t* magnitude;
- };
-
- /**
- * Swap function for the Decimal type.
- *
- * @param first First instance.
- * @param second Second instance.
- */
- void swap(Decimal& first, Decimal& second);
-}
-
-
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable.h
deleted file mode 100644
index 2afd819..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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_DIAGNOSABLE
-#define _IGNITE_ODBC_DRIVER_DIAGNOSABLE
-
-#include "ignite/odbc/diagnostic/diagnostic_record_storage.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace diagnostic
- {
- /**
- * Diagnosable interface.
- */
- class Diagnosable
- {
- public:
- /**
- * Destructor.
- */
- virtual ~Diagnosable()
- {
- // No-op.
- }
-
- /**
- * Get diagnostic record.
- *
- * @return Diagnostic record.
- */
- virtual const diagnostic::DiagnosticRecordStorage& GetDiagnosticRecords() const = 0;
-
- /**
- * Add new status record.
- *
- * @param sqlState SQL state.
- * @param message Message.
- * @param rowNum Associated row number.
- * @param columnNum Associated column number.
- */
- virtual void AddStatusRecord(SqlState sqlState, const std::string& message,
- int32_t rowNum, int32_t columnNum) = 0;
-
- /**
- * Add new status record.
- *
- * @param sqlState SQL state.
- * @param message Message.
- */
- virtual void AddStatusRecord(SqlState sqlState, const std::string& message) = 0;
-
- protected:
- /**
- * Default constructor.
- */
- Diagnosable()
- {
- // No-op.
- }
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable_adapter.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable_adapter.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable_adapter.h
deleted file mode 100644
index 5b01f49..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnosable_adapter.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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_DIAGNOSABLE_ADAPTER
-#define _IGNITE_ODBC_DRIVER_DIAGNOSABLE_ADAPTER
-
-#include "ignite/odbc/diagnostic/diagnosable.h"
-
-#define IGNITE_ODBC_API_CALL(...) \
- diagnosticRecords.Reset(); \
- SqlResult result = (__VA_ARGS__); \
- diagnosticRecords.SetHeaderRecord(result)
-
-#define IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS \
- diagnosticRecords.Reset(); \
- diagnosticRecords.SetHeaderRecord(SQL_RESULT_SUCCESS)
-
-namespace ignite
-{
- namespace odbc
- {
- class Connection;
-
- namespace diagnostic
- {
- /**
- * Diagnosable interface.
- */
- class DiagnosableAdapter : public Diagnosable
- {
- public:
- /**
- * Destructor.
- */
- virtual ~DiagnosableAdapter()
- {
- // No-op.
- }
-
- /**
- * Get diagnostic record.
- *
- * @return Diagnostic record.
- */
- virtual const diagnostic::DiagnosticRecordStorage& GetDiagnosticRecords() const
- {
- return diagnosticRecords;
- }
-
- /**
- * Add new status record.
- *
- * @param sqlState SQL state.
- * @param message Message.
- * @param rowNum Associated row number.
- * @param columnNum Associated column number.
- */
- virtual void AddStatusRecord(SqlState sqlState, const std::string& message,
- int32_t rowNum, int32_t columnNum);
-
- /**
- * Add new status record.
- *
- * @param sqlState SQL state.
- * @param message Message.
- */
- virtual void AddStatusRecord(SqlState sqlState, const std::string& message);
-
- protected:
- /**
- * Constructor.
- *
- * @param connection Pointer to connection. Used to create
- * diagnostic records with connection info.
- */
- DiagnosableAdapter(const Connection* connection = 0) :
- connection(connection)
- {
- // No-op.
- }
-
- /** Diagnostic records. */
- diagnostic::DiagnosticRecordStorage diagnosticRecords;
-
- private:
- /** Connection. */
- const Connection* connection;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record.h
deleted file mode 100644
index 87d29c1..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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_DIAGNOSTIC_RECORD
-#define _IGNITE_ODBC_DRIVER_DIAGNOSTIC_RECORD
-
-#include <stdint.h>
-
-#include <vector>
-
-#include <ignite/common/common.h>
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/app/application_data_buffer.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace diagnostic
- {
- /**
- * Status diagnostic record.
- */
- class DiagnosticRecord
- {
- public:
- /**
- * Default constructor.
- */
- DiagnosticRecord();
-
- /**
- * Constructor.
- *
- * @param sqlState SQL state code.
- * @param message Message.
- * @param connectionName Connection name.
- * @param serverName Server name.
- * @param rowNum Associated row number.
- * @param columnNum Associated column number.
- */
- DiagnosticRecord(SqlState sqlState, const std::string& message,
- const std::string& connectionName, const std::string& serverName,
- int32_t rowNum = 0, int32_t columnNum = 0);
-
- /**
- * Destructor.
- */
- ~DiagnosticRecord();
-
- /**
- * Get class origin.
- *
- * @return A string that indicates the document that defines the
- * class portion of the SQLSTATE value in this record.
- */
- const std::string& GetClassOrigin() const;
-
- /**
- * Get subclass origin.
- *
- * @return A string with the same format and valid values as origin,
- * that identifies the defining portion of the subclass
- * portion of the SQLSTATE code.
- */
- const std::string& GetSubclassOrigin() const;
-
- /**
- * Get record message text.
- *
- * @return An informational message on the error or warning.
- */
- const std::string& GetMessage() const;
-
- /**
- * Get connection name.
- *
- * @return A string that indicates the name of the connection that
- * the diagnostic record relates to.
- */
- const std::string& GetConnectionName() const;
-
- /**
- * Get server name.
- *
- * @return A string that indicates the server name that the
- * diagnostic record relates to.
- */
- const std::string& GetServerName() const;
-
- /**
- * Get SQL state of the record.
- *
- * @return A five-character SQLSTATE diagnostic code.
- */
- const std::string& GetSqlState() const;
-
- /**
- * Get row number.
- *
- * @return The row number in the rowset, or the parameter number in
- * the set of parameters, with which the status record is
- * associated.
- */
- int32_t GetRowNumber() const;
-
- /**
- * Get column number.
- *
- * @return Contains the value that represents the column number
- * in the result set or the parameter number in the set
- * of parameters.
- */
- int32_t GetColumnNumber() const;
-
- private:
- /** SQL state diagnostic code. */
- SqlState sqlState;
-
- /** An informational message on the error or warning. */
- std::string message;
-
- /**
- * A string that indicates the name of the connection that
- * the diagnostic record relates to.
- */
- std::string connectionName;
-
- /**
- * A string that indicates the server name that the
- * diagnostic record relates to.
- */
- std::string serverName;
-
- /**
- * The row number in the rowset, or the parameter number in the
- * set of parameters, with which the status record is associated.
- */
- int32_t rowNum;
-
- /**
- * Contains the value that represents the column number in the
- * result set or the parameter number in the set of parameters.
- */
- int32_t columnNum;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record_storage.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
deleted file mode 100644
index c92c7a5..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * 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_DIAGNOSTIC_RECORD_STORAGE
-#define _IGNITE_ODBC_DRIVER_DIAGNOSTIC_RECORD_STORAGE
-
-#include <stdint.h>
-
-#include <vector>
-
-#include <ignite/common/common.h>
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/app/application_data_buffer.h"
-#include "ignite/odbc/diagnostic/diagnostic_record.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace diagnostic
- {
- /**
- * Diagnostic record.
- *
- * Associated with each environment, connection, statement, and
- * descriptor handle are diagnostic records. These records contain
- * diagnostic information about the last function called that used
- * a particular handle. The records are replaced only when another
- * function is called using that handle. There is no limit to the
- * number of diagnostic records that can be stored at any one time.
- *
- * This class provides interface for interaction with all handle
- * diagnostic records. That means both header and status records.
- */
- class DiagnosticRecordStorage
- {
- public:
- /**
- * Default constructor.
- */
- DiagnosticRecordStorage();
-
- /**
- * Destructor.
- */
- ~DiagnosticRecordStorage();
-
- /**
- * Set header record values.
- *
- * @param retCode Operation return code.
- */
- void SetHeaderRecord(SqlResult result);
-
- /**
- * Add status record to diagnostic records.
- *
- * @param record Status record.
- */
- void AddStatusRecord(const DiagnosticRecord& record);
-
- /**
- * Reset diagnostic records state.
- */
- void Reset();
-
- /**
- * Get result of the last operation.
- *
- * @return Result of the last operation.
- */
- SqlResult GetOperaionResult() const;
-
- /**
- * Get return code of the last operation.
- *
- * @return Return code of the last operation.
- */
- int GetReturnCode() const;
-
- /**
- * Get row count.
- *
- * @return Count of rows in cursor.
- */
- int64_t GetRowCount() const;
-
- /**
- * Get dynamic function.
- *
- * @return String that describes the SQL statement
- * that the underlying function executed.
- */
- const std::string& GetDynamicFunction() const;
-
- /**
- * Get dynamic function code.
- *
- * @return Numeric code that describes the
- * SQL statement that was executed.
- */
- int32_t GetDynamicFunctionCode() const;
-
- /**
- * Get number of rows affected.
- *
- * @return The number of rows affected by an insert,
- * delete, or update performed by the last operation.
- */
- int32_t GetRowsAffected() const;
-
- /**
- * Get status records number.
- *
- * @return Number of status records.
- */
- int32_t GetStatusRecordsNumber() const;
-
- /**
- * Get specified status record.
- *
- * @param idx Status record index.
- * @return Status record instance reference.
- */
- const DiagnosticRecord& GetStatusRecord(int32_t idx) const;
-
- /**
- * Check if the record is in the success state.
- *
- * @return True if the record is in the success state.
- */
- bool IsSuccessful() const;
-
- /**
- * Get value of the field and put it in buffer.
- *
- * @param recNum Diagnostic record number.
- * @param field Record field.
- * @param buffer Buffer to put data to.
- * @return Operation result.
- */
- SqlResult GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const;
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(DiagnosticRecordStorage);
-
- /**
- * Header record field. This field contains the count of rows
- * in the cursor.
- */
- int64_t rowCount;
-
- /**
- * Header record field. String that describes the SQL statement
- * that the underlying function executed.
- */
- std::string dynamicFunction;
-
- /**
- * Header record field. Numeric code that describes the
- * SQL statement that was executed.
- */
- int32_t dynamicFunctionCode;
-
- /**
- * Operation result. This field is mapped to "Return code" header
- * record field.
- */
- SqlResult result;
-
- /**
- * Header record field. The number of rows affected by an insert,
- * delete, or update performed by the last operation.
- */
- int32_t rowsAffected;
-
- /** Status records. */
- std::vector<DiagnosticRecord> statusRecords;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h
deleted file mode 100644
index 7168aa3..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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_ENVIRONMENT
-#define _IGNITE_ODBC_DRIVER_ENVIRONMENT
-
-#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
-
-namespace ignite
-{
- namespace odbc
- {
- class Connection;
-
- /**
- * ODBC environment.
- */
- class Environment : public diagnostic::DiagnosableAdapter
- {
- public:
- /**
- * Constructor.
- */
- Environment();
-
- /**
- * Destructor.
- */
- ~Environment();
-
- /**
- * Create connection associated with the environment.
- *
- * @return Pointer to valid instance on success or NULL on failure.
- */
- Connection* CreateConnection();
-
- /**
- * Perform transaction commit on all the associated connections.
- */
- void TransactionCommit();
-
- /**
- * Perform transaction rollback on all the associated connections.
- */
- void TransactionRollback();
-
- /**
- * Set attribute.
- *
- * @param attr Attribute to set.
- * @param value Value.
- * @param len Value length if the attribute is of string type.
- */
- void SetAttribute(int32_t attr, void* value, int32_t len);
-
- /**
- * Get attribute.
- *
- * @param attr Attribute to set.
- * @param buffer Buffer to put value to.
- */
- void GetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer);
-
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Environment);
-
- /**
- * Create connection associated with the environment.
- * Internal call.
- *
- * @return Pointer to valid instance on success or NULL on failure.
- * @return Operation result.
- */
- SqlResult InternalCreateConnection(Connection*& connection);
-
- /**
- * Perform transaction commit on all the associated connections.
- * Internal call.
- *
- * @return Operation result.
- */
- SqlResult InternalTransactionCommit();
-
- /**
- * Perform transaction rollback on all the associated connections.
- * Internal call.
- *
- * @return Operation result.
- */
- SqlResult InternalTransactionRollback();
-
- /**
- * Set attribute.
- * Internal call.
- *
- * @param attr Attribute to set.
- * @param value Value.
- * @param len Value length if the attribute is of string type.
- * @return Operation result.
- */
- SqlResult InternalSetAttribute(int32_t attr, void* value, int32_t len);
-
- /**
- * Get attribute.
- * Internal call.
- *
- * @param attr Attribute to set.
- * @param buffer Buffer to put value to.
- * @return Operation result.
- */
- SqlResult InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer);
-
- /** ODBC version. */
- int32_t odbcVersion;
-
- /** ODBC null-termintaion of string behaviour. */
- int32_t odbcNts;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/message.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/message.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/message.h
deleted file mode 100644
index f4d1e3c..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/message.h
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * 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_MESSAGE
-#define _IGNITE_ODBC_DRIVER_MESSAGE
-
-#include <stdint.h>
-#include <string>
-
-#include "ignite/impl/binary/binary_writer_impl.h"
-#include "ignite/impl/binary/binary_reader_impl.h"
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/result_page.h"
-#include "ignite/odbc/meta/column_meta.h"
-#include "ignite/odbc/meta/table_meta.h"
-#include "ignite/odbc/app/parameter.h"
-
-namespace ignite
-{
- namespace odbc
- {
- enum RequestType
- {
- REQUEST_TYPE_EXECUTE_SQL_QUERY = 1,
-
- REQUEST_TYPE_FETCH_SQL_QUERY = 2,
-
- REQUEST_TYPE_CLOSE_SQL_QUERY = 3,
-
- REQUEST_TYPE_GET_COLUMNS_METADATA = 4,
-
- REQUEST_TYPE_GET_TABLES_METADATA = 5
- };
-
- enum ResponseStatus
- {
- RESPONSE_STATUS_SUCCESS = 0,
-
- RESPONSE_STATUS_FAILED = 1
- };
-
- /**
- * Query execute request.
- */
- class QueryExecuteRequest
- {
- public:
- /**
- * Constructor.
- *
- * @param cache Cache name.
- * @param sql SQL query.
- * @param argsNum Number of arguments.
- */
- QueryExecuteRequest(const std::string& cache, const std::string& sql,
- const app::ParameterBindingMap& params) :
- cache(cache), sql(sql), params(params)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryExecuteRequest()
- {
- // No-op.
- }
-
- /**
- * Write request using provided writer.
- * @param writer Writer.
- */
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- writer.WriteInt8(REQUEST_TYPE_EXECUTE_SQL_QUERY);
- utility::WriteString(writer, cache);
- utility::WriteString(writer, sql);
-
- writer.WriteInt32(static_cast<int32_t>(params.size()));
-
- app::ParameterBindingMap::const_iterator i;
-
- for (i = params.begin(); i != params.end(); ++i)
- i->second.Write(writer);
- }
-
- private:
- /** Cache name. */
- std::string cache;
-
- /** SQL query. */
- std::string sql;
-
- /** Parameters bindings. */
- const app::ParameterBindingMap& params;
- };
-
- /**
- * Query close request.
- */
- class QueryCloseRequest
- {
- public:
- /**
- * Constructor.
- *
- * @param queryId Query ID.
- */
- QueryCloseRequest(int64_t queryId) : queryId(queryId)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryCloseRequest()
- {
- // No-op.
- }
-
- /**
- * Write request using provided writer.
- * @param writer Writer.
- */
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- writer.WriteInt8(REQUEST_TYPE_CLOSE_SQL_QUERY);
- writer.WriteInt64(queryId);
- }
-
- private:
- /** Query ID. */
- int64_t queryId;
- };
-
- /**
- * Query fetch request.
- */
- class QueryFetchRequest
- {
- public:
- /**
- * Constructor.
- *
- * @param queryId Query ID.
- * @param pageSize Required page size.
- */
- QueryFetchRequest(int64_t queryId, int32_t pageSize) :
- queryId(queryId), pageSize(pageSize)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryFetchRequest()
- {
- // No-op.
- }
-
- /**
- * Write request using provided writer.
- * @param writer Writer.
- */
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- writer.WriteInt8(REQUEST_TYPE_FETCH_SQL_QUERY);
- writer.WriteInt64(queryId);
- writer.WriteInt32(pageSize);
- }
-
- private:
- /** Query ID. */
- int64_t queryId;
-
- /** SQL query. */
- int32_t pageSize;
- };
-
- /**
- * Query get columns metadata request.
- */
- class QueryGetColumnsMetaRequest
- {
- public:
- /**
- * Constructor.
- *
- * @param schema Schema name.
- * @param table Table name.
- * @param column Column name.
- */
- QueryGetColumnsMetaRequest(const std::string& schema, const std::string& table, const std::string& column) :
- schema(schema), table(table), column(column)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryGetColumnsMetaRequest()
- {
- // No-op.
- }
-
- /**
- * Write request using provided writer.
- * @param writer Writer.
- */
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- writer.WriteInt8(REQUEST_TYPE_GET_COLUMNS_METADATA);
-
- utility::WriteString(writer, schema);
- utility::WriteString(writer, table);
- utility::WriteString(writer, column);
- }
-
- private:
- /** Schema search pattern. */
- std::string schema;
-
- /** Table search pattern. */
- std::string table;
-
- /** Column search pattern. */
- std::string column;
- };
-
- /**
- * Query get tables metadata request.
- */
- class QueryGetTablesMetaRequest
- {
- public:
- /**
- * Constructor.
- *
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableTypes Table types search pattern.
- */
- QueryGetTablesMetaRequest(const std::string& catalog, const std::string& schema,
- const std::string& table, const std::string& tableTypes) :
- catalog(catalog), schema(schema), table(table), tableTypes(tableTypes)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryGetTablesMetaRequest()
- {
- // No-op.
- }
-
- /**
- * Write request using provided writer.
- * @param writer Writer.
- */
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
- {
- writer.WriteInt8(REQUEST_TYPE_GET_TABLES_METADATA);
-
- utility::WriteString(writer, catalog);
- utility::WriteString(writer, schema);
- utility::WriteString(writer, table);
- utility::WriteString(writer, tableTypes);
- }
-
- private:
- /** Column search pattern. */
- std::string catalog;
-
- /** Schema search pattern. */
- std::string schema;
-
- /** Table search pattern. */
- std::string table;
-
- /** Column search pattern. */
- std::string tableTypes;
- };
-
- /**
- * Query close response.
- */
- class QueryResponse
- {
- public:
- /**
- * Constructor.
- */
- QueryResponse() : status(RESPONSE_STATUS_FAILED), error()
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryResponse()
- {
- // No-op.
- }
-
- /**
- * Read response using provided reader.
- * @param reader Reader.
- */
- void Read(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- status = reader.ReadInt8();
-
- if (status == RESPONSE_STATUS_SUCCESS)
- {
- ReadOnSuccess(reader);
- }
- else
- {
- int32_t errorLen = reader.ReadString(0, 0);
- error.resize(errorLen);
-
- reader.ReadString(&error[0], static_cast<int32_t>(error.size()));
- }
- }
-
- /**
- * Get request processing status.
- * @return Status.
- */
- int8_t GetStatus() const
- {
- return status;
- }
-
- /**
- * Get resulting error.
- * @return Error.
- */
- const std::string& GetError() const
- {
- return error;
- }
-
- protected:
- /**
- * Read data if response status is RESPONSE_STATUS_SUCCESS.
- * @param reader Reader.
- */
- virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader) = 0;
-
- private:
- /** Request processing status. */
- int8_t status;
-
- /** Error message. */
- std::string error;
- };
-
-
- /**
- * Query close response.
- */
- class QueryCloseResponse : public QueryResponse
- {
- public:
- /**
- * Constructor.
- */
- QueryCloseResponse() : queryId(0)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryCloseResponse()
- {
- // No-op.
- }
-
- /**
- * Get query ID.
- * @return Query ID.
- */
- int64_t GetQueryId() const
- {
- return queryId;
- }
-
- private:
- /**
- * Read response using provided reader.
- * @param reader Reader.
- */
- virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- queryId = reader.ReadInt64();
- }
-
- /** Query ID. */
- int64_t queryId;
- };
-
- /**
- * Query execute response.
- */
- class QueryExecuteResponse : public QueryResponse
- {
- public:
- /**
- * Constructor.
- */
- QueryExecuteResponse() : queryId(0), meta()
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryExecuteResponse()
- {
- // No-op.
- }
-
- /**
- * Get query ID.
- * @return Query ID.
- */
- int64_t GetQueryId() const
- {
- return queryId;
- }
-
- /**
- * Get column metadata.
- * @return Column metadata.
- */
- const meta::ColumnMetaVector& GetMeta() const
- {
- return meta;
- }
-
- private:
- /**
- * Read response using provided reader.
- * @param reader Reader.
- */
- virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- queryId = reader.ReadInt64();
-
- meta::ReadColumnMetaVector(reader, meta);
- }
-
- /** Query ID. */
- int64_t queryId;
-
- /** Columns metadata. */
- meta::ColumnMetaVector meta;
- };
-
- /**
- * Query fetch response.
- */
- class QueryFetchResponse : public QueryResponse
- {
- public:
- /**
- * Constructor.
- * @param resultPage Result page.
- */
- QueryFetchResponse(ResultPage& resultPage) : queryId(0), resultPage(resultPage)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryFetchResponse()
- {
- // No-op.
- }
-
- /**
- * Get query ID.
- * @return Query ID.
- */
- int64_t GetQueryId() const
- {
- return queryId;
- }
-
- private:
- /**
- * Read response using provided reader.
- * @param reader Reader.
- */
- virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- queryId = reader.ReadInt64();
-
- resultPage.Read(reader);
- }
-
- /** Query ID. */
- int64_t queryId;
-
- /** Result page. */
- ResultPage& resultPage;
- };
-
- /**
- * Query get column metadata response.
- */
- class QueryGetColumnsMetaResponse : public QueryResponse
- {
- public:
- /**
- * Constructor.
- */
- QueryGetColumnsMetaResponse()
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryGetColumnsMetaResponse()
- {
- // No-op.
- }
-
- /**
- * Get column metadata.
- * @return Column metadata.
- */
- const meta::ColumnMetaVector& GetMeta() const
- {
- return meta;
- }
-
- private:
- /**
- * Read response using provided reader.
- * @param reader Reader.
- */
- virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- meta::ReadColumnMetaVector(reader, meta);
- }
-
- /** Columns metadata. */
- meta::ColumnMetaVector meta;
- };
-
- /**
- * Query get table metadata response.
- */
- class QueryGetTablesMetaResponse : public QueryResponse
- {
- public:
- /**
- * Constructor.
- */
- QueryGetTablesMetaResponse()
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~QueryGetTablesMetaResponse()
- {
- // No-op.
- }
-
- /**
- * Get column metadata.
- * @return Column metadata.
- */
- const meta::TableMetaVector& GetMeta() const
- {
- return meta;
- }
-
- private:
- /**
- * Read response using provided reader.
- * @param reader Reader.
- */
- virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- meta::ReadTableMetaVector(reader, meta);
- }
-
- /** Columns metadata. */
- meta::TableMetaVector meta;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/column_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/column_meta.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/column_meta.h
deleted file mode 100644
index 9bc7227..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/meta/column_meta.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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_COLUMN_META
-#define _IGNITE_ODBC_COLUMN_META
-
-#include <stdint.h>
-#include <string>
-
-#include "ignite/impl/binary/binary_reader_impl.h"
-
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace meta
- {
- /**
- * Column metadata.
- */
- class ColumnMeta
- {
- public:
-#ifdef ODBC_DEBUG
- /**
- * Convert attribute ID to string containing its name.
- * Debug function.
- * @param type Attribute ID.
- * @return Null-terminated string containing attribute name.
- */
- static const char* AttrIdToString(uint16_t id);
-#endif
-
- /**
- * Default constructor.
- */
- ColumnMeta()
- {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param schemaName Schema name.
- * @param tableName Table name.
- * @param columnName Column name.
- * @param typeName Type name.
- * @param dataType Data type.
- */
- ColumnMeta(const std::string& schemaName, const std::string& tableName,
- const std::string& columnName, const std::string& typeName, int8_t dataType) :
- schemaName(schemaName), tableName(tableName), columnName(columnName),
- typeName(typeName), dataType(dataType)
- {
- // No-op.
- }
-
- /**
- * Destructor.
- */
- ~ColumnMeta()
- {
- // No-op.
- }
-
- /**
- * Copy constructor.
- */
- ColumnMeta(const ColumnMeta& other) :
- schemaName(other.schemaName),
- tableName(other.tableName),
- columnName(other.columnName),
- typeName(other.typeName),
- dataType(other.dataType)
- {
- // No-op.
- }
-
- /**
- * Copy operator.
- */
- ColumnMeta& operator=(const ColumnMeta& other)
- {
- schemaName = other.schemaName;
- tableName = other.tableName;
- columnName = other.columnName;
- typeName = other.typeName;
- dataType = other.dataType;
-
- return *this;
- }
-
- /**
- * Read using reader.
- * @param reader Reader.
- */
- void Read(ignite::impl::binary::BinaryReaderImpl& reader);
-
- /**
- * Get schema name.
- * @return Schema name.
- */
- const std::string& GetSchemaName() const
- {
- return schemaName;
- }
-
- /**
- * Get table name.
- * @return Table name.
- */
- const std::string& GetTableName() const
- {
- return tableName;
- }
-
- /**
- * Get column name.
- * @return Column name.
- */
- const std::string& GetColumnName() const
- {
- return columnName;
- }
-
- /**
- * Get column type name.
- * @return Column type name.
- */
- const std::string& GetColumnTypeName() const
- {
- return typeName;
- }
-
- /**
- * Get data type.
- * @return Data type.
- */
- int8_t GetDataType() const
- {
- return dataType;
- }
-
- /**
- * Try to get attribute of a string type.
- *
- * @param fieldId Field ID.
- * @param value Output attribute value.
- * @return True if the attribute supported and false otherwise.
- */
- bool GetAttribute(uint16_t fieldId, std::string& value) const;
-
- /**
- * Try to get attribute of a integer type.
- *
- * @param fieldId Field ID.
- * @param value Output attribute value.
- * @return True if the attribute supported and false otherwise.
- */
- bool GetAttribute(uint16_t fieldId, SqlLen& value) const;
-
- private:
- /** Schema name. */
- std::string schemaName;
-
- /** Table name. */
- std::string tableName;
-
- /** Column name. */
- std::string columnName;
-
- /** Type name. */
- std::string typeName;
-
- /** Data type. */
- int8_t dataType;
- };
-
- /** Column metadata vector alias. */
- typedef std::vector<ColumnMeta> ColumnMetaVector;
-
- /**
- * Read columns metadata collection.
- * @param reader Reader.
- * @param meta Collection.
- */
- void ReadColumnMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, ColumnMetaVector& meta);
- }
- }
-}
-
-#endif
\ No newline at end of file
[02/28] ignite git commit: IGNITE-2447: Renamed ODBC classes to
follow naming convention.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java
deleted file mode 100644
index 01e4ef5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/GridTcpOdbcServer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.protocol;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.configuration.ConnectorConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
-import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.processors.odbc.GridOdbcProtocolHandler;
-import org.apache.ignite.internal.processors.odbc.request.GridOdbcRequest;
-import org.apache.ignite.internal.util.nio.*;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.IgnitePortProtocol;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.ByteOrder;
-
-/**
- * TCP server that handles communication with ODBC driver.
- */
-public class GridTcpOdbcServer {
-
- /** Server. */
- private GridNioServer<GridOdbcRequest> srv;
-
- /** NIO server listener. */
- private GridNioServerListener<GridOdbcRequest> lsnr;
-
- /** Logger. */
- protected final IgniteLogger log;
-
- /** Context. */
- protected final GridKernalContext ctx;
-
- /** Host used by this protocol. */
- protected InetAddress host;
-
- /** Port used by this protocol. */
- protected int port;
-
- /** */
- public String name() {
- return "ODBC server";
- }
-
- public GridTcpOdbcServer(GridKernalContext ctx) {
- assert ctx != null;
- assert ctx.config().getConnectorConfiguration() != null;
-
- this.ctx = ctx;
-
- log = ctx.log(getClass());
- }
-
- @SuppressWarnings("BusyWait")
- public void start(final GridOdbcProtocolHandler hnd) throws IgniteCheckedException {
- OdbcConfiguration cfg = ctx.config().getOdbcConfiguration();
-
- assert cfg != null;
-
- lsnr = new GridTcpOdbcNioListener(log, this, ctx, hnd);
-
- GridNioParser parser = new GridOdbcParser(ctx);
-
- try {
- host = resolveOdbcTcpHost(ctx.config());
-
- int odbcPort = cfg.getPort();
-
- if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) {
- port = odbcPort;
-
- System.out.println("ODBC Server has started on TCP port " + port);
-
- return;
- }
-
- U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " +
- "[odbcPort=" + odbcPort + ", host=" + host + ']');
- }
- catch (IOException e) {
- U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(),
- "Failed to start " + name() + " on port " + port + ". " +
- "Check restTcpHost configuration property.");
- }
- }
-
- /** */
- public void onKernalStart() {
- }
-
- /** */
- public void stop() {
- if (srv != null) {
- ctx.ports().deregisterPorts(getClass());
-
- srv.stop();
- }
- }
-
- /**
- * Resolves host for server using grid configuration.
- *
- * @param cfg Grid configuration.
- * @return Host address.
- * @throws IOException If failed to resolve host.
- */
- private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException {
- String host = null;
-
- ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration();
-
- if (connectionCfg != null)
- host = connectionCfg.getHost();
-
- if (host == null)
- host = cfg.getLocalHost();
-
- return U.resolveLocalHost(host);
- }
-
- /**
- * Tries to start server with given parameters.
- *
- * @param hostAddr Host on which server should be bound.
- * @param port Port on which server should be bound.
- * @param lsnr Server message listener.
- * @param parser Server message parser.
- * @param cfg Configuration for other parameters.
- * @return {@code True} if server successfully started, {@code false} if port is used and
- * server was unable to start.
- */
- private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<GridOdbcRequest> lsnr,
- GridNioParser parser, OdbcConfiguration cfg) {
- try {
- GridNioFilter codec = new GridNioCodecFilter(parser, log, false);
-
- GridNioFilter[] filters;
-
- filters = new GridNioFilter[] { codec };
-
- srv = GridNioServer.<GridOdbcRequest>builder()
- .address(hostAddr)
- .port(port)
- .listener(lsnr)
- .logger(log)
- .selectorCount(cfg.getSelectorCount())
- .gridName(ctx.gridName())
- .tcpNoDelay(cfg.isNoDelay())
- .directBuffer(cfg.isDirectBuffer())
- .byteOrder(ByteOrder.nativeOrder())
- .socketSendBufferSize(cfg.getSendBufferSize())
- .socketReceiveBufferSize(cfg.getReceiveBufferSize())
- .sendQueueLimit(cfg.getSendQueueLimit())
- .filters(filters)
- .directMode(false)
- .build();
-
- srv.idleTimeout(cfg.getIdleTimeout());
-
- srv.start();
-
- ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
-
- return true;
- }
- catch (IgniteCheckedException e) {
- if (log.isDebugEnabled())
- log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage());
-
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java
new file mode 100644
index 0000000..602f859
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcParser.java
@@ -0,0 +1,345 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.protocol;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.binary.*;
+import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
+import org.apache.ignite.internal.processors.odbc.OdbcTableMeta;
+import org.apache.ignite.internal.processors.odbc.request.*;
+import org.apache.ignite.internal.processors.odbc.response.*;
+import org.apache.ignite.internal.util.nio.GridNioParser;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+
+
+/**
+ * ODBC protocol parser.
+ */
+public class OdbcParser implements GridNioParser {
+ /** Initial output stream capacity. */
+ private static final int INIT_CAP = 1024;
+
+ /** Length in bytes of the remaining message part. */
+ int leftToReceive = 0;
+
+ /** Already received bytes of current message. */
+ ByteBuffer currentMessage = null;
+
+ /** Context. */
+ protected final GridKernalContext ctx;
+
+ /** Marshaller. */
+ private final GridBinaryMarshaller marsh;
+
+ OdbcParser(GridKernalContext context) {
+ ctx = context;
+
+ CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
+
+ marsh = cacheObjProc.marshaller();
+ }
+
+ /**
+ * Process data chunk and try to construct new message using stored and freshly received data.
+ * @param buf Fresh data buffer.
+ * @return Instance of the {@link BinaryReaderExImpl} positioned to read from the beginning of the message on
+ * success and null otherwise.
+ */
+ private BinaryRawReaderEx tryConstructMessage(ByteBuffer buf) {
+ if (leftToReceive != 0) {
+ // Still receiving message
+ int toConsume = Math.min(leftToReceive, buf.remaining());
+
+ currentMessage.put(buf.array(), buf.arrayOffset(), toConsume);
+ leftToReceive -= toConsume;
+
+ buf.position(buf.position() + toConsume);
+
+ if (leftToReceive != 0)
+ return null;
+
+ BinaryInputStream stream = new BinaryHeapInputStream(currentMessage.array());
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
+
+ currentMessage = null;
+
+ return reader;
+ }
+
+ // Receiving new message
+ // Getting message length. It's in the first four bytes of the message.
+ BinaryInputStream stream = new BinaryHeapInputStream(buf.array());
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
+
+ int messageLen = reader.readInt();
+ buf.getInt();
+
+ int remaining = buf.remaining();
+
+ if (messageLen > remaining) {
+ leftToReceive = messageLen - remaining;
+
+ currentMessage = ByteBuffer.allocate(messageLen);
+ currentMessage.put(buf);
+
+ return null;
+ }
+
+ buf.position(buf.position() + messageLen);
+
+ return reader;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public OdbcRequest decode(GridNioSession ses, ByteBuffer buf) throws IOException,
+ IgniteCheckedException {
+ BinaryRawReaderEx messageReader = tryConstructMessage(buf);
+
+ return messageReader == null ? null : readRequest(ses, messageReader);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
+ assert msg != null;
+ assert msg instanceof OdbcResponse;
+
+ System.out.println("Encoding query processing result");
+
+ BinaryRawWriterEx writer = marsh.writer(new BinaryHeapOutputStream(INIT_CAP));
+
+ // Reserving space for the message length.
+ int msgLenPos = writer.reserveInt();
+
+ writeResponse(ses, writer, (OdbcResponse)msg);
+
+ int msgLenWithHdr = writer.out().position() - msgLenPos;
+
+ int msgLen = msgLenWithHdr - 4;
+
+ writer.writeInt(msgLenPos, msgLen);
+
+ ByteBuffer buf = ByteBuffer.allocate(msgLenWithHdr);
+
+ buf.put(writer.out().array(), msgLenPos, msgLenWithHdr);
+
+ buf.flip();
+
+ return buf;
+ }
+
+ /**
+ * Read ODBC request from the raw data using provided {@link BinaryReaderExImpl} instance.
+ * @param ses Current session.
+ * @param reader Reader positioned to read the request.
+ * @return Instance of the {@link OdbcRequest}.
+ * @throws IOException if the type of the request is unknown to the parser.
+ */
+ private OdbcRequest readRequest(GridNioSession ses, BinaryRawReaderEx reader) throws IOException {
+ OdbcRequest res;
+
+ byte cmd = reader.readByte();
+
+ switch (cmd) {
+ case OdbcRequest.EXECUTE_SQL_QUERY: {
+ String cache = reader.readString();
+ String sql = reader.readString();
+ int argsNum = reader.readInt();
+
+ System.out.println("Message EXECUTE_SQL_QUERY:");
+ System.out.println("cache: " + cache);
+ System.out.println("query: " + sql);
+ System.out.println("argsNum: " + argsNum);
+
+ Object[] params = new Object[argsNum];
+
+ for (int i = 0; i < argsNum; ++i)
+ params[i] = reader.readObjectDetached();
+
+ res = new OdbcQueryExecuteRequest(cache, sql, params);
+ break;
+ }
+
+ case OdbcRequest.FETCH_SQL_QUERY: {
+ long queryId = reader.readLong();
+ int pageSize = reader.readInt();
+
+ System.out.println("Message FETCH_SQL_QUERY:");
+ System.out.println("queryId: " + queryId);
+ System.out.println("pageSize: " + pageSize);
+
+ res = new OdbcQueryFetchRequest(queryId, pageSize);
+ break;
+ }
+
+ case OdbcRequest.CLOSE_SQL_QUERY: {
+ long queryId = reader.readLong();
+
+ System.out.println("Message CLOSE_SQL_QUERY:");
+ System.out.println("queryId: " + queryId);
+
+ res = new OdbcQueryCloseRequest(queryId);
+ break;
+ }
+
+ case OdbcRequest.GET_COLUMNS_META: {
+ String cache = reader.readString();
+ String table = reader.readString();
+ String column = reader.readString();
+
+ System.out.println("Message GET_COLUMNS_META:");
+ System.out.println("cache: " + cache);
+ System.out.println("table: " + table);
+ System.out.println("column: " + column);
+
+ res = new OdbcQueryGetColumnsMetaRequest(cache, table, column);
+ break;
+ }
+
+ case OdbcRequest.GET_TABLES_META: {
+ String catalog = reader.readString();
+ String schema = reader.readString();
+ String table = reader.readString();
+ String tableType = reader.readString();
+
+ System.out.println("Message GET_COLUMNS_META:");
+ System.out.println("catalog: " + catalog);
+ System.out.println("schema: " + schema);
+ System.out.println("table: " + table);
+ System.out.println("tableType: " + tableType);
+
+ res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
+ break;
+ }
+
+ default:
+ throw new IOException("Failed to parse incoming packet (unknown command type) [ses=" + ses +
+ ", cmd=[" + Byte.toString(cmd) + ']');
+ }
+
+ return res;
+ }
+
+ /**
+ * Write ODBC response using provided {@link BinaryRawWriterEx} instance.
+ * @param ses Current session.
+ * @param writer Writer.
+ * @param rsp ODBC response that should be written.
+ * @throws IOException if the type of the response is unknown to the parser.
+ */
+ private void writeResponse(GridNioSession ses, BinaryRawWriterEx writer, OdbcResponse rsp) throws IOException {
+ // Writing status
+ writer.writeByte((byte)rsp.getSuccessStatus());
+
+ if (rsp.getSuccessStatus() != OdbcResponse.STATUS_SUCCESS) {
+ writer.writeString(rsp.getError());
+
+ return;
+ }
+
+ Object res0 = rsp.getResponse();
+
+ if (res0 instanceof OdbcQueryExecuteResult) {
+ OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0;
+
+ System.out.println("Resulting query ID: " + res.getQueryId());
+
+ writer.writeLong(res.getQueryId());
+
+ Collection<OdbcColumnMeta> metas = res.getColumnsMetadata();
+
+ assert metas != null;
+
+ writer.writeInt(metas.size());
+
+ for (OdbcColumnMeta meta : metas)
+ meta.writeBinary(writer, marsh.context());
+
+ } else if (res0 instanceof OdbcQueryFetchResult) {
+ OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0;
+
+ System.out.println("Resulting query ID: " + res.getQueryId());
+
+ writer.writeLong(res.getQueryId());
+
+ Collection<?> items0 = res.getItems();
+
+ assert items0 != null;
+
+ Collection<Collection<Object>> items = (Collection<Collection<Object>>)items0;
+
+ writer.writeBoolean(res.getLast());
+
+ writer.writeInt(items.size());
+
+ for (Collection<Object> row : items) {
+ if (row != null) {
+ writer.writeInt(row.size());
+
+ for (Object obj : row) {
+ if (obj != null)
+ writer.writeObjectDetached(obj);
+ }
+ }
+ }
+ } else if (res0 instanceof OdbcQueryCloseResult) {
+ OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0;
+
+ System.out.println("Resulting query ID: " + res.getQueryId());
+
+ writer.writeLong(res.getQueryId());
+
+ } else if (res0 instanceof OdbcQueryGetColumnsMetaResult) {
+ OdbcQueryGetColumnsMetaResult res = (OdbcQueryGetColumnsMetaResult) res0;
+
+ Collection<OdbcColumnMeta> columnsMeta = res.getMeta();
+
+ assert columnsMeta != null;
+
+ writer.writeInt(columnsMeta.size());
+
+ for (OdbcColumnMeta columnMeta : columnsMeta)
+ columnMeta.writeBinary(writer, marsh.context());
+
+ } else if (res0 instanceof OdbcQueryGetTablesMetaResult) {
+ OdbcQueryGetTablesMetaResult res = (OdbcQueryGetTablesMetaResult) res0;
+
+ Collection<OdbcTableMeta> tablesMeta = res.getMeta();
+
+ assert tablesMeta != null;
+
+ writer.writeInt(tablesMeta.size());
+
+ for (OdbcTableMeta tableMeta : tablesMeta)
+ tableMeta.writeBinary(writer);
+
+ } else {
+ throw new IOException("Failed to serialize response packet (unknown response type) [ses=" + ses + "]");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java
new file mode 100644
index 0000000..656a477
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpNioListener.java
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.protocol;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.odbc.OdbcProtocolHandler;
+import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
+import org.apache.ignite.internal.processors.odbc.response.OdbcResponse;
+import org.apache.ignite.internal.util.nio.GridNioFuture;
+import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter;
+import org.apache.ignite.internal.util.nio.GridNioSession;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Listener for ODBC driver connection.
+ */
+public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest> {
+ /** Server. */
+ private OdbcTcpServer srv;
+
+ /** Logger. */
+ protected final IgniteLogger log;
+
+ /** Context. */
+ protected final GridKernalContext ctx;
+
+ /** Protocol handler. */
+ private OdbcProtocolHandler hnd;
+
+ OdbcTcpNioListener(IgniteLogger log, OdbcTcpServer srv, GridKernalContext ctx, OdbcProtocolHandler hnd) {
+ this.log = log;
+ this.srv = srv;
+ this.ctx = ctx;
+ this.hnd = hnd;
+ }
+
+ @Override
+ public void onConnected(GridNioSession ses) {
+ System.out.println("Driver connected");
+ }
+
+ @Override
+ public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
+ System.out.println("Driver disconnected");
+
+ if (e != null) {
+ if (e instanceof RuntimeException)
+ U.error(log, "Failed to process request from remote client: " + ses, e);
+ else
+ U.warn(log, "Closed client session due to exception [ses=" + ses + ", msg=" + e.getMessage() + ']');
+ }
+ }
+
+ @Override
+ public void onMessage(GridNioSession ses, OdbcRequest msg) {
+ assert msg != null;
+
+ System.out.println("Query: " + msg.command());
+
+ OdbcResponse res;
+
+ try {
+ res = hnd.handle(msg);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to process client request: " + msg, e);
+
+ res = new OdbcResponse(OdbcResponse.STATUS_FAILED,
+ "Failed to process client request: " + e.getMessage());
+ }
+
+ System.out.println("Resulting success status: " + res.getSuccessStatus());
+
+ GridNioFuture<?> sf = ses.send(res);
+
+ // Check if send failed.
+ if (sf.isDone()) {
+ try {
+ sf.get();
+ } catch (Exception e) {
+ U.error(log, "Failed to process client request [ses=" + ses + ", msg=" + msg + ']', e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java
new file mode 100644
index 0000000..4fbd326
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/protocol/OdbcTcpServer.java
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.protocol;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.OdbcConfiguration;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.odbc.OdbcProtocolHandler;
+import org.apache.ignite.internal.processors.odbc.request.OdbcRequest;
+import org.apache.ignite.internal.util.nio.*;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.IgnitePortProtocol;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.nio.ByteOrder;
+
+/**
+ * TCP server that handles communication with ODBC driver.
+ */
+public class OdbcTcpServer {
+
+ /** Server. */
+ private GridNioServer<OdbcRequest> srv;
+
+ /** NIO server listener. */
+ private GridNioServerListener<OdbcRequest> lsnr;
+
+ /** Logger. */
+ protected final IgniteLogger log;
+
+ /** Context. */
+ protected final GridKernalContext ctx;
+
+ /** Host used by this protocol. */
+ protected InetAddress host;
+
+ /** Port used by this protocol. */
+ protected int port;
+
+ /** */
+ public String name() {
+ return "ODBC server";
+ }
+
+ public OdbcTcpServer(GridKernalContext ctx) {
+ assert ctx != null;
+ assert ctx.config().getConnectorConfiguration() != null;
+
+ this.ctx = ctx;
+
+ log = ctx.log(getClass());
+ }
+
+ @SuppressWarnings("BusyWait")
+ public void start(final OdbcProtocolHandler hnd) throws IgniteCheckedException {
+ OdbcConfiguration cfg = ctx.config().getOdbcConfiguration();
+
+ assert cfg != null;
+
+ lsnr = new OdbcTcpNioListener(log, this, ctx, hnd);
+
+ GridNioParser parser = new OdbcParser(ctx);
+
+ try {
+ host = resolveOdbcTcpHost(ctx.config());
+
+ int odbcPort = cfg.getPort();
+
+ if (startTcpServer(host, odbcPort, lsnr, parser, cfg)) {
+ port = odbcPort;
+
+ System.out.println("ODBC Server has started on TCP port " + port);
+
+ return;
+ }
+
+ U.warn(log, "Failed to start " + name() + " (possibly all ports in range are in use) " +
+ "[odbcPort=" + odbcPort + ", host=" + host + ']');
+ }
+ catch (IOException e) {
+ U.warn(log, "Failed to start " + name() + " on port " + port + ": " + e.getMessage(),
+ "Failed to start " + name() + " on port " + port + ". " +
+ "Check restTcpHost configuration property.");
+ }
+ }
+
+ /** */
+ public void onKernalStart() {
+ }
+
+ /** */
+ public void stop() {
+ if (srv != null) {
+ ctx.ports().deregisterPorts(getClass());
+
+ srv.stop();
+ }
+ }
+
+ /**
+ * Resolves host for server using grid configuration.
+ *
+ * @param cfg Grid configuration.
+ * @return Host address.
+ * @throws IOException If failed to resolve host.
+ */
+ private InetAddress resolveOdbcTcpHost(IgniteConfiguration cfg) throws IOException {
+ String host = null;
+
+ ConnectorConfiguration connectionCfg = cfg.getConnectorConfiguration();
+
+ if (connectionCfg != null)
+ host = connectionCfg.getHost();
+
+ if (host == null)
+ host = cfg.getLocalHost();
+
+ return U.resolveLocalHost(host);
+ }
+
+ /**
+ * Tries to start server with given parameters.
+ *
+ * @param hostAddr Host on which server should be bound.
+ * @param port Port on which server should be bound.
+ * @param lsnr Server message listener.
+ * @param parser Server message parser.
+ * @param cfg Configuration for other parameters.
+ * @return {@code True} if server successfully started, {@code false} if port is used and
+ * server was unable to start.
+ */
+ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener<OdbcRequest> lsnr,
+ GridNioParser parser, OdbcConfiguration cfg) {
+ try {
+ GridNioFilter codec = new GridNioCodecFilter(parser, log, false);
+
+ GridNioFilter[] filters;
+
+ filters = new GridNioFilter[] { codec };
+
+ srv = GridNioServer.<OdbcRequest>builder()
+ .address(hostAddr)
+ .port(port)
+ .listener(lsnr)
+ .logger(log)
+ .selectorCount(cfg.getSelectorCount())
+ .gridName(ctx.gridName())
+ .tcpNoDelay(cfg.isNoDelay())
+ .directBuffer(cfg.isDirectBuffer())
+ .byteOrder(ByteOrder.nativeOrder())
+ .socketSendBufferSize(cfg.getSendBufferSize())
+ .socketReceiveBufferSize(cfg.getReceiveBufferSize())
+ .sendQueueLimit(cfg.getSendQueueLimit())
+ .filters(filters)
+ .directMode(false)
+ .build();
+
+ srv.idleTimeout(cfg.getIdleTimeout());
+
+ srv.start();
+
+ ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to start " + name() + " on port " + port + ": " + e.getMessage());
+
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java
deleted file mode 100644
index c3738e2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/GridOdbcRequest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC command request.
- */
-public class GridOdbcRequest {
- /** Execute sql query. */
- public static final int EXECUTE_SQL_QUERY = 1;
-
- /** Fetch query results. */
- public static final int FETCH_SQL_QUERY = 2;
-
- /** Close query. */
- public static final int CLOSE_SQL_QUERY = 3;
-
- /** Get columns meta query. */
- public static final int GET_COLUMNS_META = 4;
-
- /** Get columns meta query. */
- public static final int GET_TABLES_META = 5;
-
- /** Command. */
- private int cmd;
-
- /**
- * @param cmd Command type.
- */
- public GridOdbcRequest(int cmd) {
- this.cmd = cmd;
- }
-
- /**
- * @return Command.
- */
- public int command() {
- return cmd;
- }
-
- /**
- * @param cmd Command.
- */
- public void command(int cmd) {
- this.cmd = cmd;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java
new file mode 100644
index 0000000..8ebcca1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryCloseRequest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.request;
+
+/**
+ * ODBC query close request.
+ */
+public class OdbcQueryCloseRequest extends OdbcRequest {
+ /** Query ID. */
+ private long queryId;
+
+ /**
+ * @param queryId Query ID.
+ */
+ public OdbcQueryCloseRequest(long queryId) {
+ super(CLOSE_SQL_QUERY);
+ this.queryId = queryId;
+ }
+
+ /**
+ * @param queryId Query ID.
+ */
+ public void cacheName(long queryId) {
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long queryId() {
+ return queryId;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java
new file mode 100644
index 0000000..a5da36a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.request;
+
+/**
+ * ODBC query execute request.
+ */
+public class OdbcQueryExecuteRequest extends OdbcRequest {
+ /** Cache name. */
+ private String cacheName;
+
+ /** Sql query. */
+ private String sqlQry;
+
+ /** Sql query arguments. */
+ private Object[] args;
+
+ /**
+ * @param cacheName Cache name.
+ * @param sqlQry SQL query.
+ * @param args Arguments list.
+ */
+ public OdbcQueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
+ super(EXECUTE_SQL_QUERY);
+ this.cacheName = cacheName;
+ this.sqlQry = sqlQry;
+ this.args = args;
+ }
+
+ /**
+ * @param sqlQry Sql query.
+ */
+ public void sqlQuery(String sqlQry) {
+ this.sqlQry = sqlQry;
+ }
+
+ /**
+ * @return Sql query.
+ */
+ public String sqlQuery() {
+ return sqlQry;
+ }
+
+ /**
+ * @param args Sql query arguments.
+ */
+ public void arguments(Object[] args) {
+ this.args = args;
+ }
+
+ /**
+ * @return Sql query arguments.
+ */
+ public Object[] arguments() {
+ return args;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public void cacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ public String cacheName() {
+ return cacheName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java
new file mode 100644
index 0000000..d30ecf7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.request;
+
+/**
+ * ODBC query fetch request.
+ */
+public class OdbcQueryFetchRequest extends OdbcRequest {
+ /** Query ID. */
+ private long queryId;
+
+ /** Page size - maximum number of rows to return. */
+ private Integer pageSize;
+
+ /**
+ * @param queryId Query ID.
+ * @param pageSize Page size.
+ */
+ public OdbcQueryFetchRequest(long queryId, int pageSize) {
+ super(FETCH_SQL_QUERY);
+ this.queryId = queryId;
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * @param pageSize Page size.
+ */
+ public void pageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ /**
+ * @return Page size.
+ */
+ public int pageSize() {
+ return pageSize;
+ }
+
+ /**
+ * @param queryId Query ID.
+ */
+ public void cacheName(long queryId) {
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long queryId() {
+ return queryId;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java
new file mode 100644
index 0000000..3ab2a16
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.request;
+
+/**
+ * ODBC query get columns meta request.
+ */
+public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
+ /** Cache name. */
+ private String cacheName;
+
+ /** Table name. */
+ private String tableName;
+
+ /** Column name. */
+ private String columnName;
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
+ super(GET_COLUMNS_META);
+
+ this.cacheName = cacheName;
+ this.tableName = tableName;
+ this.columnName = columnName;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ public void cacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ public String cacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @param tableName Table name.
+ */
+ public void tableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ /**
+ * @return Table name.
+ */
+ public String tableName() {
+ return tableName;
+ }
+
+ /**
+ * @param columnName Column name.
+ */
+ public void columnName(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * @return Column name.
+ */
+ public String columnName() {
+ return columnName;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java
new file mode 100644
index 0000000..811091c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.request;
+
+/**
+ * ODBC query get tables meta request.
+ */
+public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
+ /** Catalog search pattern. */
+ private String catalog;
+
+ /** Schema search pattern. */
+ private String schema;
+
+ /** Table search pattern. */
+ private String table;
+
+ /** Table type search pattern. */
+ private String tableType;
+
+ /**
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableType Table type search pattern.
+ */
+ public OdbcQueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) {
+ super(GET_TABLES_META);
+
+ this.catalog = catalog;
+ this.schema = schema;
+ this.table = table;
+ this.tableType = tableType;
+ }
+
+ /**
+ * @param catalog Catalog search pattern.
+ */
+ public void catalog(String catalog) {
+ this.catalog = catalog;
+ }
+
+ /**
+ * @return catalog search pattern.
+ */
+ public String catalog() {
+ return catalog;
+ }
+
+ /**
+ * @param schema Schema search pattern.
+ */
+ public void schema(String schema) {
+ this.schema = schema;
+ }
+
+ /**
+ * @return Schema search pattern.
+ */
+ public String schema() {
+ return schema;
+ }
+
+ /**
+ * @param table Schema search pattern.
+ */
+ public void table(String table) {
+ this.table = table;
+ }
+
+ /**
+ * @return Table search pattern.
+ */
+ public String table() {
+ return table;
+ }
+
+ /**
+ * @param tableType Table type search pattern.
+ */
+ public void tableType(String tableType) {
+ this.tableType = tableType;
+ }
+
+ /**
+ * @return Table type search pattern.
+ */
+ public String tableType() {
+ return tableType;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java
new file mode 100644
index 0000000..63bd747
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.request;
+
+/**
+ * ODBC command request.
+ */
+public class OdbcRequest {
+ /** Execute sql query. */
+ public static final int EXECUTE_SQL_QUERY = 1;
+
+ /** Fetch query results. */
+ public static final int FETCH_SQL_QUERY = 2;
+
+ /** Close query. */
+ public static final int CLOSE_SQL_QUERY = 3;
+
+ /** Get columns meta query. */
+ public static final int GET_COLUMNS_META = 4;
+
+ /** Get columns meta query. */
+ public static final int GET_TABLES_META = 5;
+
+ /** Command. */
+ private int cmd;
+
+ /**
+ * @param cmd Command type.
+ */
+ public OdbcRequest(int cmd) {
+ this.cmd = cmd;
+ }
+
+ /**
+ * @return Command.
+ */
+ public int command() {
+ return cmd;
+ }
+
+ /**
+ * @param cmd Command.
+ */
+ public void command(int cmd) {
+ this.cmd = cmd;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java
deleted file mode 100644
index 4ddbec4..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryCloseRequest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query close request.
- */
-public class QueryCloseRequest extends GridOdbcRequest {
- /** Query ID. */
- private long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public QueryCloseRequest(long queryId) {
- super(CLOSE_SQL_QUERY);
- this.queryId = queryId;
- }
-
- /**
- * @param queryId Query ID.
- */
- public void cacheName(long queryId) {
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java
deleted file mode 100644
index 9a16894..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryExecuteRequest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query execute request.
- */
-public class QueryExecuteRequest extends GridOdbcRequest {
- /** Cache name. */
- private String cacheName;
-
- /** Sql query. */
- private String sqlQry;
-
- /** Sql query arguments. */
- private Object[] args;
-
- /**
- * @param cacheName Cache name.
- * @param sqlQry SQL query.
- * @param args Arguments list.
- */
- public QueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
- super(EXECUTE_SQL_QUERY);
- this.cacheName = cacheName;
- this.sqlQry = sqlQry;
- this.args = args;
- }
-
- /**
- * @param sqlQry Sql query.
- */
- public void sqlQuery(String sqlQry) {
- this.sqlQry = sqlQry;
- }
-
- /**
- * @return Sql query.
- */
- public String sqlQuery() {
- return sqlQry;
- }
-
- /**
- * @param args Sql query arguments.
- */
- public void arguments(Object[] args) {
- this.args = args;
- }
-
- /**
- * @return Sql query arguments.
- */
- public Object[] arguments() {
- return args;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java
deleted file mode 100644
index 3f671dd..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryFetchRequest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query fetch request.
- */
-public class QueryFetchRequest extends GridOdbcRequest {
- /** Query ID. */
- private long queryId;
-
- /** Page size - maximum number of rows to return. */
- private Integer pageSize;
-
- /**
- * @param queryId Query ID.
- * @param pageSize Page size.
- */
- public QueryFetchRequest(long queryId, int pageSize) {
- super(FETCH_SQL_QUERY);
- this.queryId = queryId;
- this.pageSize = pageSize;
- }
-
- /**
- * @param pageSize Page size.
- */
- public void pageSize(Integer pageSize) {
- this.pageSize = pageSize;
- }
-
- /**
- * @return Page size.
- */
- public int pageSize() {
- return pageSize;
- }
-
- /**
- * @param queryId Query ID.
- */
- public void cacheName(long queryId) {
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java
deleted file mode 100644
index 255ef41..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetColumnsMetaRequest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query get columns meta request.
- */
-public class QueryGetColumnsMetaRequest extends GridOdbcRequest {
- /** Cache name. */
- private String cacheName;
-
- /** Table name. */
- private String tableName;
-
- /** Column name. */
- private String columnName;
-
- /**
- * @param cacheName Cache name.
- */
- public QueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
- super(GET_COLUMNS_META);
-
- this.cacheName = cacheName;
- this.tableName = tableName;
- this.columnName = columnName;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-
- /**
- * @param tableName Table name.
- */
- public void tableName(String tableName) {
- this.tableName = tableName;
- }
-
- /**
- * @return Table name.
- */
- public String tableName() {
- return tableName;
- }
-
- /**
- * @param columnName Column name.
- */
- public void columnName(String columnName) {
- this.columnName = columnName;
- }
-
- /**
- * @return Column name.
- */
- public String columnName() {
- return columnName;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java
deleted file mode 100644
index c92dcd7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/QueryGetTablesMetaRequest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query get tables meta request.
- */
-public class QueryGetTablesMetaRequest extends GridOdbcRequest {
- /** Catalog search pattern. */
- private String catalog;
-
- /** Schema search pattern. */
- private String schema;
-
- /** Table search pattern. */
- private String table;
-
- /** Table type search pattern. */
- private String tableType;
-
- /**
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableType Table type search pattern.
- */
- public QueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) {
- super(GET_TABLES_META);
-
- this.catalog = catalog;
- this.schema = schema;
- this.table = table;
- this.tableType = tableType;
- }
-
- /**
- * @param catalog Catalog search pattern.
- */
- public void catalog(String catalog) {
- this.catalog = catalog;
- }
-
- /**
- * @return catalog search pattern.
- */
- public String catalog() {
- return catalog;
- }
-
- /**
- * @param schema Schema search pattern.
- */
- public void schema(String schema) {
- this.schema = schema;
- }
-
- /**
- * @return Schema search pattern.
- */
- public String schema() {
- return schema;
- }
-
- /**
- * @param table Schema search pattern.
- */
- public void table(String table) {
- this.table = table;
- }
-
- /**
- * @return Table search pattern.
- */
- public String table() {
- return table;
- }
-
- /**
- * @param tableType Table type search pattern.
- */
- public void tableType(String tableType) {
- this.tableType = tableType;
- }
-
- /**
- * @return Table type search pattern.
- */
- public String tableType() {
- return tableType;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java
deleted file mode 100644
index 2167272..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/GridOdbcResponse.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * ODBC protocol response.
- */
-public class GridOdbcResponse {
-
- /** Command succeeded. */
- public static final int STATUS_SUCCESS = 0;
-
- /** Command failed. */
- public static final int STATUS_FAILED = 1;
-
- /** Success status. */
- @SuppressWarnings("RedundantFieldInitialization")
- private int successStatus = STATUS_SUCCESS;
-
- /** Error. */
- private String err;
-
- /** Response object. */
- @GridToStringInclude
- private Object obj;
-
- /**
- * Constructs successful rest response.
- *
- * @param obj Response object.
- */
- public GridOdbcResponse(Object obj) {
- successStatus = STATUS_SUCCESS;
- this.obj = obj;
- }
-
- /**
- * Constructs failed rest response.
- *
- * @param status Response status.
- * @param err Error, {@code null} if success is {@code true}.
- */
- public GridOdbcResponse(int status, @Nullable String err) {
- assert status != STATUS_SUCCESS;
-
- successStatus = status;
- this.err = err;
- }
-
- /**
- * @return Success flag.
- */
- public int getSuccessStatus() {
- return successStatus;
- }
-
- /**
- * @return Response object.
- */
- public Object getResponse() {
- return obj;
- }
-
- /**
- * @param obj Response object.
- */
- public void setResponse(@Nullable Object obj) {
- this.obj = obj;
- }
-
- /**
- * @return Error.
- */
- public String getError() {
- return err;
- }
-
- /**
- * @param err Error.
- */
- public void setError(String err) {
- this.err = err;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridOdbcResponse.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java
new file mode 100644
index 0000000..c8cdd2c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.response;
+
+/**
+ * Query result.
+ */
+public class OdbcQueryCloseResult {
+ /** Query ID. */
+ private long queryId;
+
+ /**
+ * @param queryId Query ID.
+ */
+ public OdbcQueryCloseResult(long queryId){
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long getQueryId() {
+ return queryId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java
new file mode 100644
index 0000000..119470e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.response;
+
+import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
+
+import java.util.Collection;
+
+/**
+ * Query execute result.
+ */
+public class OdbcQueryExecuteResult {
+ /** Query ID. */
+ private long queryId;
+
+ /** Fields metadata. */
+ private Collection<OdbcColumnMeta> columnsMeta;
+
+ /**
+ * @param queryId Query ID.
+ * @param columnsMeta Columns metadata.
+ */
+ public OdbcQueryExecuteResult(long queryId, Collection<OdbcColumnMeta> columnsMeta){
+ this.queryId = queryId;
+ this.columnsMeta = columnsMeta;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long getQueryId() {
+ return queryId;
+ }
+
+ /**
+ * @return Columns metadata.
+ */
+ public Collection<OdbcColumnMeta> getColumnsMetadata() {
+ return columnsMeta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java
new file mode 100644
index 0000000..8385301
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.response;
+
+import java.util.Collection;
+
+/**
+ * Query fetch result.
+ */
+public class OdbcQueryFetchResult {
+ /** Query ID. */
+ private long queryId;
+
+ /** Query result rows. */
+ private Collection<?> items = null;
+
+ /** Flag indicating the query has no unfetched results. */
+ private boolean last = false;
+
+ /**
+ * @param queryId Query ID.
+ */
+ public OdbcQueryFetchResult(long queryId){
+ this.queryId = queryId;
+ }
+
+ /**
+ * @return Query ID.
+ */
+ public long getQueryId() {
+ return queryId;
+ }
+
+ /**
+ * @param items Query result rows.
+ */
+ public void setItems(Collection<?> items) {
+ this.items = items;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public Collection<?> getItems() {
+ return items;
+ }
+
+ /**
+ * @param last Flag indicating the query has no unfetched results.
+ */
+ public void setLast(boolean last) {
+ this.last = last;
+ }
+
+ /**
+ * @return Flag indicating the query has no unfetched results.
+ */
+ public boolean getLast() {
+ return last;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java
new file mode 100644
index 0000000..46373ba
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.response;
+
+import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
+
+import java.util.Collection;
+
+/**
+ * Query get columns meta result.
+ */
+public class OdbcQueryGetColumnsMetaResult {
+ /** Query result rows. */
+ private Collection<OdbcColumnMeta> meta;
+
+ /**
+ * @param meta Column metadata.
+ */
+ public OdbcQueryGetColumnsMetaResult(Collection<OdbcColumnMeta> meta) {
+ this.meta = meta;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public Collection<OdbcColumnMeta> getMeta() {
+ return meta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java
new file mode 100644
index 0000000..3d3cb86
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.response;
+
+import org.apache.ignite.internal.processors.odbc.OdbcTableMeta;
+
+import java.util.Collection;
+
+/**
+ * Query get columns meta result.
+ */
+public class OdbcQueryGetTablesMetaResult {
+ /** Query result rows. */
+ private Collection<OdbcTableMeta> meta;
+
+ /**
+ * @param meta Column metadata.
+ */
+ public OdbcQueryGetTablesMetaResult(Collection<OdbcTableMeta> meta) {
+ this.meta = meta;
+ }
+
+ /**
+ * @return Query result rows.
+ */
+ public Collection<OdbcTableMeta> getMeta() {
+ return meta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java
new file mode 100644
index 0000000..038275d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.ignite.internal.processors.odbc.response;
+
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * ODBC protocol response.
+ */
+public class OdbcResponse {
+
+ /** Command succeeded. */
+ public static final int STATUS_SUCCESS = 0;
+
+ /** Command failed. */
+ public static final int STATUS_FAILED = 1;
+
+ /** Success status. */
+ @SuppressWarnings("RedundantFieldInitialization")
+ private int successStatus = STATUS_SUCCESS;
+
+ /** Error. */
+ private String err;
+
+ /** Response object. */
+ @GridToStringInclude
+ private Object obj;
+
+ /**
+ * Constructs successful rest response.
+ *
+ * @param obj Response object.
+ */
+ public OdbcResponse(Object obj) {
+ successStatus = STATUS_SUCCESS;
+ this.obj = obj;
+ }
+
+ /**
+ * Constructs failed rest response.
+ *
+ * @param status Response status.
+ * @param err Error, {@code null} if success is {@code true}.
+ */
+ public OdbcResponse(int status, @Nullable String err) {
+ assert status != STATUS_SUCCESS;
+
+ successStatus = status;
+ this.err = err;
+ }
+
+ /**
+ * @return Success flag.
+ */
+ public int getSuccessStatus() {
+ return successStatus;
+ }
+
+ /**
+ * @return Response object.
+ */
+ public Object getResponse() {
+ return obj;
+ }
+
+ /**
+ * @param obj Response object.
+ */
+ public void setResponse(@Nullable Object obj) {
+ this.obj = obj;
+ }
+
+ /**
+ * @return Error.
+ */
+ public String getError() {
+ return err;
+ }
+
+ /**
+ * @param err Error.
+ */
+ public void setError(String err) {
+ this.err = err;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(OdbcResponse.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java
deleted file mode 100644
index 2d7521c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryCloseResult.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-/**
- * Query result.
- */
-public class QueryCloseResult {
- /** Query ID. */
- private long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public QueryCloseResult(long queryId){
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java
deleted file mode 100644
index aa4c928..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryExecuteResult.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.processors.odbc.GridOdbcColumnMeta;
-
-import java.util.Collection;
-
-/**
- * Query execute result.
- */
-public class QueryExecuteResult {
- /** Query ID. */
- private long queryId;
-
- /** Fields metadata. */
- private Collection<GridOdbcColumnMeta> columnsMeta;
-
- /**
- * @param queryId Query ID.
- * @param columnsMeta Columns metadata.
- */
- public QueryExecuteResult(long queryId,Collection<GridOdbcColumnMeta> columnsMeta){
- this.queryId = queryId;
- this.columnsMeta = columnsMeta;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-
- /**
- * @return Columns metadata.
- */
- public Collection<GridOdbcColumnMeta> getColumnsMetadata() {
- return columnsMeta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9baf2668/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java
deleted file mode 100644
index 17cf396..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/QueryFetchResult.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import java.util.Collection;
-
-/**
- * Query fetch result.
- */
-public class QueryFetchResult {
- /** Query ID. */
- private long queryId;
-
- /** Query result rows. */
- private Collection<?> items = null;
-
- /** Flag indicating the query has no unfetched results. */
- private boolean last = false;
-
- /**
- * @param queryId Query ID.
- */
- public QueryFetchResult(long queryId){
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-
- /**
- * @param items Query result rows.
- */
- public void setItems(Collection<?> items) {
- this.items = items;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<?> getItems() {
- return items;
- }
-
- /**
- * @param last Flag indicating the query has no unfetched results.
- */
- public void setLast(boolean last) {
- this.last = last;
- }
-
- /**
- * @return Flag indicating the query has no unfetched results.
- */
- public boolean getLast() {
- return last;
- }
-}
[14/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/common_types.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/common_types.cpp b/modules/platforms/cpp/odbc/src/common_types.cpp
new file mode 100644
index 0000000..276d9fd
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/common_types.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/common_types.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ int SqlResultToReturnCode(SqlResult result)
+ {
+ switch (result)
+ {
+ case SQL_RESULT_SUCCESS:
+ return SQL_SUCCESS;
+
+ case SQL_RESULT_SUCCESS_WITH_INFO:
+ return SQL_SUCCESS_WITH_INFO;
+
+ case SQL_RESULT_NO_DATA:
+ return SQL_NO_DATA;
+
+ case SQL_RESULT_ERROR:
+ default:
+ return SQL_ERROR;
+ }
+ }
+
+ DiagnosticField DiagnosticFieldToInternal(int16_t field)
+ {
+ switch (field)
+ {
+ case SQL_DIAG_CURSOR_ROW_COUNT:
+ return IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT;
+
+ case SQL_DIAG_DYNAMIC_FUNCTION:
+ return IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION;
+
+ case SQL_DIAG_DYNAMIC_FUNCTION_CODE:
+ return IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE;
+
+ case SQL_DIAG_NUMBER:
+ return IGNITE_SQL_DIAG_HEADER_NUMBER;
+
+ case SQL_DIAG_RETURNCODE:
+ return IGNITE_SQL_DIAG_HEADER_RETURNCODE;
+
+ case SQL_DIAG_ROW_COUNT:
+ return IGNITE_SQL_DIAG_HEADER_ROW_COUNT;
+
+ case SQL_DIAG_CLASS_ORIGIN:
+ return IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN;
+
+ case SQL_DIAG_COLUMN_NUMBER:
+ return IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER;
+
+ case SQL_DIAG_CONNECTION_NAME:
+ return IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME;
+
+ case SQL_DIAG_MESSAGE_TEXT:
+ return IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT;
+
+ case SQL_DIAG_NATIVE:
+ return IGNITE_SQL_DIAG_STATUS_NATIVE;
+
+ case SQL_DIAG_ROW_NUMBER:
+ return IGNITE_SQL_DIAG_STATUS_ROW_NUMBER;
+
+ case SQL_DIAG_SERVER_NAME:
+ return IGNITE_SQL_DIAG_STATUS_SERVER_NAME;
+
+ case SQL_DIAG_SQLSTATE:
+ return IGNITE_SQL_DIAG_STATUS_SQLSTATE;
+
+ case SQL_DIAG_SUBCLASS_ORIGIN:
+ return IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN;
+
+ default:
+ break;
+ }
+
+ return IGNITE_SQL_DIAG_UNKNOWN;
+ }
+
+ EnvironmentAttribute EnvironmentAttributeToInternal(int32_t attr)
+ {
+ switch (attr)
+ {
+ case SQL_ATTR_ODBC_VERSION:
+ return IGNITE_SQL_ENV_ATTR_ODBC_VERSION;
+
+ case SQL_ATTR_OUTPUT_NTS:
+ return IGNITE_SQL_ENV_ATTR_OUTPUT_NTS;
+
+ default:
+ break;
+ }
+
+ return IGNITE_SQL_ENV_ATTR_UNKNOWN;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp
new file mode 100644
index 0000000..08ee54b
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp
@@ -0,0 +1,245 @@
+/*
+ * 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 <cstring>
+
+#include <string>
+#include <sstream>
+#include <algorithm>
+#include <iterator>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/config/configuration.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace config
+ {
+ /** Default values for configuration. */
+ namespace dflt
+ {
+ /** Default value for DSN attribute. */
+ const std::string dsn = "Default Apache Ignite DSN";
+
+ /** Default value for Driver attribute. */
+ const std::string driver = "Apache Ignite";
+
+ /** Default value for host attribute. */
+ const std::string host = "localhost";
+
+ /** Default value for port attribute. */
+ const uint16_t port = 11443;
+
+ /** Default value for cache attribute. */
+ const std::string cache = "Persons";
+ }
+
+ /** Connection attribute keywords. */
+ namespace attrkey
+ {
+ /** Connection attribute keyword for DSN attribute. */
+ const std::string dsn = "dsn";
+
+ /** Connection attribute keyword for Driver attribute. */
+ const std::string driver = "driver";
+
+ /** Connection attribute keyword for server host attribute. */
+ const std::string host = "server";
+
+ /** Connection attribute keyword for server port attribute. */
+ const std::string port = "port";
+
+ /** Default value for cache attribute. */
+ const std::string cache = "cache";
+ }
+
+ Configuration::Configuration() :
+ dsn(dflt::dsn), driver(dflt::driver),
+ host(dflt::host), port(dflt::port),
+ cache(dflt::cache)
+ {
+ // No-op.
+ }
+
+ Configuration::~Configuration()
+ {
+ // No-op.
+ }
+
+ void Configuration::FillFromConnectString(const char* str, size_t len)
+ {
+ ArgumentMap connect_attributes;
+
+ ParseAttributeList(str, len, ';', connect_attributes);
+
+ ArgumentMap::const_iterator it;
+
+ it = connect_attributes.find(attrkey::dsn);
+ if (it != connect_attributes.end())
+ dsn = it->second;
+ else
+ dsn.clear();
+
+ it = connect_attributes.find(attrkey::driver);
+ if (it != connect_attributes.end())
+ driver = it->second;
+ else
+ driver = dflt::driver;
+
+ it = connect_attributes.find(attrkey::host);
+ if (it != connect_attributes.end())
+ host = it->second;
+ else
+ host = dflt::host;
+
+ it = connect_attributes.find(attrkey::port);
+ if (it != connect_attributes.end())
+ port = atoi(it->second.c_str());
+ else
+ port = dflt::port;
+
+ it = connect_attributes.find(attrkey::cache);
+ if (it != connect_attributes.end())
+ cache = it->second;
+ else
+ cache = dflt::cache;
+ }
+
+ void Configuration::FillFromConnectString(const std::string& str)
+ {
+ FillFromConnectString(str.data(), str.size());
+ }
+
+ std::string Configuration::ToConnectString() const
+ {
+ std::stringstream connect_string_buffer;
+
+ if (!driver.empty())
+ connect_string_buffer << attrkey::driver << "={" << driver << "};";
+
+ if (!host.empty())
+ connect_string_buffer << attrkey::host << '=' << host << ';';
+
+ if (port)
+ connect_string_buffer << attrkey::port << '=' << port << ';';
+
+ if (!dsn.empty())
+ connect_string_buffer << attrkey::dsn << '=' << dsn << ';';
+
+ if (!cache.empty())
+ connect_string_buffer << attrkey::cache << '=' << cache << ';';
+
+ return connect_string_buffer.str();
+ }
+
+ void Configuration::FillFromConfigAttributes(const char * attributes)
+ {
+ ArgumentMap config_attributes;
+
+ size_t len = 0;
+
+ // Getting list length. List is terminated by two '\0'.
+ while (attributes[len] || attributes[len + 1])
+ ++len;
+
+ ++len;
+
+ ParseAttributeList(attributes, len, '\0', config_attributes);
+
+ ArgumentMap::const_iterator it;
+
+ it = config_attributes.find(attrkey::dsn);
+ if (it != config_attributes.end())
+ dsn = it->second;
+ else
+ dsn = dflt::dsn;
+
+ it = config_attributes.find(attrkey::driver);
+ if (it != config_attributes.end())
+ driver = it->second;
+ else
+ driver.clear();
+
+ it = config_attributes.find(attrkey::host);
+ if (it != config_attributes.end())
+ host = it->second;
+ else
+ host.clear();
+
+ it = config_attributes.find(attrkey::port);
+ if (it != config_attributes.end())
+ port = atoi(it->second.c_str());
+ else
+ port = 0;
+
+ it = config_attributes.find(attrkey::cache);
+ if (it != config_attributes.end())
+ cache = it->second;
+ else
+ cache.clear();
+ }
+
+ void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args) const
+ {
+ std::string connect_str(str, len);
+ args.clear();
+
+ while (!connect_str.empty())
+ {
+ size_t attr_begin = connect_str.rfind(delimeter);
+
+ if (attr_begin == std::string::npos)
+ attr_begin = 0;
+ else
+ ++attr_begin;
+
+ size_t attr_eq_pos = connect_str.rfind('=');
+
+ if (attr_eq_pos == std::string::npos)
+ attr_eq_pos = 0;
+
+ if (attr_begin < attr_eq_pos)
+ {
+ const char* key_begin = connect_str.data() + attr_begin;
+ const char* key_end = connect_str.data() + attr_eq_pos;
+
+ const char* value_begin = connect_str.data() + attr_eq_pos + 1;
+ const char* value_end = connect_str.data() + connect_str.size();
+
+ std::string key = utility::RemoveSurroundingSpaces(key_begin, key_end);
+ std::string value = utility::RemoveSurroundingSpaces(value_begin, value_end);
+
+ utility::IntoLower(key);
+
+ if (value.front() == '{' && value.back() == '}')
+ value = value.substr(1, value.size() - 2);
+
+ args[key] = value;
+ }
+
+ if (!attr_begin)
+ break;
+
+ connect_str.erase(attr_begin - 1);
+ }
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/config/connection_info.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
new file mode 100644
index 0000000..0e8e748
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
@@ -0,0 +1,419 @@
+/*
+ * 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 <cstring>
+#include <algorithm>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/config/connection_info.h"
+
+ // Temporary workaround.
+#ifndef SQL_ASYNC_NOTIFICATION
+#define SQL_ASYNC_NOTIFICATION 10025
+#endif
+
+#ifndef SQL_ASYNC_NOTIFICATION_NOT_CAPABLE
+#define SQL_ASYNC_NOTIFICATION_NOT_CAPABLE 0x00000000L
+#endif
+
+#ifndef SQL_ASYNC_NOTIFICATION_CAPABLE
+#define SQL_ASYNC_NOTIFICATION_CAPABLE 0x00000001L
+#endif
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace config
+ {
+
+#ifdef ODBC_DEBUG
+
+#define DBG_STR_CASE(x) case x: return #x
+
+ const char * ConnectionInfo::InfoTypeToString(InfoType type)
+ {
+ switch (type)
+ {
+ DBG_STR_CASE(SQL_DRIVER_NAME);
+ DBG_STR_CASE(SQL_DBMS_NAME);
+ DBG_STR_CASE(SQL_DRIVER_ODBC_VER);
+ DBG_STR_CASE(SQL_DBMS_VER);
+ DBG_STR_CASE(SQL_DRIVER_VER);
+ DBG_STR_CASE(SQL_COLUMN_ALIAS);
+ DBG_STR_CASE(SQL_IDENTIFIER_QUOTE_CHAR);
+ DBG_STR_CASE(SQL_CATALOG_NAME_SEPARATOR);
+ DBG_STR_CASE(SQL_SPECIAL_CHARACTERS);
+ DBG_STR_CASE(SQL_CATALOG_TERM);
+ DBG_STR_CASE(SQL_TABLE_TERM);
+ DBG_STR_CASE(SQL_SCHEMA_TERM);
+ DBG_STR_CASE(SQL_ASYNC_DBC_FUNCTIONS);
+ DBG_STR_CASE(SQL_ASYNC_NOTIFICATION);
+ DBG_STR_CASE(SQL_GETDATA_EXTENSIONS);
+ DBG_STR_CASE(SQL_ODBC_INTERFACE_CONFORMANCE);
+ DBG_STR_CASE(SQL_SQL_CONFORMANCE);
+ DBG_STR_CASE(SQL_CATALOG_USAGE);
+ DBG_STR_CASE(SQL_SCHEMA_USAGE);
+ DBG_STR_CASE(SQL_MAX_IDENTIFIER_LEN);
+ DBG_STR_CASE(SQL_AGGREGATE_FUNCTIONS);
+ DBG_STR_CASE(SQL_NUMERIC_FUNCTIONS);
+ DBG_STR_CASE(SQL_STRING_FUNCTIONS);
+ DBG_STR_CASE(SQL_TIMEDATE_FUNCTIONS);
+ DBG_STR_CASE(SQL_TIMEDATE_ADD_INTERVALS);
+ DBG_STR_CASE(SQL_TIMEDATE_DIFF_INTERVALS);
+ DBG_STR_CASE(SQL_DATETIME_LITERALS);
+ DBG_STR_CASE(SQL_SYSTEM_FUNCTIONS);
+ DBG_STR_CASE(SQL_CONVERT_FUNCTIONS);
+ DBG_STR_CASE(SQL_OJ_CAPABILITIES);
+ DBG_STR_CASE(SQL_POS_OPERATIONS);
+ DBG_STR_CASE(SQL_MAX_CONCURRENT_ACTIVITIES);
+ DBG_STR_CASE(SQL_CURSOR_COMMIT_BEHAVIOR);
+ DBG_STR_CASE(SQL_CURSOR_ROLLBACK_BEHAVIOR);
+ DBG_STR_CASE(SQL_TXN_CAPABLE);
+ DBG_STR_CASE(SQL_QUOTED_IDENTIFIER_CASE);
+ DBG_STR_CASE(SQL_SQL92_NUMERIC_VALUE_FUNCTIONS);
+ DBG_STR_CASE(SQL_SQL92_STRING_FUNCTIONS);
+ DBG_STR_CASE(SQL_SQL92_DATETIME_FUNCTIONS);
+ DBG_STR_CASE(SQL_SQL92_PREDICATES);
+ DBG_STR_CASE(SQL_SQL92_RELATIONAL_JOIN_OPERATORS);
+ DBG_STR_CASE(SQL_SQL92_VALUE_EXPRESSIONS);
+ default:
+ break;
+ }
+ return "<< UNKNOWN TYPE >>";
+ }
+
+#undef DBG_STR_CASE
+#endif
+
+ ConnectionInfo::ConnectionInfo() : strParams(), intParams(),
+ shortParams()
+ {
+ //========================= String Params =========================
+ // Driver name.
+ strParams[SQL_DRIVER_NAME] = "Apache Ignite";
+ strParams[SQL_DBMS_NAME] = "Apache Ignite";
+
+ // ODBC version.
+ strParams[SQL_DRIVER_ODBC_VER] = "03.00";
+ strParams[SQL_DBMS_VER] = "03.00";
+
+#ifdef SQL_DRIVER_VER
+ // Driver version. At a minimum, the version is of the form
+ // ##.##.####, where the first two digits are the major version,
+ // the next two digits are the minor version, and the last four
+ // digits are the release version.
+ strParams[SQL_DRIVER_VER] = "01.05.0000";
+#endif // SQL_DRIVER_VER
+
+#ifdef SQL_COLUMN_ALIAS
+ // A character string: "Y" if the data source supports column
+ // aliases; otherwise, "N".
+ strParams[SQL_COLUMN_ALIAS] = "N";
+#endif // SQL_COLUMN_ALIAS
+
+#ifdef SQL_IDENTIFIER_QUOTE_CHAR
+ // The character string that is used as the starting and ending
+ // delimiter of a quoted (delimited) identifier in SQL statements.
+ // Identifiers passed as arguments to ODBC functions do not have to
+ // be quoted. If the data source does not support quoted
+ // identifiers, a blank is returned.
+ strParams[SQL_IDENTIFIER_QUOTE_CHAR] = "";
+#endif // SQL_IDENTIFIER_QUOTE_CHAR
+
+#ifdef SQL_CATALOG_NAME_SEPARATOR
+ // A character string: the character or characters that the data
+ // source defines as the separator between a catalog name and the
+ // qualified name element that follows or precedes it.
+ strParams[SQL_CATALOG_NAME_SEPARATOR] = ".";
+#endif // SQL_CATALOG_NAME_SEPARATOR
+
+#ifdef SQL_SPECIAL_CHARACTERS
+ // A character string that contains all special characters (that
+ // is, all characters except a through z, A through Z, 0 through 9,
+ // and underscore) that can be used in an identifier name, such as
+ // a table name, column name, or index name, on the data source.
+ strParams[SQL_SPECIAL_CHARACTERS] = "";
+#endif // SQL_SPECIAL_CHARACTERS
+
+#ifdef SQL_CATALOG_TERM
+ // A character string with the data source vendor's name for
+ // a catalog; for example, "database" or "directory". This string
+ // can be in upper, lower, or mixed case.
+ strParams[SQL_CATALOG_TERM] = "catalog";
+#endif // SQL_CATALOG_TERM
+
+#ifdef SQL_TABLE_TERM
+ // A character string with the data source vendor's name for
+ // a table; for example, "table" or "file".
+ strParams[SQL_TABLE_TERM] = "table";
+#endif // SQL_TABLE_TERM
+
+#ifdef SQL_SCHEMA_TERM
+ // A character string with the data source vendor's name for
+ // a schema; for example, "owner", "Authorization ID", or "Schema".
+ strParams[SQL_SCHEMA_TERM] = "schema";
+#endif // SQL_SCHEMA_TERM
+
+#ifdef SQL_ASYNC_DBC_FUNCTIONS
+ //======================== Integer Params =========================
+ // Indicates if the driver can execute functions asynchronously
+ // on the connection handle.
+ // SQL_ASYNC_DBC_CAPABLE = The driver can execute connection
+ // functions asynchronously.
+ // SQL_ASYNC_DBC_NOT_CAPABLE = The driver can not execute
+ // connection functions asynchronously.
+ intParams[SQL_ASYNC_DBC_FUNCTIONS] = SQL_ASYNC_DBC_NOT_CAPABLE;
+#endif // SQL_ASYNC_DBC_FUNCTIONS
+
+#ifdef SQL_ASYNC_NOTIFICATION
+ // Indicates if the driver supports asynchronous notification.
+ // SQL_ASYNC_NOTIFICATION_CAPABLE = Asynchronous execution
+ // notification is supported by the driver.
+ // SQL_ASYNC_NOTIFICATION_NOT_CAPABLE Asynchronous execution
+ // notification is not supported by the driver.
+ intParams[SQL_ASYNC_NOTIFICATION] = SQL_ASYNC_NOTIFICATION_NOT_CAPABLE;
+#endif // SQL_ASYNC_NOTIFICATION
+
+#ifdef SQL_GETDATA_EXTENSIONS
+ // Bitmask enumerating extensions to SQLGetData.
+ intParams[SQL_GETDATA_EXTENSIONS] = SQL_GD_ANY_COLUMN;
+#endif // SQL_GETDATA_EXTENSIONS
+
+#ifdef SQL_ODBC_INTERFACE_CONFORMANCE
+ // Indicates the level of the ODBC 3.x interface that the driver
+ // complies with.
+ intParams[SQL_ODBC_INTERFACE_CONFORMANCE] = SQL_OIC_CORE;
+#endif // SQL_ODBC_INTERFACE_CONFORMANCE
+
+#ifdef SQL_SQL_CONFORMANCE
+ // Indicates the level of SQL-92 supported by the driver.
+ intParams[SQL_SQL_CONFORMANCE] = 0; // SQL_SC_SQL92_ENTRY;
+#endif // SQL_SQL_CONFORMANCE
+
+#ifdef SQL_CATALOG_USAGE
+ // Bitmask enumerating the statements in which catalogs can be used.
+ intParams[SQL_CATALOG_USAGE] = 0;
+#endif // SQL_CATALOG_USAGE
+
+#ifdef SQL_SCHEMA_USAGE
+ // Bitmask enumerating the statements in which schemas can be used.
+ intParams[SQL_SCHEMA_USAGE] = 0;
+#endif // SQL_SCHEMA_USAGE
+
+#ifdef SQL_MAX_IDENTIFIER_LEN
+ // Indicates the maximum size in characters that the data source
+ // supports for user-defined names.
+ intParams[SQL_MAX_IDENTIFIER_LEN] = 128;
+#endif // SQL_MAX_IDENTIFIER_LEN
+
+#ifdef SQL_AGGREGATE_FUNCTIONS
+ // Bitmask enumerating support for aggregation functions.
+ intParams[SQL_AGGREGATE_FUNCTIONS] = SQL_AF_ALL | SQL_AF_AVG |
+ SQL_AF_COUNT | SQL_AF_DISTINCT | SQL_AF_MAX | SQL_AF_MIN |
+ SQL_AF_SUM;
+#endif // SQL_AGGREGATE_FUNCTIONS
+
+#ifdef SQL_NUMERIC_FUNCTIONS
+ // Bitmask enumerating the scalar numeric functions supported by
+ // the driver and associated data source.
+ intParams[SQL_NUMERIC_FUNCTIONS] = SQL_FN_NUM_ABS;
+#endif // SQL_NUMERIC_FUNCTIONS
+
+#ifdef SQL_STRING_FUNCTIONS
+ // Bitmask enumerating the scalar string functions supported by the
+ // driver and associated data source.
+ intParams[SQL_STRING_FUNCTIONS] = 0;
+#endif // SQL_STRING_FUNCTIONS
+
+#ifdef SQL_TIMEDATE_FUNCTIONS
+ // Bitmask enumerating the scalar date and time functions supported
+ // by the driver and associated data source.
+ intParams[SQL_TIMEDATE_FUNCTIONS] = 0;
+#endif // SQL_TIMEDATE_FUNCTIONS
+
+#ifdef SQL_TIMEDATE_ADD_INTERVALS
+ // Bitmask enumerating timestamp intervals supported by the driver
+ // and associated data source for the TIMESTAMPADD scalar function.
+ intParams[SQL_TIMEDATE_ADD_INTERVALS] = 0;
+#endif // SQL_TIMEDATE_ADD_INTERVALS
+
+#ifdef SQL_TIMEDATE_DIFF_INTERVALS
+ // Bitmask enumerating timestamp intervals supported by the driver
+ // and associated data source for the TIMESTAMPDIFF scalar function.
+ intParams[SQL_TIMEDATE_DIFF_INTERVALS] = 0;
+#endif // SQL_TIMEDATE_DIFF_INTERVALS
+
+#ifdef SQL_DATETIME_LITERALS
+ // Bitmask enumerating the SQL-92 datetime literals supported by
+ // the data source.
+ intParams[SQL_DATETIME_LITERALS] = 0;
+#endif // SQL_DATETIME_LITERALS
+
+#ifdef SQL_SYSTEM_FUNCTIONS
+ // Bitmask enumerating the scalar system functions supported by the
+ // driver and associated data source.
+ intParams[SQL_SYSTEM_FUNCTIONS] = 0;
+#endif // SQL_SYSTEM_FUNCTIONS
+
+#ifdef SQL_CONVERT_FUNCTIONS
+ // Bitmask enumerating the scalar conversion functions supported
+ // by the driver and associated data source.
+ intParams[SQL_CONVERT_FUNCTIONS] = 0;
+#endif // SQL_CONVERT_FUNCTIONS
+
+#ifdef SQL_OJ_CAPABILITIES
+ // Bitmask enumerating the types of outer joins supported by the
+ // driver and data source.
+ intParams[SQL_OJ_CAPABILITIES] = SQL_OJ_LEFT | SQL_OJ_RIGHT |
+ SQL_OJ_FULL | SQL_OJ_NESTED | SQL_OJ_INNER |
+ SQL_OJ_ALL_COMPARISON_OPS;
+#endif // SQL_OJ_CAPABILITIES
+
+#ifdef SQL_POS_OPERATIONS
+ // Bitmask enumerating the support operations in SQLSetPos.
+ intParams[SQL_POS_OPERATIONS] = 0;
+#endif // SQL_POS_OPERATIONS
+
+#ifdef SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
+ // Bitmask enumerating the numeric value scalar functions.
+ intParams[SQL_SQL92_NUMERIC_VALUE_FUNCTIONS] = 0;
+#endif // SQL_SQL92_NUMERIC_VALUE_FUNCTIONS
+
+#ifdef SQL_SQL92_STRING_FUNCTIONS
+ // Bitmask enumerating the string scalar functions.
+ intParams[SQL_SQL92_STRING_FUNCTIONS] = 0;
+#endif // SQL_SQL92_STRING_FUNCTIONS
+
+#ifdef SQL_SQL92_DATETIME_FUNCTIONS
+ // Bitmask enumerating the datetime scalar functions.
+ intParams[SQL_SQL92_DATETIME_FUNCTIONS] = 0;
+#endif // SQL_SQL92_DATETIME_FUNCTIONS
+
+#ifdef SQL_SQL92_VALUE_EXPRESSIONS
+ // Bitmask enumerating the value expressions supported,
+ // as defined in SQL-92.
+ intParams[SQL_SQL92_VALUE_EXPRESSIONS] = SQL_SVE_CASE |
+ SQL_SVE_COALESCE | SQL_SVE_NULLIF;
+#endif // SQL_SQL92_VALUE_EXPRESSIONS
+
+#ifdef SQL_SQL92_PREDICATES
+ // Bitmask enumerating the datetime scalar functions.
+ intParams[SQL_SQL92_PREDICATES] = SQL_SP_BETWEEN |
+ SQL_SP_COMPARISON | SQL_SP_EXISTS | SQL_SP_IN |
+ SQL_SP_ISNOTNULL | SQL_SP_ISNULL | SQL_SP_LIKE |
+ SQL_SP_MATCH_FULL | SQL_SP_MATCH_PARTIAL |
+ SQL_SP_MATCH_UNIQUE_FULL | SQL_SP_MATCH_UNIQUE_PARTIAL |
+ SQL_SP_OVERLAPS | SQL_SP_QUANTIFIED_COMPARISON |
+ SQL_SP_UNIQUE;
+#endif // SQL_SQL92_PREDICATES
+
+#ifdef SQL_SQL92_RELATIONAL_JOIN_OPERATORS
+ // Bitmask enumerating the relational join operators supported
+ // in a SELECT statement, as defined in SQL-92.
+ intParams[SQL_SQL92_RELATIONAL_JOIN_OPERATORS] =
+ SQL_SRJO_CORRESPONDING_CLAUSE | SQL_SRJO_CROSS_JOIN |
+ SQL_SRJO_EXCEPT_JOIN | SQL_SRJO_EXCEPT_JOIN |
+ SQL_SRJO_INNER_JOIN | SQL_SRJO_INTERSECT_JOIN |
+ SQL_SRJO_LEFT_OUTER_JOIN | SQL_SRJO_NATURAL_JOIN |
+ SQL_SRJO_RIGHT_OUTER_JOIN | SQL_SRJO_UNION_JOIN;
+#endif // SQL_SQL92_RELATIONAL_JOIN_OPERATORS
+
+ //========================= Short Params ==========================
+#ifdef SQL_MAX_CONCURRENT_ACTIVITIES
+ // The maximum number of active statements that the driver can
+ // support for a connection. Zero mean no limit.
+ shortParams[SQL_MAX_CONCURRENT_ACTIVITIES] = 32;
+#endif // SQL_MAX_CONCURRENT_ACTIVITIES
+
+#ifdef SQL_CURSOR_COMMIT_BEHAVIOR
+ // Indicates how a COMMIT operation affects cursors and prepared
+ // statements in the data source.
+ shortParams[SQL_CURSOR_COMMIT_BEHAVIOR] = SQL_CB_PRESERVE;
+#endif // SQL_CURSOR_COMMIT_BEHAVIOR
+
+#ifdef SQL_CURSOR_ROLLBACK_BEHAVIOR
+ // Indicates how a ROLLBACK operation affects cursors and prepared
+ // statements in the data source.
+ shortParams[SQL_CURSOR_ROLLBACK_BEHAVIOR] = SQL_CB_PRESERVE;
+#endif // SQL_CURSOR_ROLLBACK_BEHAVIOR
+
+#ifdef SQL_TXN_CAPABLE
+ // Describs the transaction support in the driver or data source.
+ shortParams[SQL_TXN_CAPABLE] = SQL_TC_NONE;
+#endif // SQL_TXN_CAPABLE
+
+#ifdef SQL_QUOTED_IDENTIFIER_CASE
+ // Case-sensitiveness of the quoted identifiers in SQL.
+ shortParams[SQL_QUOTED_IDENTIFIER_CASE] = SQL_IC_SENSITIVE;
+#endif // SQL_QUOTED_IDENTIFIER_CASE
+ }
+
+ ConnectionInfo::~ConnectionInfo()
+ {
+ // No-op.
+ }
+
+ SqlResult ConnectionInfo::GetInfo(InfoType type, void* buf,
+ short buflen, short* reslen) const
+ {
+ if (!buf || !buflen)
+ return SQL_RESULT_ERROR;
+
+ StringInfoMap::const_iterator itStr = strParams.find(type);
+
+ if (itStr != strParams.cend())
+ {
+ unsigned short strlen = static_cast<short>(
+ utility::CopyStringToBuffer(itStr->second,
+ reinterpret_cast<char*>(buf), buflen));
+
+ if (reslen)
+ *reslen = strlen;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ UintInfoMap::const_iterator itInt = intParams.find(type);
+
+ if (itInt != intParams.cend())
+ {
+ unsigned int *res = reinterpret_cast<unsigned int*>(buf);
+
+ *res = itInt->second;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ UshortInfoMap::const_iterator itShort = shortParams.find(type);
+
+ if (itShort != shortParams.cend())
+ {
+ unsigned short *res = reinterpret_cast<unsigned short*>(buf);
+
+ *res = itShort->second;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ return SQL_RESULT_ERROR;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp
new file mode 100644
index 0000000..28cd7ca
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -0,0 +1,269 @@
+/*
+ * 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 <cstring>
+
+#include <sstream>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/statement.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/config/configuration.h"
+
+// TODO: implement appropriate protocol with de-/serialisation.
+namespace
+{
+#pragma pack(push, 1)
+ struct OdbcProtocolHeader
+ {
+ int32_t len;
+ };
+#pragma pack(pop)
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ Connection::Connection() : socket(), connected(false), cache(), parser()
+ {
+ // No-op.
+ }
+
+ Connection::~Connection()
+ {
+ // No-op.
+ }
+
+ const config::ConnectionInfo& Connection::GetInfo() const
+ {
+ // Connection info is the same for all connections now.
+ static config::ConnectionInfo info;
+
+ return info;
+ }
+
+ void Connection::GetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen)
+ {
+ IGNITE_ODBC_API_CALL(InternalGetInfo(type, buf, buflen, reslen));
+ }
+
+ SqlResult Connection::InternalGetInfo(config::ConnectionInfo::InfoType type, void* buf, short buflen, short* reslen)
+ {
+ const config::ConnectionInfo& info = GetInfo();
+
+ SqlResult res = info.GetInfo(type, buf, buflen, reslen);
+
+ if (res != SQL_RESULT_SUCCESS)
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Not implemented.");
+
+ return res;
+ }
+
+ void Connection::Establish(const std::string& server)
+ {
+ IGNITE_ODBC_API_CALL(InternalEstablish(server));
+ }
+
+ SqlResult Connection::InternalEstablish(const std::string& server)
+ {
+ config::Configuration config;
+
+ if (server != config.GetDsn())
+ {
+ AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown DNS.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return InternalEstablish(config.GetHost(), config.GetPort(), config.GetCache());
+ }
+
+ void Connection::Establish(const std::string& host, uint16_t port, const std::string& cache)
+ {
+ IGNITE_ODBC_API_CALL(InternalEstablish(host, port, cache));
+ }
+
+ SqlResult Connection::InternalEstablish(const std::string & host, uint16_t port, const std::string & cache)
+ {
+ if (connected)
+ {
+ AddStatusRecord(SQL_STATE_08002_ALREADY_CONNECTED, "Already connected.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cache.empty())
+ {
+ AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Cache is not specified.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ this->cache = cache;
+
+ connected = socket.Connect(host.c_str(), port);
+
+ if (!connected)
+ {
+ AddStatusRecord(SQL_STATE_08001_CANNOT_CONNECT, "Failed to establish connection with the host.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Connection::Release()
+ {
+ IGNITE_ODBC_API_CALL(InternalRelease());
+ }
+
+ SqlResult Connection::InternalRelease()
+ {
+ if (!connected)
+ {
+ AddStatusRecord(SQL_STATE_08003_NOT_CONNECTED, "Connection is not open.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ socket.Close();
+
+ connected = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ Statement* Connection::CreateStatement()
+ {
+ Statement* statement;
+
+ IGNITE_ODBC_API_CALL(InternalCreateStatement(statement));
+
+ return statement;
+ }
+
+ SqlResult Connection::InternalCreateStatement(Statement*& statement)
+ {
+ statement = new Statement(*this);
+
+ if (!statement)
+ {
+ AddStatusRecord(SQL_STATE_HY001_MEMORY_ALLOCATION, "Not enough memory.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool Connection::Send(const int8_t* data, size_t len)
+ {
+ if (!connected)
+ return false;
+
+ size_t sent = 0;
+
+ while (sent != len)
+ {
+ size_t res = socket.Send(data + sent, len - sent);
+
+ if (res <= 0)
+ return false;
+
+ sent += res;
+ }
+
+ return true;
+ }
+
+ bool Connection::Receive(std::vector<int8_t>& msg)
+ {
+ if (!connected)
+ return false;
+
+ msg.clear();
+
+ OdbcProtocolHeader hdr;
+
+ int received = socket.Receive(reinterpret_cast<int8_t*>(&hdr), sizeof(hdr));
+ LOG_MSG("Received: %d\n", received);
+
+ if (received != sizeof(hdr))
+ return false;
+
+ size_t remain = hdr.len;
+ size_t receivedAtAll = 0;
+
+ msg.resize(remain);
+
+ while (remain)
+ {
+ received = socket.Receive(&msg[receivedAtAll], remain);
+ LOG_MSG("Received: %d\n", received);
+ LOG_MSG("remain: %d\n", remain);
+
+ if (received <= 0)
+ {
+ msg.resize(receivedAtAll);
+
+ return false;
+ }
+
+ remain -= static_cast<size_t>(received);
+ }
+
+ return true;
+ }
+
+ const std::string& Connection::GetCache() const
+ {
+ return cache;
+ }
+
+ diagnostic::DiagnosticRecord Connection::CreateStatusRecord(SqlState sqlState,
+ const std::string& message, int32_t rowNum, int32_t columnNum) const
+ {
+ return diagnostic::DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum);
+ }
+
+ void Connection::TransactionCommit()
+ {
+ IGNITE_ODBC_API_CALL(InternalTransactionCommit());
+ }
+
+ SqlResult Connection::InternalTransactionCommit()
+ {
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Connection::TransactionRollback()
+ {
+ IGNITE_ODBC_API_CALL(InternalTransactionRollback());
+ }
+
+ SqlResult Connection::InternalTransactionRollback()
+ {
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ "Rollback operation is not supported.");
+
+ return SQL_RESULT_ERROR;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/cursor.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/cursor.cpp b/modules/platforms/cpp/odbc/src/cursor.cpp
new file mode 100644
index 0000000..edd1818
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/cursor.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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 "ignite/odbc/cursor.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ Cursor::Cursor(int64_t queryId) : queryId(queryId), currentPage(),
+ currentPagePos(0), currentRow()
+ {
+ // No-op.
+ }
+
+ Cursor::~Cursor()
+ {
+ // No-op.
+ }
+
+ bool Cursor::Increment()
+ {
+ if (currentPage.get() && currentPagePos < currentPage->GetSize())
+ {
+ ++currentPagePos;
+
+ Row *row = currentRow.get();
+
+ if (row)
+ row->MoveToNext();
+
+ return true;
+ }
+ return false;
+ }
+
+ bool Cursor::NeedDataUpdate() const
+ {
+ return !currentPage.get() || (!currentPage->IsLast() &&
+ currentPagePos == currentPage->GetSize());
+ }
+
+ bool Cursor::HasNext() const
+ {
+ return !currentPage.get() || !currentPage->IsLast() ||
+ currentPagePos < currentPage->GetSize();
+ }
+
+ void Cursor::UpdateData(std::auto_ptr<ResultPage>& newPage)
+ {
+ currentPage = newPage;
+
+ currentPagePos = 1;
+
+ currentRow.reset(new Row(currentPage->GetData()));
+ }
+
+ Row* Cursor::GetRow()
+ {
+ return currentRow.get();
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/decimal.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/decimal.cpp b/modules/platforms/cpp/odbc/src/decimal.cpp
new file mode 100644
index 0000000..0fa37fb
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/decimal.cpp
@@ -0,0 +1,117 @@
+/*
+ * 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 <cstring>
+#include <utility>
+
+#include "ignite/odbc/decimal.h"
+
+namespace ignite
+{
+ Decimal::Decimal() :
+ scale(0), len(0), magnitude(0)
+ {
+ // No-op.
+ }
+
+ Decimal::Decimal(int32_t scale, const int8_t* mag, int32_t len) :
+ scale(scale), len(len), magnitude(0)
+ {
+ magnitude = new int8_t[len];
+
+ memcpy(magnitude, mag, len);
+ }
+
+ Decimal::Decimal(const Decimal& other) :
+ scale(other.scale), len(other.len), magnitude(0)
+ {
+ magnitude = new int8_t[len];
+
+ memcpy(magnitude, other.magnitude, len);
+ }
+
+ Decimal::~Decimal()
+ {
+ if (magnitude)
+ delete[] magnitude;
+ }
+
+ Decimal& Decimal::operator=(const Decimal& other)
+ {
+ Decimal tmp(other);
+
+ swap(tmp, *this);
+
+ return *this;
+ }
+
+ Decimal::operator double() const
+ {
+ double res = 0;
+
+ int32_t localScale = GetScale();
+
+ for (int32_t i = 0; i < len; ++i)
+ {
+ res = (res * 256) + magnitude[i];
+
+ while (localScale && res > 10.0)
+ {
+ res /= 10.0;
+
+ --localScale;
+ }
+ }
+
+ return res * GetSign();
+ }
+
+ int32_t Decimal::GetScale() const
+ {
+ return scale & 0x7FFFFFFF;
+ }
+
+ int32_t Decimal::GetSign() const
+ {
+ return IsNegative() ? -1 : 1;
+ }
+
+ bool Decimal::IsNegative() const
+ {
+ return (scale & 0x80000000) != 0;
+ }
+
+ int32_t Decimal::GetLength() const
+ {
+ return scale;
+ }
+
+ const int8_t* Decimal::GetMagnitude() const
+ {
+ return magnitude;
+ }
+
+ void swap(Decimal& first, Decimal& second)
+ {
+ using std::swap;
+
+ std::swap(first.scale, second.scale);
+ std::swap(first.len, second.len);
+ std::swap(first.magnitude, second.magnitude);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/diagnostic/diagnosable_adapter.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnosable_adapter.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnosable_adapter.cpp
new file mode 100644
index 0000000..d6cf4fe
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnosable_adapter.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "ignite/odbc/connection.h"
+#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ void DiagnosableAdapter::AddStatusRecord(SqlState sqlState,
+ const std::string& message, int32_t rowNum, int32_t columnNum)
+ {
+ if (connection)
+ {
+ diagnosticRecords.AddStatusRecord(
+ connection->CreateStatusRecord(sqlState, message, rowNum, columnNum));
+ }
+ else
+ {
+ diagnosticRecords.AddStatusRecord(
+ DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum));
+ }
+ }
+
+ void DiagnosableAdapter::AddStatusRecord(SqlState sqlState, const std::string & message)
+ {
+ AddStatusRecord(sqlState, message, 0, 0);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
new file mode 100644
index 0000000..568c125
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
@@ -0,0 +1,241 @@
+/*
+ * 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 <set>
+#include <string>
+
+#include "ignite/odbc/diagnostic/diagnostic_record.h"
+
+namespace
+{
+ /** SQLSTATEs defined by Open Group and ISO call-level interface. */
+ const std::string ORIGIN_ISO_9075 = "ISO 9075";
+
+ /** ODBC-specific SQLSTATEs (all those whose SQLSTATE class is "IM"). */
+ const std::string ORIGIN_ODBC_3_0 = "ODBC 3.0";
+
+ /** SQL state unknown constant. */
+ const std::string STATE_UNKNOWN = "";
+
+ /** SQL state 01004 constant. */
+ const std::string STATE_01004 = "01004";
+
+ /** SQL state 01S01 constant. */
+ const std::string STATE_01S01 = "01S01";
+
+ /** SQL state 24000 constant. */
+ const std::string STATE_24000 = "24000";
+
+ /** SQL state 08001 constant. */
+ const std::string STATE_08001 = "08001";
+
+ /** SQL state 08002 constant. */
+ const std::string STATE_08002 = "08002";
+
+ /** SQL state 08003 constant. */
+ const std::string STATE_08003 = "08003";
+
+ /** SQL state HY000 constant. */
+ const std::string STATE_HY000 = "HY000";
+
+ /** SQL state HY001 constant. */
+ const std::string STATE_HY001 = "HY001";
+
+ /** SQL state HY010 constant. */
+ const std::string STATE_HY010 = "HY010";
+
+ /** SQL state HYC00 constant. */
+ const std::string STATE_HYC00 = "HYC00";
+
+ /** SQL state HYT01 constant. */
+ const std::string STATE_HYT01 = "HYT01";
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ DiagnosticRecord::DiagnosticRecord() :
+ sqlState(SQL_STATE_UNKNOWN),
+ message(),
+ connectionName(),
+ serverName(),
+ rowNum(0),
+ columnNum(0)
+ {
+ // No-op.
+ }
+
+ DiagnosticRecord::DiagnosticRecord(SqlState sqlState,
+ const std::string& message, const std::string& connectionName,
+ const std::string& serverName, int32_t rowNum, int32_t columnNum) :
+ sqlState(sqlState),
+ message(message),
+ connectionName(connectionName),
+ serverName(serverName),
+ rowNum(rowNum),
+ columnNum(columnNum)
+ {
+ // No-op.
+ }
+
+ DiagnosticRecord::~DiagnosticRecord()
+ {
+ // No-op.
+ }
+
+ const std::string& DiagnosticRecord::GetClassOrigin() const
+ {
+ const std::string& state = GetSqlState();
+
+ if (state[0] == 'I' && state[1] == 'M')
+ return ORIGIN_ODBC_3_0;
+
+ return ORIGIN_ISO_9075;
+ }
+
+ const std::string& DiagnosticRecord::GetSubclassOrigin() const
+ {
+ static std::set<std::string> odbcSubclasses;
+
+ if (odbcSubclasses.empty())
+ {
+ odbcSubclasses.insert("01S00");
+ odbcSubclasses.insert("01S01");
+ odbcSubclasses.insert("01S02");
+ odbcSubclasses.insert("01S06");
+ odbcSubclasses.insert("01S07");
+ odbcSubclasses.insert("07S01");
+ odbcSubclasses.insert("08S01");
+ odbcSubclasses.insert("21S01");
+ odbcSubclasses.insert("21S02");
+ odbcSubclasses.insert("25S01");
+ odbcSubclasses.insert("25S02");
+ odbcSubclasses.insert("25S03");
+ odbcSubclasses.insert("42S01");
+ odbcSubclasses.insert("42S02");
+ odbcSubclasses.insert("42S11");
+ odbcSubclasses.insert("42S12");
+ odbcSubclasses.insert("42S21");
+ odbcSubclasses.insert("42S22");
+ odbcSubclasses.insert("HY095");
+ odbcSubclasses.insert("HY097");
+ odbcSubclasses.insert("HY098");
+ odbcSubclasses.insert("HY099");
+ odbcSubclasses.insert("HY100");
+ odbcSubclasses.insert("HY101");
+ odbcSubclasses.insert("HY105");
+ odbcSubclasses.insert("HY107");
+ odbcSubclasses.insert("HY109");
+ odbcSubclasses.insert("HY110");
+ odbcSubclasses.insert("HY111");
+ odbcSubclasses.insert("HYT00");
+ odbcSubclasses.insert("HYT01");
+ odbcSubclasses.insert("IM001");
+ odbcSubclasses.insert("IM002");
+ odbcSubclasses.insert("IM003");
+ odbcSubclasses.insert("IM004");
+ odbcSubclasses.insert("IM005");
+ odbcSubclasses.insert("IM006");
+ odbcSubclasses.insert("IM007");
+ odbcSubclasses.insert("IM008");
+ odbcSubclasses.insert("IM010");
+ odbcSubclasses.insert("IM011");
+ odbcSubclasses.insert("IM012");
+ }
+
+ const std::string& state = GetSqlState();
+
+ if (odbcSubclasses.find(state) != odbcSubclasses.end())
+ return ORIGIN_ODBC_3_0;
+
+ return ORIGIN_ISO_9075;
+ }
+
+ const std::string& DiagnosticRecord::GetMessage() const
+ {
+ return message;
+ }
+
+ const std::string& DiagnosticRecord::GetConnectionName() const
+ {
+ return connectionName;
+ }
+
+ const std::string& DiagnosticRecord::GetServerName() const
+ {
+ return serverName;
+ }
+
+ const std::string& DiagnosticRecord::GetSqlState() const
+ {
+ switch (sqlState)
+ {
+ case SQL_STATE_01004_DATA_TRUNCATED:
+ return STATE_01004;
+
+ case SQL_STATE_01S01_ERROR_IN_ROW:
+ return STATE_01S01;
+
+ case SQL_STATE_24000_INVALID_CURSOR_STATE:
+ return STATE_24000;
+
+ case SQL_STATE_08001_CANNOT_CONNECT:
+ return STATE_08001;
+
+ case SQL_STATE_08002_ALREADY_CONNECTED:
+ return STATE_08002;
+
+ case SQL_STATE_08003_NOT_CONNECTED:
+ return STATE_08003;
+
+ case SQL_STATE_HY000_GENERAL_ERROR:
+ return STATE_HY000;
+
+ case SQL_STATE_HY001_MEMORY_ALLOCATION:
+ return STATE_HY001;
+
+ case SQL_STATE_HY010_SEQUENCE_ERROR:
+ return STATE_HY010;
+
+ case SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED:
+ return STATE_HYC00;
+
+ case SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT:
+ return STATE_HYT01;
+
+ default:
+ break;
+ }
+
+ return STATE_UNKNOWN;
+ }
+
+ int32_t DiagnosticRecord::GetRowNumber() const
+ {
+ return rowNum;
+ }
+
+ int32_t DiagnosticRecord::GetColumnNumber() const
+ {
+ return columnNum;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
new file mode 100644
index 0000000..90c0a4f
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
@@ -0,0 +1,242 @@
+/*
+ * 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 <set>
+#include <string>
+
+#include "ignite/odbc/diagnostic/diagnostic_record_storage.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ DiagnosticRecordStorage::DiagnosticRecordStorage() :
+ rowCount(0),
+ dynamicFunction(),
+ dynamicFunctionCode(0),
+ result(SQL_RESULT_SUCCESS),
+ rowsAffected(0)
+ {
+ // No-op.
+ }
+
+ DiagnosticRecordStorage::~DiagnosticRecordStorage()
+ {
+ // No-op.
+ }
+
+ void DiagnosticRecordStorage::SetHeaderRecord(SqlResult result)
+ {
+ rowCount = 0;
+ dynamicFunction.clear();
+ dynamicFunctionCode = 0;
+ this->result = result;
+ rowsAffected = 0;
+ }
+
+ void DiagnosticRecordStorage::AddStatusRecord(const DiagnosticRecord& record)
+ {
+ statusRecords.push_back(record);
+ }
+
+ void DiagnosticRecordStorage::Reset()
+ {
+ SetHeaderRecord(SQL_RESULT_ERROR);
+
+ statusRecords.clear();
+ }
+
+ SqlResult DiagnosticRecordStorage::GetOperaionResult() const
+ {
+ return result;
+ }
+
+ int DiagnosticRecordStorage::GetReturnCode() const
+ {
+ return SqlResultToReturnCode(result);
+ }
+
+ int64_t DiagnosticRecordStorage::GetRowCount() const
+ {
+ return rowCount;
+ }
+
+ const std::string & DiagnosticRecordStorage::GetDynamicFunction() const
+ {
+ return dynamicFunction;
+ }
+
+ int32_t DiagnosticRecordStorage::GetDynamicFunctionCode() const
+ {
+ return dynamicFunctionCode;
+ }
+
+ int32_t DiagnosticRecordStorage::GetRowsAffected() const
+ {
+ return rowsAffected;
+ }
+
+ int32_t DiagnosticRecordStorage::GetStatusRecordsNumber() const
+ {
+ return static_cast<int32_t>(statusRecords.size());
+ }
+
+ const DiagnosticRecord& DiagnosticRecordStorage::GetStatusRecord(int32_t idx) const
+ {
+ return statusRecords[idx - 1];
+ }
+
+ bool DiagnosticRecordStorage::IsSuccessful() const
+ {
+ return result == SQL_RESULT_SUCCESS ||
+ result == SQL_RESULT_SUCCESS_WITH_INFO;
+ }
+
+ SqlResult DiagnosticRecordStorage::GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const
+ {
+ // Header record.
+ switch (field)
+ {
+ case IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT:
+ {
+ buffer.PutInt64(GetRowCount());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION:
+ {
+ buffer.PutString(GetDynamicFunction());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE:
+ {
+ buffer.PutInt32(GetDynamicFunctionCode());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_HEADER_NUMBER:
+ {
+ buffer.PutInt32(GetStatusRecordsNumber());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_HEADER_RETURNCODE:
+ {
+ buffer.PutInt32(GetReturnCode());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_HEADER_ROW_COUNT:
+ {
+ buffer.PutInt64(GetRowsAffected());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ default:
+ break;
+ }
+
+ if (recNum < 1 || static_cast<size_t>(recNum) > statusRecords.size())
+ return SQL_RESULT_NO_DATA;
+
+ // Status record.
+ const DiagnosticRecord& record = GetStatusRecord(recNum);
+
+ switch (field)
+ {
+ case IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN:
+ {
+ buffer.PutString(record.GetClassOrigin());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER:
+ {
+ buffer.PutInt32(record.GetColumnNumber());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME:
+ {
+ buffer.PutString(record.GetConnectionName());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT:
+ {
+ buffer.PutString(record.GetMessage());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_NATIVE:
+ {
+ buffer.PutInt32(0);
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_ROW_NUMBER:
+ {
+ buffer.PutInt64(record.GetRowNumber());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_SERVER_NAME:
+ {
+ buffer.PutString(record.GetServerName());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_SQLSTATE:
+ {
+ buffer.PutString(record.GetSqlState());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN:
+ {
+ buffer.PutString(record.GetSubclassOrigin());
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ default:
+ break;
+ }
+
+ return SQL_RESULT_ERROR;
+ }
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/environment.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/environment.cpp b/modules/platforms/cpp/odbc/src/environment.cpp
new file mode 100644
index 0000000..ba213ab
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/environment.cpp
@@ -0,0 +1,172 @@
+/*
+ * 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 "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/environment.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ Environment::Environment() :
+ odbcVersion(SQL_OV_ODBC3), odbcNts(SQL_TRUE)
+ {
+ // No-op.
+ }
+
+ Environment::~Environment()
+ {
+ // No-op.
+ }
+
+ Connection* Environment::CreateConnection()
+ {
+ Connection* connection;
+
+ IGNITE_ODBC_API_CALL(InternalCreateConnection(connection));
+
+ return connection;
+ }
+
+ SqlResult Environment::InternalCreateConnection(Connection*& connection)
+ {
+ connection = new Connection;
+
+ if (!connection)
+ {
+ AddStatusRecord(SQL_STATE_HY001_MEMORY_ALLOCATION, "Not enough memory.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Environment::TransactionCommit()
+ {
+ IGNITE_ODBC_API_CALL(InternalTransactionCommit());
+ }
+
+ SqlResult Environment::InternalTransactionCommit()
+ {
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Environment::TransactionRollback()
+ {
+ IGNITE_ODBC_API_CALL(InternalTransactionRollback());
+ }
+
+ SqlResult Environment::InternalTransactionRollback()
+ {
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ "Rollback operation is not supported.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ void Environment::SetAttribute(int32_t attr, void* value, int32_t len)
+ {
+ IGNITE_ODBC_API_CALL(InternalSetAttribute(attr, value, len));
+ }
+
+ SqlResult Environment::InternalSetAttribute(int32_t attr, void* value, int32_t len)
+ {
+ EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr);
+
+ switch (attribute)
+ {
+ case IGNITE_SQL_ENV_ATTR_ODBC_VERSION:
+ {
+ int32_t version = reinterpret_cast<int32_t>(value);
+
+ if (version != odbcVersion)
+ {
+ AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED,
+ "ODBC version is not supported.");
+
+ return SQL_RESULT_SUCCESS_WITH_INFO;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS:
+ {
+ int32_t nts = reinterpret_cast<int32_t>(value);
+
+ if (nts != odbcNts)
+ {
+ AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED,
+ "Only null-termination of strings is supported.");
+
+ return SQL_RESULT_SUCCESS_WITH_INFO;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_ENV_ATTR_UNKNOWN:
+ default:
+ break;
+ }
+
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ "Attribute is not supported.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ void Environment::GetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer)
+ {
+ IGNITE_ODBC_API_CALL(InternalGetAttribute(attr, buffer));
+ }
+
+ SqlResult Environment::InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer)
+ {
+ EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr);
+
+ switch (attribute)
+ {
+ case IGNITE_SQL_ENV_ATTR_ODBC_VERSION:
+ {
+ buffer.PutInt32(odbcVersion);
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS:
+ {
+ buffer.PutInt32(odbcNts);
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ case IGNITE_SQL_ENV_ATTR_UNKNOWN:
+ default:
+ break;
+ }
+
+ AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ "Attribute is not supported.");
+
+ return SQL_RESULT_ERROR;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/meta/column_meta.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/meta/column_meta.cpp b/modules/platforms/cpp/odbc/src/meta/column_meta.cpp
new file mode 100644
index 0000000..114dd03
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/meta/column_meta.cpp
@@ -0,0 +1,275 @@
+/*
+ * 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 "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/meta/column_meta.h"
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/common_types.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+
+#ifdef ODBC_DEBUG
+
+#define DBG_STR_CASE(x) case x: return #x
+
+ const char* ColumnMeta::AttrIdToString(uint16_t id)
+ {
+ switch (id)
+ {
+ DBG_STR_CASE(SQL_DESC_LABEL);
+ DBG_STR_CASE(SQL_DESC_BASE_COLUMN_NAME);
+ DBG_STR_CASE(SQL_DESC_NAME);
+ DBG_STR_CASE(SQL_DESC_TABLE_NAME);
+ DBG_STR_CASE(SQL_DESC_BASE_TABLE_NAME);
+ DBG_STR_CASE(SQL_DESC_SCHEMA_NAME);
+ DBG_STR_CASE(SQL_DESC_CATALOG_NAME);
+ DBG_STR_CASE(SQL_DESC_LITERAL_PREFIX);
+ DBG_STR_CASE(SQL_DESC_LITERAL_SUFFIX);
+ DBG_STR_CASE(SQL_DESC_TYPE_NAME);
+ DBG_STR_CASE(SQL_DESC_LOCAL_TYPE_NAME);
+ DBG_STR_CASE(SQL_DESC_FIXED_PREC_SCALE);
+ DBG_STR_CASE(SQL_DESC_AUTO_UNIQUE_VALUE);
+ DBG_STR_CASE(SQL_DESC_CASE_SENSITIVE);
+ DBG_STR_CASE(SQL_DESC_CONCISE_TYPE);
+ DBG_STR_CASE(SQL_DESC_TYPE);
+ DBG_STR_CASE(SQL_DESC_DISPLAY_SIZE);
+ DBG_STR_CASE(SQL_DESC_LENGTH);
+ DBG_STR_CASE(SQL_DESC_OCTET_LENGTH);
+ DBG_STR_CASE(SQL_DESC_NULLABLE);
+ DBG_STR_CASE(SQL_DESC_NUM_PREC_RADIX);
+ DBG_STR_CASE(SQL_DESC_PRECISION);
+ DBG_STR_CASE(SQL_DESC_SCALE);
+ DBG_STR_CASE(SQL_DESC_SEARCHABLE);
+ DBG_STR_CASE(SQL_DESC_UNNAMED);
+ DBG_STR_CASE(SQL_DESC_UNSIGNED);
+ DBG_STR_CASE(SQL_DESC_UPDATABLE);
+ default:
+ break;
+ }
+ return "<< UNKNOWN ID >>";
+ }
+
+#undef DBG_STR_CASE
+
+#endif
+
+ void ColumnMeta::Read(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ utility::ReadString(reader, schemaName);
+ utility::ReadString(reader, tableName);
+ utility::ReadString(reader, columnName);
+ utility::ReadString(reader, typeName);
+
+ dataType = reader.ReadInt8();
+ }
+
+ bool ColumnMeta::GetAttribute(uint16_t fieldId, std::string& value) const
+ {
+ using namespace ignite::impl::binary;
+
+ switch (fieldId)
+ {
+ case SQL_DESC_LABEL:
+ case SQL_DESC_BASE_COLUMN_NAME:
+ case SQL_DESC_NAME:
+ {
+ value = columnName;
+
+ return true;
+ }
+
+ case SQL_DESC_TABLE_NAME:
+ case SQL_DESC_BASE_TABLE_NAME:
+ {
+ value = tableName;
+
+ return true;
+ }
+
+ case SQL_DESC_SCHEMA_NAME:
+ {
+ value = schemaName;
+
+ return true;
+ }
+
+ case SQL_DESC_CATALOG_NAME:
+ {
+ value.clear();
+
+ return true;
+ }
+
+ case SQL_DESC_LITERAL_PREFIX:
+ case SQL_DESC_LITERAL_SUFFIX:
+ {
+ if (dataType == IGNITE_TYPE_STRING)
+ value = "'";
+ else
+ value.clear();
+
+ return true;
+ }
+
+ case SQL_DESC_TYPE_NAME:
+ case SQL_DESC_LOCAL_TYPE_NAME:
+ {
+ value = type_traits::BinaryTypeToSqlTypeName(dataType);
+
+ return true;
+ }
+
+ default:
+ return false;
+ }
+ }
+
+ bool ColumnMeta::GetAttribute(uint16_t fieldId, SqlLen& value) const
+ {
+ using namespace ignite::impl::binary;
+
+ switch (fieldId)
+ {
+ case SQL_DESC_FIXED_PREC_SCALE:
+ case SQL_DESC_AUTO_UNIQUE_VALUE:
+ {
+ value = SQL_FALSE;
+
+ return true;
+ }
+
+ case SQL_DESC_CASE_SENSITIVE:
+ {
+ if (dataType == IGNITE_TYPE_STRING)
+ value = SQL_TRUE;
+ else
+ value = SQL_FALSE;
+
+ return true;
+ }
+
+ case SQL_DESC_CONCISE_TYPE:
+ case SQL_DESC_TYPE:
+ {
+ value = type_traits::BinaryToSqlType(dataType);
+
+ return true;
+ }
+
+ case SQL_DESC_DISPLAY_SIZE:
+ {
+ value = type_traits::BinaryTypeDisplaySize(dataType);
+
+ return true;
+ }
+
+ case SQL_DESC_LENGTH:
+ case SQL_DESC_OCTET_LENGTH:
+ {
+ value = type_traits::BinaryTypeTransferLength(dataType);
+
+ return true;
+ }
+
+ case SQL_DESC_NULLABLE:
+ {
+ value = type_traits::BinaryTypeNullability(dataType);
+
+ return true;
+ }
+
+ case SQL_DESC_NUM_PREC_RADIX:
+ {
+ value = type_traits::BinaryTypeNumPrecRadix(dataType);
+
+ return true;
+ }
+
+ case SQL_DESC_PRECISION:
+ {
+ value = type_traits::BinaryTypeColumnSize(dataType);
+
+ return true;
+ }
+
+ case SQL_DESC_SCALE:
+ {
+ value = type_traits::BinaryTypeDecimalDigits(dataType);
+
+ if (value < 0)
+ value = 0;
+
+ return true;
+ }
+
+ case SQL_DESC_SEARCHABLE:
+ {
+ value = SQL_PRED_BASIC;
+
+ return true;
+ }
+
+ case SQL_DESC_UNNAMED:
+ {
+ value = columnName.empty() ? SQL_UNNAMED : SQL_NAMED;
+
+ return true;
+ }
+
+ case SQL_DESC_UNSIGNED:
+ {
+ value = type_traits::BinaryTypeUnsigned(dataType) ? SQL_TRUE : SQL_FALSE;
+
+ return true;
+ }
+
+ case SQL_DESC_UPDATABLE:
+ {
+ // We do not support update for now so just set all
+ // columns to readonly.
+ value = SQL_ATTR_READONLY;
+
+ return true;
+ }
+
+ default:
+ return false;
+ }
+ }
+
+ void ReadColumnMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, ColumnMetaVector& meta)
+ {
+ int32_t metaNum = reader.ReadInt32();
+
+ meta.clear();
+ meta.reserve(static_cast<size_t>(metaNum));
+
+ for (int32_t i = 0; i < metaNum; ++i)
+ {
+ meta.push_back(ColumnMeta());
+
+ meta.back().Read(reader);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/meta/table_meta.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/meta/table_meta.cpp b/modules/platforms/cpp/odbc/src/meta/table_meta.cpp
new file mode 100644
index 0000000..71ced8f
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/meta/table_meta.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "ignite/odbc/meta/table_meta.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ void TableMeta::Read(ignite::impl::binary::BinaryReaderImpl & reader)
+ {
+ utility::ReadString(reader, catalogName);
+ utility::ReadString(reader, schemaName);
+ utility::ReadString(reader, tableName);
+ utility::ReadString(reader, tableType);
+ }
+
+ void ReadTableMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, TableMetaVector& meta)
+ {
+ int32_t metaNum = reader.ReadInt32();
+
+ meta.clear();
+ meta.reserve(static_cast<size_t>(metaNum));
+
+ for (int32_t i = 0; i < metaNum; ++i)
+ {
+ meta.push_back(TableMeta());
+
+ meta.back().Read(reader);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
[13/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
new file mode 100644
index 0000000..84e312a
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -0,0 +1,1687 @@
+/*
+ * 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 <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <algorithm>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/config/configuration.h"
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/environment.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/statement.h"
+
+#ifdef ODBC_DEBUG
+
+FILE* log_file = NULL;
+
+void logInit(const char* path)
+{
+ if (!log_file)
+ {
+ log_file = fopen(path, "w");
+ }
+}
+
+#endif //ODBC_DEBUG
+
+BOOL INSTAPI ConfigDSN(HWND hwndParent,
+ WORD req,
+ LPCSTR driver,
+ LPCSTR attributes)
+{
+ LOG_MSG("ConfigDSN called\n");
+
+ ignite::odbc::config::Configuration config;
+
+ config.FillFromConfigAttributes(attributes);
+
+ if (!SQLValidDSN(config.GetDsn().c_str()))
+ return SQL_FALSE;
+
+ LOG_MSG("Driver: %s\n", driver);
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
+
+ switch (req)
+ {
+ case ODBC_ADD_DSN:
+ {
+ LOG_MSG("ODBC_ADD_DSN\n");
+
+ return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
+ }
+
+ case ODBC_CONFIG_DSN:
+ {
+ LOG_MSG("ODBC_CONFIG_DSN\n");
+ break;
+ }
+
+ case ODBC_REMOVE_DSN:
+ {
+ LOG_MSG("ODBC_REMOVE_DSN\n");
+
+ return SQLRemoveDSNFromIni(config.GetDsn().c_str());
+ }
+
+ default:
+ {
+ return SQL_FALSE;
+ }
+ }
+
+ return SQL_TRUE;
+}
+
+SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
+ SQLUSMALLINT infoType,
+ SQLPOINTER infoValue,
+ SQLSMALLINT infoValueMax,
+ SQLSMALLINT* length)
+{
+ using ignite::odbc::Connection;
+ using ignite::odbc::config::ConnectionInfo;
+
+ LOG_MSG("SQLGetInfo called: %d (%s)\n", infoType, ConnectionInfo::InfoTypeToString(infoType));
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ connection->GetInfo(infoType, infoValue, infoValueMax, length);
+
+ return connection->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result)
+{
+ //LOG_MSG("SQLAllocHandle called\n");
+ switch (type)
+ {
+ case SQL_HANDLE_ENV:
+ return SQLAllocEnv(result);
+
+ case SQL_HANDLE_DBC:
+ return SQLAllocConnect(parent, result);
+
+ case SQL_HANDLE_STMT:
+ return SQLAllocStmt(parent, result);
+
+ case SQL_HANDLE_DESC:
+ default:
+ break;
+ }
+
+ *result = 0;
+ return SQL_ERROR;
+}
+
+SQLRETURN SQL_API SQLAllocEnv(SQLHENV* env)
+{
+ using ignite::odbc::Environment;
+
+ LOG_MSG("SQLAllocEnv called\n");
+
+ *env = reinterpret_cast<SQLHENV>(new Environment());
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC* conn)
+{
+ using ignite::odbc::Environment;
+ using ignite::odbc::Connection;
+
+ LOG_MSG("SQLAllocConnect called\n");
+
+ *conn = SQL_NULL_HDBC;
+
+ Environment *environment = reinterpret_cast<Environment*>(env);
+
+ if (!environment)
+ return SQL_INVALID_HANDLE;
+
+ Connection *connection = environment->CreateConnection();
+
+ if (!connection)
+ return environment->GetDiagnosticRecords().GetReturnCode();
+
+ *conn = reinterpret_cast<SQLHDBC>(connection);
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt)
+{
+ using ignite::odbc::Connection;
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLAllocStmt called\n");
+
+ *stmt = SQL_NULL_HDBC;
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ Statement *statement = connection->CreateStatement();
+
+ *stmt = reinterpret_cast<SQLHSTMT>(statement);
+
+ return connection->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle)
+{
+ switch (type)
+ {
+ case SQL_HANDLE_ENV:
+ return SQLFreeEnv(handle);
+
+ case SQL_HANDLE_DBC:
+ return SQLFreeConnect(handle);
+
+ case SQL_HANDLE_STMT:
+ return SQLFreeStmt(handle, SQL_DROP);
+
+ case SQL_HANDLE_DESC:
+ default:
+ break;
+ }
+
+ return SQL_ERROR;
+}
+
+SQLRETURN SQL_API SQLFreeEnv(SQLHENV env)
+{
+ using ignite::odbc::Environment;
+
+ LOG_MSG("SQLFreeEnv called\n");
+
+ Environment *environment = reinterpret_cast<Environment*>(env);
+
+ if (!environment)
+ return SQL_INVALID_HANDLE;
+
+ delete environment;
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLFreeConnect(SQLHDBC conn)
+{
+ using ignite::odbc::Connection;
+
+ LOG_MSG("SQLFreeConnect called\n");
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ delete connection;
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLFreeStmt called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ switch (option)
+ {
+ case SQL_DROP:
+ {
+ delete statement;
+
+ break;
+ }
+
+ case SQL_CLOSE:
+ {
+ return SQLCloseCursor(stmt);
+ }
+
+ case SQL_UNBIND:
+ {
+ statement->UnbindAllColumns();
+
+ break;
+ }
+
+ case SQL_RESET_PARAMS:
+ {
+ statement->UnbindAllParameters();
+
+ break;
+ }
+
+ default:
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLCloseCursor called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ statement->Close();
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLDriverConnect(SQLHDBC conn,
+ SQLHWND windowHandle,
+ SQLCHAR* inConnectionString,
+ SQLSMALLINT inConnectionStringLen,
+ SQLCHAR* outConnectionString,
+ SQLSMALLINT outConnectionStringBufferLen,
+ SQLSMALLINT* outConnectionStringLen,
+ SQLUSMALLINT driverCompletion)
+{
+ using ignite::odbc::Connection;
+ using ignite::odbc::diagnostic::DiagnosticRecordStorage;
+ using ignite::utility::SqlStringToString;
+ using ignite::utility::CopyStringToBuffer;
+
+ UNREFERENCED_PARAMETER(windowHandle);
+
+ LOG_MSG("SQLDriverConnect called\n");
+ LOG_MSG("Connection String: [%s]\n", inConnectionString);
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
+
+ ignite::odbc::config::Configuration config;
+
+ config.FillFromConnectString(connectStr);
+
+ connection->Establish(config.GetHost(), config.GetPort(), config.GetCache());
+
+ const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
+
+ if (!diag.IsSuccessful())
+ return diag.GetReturnCode();
+
+ std::string outConnectStr = config.ToConnectString();
+
+ size_t reslen = CopyStringToBuffer(outConnectStr,
+ reinterpret_cast<char*>(outConnectionString),
+ static_cast<size_t>(outConnectionStringBufferLen));
+
+ if (outConnectionStringLen)
+ *outConnectionStringLen = static_cast<SQLSMALLINT>(reslen);
+
+ LOG_MSG("%s\n", outConnectionString);
+
+ return diag.GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLConnect(SQLHDBC conn,
+ SQLCHAR* serverName,
+ SQLSMALLINT serverNameLen,
+ SQLCHAR* userName,
+ SQLSMALLINT userNameLen,
+ SQLCHAR* auth,
+ SQLSMALLINT authLen)
+{
+ using ignite::odbc::Connection;
+ using ignite::odbc::diagnostic::DiagnosticRecordStorage;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLConnect called\n");
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ std::string server = SqlStringToString(serverName, serverNameLen);
+
+ connection->Establish(server);
+
+ return connection->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLDisconnect(SQLHDBC conn)
+{
+ using ignite::odbc::Connection;
+
+ LOG_MSG("SQLDisconnect called\n");
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ connection->Release();
+
+ return connection->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
+{
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLPrepare called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string sql = SqlStringToString(query, queryLen);
+
+ LOG_MSG("SQL: %s\n", sql.c_str());
+
+ statement->PrepareSqlQuery(sql);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLExecute called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ statement->ExecuteSqlQuery();
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
+{
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLExecDirect called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string sql = SqlStringToString(query, queryLen);
+
+ LOG_MSG("SQL: %s\n", sql.c_str());
+
+ statement->ExecuteSqlQuery(sql);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator)
+{
+ using namespace ignite::odbc::type_traits;
+
+ using ignite::odbc::Statement;
+ using ignite::odbc::app::ApplicationDataBuffer;
+
+ LOG_MSG("SQLBindCol called: index=%d, type=%d\n", colNum, targetType);
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ IgniteSqlType driverType = ToDriverType(targetType);
+
+ if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
+ return SQL_ERROR;
+
+ if (bufferLength < 0)
+ return SQL_ERROR;
+
+ if (targetValue || strLengthOrIndicator)
+ {
+ ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
+
+ statement->BindColumn(colNum, dataBuffer);
+ }
+ else
+ statement->UnbindColumn(colNum);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLFetch called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ statement->FetchRow();
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt,
+ SQLSMALLINT orientation,
+ SQLLEN offset)
+{
+ LOG_MSG("SQLFetchScroll called\n");
+ LOG_MSG("Orientation: %d, Offset: %d\n", orientation, offset);
+
+ if (orientation != SQL_FETCH_NEXT)
+ return SQL_ERROR;
+
+ return SQLFetch(stmt);
+}
+
+SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt,
+ SQLUSMALLINT orientation,
+ SQLLEN offset,
+ SQLULEN* rowCount,
+ SQLUSMALLINT* rowStatusArray)
+{
+ LOG_MSG("SQLExtendedFetch called\n");
+
+ SQLRETURN res = SQLFetchScroll(stmt, orientation, offset);
+
+ if (res == SQL_SUCCESS || res == SQL_NO_DATA)
+ {
+ if (rowCount)
+ *rowCount = 1;
+
+ if (rowStatusArray)
+ rowStatusArray[0] = SQL_ROW_SUCCESS;
+ }
+
+ return res;
+}
+
+SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *columnNum)
+{
+ using ignite::odbc::Statement;
+ using ignite::odbc::meta::ColumnMetaVector;
+
+ LOG_MSG("SQLNumResultCols called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ int32_t res = statement->GetColumnNumber();
+
+ *columnNum = static_cast<SQLSMALLINT>(res);
+
+ LOG_MSG("columnNum: %d\n", *columnNum);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLTables(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* tableType,
+ SQLSMALLINT tableTypeLen)
+{
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLTables called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
+ std::string tableTypeStr = SqlStringToString(tableType, tableTypeLen);
+
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
+ LOG_MSG("tableType: %s\n", tableTypeStr.c_str());
+
+ statement->ExecuteGetTablesMetaQuery(catalog, schema, table, tableTypeStr);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* columnName,
+ SQLSMALLINT columnNameLen)
+{
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLColumns called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
+ std::string column = SqlStringToString(columnName, columnNameLen);
+
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
+ LOG_MSG("column: %s\n", column.c_str());
+
+ statement->ExecuteGetColumnsMetaQuery(schema, table, column);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLMoreResults called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ //TODO: reset diagnostic here.
+ return statement->DataAvailable() ? SQL_SUCCESS : SQL_NO_DATA;
+}
+
+SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt,
+ SQLUSMALLINT paramIdx,
+ SQLSMALLINT ioType,
+ SQLSMALLINT bufferType,
+ SQLSMALLINT paramSqlType,
+ SQLULEN columnSize,
+ SQLSMALLINT decDigits,
+ SQLPOINTER buffer,
+ SQLLEN bufferLen,
+ SQLLEN* resLen)
+{
+ using namespace ignite::odbc::type_traits;
+
+ using ignite::odbc::Statement;
+ using ignite::odbc::app::ApplicationDataBuffer;
+ using ignite::odbc::app::Parameter;
+ using ignite::odbc::type_traits::IsSqlTypeSupported;
+
+ LOG_MSG("SQLBindParameter called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ if (ioType != SQL_PARAM_INPUT)
+ return SQL_ERROR;
+
+ if (*resLen == SQL_DATA_AT_EXEC || *resLen <= SQL_LEN_DATA_AT_EXEC_OFFSET)
+ return SQL_ERROR;
+
+ if (!IsSqlTypeSupported(paramSqlType))
+ return SQL_ERROR;
+
+ IgniteSqlType driverType = ToDriverType(bufferType);
+
+ if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
+ return SQL_ERROR;
+
+ if (buffer)
+ {
+ ApplicationDataBuffer dataBuffer(driverType, buffer, bufferLen, resLen);
+
+ Parameter param(dataBuffer, paramSqlType, columnSize, decDigits);
+
+ statement->BindParameter(paramIdx, param);
+ }
+ else
+ statement->UnbindParameter(paramIdx);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLNativeSql(SQLHDBC conn,
+ SQLCHAR* inQuery,
+ SQLINTEGER inQueryLen,
+ SQLCHAR* outQueryBuffer,
+ SQLINTEGER outQueryBufferLen,
+ SQLINTEGER* outQueryLen)
+{
+ using namespace ignite::utility;
+
+ LOG_MSG("SQLNativeSql called\n");
+
+ std::string in = SqlStringToString(inQuery, inQueryLen);
+
+ CopyStringToBuffer(in, reinterpret_cast<char*>(outQueryBuffer),
+ static_cast<size_t>(outQueryBufferLen));
+
+ *outQueryLen = std::min(outQueryBufferLen, static_cast<SQLINTEGER>(in.size()));
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLUSMALLINT fieldId,
+ SQLPOINTER strAttr,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* strAttrLen,
+ SQLLEN* numericAttr)
+{
+ using ignite::odbc::Statement;
+ using ignite::odbc::meta::ColumnMetaVector;
+ using ignite::odbc::meta::ColumnMeta;
+
+ LOG_MSG("SQLColAttribute called: %d (%s)\n", fieldId, ColumnMeta::AttrIdToString(fieldId));
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ // This is a special case
+ if (fieldId == SQL_DESC_COUNT)
+ {
+ SQLSMALLINT val = 0;
+
+ SQLRETURN res = SQLNumResultCols(stmt, &val);
+
+ if (res == SQL_SUCCESS)
+ *numericAttr = val;
+
+ return res;
+ }
+
+ statement->GetColumnAttribute(columnNum, fieldId, reinterpret_cast<char*>(strAttr),
+ bufferLen, strAttrLen, numericAttr);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLCHAR* columnNameBuf,
+ SQLSMALLINT columnNameBufLen,
+ SQLSMALLINT* columnNameLen,
+ SQLSMALLINT* dataType,
+ SQLULEN* columnSize,
+ SQLSMALLINT* decimalDigits,
+ SQLSMALLINT* nullable)
+{
+ using ignite::odbc::Statement;
+ using ignite::odbc::SqlLen;
+
+ LOG_MSG("SQLDescribeCol called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ statement->GetColumnAttribute(columnNum, SQL_DESC_NAME,
+ reinterpret_cast<char*>(columnNameBuf), columnNameBufLen, columnNameLen, 0);
+
+ SqlLen dataTypeRes;
+ SqlLen columnSizeRes;
+ SqlLen decimalDigitsRes;
+ SqlLen nullableRes;
+
+ statement->GetColumnAttribute(columnNum, SQL_DESC_TYPE, 0, 0, 0, &dataTypeRes);
+ statement->GetColumnAttribute(columnNum, SQL_DESC_PRECISION, 0, 0, 0, &columnSizeRes);
+ statement->GetColumnAttribute(columnNum, SQL_DESC_SCALE, 0, 0, 0, &decimalDigitsRes);
+ statement->GetColumnAttribute(columnNum, SQL_DESC_NULLABLE, 0, 0, 0, &nullableRes);
+
+ LOG_MSG("columnNum: %lld\n", columnNum);
+ LOG_MSG("dataTypeRes: %lld\n", dataTypeRes);
+ LOG_MSG("columnSizeRes: %lld\n", columnSizeRes);
+ LOG_MSG("decimalDigitsRes: %lld\n", decimalDigitsRes);
+ LOG_MSG("nullableRes: %lld\n", nullableRes);
+ LOG_MSG("columnNameBuf: %s\n", columnNameBuf);
+ LOG_MSG("columnNameLen: %d\n", *columnNameLen);
+
+ *dataType = static_cast<SQLSMALLINT>(dataTypeRes);
+ *columnSize = static_cast<SQLULEN>(columnSizeRes);
+ *decimalDigits = static_cast<SQLSMALLINT>(decimalDigitsRes);
+ *nullable = static_cast<SQLSMALLINT>(nullableRes);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+
+SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCnt)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLRowCount called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ int64_t res = statement->AffectedRows();
+
+ *rowCnt = static_cast<SQLLEN>(res);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt,
+ SQLCHAR* primaryCatalogName,
+ SQLSMALLINT primaryCatalogNameLen,
+ SQLCHAR* primarySchemaName,
+ SQLSMALLINT primarySchemaNameLen,
+ SQLCHAR* primaryTableName,
+ SQLSMALLINT primaryTableNameLen,
+ SQLCHAR* foreignCatalogName,
+ SQLSMALLINT foreignCatalogNameLen,
+ SQLCHAR* foreignSchemaName,
+ SQLSMALLINT foreignSchemaNameLen,
+ SQLCHAR* foreignTableName,
+ SQLSMALLINT foreignTableNameLen)
+{
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLForeignKeys called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string primaryCatalog = SqlStringToString(primaryCatalogName, primaryCatalogNameLen);
+ std::string primarySchema = SqlStringToString(primarySchemaName, primarySchemaNameLen);
+ std::string primaryTable = SqlStringToString(primaryTableName, primaryTableNameLen);
+ std::string foreignCatalog = SqlStringToString(foreignCatalogName, foreignCatalogNameLen);
+ std::string foreignSchema = SqlStringToString(foreignSchemaName, foreignSchemaNameLen);
+ std::string foreignTable = SqlStringToString(foreignTableName, foreignTableNameLen);
+
+ LOG_MSG("primaryCatalog: %s\n", primaryCatalog.c_str());
+ LOG_MSG("primarySchema: %s\n", primarySchema.c_str());
+ LOG_MSG("primaryTable: %s\n", primaryTable.c_str());
+ LOG_MSG("foreignCatalog: %s\n", foreignCatalog.c_str());
+ LOG_MSG("foreignSchema: %s\n", foreignSchema.c_str());
+ LOG_MSG("foreignTable: %s\n", foreignTable.c_str());
+
+ statement->ExecuteGetForeignKeysQuery(primaryCatalog, primarySchema,
+ primaryTable, foreignCatalog, foreignSchema, foreignTable);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLGetStmtAttr called");
+
+#ifdef ODBC_DEBUG
+ using ignite::odbc::type_traits::StatementAttrIdToString;
+
+ LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
+#endif //ODBC_DEBUG
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ //TODO: move this logic into Statement.
+ switch (attr)
+ {
+ case SQL_ATTR_APP_ROW_DESC:
+ case SQL_ATTR_APP_PARAM_DESC:
+ case SQL_ATTR_IMP_ROW_DESC:
+ case SQL_ATTR_IMP_PARAM_DESC:
+ {
+ SQLPOINTER *val = reinterpret_cast<SQLPOINTER*>(valueBuf);
+
+ *val = static_cast<SQLPOINTER>(stmt);
+
+ break;
+ }
+
+ case SQL_ATTR_ROW_ARRAY_SIZE:
+ {
+ SQLINTEGER *val = reinterpret_cast<SQLINTEGER*>(valueBuf);
+
+ *val = static_cast<SQLINTEGER>(1);
+
+ break;
+ }
+
+ case SQL_ATTR_ROWS_FETCHED_PTR:
+ {
+ SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
+
+ *val = reinterpret_cast<SQLULEN*>(statement->GetRowsFetchedPtr());
+
+ break;
+ }
+
+ case SQL_ATTR_ROW_STATUS_PTR:
+ {
+ SQLUSMALLINT** val = reinterpret_cast<SQLUSMALLINT**>(valueBuf);
+
+ *val = reinterpret_cast<SQLUSMALLINT*>(statement->GetRowStatusesPtr());
+
+ break;
+ }
+
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
+ {
+ SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
+
+ *val = reinterpret_cast<SQLULEN*>(statement->GetParamBindOffsetPtr());
+
+ break;
+ }
+
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR:
+ {
+ SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
+
+ *val = reinterpret_cast<SQLULEN*>(statement->GetColumnBindOffsetPtr());
+
+ break;
+ }
+
+ default:
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLSetStmtAttr called");
+
+#ifdef ODBC_DEBUG
+ using ignite::odbc::type_traits::StatementAttrIdToString;
+
+ LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
+#endif //ODBC_DEBUG
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ //TODO: move this logic into Statement.
+ switch (attr)
+ {
+ case SQL_ATTR_ROW_ARRAY_SIZE:
+ {
+ SQLULEN val = reinterpret_cast<SQLULEN>(value);
+
+ LOG_MSG("Value: %d\n", val);
+
+ if (val != 1)
+ return SQL_ERROR;
+
+ break;
+ }
+
+ case SQL_ATTR_ROWS_FETCHED_PTR:
+ {
+ statement->SetRowsFetchedPtr(reinterpret_cast<size_t*>(value));
+
+ break;
+ }
+
+ case SQL_ATTR_ROW_STATUS_PTR:
+ {
+ statement->SetRowStatusesPtr(reinterpret_cast<uint16_t*>(value));
+
+ break;
+ }
+
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
+ {
+ statement->SetParamBindOffsetPtr(reinterpret_cast<size_t*>(value));
+
+ break;
+ }
+
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR:
+ {
+ statement->SetColumnBindOffsetPtr(reinterpret_cast<size_t*>(value));
+
+ break;
+ }
+
+ default:
+ return SQL_ERROR;
+ }
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+{
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLPrimaryKeys called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
+
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
+
+ statement->ExecuteGetPrimaryKeysQuery(catalog, schema, table);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLNumParams called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ *paramCnt = static_cast<SQLSMALLINT>(statement->GetParametersNumber());
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLSMALLINT diagId,
+ SQLPOINTER buffer,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* resLen)
+{
+ using namespace ignite::odbc;
+ using namespace ignite::odbc::diagnostic;
+ using namespace ignite::odbc::type_traits;
+
+ using ignite::odbc::app::ApplicationDataBuffer;
+
+ LOG_MSG("SQLGetDiagField called: %d\n", recNum);
+
+ SqlLen outResLen;
+ ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, buffer, bufferLen, &outResLen);
+
+ SqlResult result;
+
+ DiagnosticField field = DiagnosticFieldToInternal(diagId);
+
+ switch (handleType)
+ {
+ case SQL_HANDLE_ENV:
+ case SQL_HANDLE_DBC:
+ case SQL_HANDLE_STMT:
+ {
+ Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
+
+ result = diag->GetDiagnosticRecords().GetField(recNum, field, outBuffer);
+
+ break;
+ }
+
+ default:
+ {
+ result = SQL_RESULT_NO_DATA;
+ break;
+ }
+ }
+
+ if (result == SQL_RESULT_SUCCESS)
+ *resLen = static_cast<SQLSMALLINT>(outResLen);
+
+ return SqlResultToReturnCode(result);
+}
+
+SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLCHAR* sqlState,
+ SQLINTEGER* nativeError,
+ SQLCHAR* msgBuffer,
+ SQLSMALLINT msgBufferLen,
+ SQLSMALLINT* msgLen)
+{
+ using namespace ignite::utility;
+ using namespace ignite::odbc;
+ using namespace ignite::odbc::diagnostic;
+ using namespace ignite::odbc::type_traits;
+
+ using ignite::odbc::app::ApplicationDataBuffer;
+
+ LOG_MSG("SQLGetDiagRec called\n");
+
+ const DiagnosticRecordStorage* records = 0;
+
+ switch (handleType)
+ {
+ case SQL_HANDLE_ENV:
+ case SQL_HANDLE_DBC:
+ case SQL_HANDLE_STMT:
+ {
+ Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
+
+ records = &diag->GetDiagnosticRecords();
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (!records || recNum < 1 || recNum > records->GetStatusRecordsNumber())
+ return SQL_NO_DATA;
+
+ const DiagnosticRecord& record = records->GetStatusRecord(recNum);
+
+ if (sqlState)
+ CopyStringToBuffer(record.GetSqlState(), reinterpret_cast<char*>(sqlState), 6);
+
+ if (nativeError)
+ *nativeError = 0;
+
+ SqlLen outResLen;
+ ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
+
+ outBuffer.PutString(record.GetMessage());
+
+ *msgLen = static_cast<SQLSMALLINT>(outResLen);
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt,
+ SQLSMALLINT type)
+{
+ using ignite::odbc::Statement;
+
+ LOG_MSG("SQLGetTypeInfo called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ statement->ExecuteGetTypeInfoQuery(static_cast<int16_t>(type));
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT completionType)
+{
+ using namespace ignite::odbc;
+
+ LOG_MSG("SQLEndTran called\n");
+
+ SQLRETURN result;
+
+ switch (handleType)
+ {
+ case SQL_HANDLE_ENV:
+ {
+ Environment *env = reinterpret_cast<Environment*>(handle);
+
+ if (!env)
+ return SQL_INVALID_HANDLE;
+
+ if (completionType == SQL_COMMIT)
+ env->TransactionCommit();
+ else
+ env->TransactionRollback();
+
+ result = env->GetDiagnosticRecords().GetReturnCode();
+
+ break;
+ }
+
+ case SQL_HANDLE_DBC:
+ {
+ Connection *conn = reinterpret_cast<Connection*>(handle);
+
+ if (!conn)
+ return SQL_INVALID_HANDLE;
+
+ if (completionType == SQL_COMMIT)
+ conn->TransactionCommit();
+ else
+ conn->TransactionRollback();
+
+ result = conn->GetDiagnosticRecords().GetReturnCode();
+
+ break;
+ }
+
+ default:
+ {
+ result = SQL_INVALID_HANDLE;
+
+ break;
+ }
+ }
+
+ return result;
+}
+
+SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator)
+{
+ using namespace ignite::odbc::type_traits;
+
+ using ignite::odbc::Statement;
+ using ignite::odbc::app::ApplicationDataBuffer;
+
+ LOG_MSG("SQLGetData called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ IgniteSqlType driverType = ToDriverType(targetType);
+
+ ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
+
+ statement->GetColumnData(colNum, dataBuffer);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+{
+ using ignite::odbc::Environment;
+
+ LOG_MSG("SQLSetEnvAttr called\n");
+
+ Environment *environment = reinterpret_cast<Environment*>(env);
+
+ if (!environment)
+ return SQL_INVALID_HANDLE;
+
+ environment->SetAttribute(attr, value, valueLen);
+
+ return environment->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+{
+ using namespace ignite::odbc;
+ using namespace ignite::odbc::type_traits;
+
+ using ignite::odbc::app::ApplicationDataBuffer;
+
+ LOG_MSG("SQLGetEnvAttr called\n");
+
+ Environment *environment = reinterpret_cast<Environment*>(env);
+
+ if (!environment)
+ return SQL_INVALID_HANDLE;
+
+ SqlLen outResLen;
+ ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, valueBuf,
+ static_cast<int32_t>(valueBufLen), &outResLen);
+
+ environment->GetAttribute(attr, outBuffer);
+
+ *valueResLen = static_cast<SQLSMALLINT>(outResLen);
+
+ return environment->GetDiagnosticRecords().GetReturnCode();
+}
+
+SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt,
+ SQLSMALLINT idType,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLSMALLINT scope,
+ SQLSMALLINT nullable)
+{
+ using namespace ignite::odbc;
+
+ using ignite::utility::SqlStringToString;
+
+ LOG_MSG("SQLSpecialColumns called\n");
+
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
+
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
+
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
+
+ statement->ExecuteSpecialColumnsQuery(idType, catalog, schema, table, scope, nullable);
+
+ return statement->GetDiagnosticRecords().GetReturnCode();
+}
+
+//
+// ==== Not implemented ====
+//
+
+SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt)
+{
+ LOG_MSG("SQLCancel called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLUSMALLINT fieldId,
+ SQLPOINTER strAttrBuf,
+ SQLSMALLINT strAttrBufLen,
+ SQLSMALLINT* strAttrResLen,
+ SQLLEN* numAttrBuf)
+{
+ LOG_MSG("SQLColAttributes called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLError(SQLHENV env,
+ SQLHDBC conn,
+ SQLHSTMT stmt,
+ SQLCHAR* state,
+ SQLINTEGER* error,
+ SQLCHAR* msgBuf,
+ SQLSMALLINT msgBufLen,
+ SQLSMALLINT* msgResLen)
+{
+ LOG_MSG("SQLError called\n");
+ return(SQL_NO_DATA_FOUND);
+}
+
+SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt,
+ SQLCHAR* nameBuf,
+ SQLSMALLINT nameBufLen,
+ SQLSMALLINT* nameResLen)
+{
+ LOG_MSG("SQLGetCursorName called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt,
+ SQLCHAR* name,
+ SQLSMALLINT nameLen)
+{
+ LOG_MSG("SQLSetCursorName called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC conn,
+ SQLUSMALLINT option,
+ SQLPOINTER value)
+{
+ LOG_MSG("SQLGetConnectOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetFunctions(SQLHDBC conn,
+ SQLUSMALLINT funcId,
+ SQLUSMALLINT* supported)
+{
+ LOG_MSG("SQLGetFunctions called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt,
+ SQLUSMALLINT option,
+ SQLPOINTER value)
+{
+ LOG_MSG("SQLGetStmtOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt,
+ SQLPOINTER* value)
+{
+ LOG_MSG("SQLParamData called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt,
+ SQLPOINTER data,
+ SQLLEN strLengthOrIndicator)
+{
+ LOG_MSG("SQLPutData called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC conn,
+ SQLUSMALLINT option,
+ SQLULEN value)
+{
+ LOG_MSG("SQLSetConnectOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt,
+ SQLUSMALLINT option,
+ SQLULEN value)
+{
+ LOG_MSG("SQLSetStmtOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLUSMALLINT unique,
+ SQLUSMALLINT reserved)
+{
+ LOG_MSG("SQLStatistics called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC conn,
+ SQLCHAR* inConnectionStr,
+ SQLSMALLINT inConnectionStrLen,
+ SQLCHAR* outConnectionStrBuf,
+ SQLSMALLINT outConnectionStrBufLen,
+ SQLSMALLINT* outConnectionStrResLen)
+{
+ LOG_MSG("SQLBrowseConnect called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt,
+ SQLCHAR * catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR * schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR * procName,
+ SQLSMALLINT procNameLen,
+ SQLCHAR * columnName,
+ SQLSMALLINT columnNameLen)
+{
+ LOG_MSG("SQLProcedureColumns called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt,
+ SQLSETPOSIROW rowNum,
+ SQLUSMALLINT operation,
+ SQLUSMALLINT lockType)
+{
+ LOG_MSG("SQLSetPos called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt,
+ SQLUSMALLINT concurrency,
+ SQLLEN crowKeyset,
+ SQLUSMALLINT crowRowset)
+{
+ LOG_MSG("SQLSetScrollOptions called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC conn,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+{
+ LOG_MSG("SQLGetConnectAttr called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC conn,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+{
+ using ignite::odbc::Connection;
+
+ LOG_MSG("SQLSetConnectAttr called\n");
+
+ Connection *connection = reinterpret_cast<Connection*>(conn);
+
+ if (!connection)
+ return SQL_INVALID_HANDLE;
+
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt,
+ SQLUSMALLINT operation)
+{
+ LOG_MSG("SQLBulkOperations called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+{
+ LOG_MSG("SQLTablePrivileges called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLCopyDesc(SQLHDESC src, SQLHDESC dst)
+{
+ LOG_MSG("SQLCopyDesc called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetDescField(SQLHDESC descr,
+ SQLSMALLINT recNum,
+ SQLSMALLINT fieldId,
+ SQLPOINTER buffer,
+ SQLINTEGER bufferLen,
+ SQLINTEGER* resLen)
+{
+ LOG_MSG("SQLGetDescField called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber,
+ SQLCHAR* nameBuffer,
+ SQLSMALLINT nameBufferLen,
+ SQLSMALLINT* strLen,
+ SQLSMALLINT* type,
+ SQLSMALLINT* subType,
+ SQLLEN* len,
+ SQLSMALLINT* precision,
+ SQLSMALLINT* scale,
+ SQLSMALLINT* nullable)
+{
+ LOG_MSG("SQLGetDescRec called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetDescField(SQLHDESC descr,
+ SQLSMALLINT recNum,
+ SQLSMALLINT fieldId,
+ SQLPOINTER buffer,
+ SQLINTEGER bufferLen)
+{
+ LOG_MSG("SQLSetDescField called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetDescRec(SQLHDESC descr,
+ SQLSMALLINT recNum,
+ SQLSMALLINT type,
+ SQLSMALLINT subType,
+ SQLLEN len,
+ SQLSMALLINT precision,
+ SQLSMALLINT scale,
+ SQLPOINTER buffer,
+ SQLLEN* resLen,
+ SQLLEN* id)
+{
+ LOG_MSG("SQLSetDescRec called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* columnName,
+ SQLSMALLINT columnNameLen)
+{
+ LOG_MSG("SQLColumnPrivileges called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT stmt,
+ SQLUSMALLINT paramNum,
+ SQLSMALLINT* dataType,
+ SQLULEN* paramSize,
+ SQLSMALLINT* decimalDigits,
+ SQLSMALLINT* nullable)
+{
+ LOG_MSG("SQLDescribeParam called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLParamOptions(SQLHSTMT stmt,
+ SQLULEN paramSetSize,
+ SQLULEN* paramsProcessed)
+{
+ LOG_MSG("SQLParamOptions called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLProcedures(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+{
+ LOG_MSG("SQLProcedures called\n");
+ return SQL_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp b/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp
new file mode 100644
index 0000000..69a08b1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp
@@ -0,0 +1,317 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/message.h"
+#include "ignite/odbc/query/column_metadata_query.h"
+
+namespace
+{
+ enum ResultColumn
+ {
+ /** Catalog name. NULL if not applicable to the data source. */
+ TABLE_CAT = 1,
+
+ /** Schema name. NULL if not applicable to the data source. */
+ TABLE_SCHEM,
+
+ /** Table name. */
+ TABLE_NAME,
+
+ /** Column name. */
+ COLUMN_NAME,
+
+ /** SQL data type. */
+ DATA_TYPE,
+
+ /** Data source�dependent data type name. */
+ TYPE_NAME,
+
+ /** Column size. */
+ COLUMN_SIZE,
+
+ /** The length in bytes of data transferred on fetch. */
+ BUFFER_LENGTH,
+
+ /** The total number of significant digits to the right of the decimal point. */
+ DECIMAL_DIGITS,
+
+ /** Precision. */
+ NUM_PREC_RADIX,
+
+ /** Nullability of the data in column. */
+ NULLABLE,
+
+ /** A description of the column. */
+ REMARKS
+ };
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ ColumnMetadataQuery::ColumnMetadataQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& schema,
+ const std::string& table, const std::string& column) :
+ Query(diag),
+ connection(connection),
+ schema(schema),
+ table(table),
+ column(column),
+ executed(false),
+ meta(),
+ columnsMeta()
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::odbc::type_traits;
+
+ using meta::ColumnMeta;
+
+ columnsMeta.reserve(12);
+
+ const std::string sch("");
+ const std::string tbl("");
+
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_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, "TYPE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_SIZE", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "BUFFER_LENGTH", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "DECIMAL_DIGITS", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "NUM_PREC_RADIX", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "NULLABLE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "REMARKS", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ }
+
+ ColumnMetadataQuery::~ColumnMetadataQuery()
+ {
+ // No-op.
+ }
+
+ SqlResult ColumnMetadataQuery::Execute()
+ {
+ if (executed)
+ Close();
+
+ SqlResult result = MakeRequestGetColumnsMeta();
+
+ if (result == SQL_RESULT_SUCCESS)
+ {
+ executed = true;
+
+ cursor = meta.begin();
+ }
+
+ return result;
+ }
+
+ const meta::ColumnMetaVector& ColumnMetadataQuery::GetMeta() const
+ {
+ return columnsMeta;
+ }
+
+ SqlResult ColumnMetadataQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cursor == meta.end())
+ return SQL_RESULT_NO_DATA;
+
+ app::ColumnBindingMap::iterator it;
+
+ for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
+ GetColumn(it->first, it->second);
+
+ ++cursor;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult ColumnMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cursor == meta.end())
+ return SQL_RESULT_NO_DATA;
+
+ const meta::ColumnMeta& currentColumn = *cursor;
+ uint8_t columnType = currentColumn.GetDataType();
+
+ switch (columnIdx)
+ {
+ case TABLE_CAT:
+ {
+ buffer.PutNull();
+ break;
+ }
+
+ case TABLE_SCHEM:
+ {
+ buffer.PutString(currentColumn.GetSchemaName());
+ break;
+ }
+
+ case TABLE_NAME:
+ {
+ buffer.PutString(currentColumn.GetTableName());
+ break;
+ }
+
+ case COLUMN_NAME:
+ {
+ buffer.PutString(currentColumn.GetColumnName());
+ break;
+ }
+
+ case DATA_TYPE:
+ {
+ buffer.PutInt16(type_traits::BinaryToSqlType(columnType));
+ break;
+ }
+
+ case TYPE_NAME:
+ {
+ buffer.PutString(currentColumn.GetColumnTypeName());
+ break;
+ }
+
+ case COLUMN_SIZE:
+ {
+ buffer.PutInt16(type_traits::BinaryTypeColumnSize(columnType));
+ break;
+ }
+
+ case BUFFER_LENGTH:
+ {
+ buffer.PutInt16(type_traits::BinaryTypeTransferLength(columnType));
+ break;
+ }
+
+ case DECIMAL_DIGITS:
+ {
+ int32_t decDigits = type_traits::BinaryTypeDecimalDigits(columnType);
+ if (decDigits < 0)
+ buffer.PutNull();
+ else
+ buffer.PutInt16(static_cast<int16_t>(decDigits));
+ break;
+ }
+
+ case NUM_PREC_RADIX:
+ {
+ buffer.PutInt16(type_traits::BinaryTypeNumPrecRadix(columnType));
+ break;
+ }
+
+ case NULLABLE:
+ {
+ buffer.PutInt16(type_traits::BinaryTypeNullability(columnType));
+ break;
+ }
+
+ case REMARKS:
+ {
+ buffer.PutNull();
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult ColumnMetadataQuery::Close()
+ {
+ meta.clear();
+
+ executed = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool ColumnMetadataQuery::DataAvailable() const
+ {
+ return cursor != meta.end();
+ }
+
+ int64_t ColumnMetadataQuery::AffectedRows() const
+ {
+ return 0;
+ }
+
+ SqlResult ColumnMetadataQuery::MakeRequestGetColumnsMeta()
+ {
+ QueryGetColumnsMetaRequest req(schema, table, column);
+ QueryGetColumnsMetaResponse rsp;
+
+ bool success = connection.SyncMessage(req, rsp);
+
+ if (!success)
+ {
+ diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
+ {
+ LOG_MSG("Error: %s\n", rsp.GetError().c_str());
+
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ meta = rsp.GetMeta();
+
+ for (size_t i = 0; i < meta.size(); ++i)
+ {
+ LOG_MSG("[%d] SchemaName: %s\n", i, meta[i].GetSchemaName().c_str());
+ LOG_MSG("[%d] TableName: %s\n", i, meta[i].GetTableName().c_str());
+ LOG_MSG("[%d] ColumnName: %s\n", i, meta[i].GetColumnName().c_str());
+ LOG_MSG("[%d] ColumnTypeName: %s\n", i, meta[i].GetColumnTypeName().c_str());
+ LOG_MSG("[%d] ColumnType: %d\n", i, meta[i].GetDataType());
+ LOG_MSG("\n");
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/data_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/data_query.cpp b/modules/platforms/cpp/odbc/src/query/data_query.cpp
new file mode 100644
index 0000000..4e9239b
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/data_query.cpp
@@ -0,0 +1,277 @@
+/*
+ * 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 "ignite/odbc/connection.h"
+#include "ignite/odbc/message.h"
+#include "ignite/odbc/query/data_query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ DataQuery::DataQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& sql,
+ const app::ParameterBindingMap& params) :
+ Query(diag),
+ connection(connection),
+ sql(sql),
+ params(params)
+ {
+ // No-op.
+ }
+
+ DataQuery::~DataQuery()
+ {
+ Close();
+ }
+
+ SqlResult DataQuery::Execute()
+ {
+ if (cursor.get())
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query cursor is in open state already.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return MakeRequestExecute();
+ }
+
+ const meta::ColumnMetaVector & DataQuery::GetMeta() const
+ {
+ return resultMeta;
+ }
+
+ SqlResult DataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings)
+ {
+ if (!cursor.get())
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (!cursor->HasNext())
+ return SQL_RESULT_NO_DATA;
+
+ if (cursor->NeedDataUpdate())
+ {
+ SqlResult result = MakeRequestFetch();
+
+ if (result != SQL_RESULT_SUCCESS)
+ return result;
+
+ if (!cursor->HasNext())
+ return SQL_RESULT_NO_DATA;
+ }
+ else
+ cursor->Increment();
+
+ Row* row = cursor->GetRow();
+
+ if (!row)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown error.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ for (int32_t i = 1; i < row->GetSize() + 1; ++i)
+ {
+ app::ColumnBindingMap::iterator it = columnBindings.find(i);
+
+ SqlResult result;
+
+ if (it != columnBindings.end())
+ result = row->ReadColumnToBuffer(i, it->second);
+
+ if (result == SQL_RESULT_ERROR)
+ {
+ diag.AddStatusRecord(SQL_STATE_01S01_ERROR_IN_ROW, "Can not retrieve row column.", 0, i);
+
+ return SQL_RESULT_ERROR;
+ }
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult DataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ if (!cursor.get())
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ Row* row = cursor->GetRow();
+
+ if (!row)
+ return SQL_RESULT_NO_DATA;
+
+ SqlResult result = row->ReadColumnToBuffer(columnIdx, buffer);
+
+ if (result == SQL_RESULT_ERROR)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown column type.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return result;
+ }
+
+ SqlResult DataQuery::Close()
+ {
+ if (!cursor.get())
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query cursor is not in open state.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ SqlResult result = MakeRequestClose();
+
+ if (result == SQL_RESULT_SUCCESS)
+ cursor.reset();
+
+ return result;
+ }
+
+ bool DataQuery::DataAvailable() const
+ {
+ return cursor.get() && cursor->HasNext();
+ }
+
+ int64_t DataQuery::AffectedRows() const
+ {
+ // We are only support SELECT statements so we should not
+ // return anything particullar.
+ return 0;
+ }
+
+ SqlResult DataQuery::MakeRequestExecute()
+ {
+ const std::string& cacheName = connection.GetCache();
+
+ QueryExecuteRequest req(cacheName, sql, params);
+ QueryExecuteResponse rsp;
+
+ bool success = connection.SyncMessage(req, rsp);
+
+ if (!success)
+ {
+ diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
+ {
+ LOG_MSG("Error: %s\n", rsp.GetError().c_str());
+
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ cursor.reset(new Cursor(rsp.GetQueryId()));
+
+ resultMeta.assign(rsp.GetMeta().begin(), rsp.GetMeta().end());
+
+ LOG_MSG("Query id: %lld\n", cursor->GetQueryId());
+
+ for (size_t i = 0; i < rsp.GetMeta().size(); ++i)
+ {
+ LOG_MSG("[%d] SchemaName: %s\n", i, rsp.GetMeta()[i].GetSchemaName().c_str());
+ LOG_MSG("[%d] TypeName: %s\n", i, rsp.GetMeta()[i].GetTableName().c_str());
+ LOG_MSG("[%d] ColumnName: %s\n", i, rsp.GetMeta()[i].GetColumnName().c_str());
+ LOG_MSG("[%d] ColumnTypeName: %s\n", i, rsp.GetMeta()[i].GetColumnTypeName().c_str());
+ LOG_MSG("[%d] ColumnType: %d\n", i, rsp.GetMeta()[i].GetDataType());
+ LOG_MSG("\n");
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult DataQuery::MakeRequestClose()
+ {
+ QueryCloseRequest req(cursor->GetQueryId());
+ QueryCloseResponse rsp;
+
+ bool success = connection.SyncMessage(req, rsp);
+
+ if (!success)
+ {
+ diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ LOG_MSG("Query id: %lld\n", rsp.GetQueryId());
+
+ if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
+ {
+ LOG_MSG("Error: %s\n", rsp.GetError().c_str());
+
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult DataQuery::MakeRequestFetch()
+ {
+ std::auto_ptr<ResultPage> resultPage(new ResultPage());
+
+ QueryFetchRequest req(cursor->GetQueryId(), ResultPage::DEFAULT_SIZE);
+ QueryFetchResponse rsp(*resultPage);
+
+ bool success = connection.SyncMessage(req, rsp);
+
+ LOG_MSG("Query id: %lld\n", rsp.GetQueryId());
+ LOG_MSG("Request status: %s\n", success ? "Success" : "Failure");
+
+ if (!success)
+ {
+ diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
+ {
+ LOG_MSG("Error: %s\n", rsp.GetError().c_str());
+
+ diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ cursor->UpdateData(resultPage);
+
+ return SQL_RESULT_SUCCESS;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp b/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp
new file mode 100644
index 0000000..78e1464
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/message.h"
+#include "ignite/odbc/query/foreign_keys_query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ ForeignKeysQuery::ForeignKeysQuery(diagnostic::Diagnosable& diag, Connection& connection,
+ const std::string& primaryCatalog, const std::string& primarySchema,
+ const std::string& primaryTable, const std::string& foreignCatalog,
+ const std::string& foreignSchema, const std::string& foreignTable) :
+ Query(diag),
+ connection(connection),
+ primaryCatalog(primaryCatalog),
+ primarySchema(primarySchema),
+ primaryTable(primaryTable),
+ foreignCatalog(foreignCatalog),
+ foreignSchema(foreignSchema),
+ foreignTable(foreignTable),
+ executed(false),
+ columnsMeta()
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::odbc::type_traits;
+
+ using meta::ColumnMeta;
+
+ columnsMeta.reserve(14);
+
+ const std::string sch("");
+ const std::string tbl("");
+
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PKTABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PKTABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PKTABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PKCOLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "FKTABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "FKTABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "FKTABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "FKCOLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "KEY_SEQ", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "UPDATE_RULE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "DELETE_RULE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "FK_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PK_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "DEFERRABILITY", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ }
+
+ ForeignKeysQuery::~ForeignKeysQuery()
+ {
+ // No-op.
+ }
+
+ SqlResult ForeignKeysQuery::Execute()
+ {
+ executed = true;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ const meta::ColumnMetaVector & ForeignKeysQuery::GetMeta() const
+ {
+ return columnsMeta;
+ }
+
+ 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;
+ }
+
+ SqlResult ForeignKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_NO_DATA;
+ }
+
+ SqlResult ForeignKeysQuery::Close()
+ {
+ executed = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool ForeignKeysQuery::DataAvailable() const
+ {
+ return false;
+ }
+ int64_t ForeignKeysQuery::AffectedRows() const
+ {
+ return 0;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp b/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp
new file mode 100644
index 0000000..b616db3
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp
@@ -0,0 +1,210 @@
+/*
+ * 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 <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/message.h"
+#include "ignite/odbc/query/primary_keys_query.h"
+
+namespace
+{
+ enum ResultColumn
+ {
+ /** Catalog name. NULL if not applicable to the data source. */
+ TABLE_CAT = 1,
+
+ /** Schema name. NULL if not applicable to the data source. */
+ TABLE_SCHEM,
+
+ /** Table name. */
+ TABLE_NAME,
+
+ /** Column name. */
+ COLUMN_NAME,
+
+ /** Column sequence number in key. */
+ KEY_SEQ,
+
+ /** Primary key name. */
+ PK_NAME
+ };
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ PrimaryKeysQuery::PrimaryKeysQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& catalog,
+ const std::string& schema, const std::string& table) :
+ Query(diag),
+ connection(connection),
+ catalog(catalog),
+ schema(schema),
+ table(table),
+ executed(false),
+ columnsMeta()
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::odbc::type_traits;
+
+ using meta::ColumnMeta;
+
+ columnsMeta.reserve(6);
+
+ const std::string sch("");
+ const std::string tbl("");
+
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "KEY_SEQ", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PK_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ }
+
+ PrimaryKeysQuery::~PrimaryKeysQuery()
+ {
+ // No-op.
+ }
+
+ SqlResult PrimaryKeysQuery::Execute()
+ {
+ if (executed)
+ Close();
+
+ meta.push_back(meta::PrimaryKeyMeta(catalog, schema, table, "_KEY", 1, "_KEY"));
+
+ executed = true;
+
+ cursor = meta.begin();
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ const meta::ColumnMetaVector & PrimaryKeysQuery::GetMeta() const
+ {
+ return columnsMeta;
+ }
+
+ SqlResult PrimaryKeysQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cursor == meta.end())
+ return SQL_RESULT_NO_DATA;
+
+ app::ColumnBindingMap::iterator it;
+
+ for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
+ GetColumn(it->first, it->second);
+
+ ++cursor;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult PrimaryKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ if (cursor == meta.end())
+ return SQL_RESULT_NO_DATA;
+
+ const meta::PrimaryKeyMeta& currentColumn = *cursor;
+
+ switch (columnIdx)
+ {
+ case TABLE_CAT:
+ {
+ buffer.PutString(currentColumn.GetCatalogName());
+ break;
+ }
+
+ case TABLE_SCHEM:
+ {
+ buffer.PutString(currentColumn.GetSchemaName());
+ break;
+ }
+
+ case TABLE_NAME:
+ {
+ buffer.PutString(currentColumn.GetTableName());
+ break;
+ }
+
+ case COLUMN_NAME:
+ {
+ buffer.PutString(currentColumn.GetColumnName());
+ break;
+ }
+
+ case KEY_SEQ:
+ {
+ buffer.PutInt16(currentColumn.GetKeySeq());
+ break;
+ }
+
+ case PK_NAME:
+ {
+ buffer.PutString(currentColumn.GetKeyName());
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ SqlResult PrimaryKeysQuery::Close()
+ {
+ meta.clear();
+
+ executed = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool PrimaryKeysQuery::DataAvailable() const
+ {
+ return cursor != meta.end();
+ }
+
+ int64_t PrimaryKeysQuery::AffectedRows() const
+ {
+ return 0;
+ }
+ }
+ }
+}
+
[28/28] ignite git commit: Merge branch 'ignite-1786-review' of
https://github.com/isapego/ignite into ignite-1786
Posted by vo...@apache.org.
Merge branch 'ignite-1786-review' of https://github.com/isapego/ignite into ignite-1786
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/12ad51ce
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/12ad51ce
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/12ad51ce
Branch: refs/heads/ignite-1786
Commit: 12ad51cee08e15e61f9994e1e1cea831181f6559
Parents: abe6fdb de10055
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Jan 27 13:29:58 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Jan 27 13:29:58 2016 +0300
----------------------------------------------------------------------
.../configuration/IgniteConfiguration.java | 8 +-
.../ignite/configuration/OdbcConfiguration.java | 43 +-
.../ignite/internal/GridKernalContext.java | 4 +-
.../ignite/internal/GridKernalContextImpl.java | 10 +-
.../apache/ignite/internal/IgniteKernal.java | 4 +-
.../processors/odbc/GridOdbcColumnMeta.java | 125 --
.../processors/odbc/GridOdbcCommandHandler.java | 337 ----
.../processors/odbc/GridOdbcProcessor.java | 160 --
.../odbc/GridOdbcProtocolHandler.java | 40 -
.../processors/odbc/GridOdbcTableMeta.java | 89 -
.../processors/odbc/OdbcColumnMeta.java | 130 ++
.../processors/odbc/OdbcCommandHandler.java | 344 ++++
.../internal/processors/odbc/OdbcParser.java | 366 ++++
.../internal/processors/odbc/OdbcProcessor.java | 165 ++
.../processors/odbc/OdbcProtocolHandler.java | 42 +
.../processors/odbc/OdbcQueryCloseRequest.java | 41 +
.../processors/odbc/OdbcQueryCloseResult.java | 39 +
.../odbc/OdbcQueryExecuteRequest.java | 65 +
.../processors/odbc/OdbcQueryExecuteResult.java | 53 +
.../processors/odbc/OdbcQueryFetchRequest.java | 53 +
.../processors/odbc/OdbcQueryFetchResult.java | 65 +
.../odbc/OdbcQueryGetColumnsMetaRequest.java | 65 +
.../odbc/OdbcQueryGetColumnsMetaResult.java | 41 +
.../odbc/OdbcQueryGetTablesMetaRequest.java | 77 +
.../odbc/OdbcQueryGetTablesMetaResult.java | 41 +
.../internal/processors/odbc/OdbcRequest.java | 54 +
.../internal/processors/odbc/OdbcResponse.java | 95 +
.../internal/processors/odbc/OdbcTableMeta.java | 91 +
.../processors/odbc/OdbcTcpNioListener.java | 95 +
.../internal/processors/odbc/OdbcTcpServer.java | 177 ++
.../odbc/protocol/GridOdbcParser.java | 345 ----
.../odbc/protocol/GridTcpOdbcNioListener.java | 102 --
.../odbc/protocol/GridTcpOdbcServer.java | 191 --
.../odbc/request/GridOdbcRequest.java | 61 -
.../odbc/request/QueryCloseRequest.java | 47 -
.../odbc/request/QueryExecuteRequest.java | 85 -
.../odbc/request/QueryFetchRequest.java | 66 -
.../request/QueryGetColumnsMetaRequest.java | 84 -
.../odbc/request/QueryGetTablesMetaRequest.java | 105 --
.../odbc/response/GridOdbcResponse.java | 107 --
.../odbc/response/QueryCloseResult.java | 39 -
.../odbc/response/QueryExecuteResult.java | 55 -
.../odbc/response/QueryFetchResult.java | 75 -
.../response/QueryGetColumnsMetaResult.java | 43 -
.../odbc/response/QueryGetTablesMetaResult.java | 43 -
.../cpp/binary/project/vs/binary.vcxproj | 2 +-
.../cpp/common/project/vs/common.vcxproj | 2 +-
.../cpp/ignite/project/vs/ignite.vcxproj | 2 +-
modules/platforms/cpp/odbc-test/Makefile.am | 55 +
modules/platforms/cpp/odbc-test/README.TXT | 1 +
modules/platforms/cpp/odbc-test/configure.ac | 62 +
.../cpp/odbc-test/include/teamcity_messages.h | 55 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 189 ++
.../project/vs/odbc-test.vcxproj.filters | 79 +
.../src/application_data_buffer_test.cpp | 630 +++++++
.../platforms/cpp/odbc-test/src/column_test.cpp | 290 +++
.../cpp/odbc-test/src/configuration_test.cpp | 206 +++
.../cpp/odbc-test/src/connection_info_test.cpp | 219 +++
.../platforms/cpp/odbc-test/src/cursor_test.cpp | 166 ++
.../platforms/cpp/odbc-test/src/parser_test.cpp | 94 +
.../platforms/cpp/odbc-test/src/row_test.cpp | 167 ++
.../cpp/odbc-test/src/teamcity_boost.cpp | 159 ++
.../cpp/odbc-test/src/teamcity_messages.cpp | 150 ++
.../cpp/odbc-test/src/utility_test.cpp | 81 +
modules/platforms/cpp/odbc/Makefile.am | 67 +
modules/platforms/cpp/odbc/configure.ac | 62 +
modules/platforms/cpp/odbc/ignite-odbc.pc.in | 9 +
.../ignite/odbc/app/application_data_buffer.h | 342 ++++
.../odbc/include/ignite/odbc/app/parameter.h | 113 ++
.../cpp/odbc/include/ignite/odbc/column.h | 149 ++
.../cpp/odbc/include/ignite/odbc/common_types.h | 225 +++
.../include/ignite/odbc/config/configuration.h | 164 ++
.../ignite/odbc/config/connection_info.h | 98 +
.../cpp/odbc/include/ignite/odbc/connection.h | 258 +++
.../cpp/odbc/include/ignite/odbc/cursor.h | 108 ++
.../cpp/odbc/include/ignite/odbc/decimal.h | 126 ++
.../ignite/odbc/diagnostic/diagnosable.h | 82 +
.../odbc/diagnostic/diagnosable_adapter.h | 107 ++
.../ignite/odbc/diagnostic/diagnostic_record.h | 165 ++
.../odbc/diagnostic/diagnostic_record_storage.h | 198 ++
.../cpp/odbc/include/ignite/odbc/environment.h | 137 ++
.../cpp/odbc/include/ignite/odbc/message.h | 630 +++++++
.../odbc/include/ignite/odbc/meta/column_meta.h | 210 +++
.../include/ignite/odbc/meta/primary_key_meta.h | 188 ++
.../odbc/include/ignite/odbc/meta/table_meta.h | 166 ++
.../cpp/odbc/include/ignite/odbc/parser.h | 141 ++
.../ignite/odbc/query/column_metadata_query.h | 146 ++
.../odbc/include/ignite/odbc/query/data_query.h | 152 ++
.../ignite/odbc/query/foreign_keys_query.h | 143 ++
.../ignite/odbc/query/primary_keys_query.h | 137 ++
.../cpp/odbc/include/ignite/odbc/query/query.h | 119 ++
.../ignite/odbc/query/special_columns_query.h | 142 ++
.../ignite/odbc/query/table_metadata_query.h | 150 ++
.../include/ignite/odbc/query/type_info_query.h | 118 ++
.../cpp/odbc/include/ignite/odbc/result_page.h | 101 ++
.../cpp/odbc/include/ignite/odbc/row.h | 132 ++
.../cpp/odbc/include/ignite/odbc/statement.h | 525 ++++++
.../include/ignite/odbc/system/odbc_constants.h | 45 +
.../include/ignite/odbc/system/socket_client.h | 92 +
.../cpp/odbc/include/ignite/odbc/type_traits.h | 313 ++++
.../cpp/odbc/include/ignite/odbc/utility.h | 171 ++
.../platforms/cpp/odbc/odbc-driver/Makefile.am | 67 -
.../platforms/cpp/odbc/odbc-driver/configure.ac | 62 -
.../cpp/odbc/odbc-driver/ignite-odbc.pc.in | 9 -
.../ignite/odbc/app/application_data_buffer.h | 342 ----
.../include/ignite/odbc/app/parameter.h | 113 --
.../odbc-driver/include/ignite/odbc/column.h | 149 --
.../include/ignite/odbc/common_types.h | 225 ---
.../include/ignite/odbc/config/configuration.h | 164 --
.../ignite/odbc/config/connection_info.h | 98 -
.../include/ignite/odbc/connection.h | 258 ---
.../odbc-driver/include/ignite/odbc/cursor.h | 108 --
.../odbc-driver/include/ignite/odbc/decimal.h | 126 --
.../ignite/odbc/diagnostic/diagnosable.h | 82 -
.../odbc/diagnostic/diagnosable_adapter.h | 107 --
.../ignite/odbc/diagnostic/diagnostic_record.h | 165 --
.../odbc/diagnostic/diagnostic_record_storage.h | 198 --
.../include/ignite/odbc/environment.h | 137 --
.../odbc-driver/include/ignite/odbc/message.h | 630 -------
.../include/ignite/odbc/meta/column_meta.h | 210 ---
.../include/ignite/odbc/meta/primary_key_meta.h | 188 --
.../include/ignite/odbc/meta/table_meta.h | 166 --
.../odbc-driver/include/ignite/odbc/parser.h | 141 --
.../ignite/odbc/query/column_metadata_query.h | 146 --
.../include/ignite/odbc/query/data_query.h | 152 --
.../ignite/odbc/query/foreign_keys_query.h | 143 --
.../ignite/odbc/query/primary_keys_query.h | 137 --
.../include/ignite/odbc/query/query.h | 119 --
.../ignite/odbc/query/special_columns_query.h | 142 --
.../ignite/odbc/query/table_metadata_query.h | 150 --
.../include/ignite/odbc/query/type_info_query.h | 118 --
.../include/ignite/odbc/result_page.h | 101 --
.../odbc/odbc-driver/include/ignite/odbc/row.h | 132 --
.../odbc-driver/include/ignite/odbc/statement.h | 525 ------
.../include/ignite/odbc/system/odbc_constants.h | 45 -
.../include/ignite/odbc/system/socket_client.h | 92 -
.../include/ignite/odbc/type_traits.h | 313 ----
.../odbc-driver/include/ignite/odbc/utility.h | 171 --
.../os/linux/src/system/socket_client.cpp | 120 --
.../os/win/src/system/socket_client.cpp | 133 --
.../cpp/odbc/odbc-driver/project/README.TXT | 1 -
.../cpp/odbc/odbc-driver/project/vs/README.TXT | 1 -
.../cpp/odbc/odbc-driver/project/vs/module.def | 69 -
.../odbc-driver/project/vs/odbc-driver.vcxproj | 233 ---
.../project/vs/odbc-driver.vcxproj.filters | 229 ---
.../src/app/application_data_buffer.cpp | 834 ---------
.../cpp/odbc/odbc-driver/src/app/parameter.cpp | 147 --
.../cpp/odbc/odbc-driver/src/column.cpp | 454 -----
.../cpp/odbc/odbc-driver/src/common_types.cpp | 120 --
.../odbc-driver/src/config/configuration.cpp | 245 ---
.../odbc-driver/src/config/connection_info.cpp | 419 -----
.../cpp/odbc/odbc-driver/src/connection.cpp | 269 ---
.../cpp/odbc/odbc-driver/src/cursor.cpp | 78 -
.../cpp/odbc/odbc-driver/src/decimal.cpp | 117 --
.../src/diagnostic/diagnosable_adapter.cpp | 49 -
.../src/diagnostic/diagnostic_record.cpp | 241 ---
.../diagnostic/diagnostic_record_storage.cpp | 242 ---
.../cpp/odbc/odbc-driver/src/environment.cpp | 172 --
.../odbc/odbc-driver/src/meta/column_meta.cpp | 275 ---
.../odbc/odbc-driver/src/meta/table_meta.cpp | 50 -
.../platforms/cpp/odbc/odbc-driver/src/odbc.cpp | 1687 ------------------
.../src/query/column_metadata_query.cpp | 317 ----
.../odbc/odbc-driver/src/query/data_query.cpp | 277 ---
.../src/query/foreign_keys_query.cpp | 131 --
.../src/query/primary_keys_query.cpp | 210 ---
.../src/query/special_columns_query.cpp | 121 --
.../src/query/table_metadata_query.cpp | 242 ---
.../odbc-driver/src/query/type_info_query.cpp | 394 ----
.../cpp/odbc/odbc-driver/src/result_page.cpp | 58 -
.../platforms/cpp/odbc/odbc-driver/src/row.cpp | 120 --
.../cpp/odbc/odbc-driver/src/statement.cpp | 529 ------
.../cpp/odbc/odbc-driver/src/type_traits.cpp | 657 -------
.../cpp/odbc/odbc-driver/src/utility.cpp | 105 --
.../platforms/cpp/odbc/odbc-test/Makefile.am | 55 -
modules/platforms/cpp/odbc/odbc-test/README.TXT | 1 -
.../platforms/cpp/odbc/odbc-test/configure.ac | 62 -
.../odbc/odbc-test/include/teamcity_messages.h | 55 -
.../odbc/odbc-test/project/vs/odbc-test.vcxproj | 189 --
.../project/vs/odbc-test.vcxproj.filters | 79 -
.../src/application_data_buffer_test.cpp | 630 -------
.../cpp/odbc/odbc-test/src/column_test.cpp | 290 ---
.../odbc/odbc-test/src/configuration_test.cpp | 206 ---
.../odbc/odbc-test/src/connection_info_test.cpp | 219 ---
.../cpp/odbc/odbc-test/src/cursor_test.cpp | 166 --
.../cpp/odbc/odbc-test/src/parser_test.cpp | 94 -
.../cpp/odbc/odbc-test/src/row_test.cpp | 167 --
.../cpp/odbc/odbc-test/src/teamcity_boost.cpp | 159 --
.../odbc/odbc-test/src/teamcity_messages.cpp | 150 --
.../cpp/odbc/odbc-test/src/utility_test.cpp | 81 -
.../odbc/os/linux/src/system/socket_client.cpp | 120 ++
.../odbc/os/win/src/system/socket_client.cpp | 133 ++
modules/platforms/cpp/odbc/project/README.TXT | 1 +
.../platforms/cpp/odbc/project/vs/README.TXT | 1 +
.../platforms/cpp/odbc/project/vs/module.def | 69 +
modules/platforms/cpp/odbc/project/vs/odbc.sln | 58 -
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 233 +++
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 229 +++
.../odbc/src/app/application_data_buffer.cpp | 834 +++++++++
.../platforms/cpp/odbc/src/app/parameter.cpp | 147 ++
modules/platforms/cpp/odbc/src/column.cpp | 454 +++++
modules/platforms/cpp/odbc/src/common_types.cpp | 120 ++
.../cpp/odbc/src/config/configuration.cpp | 245 +++
.../cpp/odbc/src/config/connection_info.cpp | 419 +++++
modules/platforms/cpp/odbc/src/connection.cpp | 269 +++
modules/platforms/cpp/odbc/src/cursor.cpp | 78 +
modules/platforms/cpp/odbc/src/decimal.cpp | 117 ++
.../odbc/src/diagnostic/diagnosable_adapter.cpp | 49 +
.../odbc/src/diagnostic/diagnostic_record.cpp | 241 +++
.../diagnostic/diagnostic_record_storage.cpp | 242 +++
modules/platforms/cpp/odbc/src/environment.cpp | 172 ++
.../platforms/cpp/odbc/src/meta/column_meta.cpp | 275 +++
.../platforms/cpp/odbc/src/meta/table_meta.cpp | 50 +
modules/platforms/cpp/odbc/src/odbc.cpp | 1687 ++++++++++++++++++
.../odbc/src/query/column_metadata_query.cpp | 317 ++++
.../platforms/cpp/odbc/src/query/data_query.cpp | 277 +++
.../cpp/odbc/src/query/foreign_keys_query.cpp | 131 ++
.../cpp/odbc/src/query/primary_keys_query.cpp | 210 +++
.../odbc/src/query/special_columns_query.cpp | 121 ++
.../cpp/odbc/src/query/table_metadata_query.cpp | 242 +++
.../cpp/odbc/src/query/type_info_query.cpp | 394 ++++
modules/platforms/cpp/odbc/src/result_page.cpp | 58 +
modules/platforms/cpp/odbc/src/row.cpp | 120 ++
modules/platforms/cpp/odbc/src/statement.cpp | 529 ++++++
modules/platforms/cpp/odbc/src/type_traits.cpp | 657 +++++++
modules/platforms/cpp/odbc/src/utility.cpp | 105 ++
modules/platforms/cpp/project/vs/ignite.sln | 20 +
226 files changed, 20357 insertions(+), 20454 deletions(-)
----------------------------------------------------------------------
[15/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-test/src/utility_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-test/src/utility_test.cpp b/modules/platforms/cpp/odbc/odbc-test/src/utility_test.cpp
deleted file mode 100644
index 6c4d104..0000000
--- a/modules/platforms/cpp/odbc/odbc-test/src/utility_test.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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 _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <ignite/impl/binary/binary_writer_impl.h>
-
-#include <ignite/odbc/utility.h>
-
-using namespace ignite::utility;
-
-BOOST_AUTO_TEST_SUITE(UtilityTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestUtilityRemoveSurroundingSpaces)
-{
- std::string inStr(" \r \n \t some meaningfull data \n\n \t \r ");
- std::string expectedOutStr("some meaningfull data");
-
- std::string realOutStr(RemoveSurroundingSpaces(inStr.begin(), inStr.end()));
-
- BOOST_REQUIRE(expectedOutStr == realOutStr);
-}
-
-BOOST_AUTO_TEST_CASE(TestUtilityCopyStringToBuffer)
-{
- char buffer[1024];
-
- std::string str("Some data. And some more data here.");
-
- CopyStringToBuffer(str, buffer, sizeof(buffer));
-
- BOOST_REQUIRE(!strcmp(buffer, str.c_str()));
-
- CopyStringToBuffer(str, buffer, 11);
-
- BOOST_REQUIRE(!strcmp(buffer, str.substr(0, 10).c_str()));
-}
-
-BOOST_AUTO_TEST_CASE(TestUtilityReadString)
-{
- using namespace ignite::impl::binary;
- using namespace ignite::impl::interop;
-
- std::string inputStr("Hello World!");
- std::string outputStr;
-
- ignite::impl::interop::InteropUnpooledMemory mem(1024);
- InteropOutputStream outStream(&mem);
- BinaryWriterImpl writer(&outStream, 0);
-
- writer.WriteString(inputStr.data(), static_cast<int32_t>(inputStr.size()));
-
- outStream.Synchronize();
-
- InteropInputStream inStream(&mem);
- BinaryReaderImpl reader(&inStream);
-
- ReadString(reader, outputStr);
-
- BOOST_REQUIRE(inputStr == outputStr);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/os/linux/src/system/socket_client.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/linux/src/system/socket_client.cpp b/modules/platforms/cpp/odbc/os/linux/src/system/socket_client.cpp
new file mode 100644
index 0000000..a355625
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/linux/src/system/socket_client.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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 <sys/socket.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <unistd.h>
+
+#include <cstring>
+
+#include <sstream>
+
+#include "ignite/odbc/system/socket_client.h"
+#include "ignite/odbc/utility.h"
+
+#define SOCKET_ERROR (-1)
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace tcp
+ {
+
+ SocketClient::SocketClient() : socketHandle(SOCKET_ERROR)
+ {
+ // No-op.
+ }
+
+ SocketClient::~SocketClient()
+ {
+ Close();
+ }
+
+ bool SocketClient::Connect(const char* hostname, uint16_t port)
+ {
+ LOG_MSG("Host: %s, port: %d\n", hostname, port);
+
+ addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+ std::stringstream converter;
+ converter << port;
+
+ // Resolve the server address and port
+ addrinfo *result = NULL;
+ int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result);
+
+ if (res != 0)
+ return false;
+
+ // Attempt to connect to an address until one succeeds
+ for (addrinfo *it = result; it != NULL; it = it->ai_next)
+ {
+ LOG_MSG("Addr: %u.%u.%u.%u\n", it->ai_addr->sa_data[2], it->ai_addr->sa_data[3],
+ it->ai_addr->sa_data[4], it->ai_addr->sa_data[5]);
+
+ // Create a SOCKET for connecting to server
+ socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
+
+ if (socketHandle == SOCKET_ERROR)
+ return false;
+
+ // Connect to server.
+ res = connect(socketHandle, it->ai_addr, (int)it->ai_addrlen);
+ if (res == SOCKET_ERROR)
+ {
+ Close();
+
+ continue;
+ }
+ break;
+ }
+
+ freeaddrinfo(result);
+
+ return socketHandle != SOCKET_ERROR;
+ }
+
+ void SocketClient::Close()
+ {
+ if (socketHandle != SOCKET_ERROR)
+ {
+ close(socketHandle);
+
+ socketHandle = SOCKET_ERROR;
+ }
+ }
+
+ int SocketClient::Send(const int8_t* data, size_t size)
+ {
+ return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0);
+ }
+
+ int SocketClient::Receive(int8_t* buffer, size_t size)
+ {
+ return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp b/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp
new file mode 100644
index 0000000..bc4cdc0
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/socket_client.cpp
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#define _WINSOCKAPI_
+
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+#include <cstring>
+
+#include <sstream>
+
+#include "ignite/odbc/system/socket_client.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace tcp
+ {
+
+ SocketClient::SocketClient() : socketHandle(INVALID_SOCKET)
+ {
+ // No-op.
+ }
+
+ SocketClient::~SocketClient()
+ {
+ Close();
+ }
+
+ bool SocketClient::Connect(const char* hostname, uint16_t port)
+ {
+ static bool networkInited = false;
+
+ // Initing networking if is not inited.
+ if (!networkInited)
+ {
+ WSADATA wsaData;
+
+ networkInited = (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0);
+
+ if (!networkInited)
+ return false;
+ }
+
+ addrinfo *result = NULL;
+ addrinfo hints;
+
+ LOG_MSG("Host: %s, port: %d\n", hostname, port);
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+ std::stringstream converter;
+ converter << port;
+
+ // Resolve the server address and port
+ int res = getaddrinfo(hostname, converter.str().c_str(), &hints, &result);
+
+ if (res != 0)
+ return false;
+
+ // Attempt to connect to an address until one succeeds
+ for (addrinfo *it = result; it != NULL; it = it->ai_next)
+ {
+ LOG_MSG("Addr: %u.%u.%u.%u\n", it->ai_addr->sa_data[2], it->ai_addr->sa_data[3],
+ it->ai_addr->sa_data[4], it->ai_addr->sa_data[5]);
+
+ // Create a SOCKET for connecting to server
+ socketHandle = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
+
+ if (socketHandle == INVALID_SOCKET)
+ return false;
+
+ // Connect to server.
+ res = connect(socketHandle, it->ai_addr, static_cast<int>(it->ai_addrlen));
+ if (res == SOCKET_ERROR)
+ {
+ Close();
+
+ continue;
+ }
+ break;
+ }
+
+ freeaddrinfo(result);
+
+ return socketHandle != INVALID_SOCKET;
+ }
+
+ void SocketClient::Close()
+ {
+ if (socketHandle != INVALID_SOCKET)
+ {
+ closesocket(socketHandle);
+
+ socketHandle = INVALID_SOCKET;
+ }
+ }
+
+ int SocketClient::Send(const int8_t* data, size_t size)
+ {
+ return send(socketHandle, reinterpret_cast<const char*>(data), static_cast<int>(size), 0);
+ }
+
+ int SocketClient::Receive(int8_t* buffer, size_t size)
+ {
+ return recv(socketHandle, reinterpret_cast<char*>(buffer), static_cast<int>(size), 0);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/project/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/README.TXT b/modules/platforms/cpp/odbc/project/README.TXT
new file mode 100644
index 0000000..97f4c64
--- /dev/null
+++ b/modules/platforms/cpp/odbc/project/README.TXT
@@ -0,0 +1 @@
+Contains IDE projects artifacts.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/project/vs/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/README.TXT b/modules/platforms/cpp/odbc/project/vs/README.TXT
new file mode 100644
index 0000000..f4fb456
--- /dev/null
+++ b/modules/platforms/cpp/odbc/project/vs/README.TXT
@@ -0,0 +1 @@
+Contains Visual Studio project artifacts.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/module.def b/modules/platforms/cpp/odbc/project/vs/module.def
new file mode 100644
index 0000000..9da4b35
--- /dev/null
+++ b/modules/platforms/cpp/odbc/project/vs/module.def
@@ -0,0 +1,69 @@
+
+LIBRARY odbc
+EXPORTS
+ ConfigDSN
+ SQLAllocConnect
+ SQLAllocEnv
+ SQLAllocStmt
+ SQLAllocHandle
+ SQLFreeConnect
+ SQLFreeEnv
+ SQLFreeStmt
+ SQLBindCol
+ SQLCancel
+ SQLConnect
+ SQLDescribeCol
+ SQLDisconnect
+ SQLError
+ SQLExecDirect
+ SQLExecute
+ SQLExtendedFetch
+ SQLFetch
+ SQLGetCursorName
+ SQLNumResultCols
+ SQLPrepare
+ SQLRowCount
+ SQLSetCursorName
+ SQLColumns
+ SQLDriverConnect
+ SQLGetData
+ SQLGetInfo
+ SQLGetTypeInfo
+ SQLParamData
+ SQLPutData
+ SQLStatistics
+ SQLTables
+ SQLBrowseConnect
+ SQLColumnPrivileges
+ SQLDescribeParam
+ SQLForeignKeys
+ SQLMoreResults
+ SQLNativeSql
+ SQLNumParams
+ SQLPrimaryKeys
+ SQLProcedureColumns
+ SQLProcedures
+ SQLSetPos
+ SQLTablePrivileges
+ SQLBindParameter
+ SQLCloseCursor
+ SQLColAttribute
+ SQLCopyDesc
+ SQLEndTran
+ SQLFetchScroll
+ SQLFreeHandle
+ SQLGetConnectAttr
+ SQLGetDescField
+ SQLGetDescRec
+ SQLGetDiagField
+ SQLGetDiagRec
+ SQLGetEnvAttr
+ SQLGetStmtAttr
+ SQLSetConnectAttr
+ SQLSetDescField
+ SQLSetDescRec
+ SQLSetEnvAttr
+ SQLSetStmtAttr
+ SQLBulkOperations
+ SQLSpecialColumns
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/project/vs/odbc.sln
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.sln b/modules/platforms/cpp/odbc/project/vs/odbc.sln
deleted file mode 100644
index 89144a3..0000000
--- a/modules/platforms/cpp/odbc/project/vs/odbc.sln
+++ /dev/null
@@ -1,56 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc-driver", "..\..\odbc-driver\project\vs\odbc-driver.vcxproj", "{12F77E12-38FE-42D3-B1DA-7E5979362961}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odbc-test", "..\..\odbc-test\project\vs\odbc-test.vcxproj", "{309BEA40-495D-463F-98D5-4657F03F6D8F}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "..\..\..\common\project\vs\common.vcxproj", "{4F7E4917-4612-4B96-9838-025711ADE391}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "binary", "..\..\..\binary\project\vs\binary.vcxproj", "{4F15669B-92EB-49F0-B774-8F19BAE0B960}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|Win32 = Debug|Win32
- Release|x64 = Release|x64
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|x64.ActiveCfg = Debug|x64
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|x64.Build.0 = Debug|x64
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|Win32.ActiveCfg = Debug|Win32
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Debug|Win32.Build.0 = Debug|Win32
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|x64.ActiveCfg = Release|x64
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|x64.Build.0 = Release|x64
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|Win32.ActiveCfg = Release|Win32
- {12F77E12-38FE-42D3-B1DA-7E5979362961}.Release|Win32.Build.0 = Release|Win32
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|x64.ActiveCfg = Debug|x64
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|x64.Build.0 = Debug|x64
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|Win32.ActiveCfg = Debug|Win32
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Debug|Win32.Build.0 = Debug|Win32
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|x64.ActiveCfg = Release|x64
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|x64.Build.0 = Release|x64
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|Win32.ActiveCfg = Release|Win32
- {309BEA40-495D-463F-98D5-4657F03F6D8F}.Release|Win32.Build.0 = Release|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.ActiveCfg = Debug|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|x64.Build.0 = Debug|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|Win32.ActiveCfg = Debug|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Debug|Win32.Build.0 = Debug|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.ActiveCfg = Release|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|x64.Build.0 = Release|x64
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|Win32.ActiveCfg = Release|Win32
- {4F7E4917-4612-4B96-9838-025711ADE391}.Release|Win32.Build.0 = Release|Win32
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Debug|x64.ActiveCfg = Debug|x64
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Debug|x64.Build.0 = Debug|x64
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Debug|Win32.ActiveCfg = Debug|Win32
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Debug|Win32.Build.0 = Debug|Win32
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|x64.ActiveCfg = Release|x64
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|x64.Build.0 = Release|x64
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|Win32.ActiveCfg = Release|Win32
- {4F15669B-92EB-49F0-B774-8F19BAE0B960}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
new file mode 100644
index 0000000..f22b0b1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{12F77E12-38FE-42D3-B1DA-7E5979362961}</ProjectGuid>
+ <RootNamespace>odbc</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
+ <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>false</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
+ <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
+ <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>false</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <ModuleDefinitionFile>module.def</ModuleDefinitionFile>
+ <AdditionalDependencies>Ws2_32.lib;Mswsock.lib;Advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\os\win\src\system\socket_client.cpp" />
+ <ClCompile Include="..\..\src\app\application_data_buffer.cpp" />
+ <ClCompile Include="..\..\src\app\parameter.cpp" />
+ <ClCompile Include="..\..\src\column.cpp" />
+ <ClCompile Include="..\..\src\common_types.cpp" />
+ <ClCompile Include="..\..\src\config\configuration.cpp" />
+ <ClCompile Include="..\..\src\config\connection_info.cpp" />
+ <ClCompile Include="..\..\src\connection.cpp" />
+ <ClCompile Include="..\..\src\cursor.cpp" />
+ <ClCompile Include="..\..\src\decimal.cpp" />
+ <ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp" />
+ <ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp" />
+ <ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp" />
+ <ClCompile Include="..\..\src\environment.cpp" />
+ <ClCompile Include="..\..\src\meta\column_meta.cpp" />
+ <ClCompile Include="..\..\src\meta\table_meta.cpp" />
+ <ClCompile Include="..\..\src\odbc.cpp" />
+ <ClCompile Include="..\..\src\query\data_query.cpp" />
+ <ClCompile Include="..\..\src\query\column_metadata_query.cpp" />
+ <ClCompile Include="..\..\src\query\foreign_keys_query.cpp" />
+ <ClCompile Include="..\..\src\query\primary_keys_query.cpp" />
+ <ClCompile Include="..\..\src\query\special_columns_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" />
+ <ClCompile Include="..\..\src\type_traits.cpp" />
+ <ClCompile Include="..\..\src\utility.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="module.def" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\ignite\odbc\app\application_data_buffer.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\app\parameter.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\column.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\common_types.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\config\configuration.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\config\connection_info.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\connection.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\cursor.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\decimal.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\environment.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\message.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\meta\primary_key_meta.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\meta\table_meta.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\parser.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\data_query.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\column_metadata_query.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\primary_keys_query.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\query.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\special_columns_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" />
+ <ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\type_traits.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\utility.h" />
+ <ClInclude Include="result_page.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj">
+ <Project>{4f15669b-92eb-49f0-b774-8f19bae0b960}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
+ <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
new file mode 100644
index 0000000..d47684a
--- /dev/null
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Code">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Misc">
+ <UniqueIdentifier>{3f714d15-6347-46a7-bc59-d87c1aea900c}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\query">
+ <UniqueIdentifier>{b09a6b2e-c30c-4727-8e85-4b315e757706}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\meta">
+ <UniqueIdentifier>{71d6243f-e8c9-4f21-a5a3-3dc89641af28}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\config">
+ <UniqueIdentifier>{71117941-fa47-4768-afe8-901c94d431c7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\app">
+ <UniqueIdentifier>{dbe40149-df23-4b89-92e4-16817775cd0e}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\system">
+ <UniqueIdentifier>{7ab279dc-6586-4b32-aca7-0add0c0ab68a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\diagnostic">
+ <UniqueIdentifier>{df33e506-b5d8-423f-bcc5-1825242a3e28}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\odbc.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\connection.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\environment.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\statement.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\type_traits.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\common_types.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\utility.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\cursor.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\result_page.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\row.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\data_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\column_metadata_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\table_metadata_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\meta\column_meta.cpp">
+ <Filter>Code\meta</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\meta\table_meta.cpp">
+ <Filter>Code\meta</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\config\configuration.cpp">
+ <Filter>Code\config</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\config\connection_info.cpp">
+ <Filter>Code\config</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\app\application_data_buffer.cpp">
+ <Filter>Code\app</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\app\parameter.cpp">
+ <Filter>Code\app</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\foreign_keys_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\primary_keys_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp">
+ <Filter>Code\diagnostic</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp">
+ <Filter>Code\diagnostic</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp">
+ <Filter>Code\diagnostic</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\socket_client.cpp">
+ <Filter>Code\system</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\decimal.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\type_info_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\column.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\query\special_columns_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="module.def">
+ <Filter>Misc</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="result_page.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\common_types.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\connection.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\cursor.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\environment.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\message.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\parser.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\result_page.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\row.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\statement.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\type_traits.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\utility.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\data_query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\column_metadata_query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\table_metadata_query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h">
+ <Filter>Code\meta</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\meta\table_meta.h">
+ <Filter>Code\meta</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\config\configuration.h">
+ <Filter>Code\config</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\config\connection_info.h">
+ <Filter>Code\config</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\app\application_data_buffer.h">
+ <Filter>Code\app</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\app\parameter.h">
+ <Filter>Code\app</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\primary_keys_query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\meta\primary_key_meta.h">
+ <Filter>Code\meta</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h">
+ <Filter>Code\diagnostic</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h">
+ <Filter>Code\diagnostic</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable.h">
+ <Filter>Code\diagnostic</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h">
+ <Filter>Code\diagnostic</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h">
+ <Filter>Code\system</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h">
+ <Filter>Code\system</Filter>
+ </ClInclude>
+ <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>
+ <ClInclude Include="..\..\include\ignite\odbc\column.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\special_columns_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/e8287063/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
new file mode 100644
index 0000000..e10011b
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
@@ -0,0 +1,834 @@
+/*
+ * 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 <algorithm>
+#include <string>
+#include <sstream>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/app/application_data_buffer.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace app
+ {
+ ApplicationDataBuffer::ApplicationDataBuffer() :
+ type(type_traits::IGNITE_ODBC_C_TYPE_UNSUPPORTED), buffer(0), buflen(0), reslen(0), offset(0)
+ {
+ // No-op.
+ }
+
+ ApplicationDataBuffer::ApplicationDataBuffer(type_traits::IgniteSqlType type,
+ void* buffer, SqlLen buflen, SqlLen* reslen, size_t** offset) :
+ type(type), buffer(buffer), buflen(buflen), reslen(reslen), offset(offset)
+ {
+ // No-op.
+ }
+
+ ApplicationDataBuffer::ApplicationDataBuffer(const ApplicationDataBuffer & other) :
+ type(other.type), buffer(other.buffer), buflen(other.buflen), reslen(other.reslen), offset(other.offset)
+ {
+ // No-op.
+ }
+
+ ApplicationDataBuffer::~ApplicationDataBuffer()
+ {
+ // No-op.
+ }
+
+ ApplicationDataBuffer & ApplicationDataBuffer::operator=(const ApplicationDataBuffer & other)
+ {
+ type = other.type;
+ buffer = other.buffer;
+ buflen = other.buflen;
+ reslen = other.reslen;
+ offset = other.offset;
+
+ return *this;
+ }
+
+ template<typename T>
+ void ApplicationDataBuffer::PutNum(T value)
+ {
+ using namespace type_traits;
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
+ {
+ PutNumToNumBuffer<signed char>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_BIT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
+ {
+ PutNumToNumBuffer<unsigned char>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
+ {
+ PutNumToNumBuffer<short>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
+ {
+ PutNumToNumBuffer<unsigned short>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
+ {
+ PutNumToNumBuffer<long>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
+ {
+ PutNumToNumBuffer<unsigned long>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
+ {
+ PutNumToNumBuffer<int64_t>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
+ {
+ PutNumToNumBuffer<uint64_t>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_FLOAT:
+ {
+ PutNumToNumBuffer<float>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_DOUBLE:
+ {
+ PutNumToNumBuffer<double>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ PutValToStrBuffer<char>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_WCHAR:
+ {
+ PutValToStrBuffer<wchar_t>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_NUMERIC:
+ {
+ if (GetData())
+ {
+ SQL_NUMERIC_STRUCT* out =
+ reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());
+
+ out->precision = 0;
+ out->scale = 0;
+ out->sign = value > 0 ? 1 : 0;
+
+ memset(out->val, 0, SQL_MAX_NUMERIC_LEN);
+
+ // TODO: implement propper conversation to numeric type.
+ int64_t intVal = static_cast<int64_t>(std::abs(value));
+
+ memcpy(out->val, &intVal, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(intVal)));
+ }
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_BINARY:
+ case IGNITE_ODBC_C_TYPE_DEFAULT:
+ {
+ if (GetData())
+ {
+ if (buflen >= sizeof(value))
+ {
+ memcpy(GetData(), &value, sizeof(value));
+
+ if (GetResLen())
+ *GetResLen() = sizeof(value);
+ }
+ else
+ {
+ memcpy(GetData(), &value, static_cast<size_t>(buflen));
+
+ if (GetResLen())
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+ else if (GetResLen())
+ {
+ *GetResLen() = sizeof(value);
+ }
+ break;
+ }
+
+ default:
+ {
+ if (GetResLen())
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+ }
+
+ template<typename Tbuf, typename Tin>
+ void ApplicationDataBuffer::PutNumToNumBuffer(Tin value)
+ {
+ if (GetData())
+ {
+ Tbuf* out = reinterpret_cast<Tbuf*>(GetData());
+ *out = static_cast<Tbuf>(value);
+ }
+ }
+
+ template<typename CharT, typename Tin>
+ void ApplicationDataBuffer::PutValToStrBuffer(const Tin & value)
+ {
+ typedef std::basic_stringstream<CharT> ConverterType;
+
+ ConverterType converter;
+
+ converter << value;
+
+ PutStrToStrBuffer<CharT>(converter.str());
+ }
+
+ template<typename CharT>
+ void ApplicationDataBuffer::PutValToStrBuffer(const int8_t & value)
+ {
+ typedef std::basic_stringstream<CharT> ConverterType;
+
+ ConverterType converter;
+
+ converter << static_cast<int>(value);
+
+ PutStrToStrBuffer<CharT>(converter.str());
+ }
+
+ template<typename OutCharT, typename InCharT>
+ void ApplicationDataBuffer::PutStrToStrBuffer(const std::basic_string<InCharT>& value)
+ {
+ SqlLen charSize = static_cast<SqlLen>(sizeof(OutCharT));
+
+ if (GetData())
+ {
+ if (buflen >= charSize)
+ {
+ OutCharT* out = reinterpret_cast<OutCharT*>(GetData());
+
+ SqlLen outLen = (buflen / charSize) - 1;
+
+ SqlLen toCopy = std::min<size_t>(outLen, value.size());
+
+ for (SqlLen i = 0; i < toCopy; ++i)
+ out[i] = value[i];
+
+ out[toCopy] = 0;
+ }
+
+ if (GetResLen())
+ {
+ if (buflen >= static_cast<SqlLen>((value.size() + 1) * charSize))
+ *GetResLen() = static_cast<SqlLen>(value.size());
+ else
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+ else if (GetResLen())
+ *GetResLen() = value.size();
+ }
+
+ void ApplicationDataBuffer::PutRawDataToBuffer(void *data, size_t len)
+ {
+ SqlLen ilen = static_cast<SqlLen>(len);
+
+ if (GetData())
+ {
+ size_t toCopy = static_cast<size_t>(std::min(buflen, ilen));
+
+ memcpy(GetData(), data, toCopy);
+
+ if (GetResLen())
+ {
+ if (buflen >= ilen)
+ *GetResLen() = ilen;
+ else
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+ else if (GetResLen())
+ *GetResLen() = ilen;
+ }
+
+ void ApplicationDataBuffer::PutInt8(int8_t value)
+ {
+ PutNum(value);
+ }
+
+ void ApplicationDataBuffer::PutInt16(int16_t value)
+ {
+ PutNum(value);
+ }
+
+ void ApplicationDataBuffer::PutInt32(int32_t value)
+ {
+ PutNum(value);
+ }
+
+ void ApplicationDataBuffer::PutInt64(int64_t value)
+ {
+ PutNum(value);
+ }
+
+ void ApplicationDataBuffer::PutFloat(float value)
+ {
+ PutNum(value);
+ }
+
+ void ApplicationDataBuffer::PutDouble(double value)
+ {
+ PutNum(value);
+ }
+
+ int32_t ApplicationDataBuffer::PutString(const std::string & value)
+ {
+ using namespace type_traits;
+
+ int32_t used = 0;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_BIT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
+ case IGNITE_ODBC_C_TYPE_NUMERIC:
+ {
+ std::stringstream converter(value);
+
+ int64_t numValue;
+
+ converter >> numValue;
+
+ PutNum(numValue);
+
+ used = static_cast<int32_t>(value.size());
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_FLOAT:
+ case IGNITE_ODBC_C_TYPE_DOUBLE:
+ {
+ std::stringstream converter(value);
+
+ double numValue;
+
+ converter >> numValue;
+
+ PutNum(numValue);
+
+ used = static_cast<int32_t>(value.size());
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ case IGNITE_ODBC_C_TYPE_BINARY:
+ case IGNITE_ODBC_C_TYPE_DEFAULT:
+ {
+ PutStrToStrBuffer<char>(value);
+
+ used = static_cast<int32_t>(GetSize()) - 1;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_WCHAR:
+ {
+ PutStrToStrBuffer<wchar_t>(value);
+
+ used = (static_cast<int32_t>(GetSize()) / 2) - 1;
+
+ break;
+ }
+
+ default:
+ {
+ if (GetResLen())
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+
+ return used < 0 ? 0 : used;
+ }
+
+ void ApplicationDataBuffer::PutGuid(const Guid & value)
+ {
+ using namespace type_traits;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ case IGNITE_ODBC_C_TYPE_BINARY:
+ case IGNITE_ODBC_C_TYPE_DEFAULT:
+ {
+ PutValToStrBuffer<char>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_WCHAR:
+ {
+ PutValToStrBuffer<wchar_t>(value);
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_GUID:
+ {
+ SQLGUID* guid = reinterpret_cast<SQLGUID*>(GetData());
+
+ guid->Data1 = static_cast<uint32_t>(value.GetMostSignificantBits() >> 32);
+ guid->Data2 = static_cast<uint16_t>(value.GetMostSignificantBits() >> 16);
+ guid->Data3 = static_cast<uint16_t>(value.GetMostSignificantBits());
+
+ uint64_t lsb = value.GetLeastSignificantBits();
+ for (size_t i = 0; i < sizeof(guid->Data4); ++i)
+ guid->Data4[i] = (lsb >> (sizeof(guid->Data4) - i - 1) * 8) & 0xFF;
+
+ break;
+ }
+
+ default:
+ {
+ if (GetResLen())
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+ }
+
+ int32_t ApplicationDataBuffer::PutBinaryData(void *data, size_t len)
+ {
+ using namespace type_traits;
+
+ int32_t used = 0;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_BINARY:
+ case IGNITE_ODBC_C_TYPE_DEFAULT:
+ {
+ PutRawDataToBuffer(data, len);
+
+ used = static_cast<int32_t>(GetSize());
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ std::stringstream converter;
+
+ uint8_t *dataBytes = reinterpret_cast<uint8_t*>(data);
+
+ for (size_t i = 0; i < len; ++i)
+ {
+ converter << std::hex
+ << std::setfill('0')
+ << std::setw(2)
+ << static_cast<unsigned>(dataBytes[i]);
+ }
+
+ PutStrToStrBuffer<char>(converter.str());
+
+ used = static_cast<int32_t>(GetSize()) - 1;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_WCHAR:
+ {
+ std::wstringstream converter;
+
+ uint8_t *dataBytes = reinterpret_cast<uint8_t*>(data);
+
+ for (size_t i = 0; i < len; ++i)
+ {
+ converter << std::hex
+ << std::setfill<wchar_t>('0')
+ << std::setw(2)
+ << static_cast<unsigned>(dataBytes[i]);
+ }
+
+ PutStrToStrBuffer<wchar_t>(converter.str());
+
+ used = static_cast<int32_t>(GetSize() / 2) - 1;
+
+ break;
+ }
+
+ default:
+ {
+ if (GetResLen())
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+
+ return used < 0 ? 0 : used;
+ }
+
+ void ApplicationDataBuffer::PutNull()
+ {
+ if (GetResLen())
+ *GetResLen() = SQL_NULL_DATA;
+ }
+
+ void ApplicationDataBuffer::PutDecimal(const Decimal& value)
+ {
+ using namespace type_traits;
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_BIT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
+ case IGNITE_ODBC_C_TYPE_FLOAT:
+ case IGNITE_ODBC_C_TYPE_DOUBLE:
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ case IGNITE_ODBC_C_TYPE_WCHAR:
+ {
+ PutNum<double>(static_cast<double>(value));
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_NUMERIC:
+ {
+ if (GetData())
+ {
+ SQL_NUMERIC_STRUCT* numeric =
+ reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());
+
+ numeric->sign = value.IsNegative() ? 1 : 0;
+ numeric->precision = 0;
+ numeric->scale = value.GetScale();
+ memcpy(numeric->val, value.GetMagnitude(), std::min<size_t>(SQL_MAX_NUMERIC_LEN, value.GetLength()));
+ }
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_DEFAULT:
+ {
+ if (GetData())
+ memcpy(GetData(), &value, std::min(static_cast<size_t>(buflen), sizeof(value)));
+
+ if (GetResLen())
+ *GetResLen() = sizeof(value);
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_BINARY:
+ default:
+ {
+ if (GetResLen())
+ *GetResLen() = SQL_NO_TOTAL;
+ }
+ }
+ }
+
+ std::string ApplicationDataBuffer::GetString(size_t maxLen) const
+ {
+ using namespace type_traits;
+ std::string res;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ res.assign(reinterpret_cast<const char*>(GetData()),
+ std::min(maxLen, static_cast<size_t>(buflen)));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
+ {
+ std::stringstream converter;
+
+ converter << GetNum<int64_t>();
+
+ res = converter.str();
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_BIT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
+ {
+ std::stringstream converter;
+
+ converter << GetNum<uint64_t>();
+
+ res = converter.str();
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_FLOAT:
+ {
+ std::stringstream converter;
+
+ converter << GetNum<float>();
+
+ res = converter.str();
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_NUMERIC:
+ case IGNITE_ODBC_C_TYPE_DOUBLE:
+ {
+ std::stringstream converter;
+
+ converter << GetNum<double>();
+
+ res = converter.str();
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return res;
+ }
+
+ int8_t ApplicationDataBuffer::GetInt8() const
+ {
+ return GetNum<int8_t>();
+ }
+
+ int16_t ApplicationDataBuffer::GetInt16() const
+ {
+ return GetNum<int16_t>();
+ }
+
+ int32_t ApplicationDataBuffer::GetInt32() const
+ {
+ return GetNum<int32_t>();
+ }
+
+ int64_t ApplicationDataBuffer::GetInt64() const
+ {
+ return GetNum<int64_t>();
+ }
+
+ float ApplicationDataBuffer::GetFloat() const
+ {
+ return GetNum<float>();
+ }
+
+ double ApplicationDataBuffer::GetDouble() const
+ {
+ return GetNum<double>();
+ }
+
+ const void* ApplicationDataBuffer::GetData() const
+ {
+ return ApplyOffset(buffer);
+ }
+
+ const SqlLen* ApplicationDataBuffer::GetResLen() const
+ {
+ return ApplyOffset(reslen);
+ }
+
+ void* ApplicationDataBuffer::GetData()
+ {
+ return ApplyOffset(buffer);
+ }
+
+ SqlLen* ApplicationDataBuffer::GetResLen()
+ {
+ return ApplyOffset(reslen);
+ }
+
+ template<typename T>
+ T ApplicationDataBuffer::GetNum() const
+ {
+ using namespace type_traits;
+
+ T res = 0;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ std::string str = GetString(static_cast<size_t>(buflen));
+
+ std::stringstream converter(str);
+
+ // Workaround for char types which are recognised as
+ // symbolyc types and not numeric types.
+ if (sizeof(T) == 1)
+ {
+ short tmp;
+
+ converter >> tmp;
+
+ res = static_cast<T>(tmp);
+ }
+ else
+ converter >> res;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const signed char*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_BIT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const unsigned char*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const signed short*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const unsigned short*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
+ {
+ res = static_cast<T>(*reinterpret_cast<const signed long*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
+ {
+ res = static_cast<T>(*reinterpret_cast<const unsigned long*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const int64_t*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const uint64_t*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_FLOAT:
+ {
+ res = static_cast<T>(*reinterpret_cast<const float*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_DOUBLE:
+ {
+ res = static_cast<T>(*reinterpret_cast<const double*>(GetData()));
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_NUMERIC:
+ {
+ const SQL_NUMERIC_STRUCT* numeric =
+ reinterpret_cast<const SQL_NUMERIC_STRUCT*>(GetData());
+
+ int64_t resInt;
+
+ // TODO: implement propper conversation from numeric type.
+ memcpy(&resInt, numeric->val, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(resInt)));
+
+ if (numeric->sign)
+ resInt *= -1;
+
+ double resDouble = static_cast<double>(resInt);
+
+ for (SQLSCHAR scale = numeric->scale; scale > 0; --scale)
+ resDouble /= 10.0;
+
+ res = static_cast<T>(resDouble);
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return res;
+ }
+
+ template<typename T>
+ T* ApplicationDataBuffer::ApplyOffset(T* ptr) const
+ {
+ if (!ptr || !offset || !*offset)
+ return ptr;
+
+ return utility::GetPointerWithOffset(ptr, **offset);
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/app/parameter.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/parameter.cpp b/modules/platforms/cpp/odbc/src/app/parameter.cpp
new file mode 100644
index 0000000..dbe33e1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/app/parameter.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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 <algorithm>
+#include <string>
+#include <sstream>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/app/parameter.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace app
+ {
+ Parameter::Parameter() :
+ buffer(),
+ sqlType(),
+ columnSize(),
+ decDigits()
+ {
+ // No-op.
+ }
+
+ Parameter::Parameter(const ApplicationDataBuffer& buffer, int16_t sqlType,
+ size_t columnSize, int16_t decDigits) :
+ buffer(buffer),
+ sqlType(sqlType),
+ columnSize(columnSize),
+ decDigits(decDigits)
+ {
+ // No-op.
+ }
+
+ Parameter::Parameter(const Parameter & other) :
+ buffer(other.buffer),
+ sqlType(other.sqlType),
+ columnSize(other.columnSize),
+ decDigits(other.decDigits)
+ {
+ // No-op.
+ }
+
+ Parameter::~Parameter()
+ {
+ // No-op.
+ }
+
+ Parameter& Parameter::operator=(const Parameter &other)
+ {
+ buffer = other.buffer;
+ sqlType = other.sqlType;
+ columnSize = other.columnSize;
+ decDigits = other.decDigits;
+
+ return *this;
+ }
+
+ void Parameter::Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ switch (sqlType)
+ {
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ case SQL_LONGVARCHAR:
+ {
+ utility::WriteString(writer, buffer.GetString(columnSize));
+ break;
+ }
+
+ case SQL_SMALLINT:
+ {
+ writer.WriteInt16(buffer.GetInt16());
+ break;
+ }
+
+ case SQL_INTEGER:
+ {
+ writer.WriteInt32(buffer.GetInt32());
+ break;
+ }
+
+ case SQL_FLOAT:
+ {
+ writer.WriteFloat(buffer.GetFloat());
+ break;
+ }
+
+ case SQL_DOUBLE:
+ {
+ writer.WriteDouble(buffer.GetDouble());
+ break;
+ }
+
+ case SQL_TINYINT:
+ case SQL_BIT:
+ {
+ writer.WriteBool(buffer.GetInt8() != 0);
+ break;
+ }
+
+ case SQL_BIGINT:
+ {
+ writer.WriteInt64(buffer.GetInt64());
+ break;
+ }
+
+ case SQL_BINARY:
+ case SQL_VARBINARY:
+ case SQL_LONGVARBINARY:
+ {
+ writer.WriteInt8Array(reinterpret_cast<const int8_t*>(buffer.GetData()),
+ static_cast<int32_t>(buffer.GetSize()));
+ break;
+ }
+
+ case SQL_GUID:
+ default:
+ //TODO: Add GUID type support.
+ break;
+ }
+ }
+
+ ApplicationDataBuffer & Parameter::GetBuffer()
+ {
+ return buffer;
+ }
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/src/column.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/column.cpp b/modules/platforms/cpp/odbc/src/column.cpp
new file mode 100644
index 0000000..7b2f1e9
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/column.cpp
@@ -0,0 +1,454 @@
+/*
+ * 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 <ignite/impl/interop/interop_stream_position_guard.h>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/column.h"
+
+namespace
+{
+ using namespace ignite::impl::interop;
+ using namespace ignite::impl::binary;
+
+ bool GetObjectLength(InteropInputStream& stream, int32_t& len)
+ {
+ InteropStreamPositionGuard<InteropInputStream> guard(stream);
+
+ int8_t hdr = stream.ReadInt8();
+
+ if (hdr != IGNITE_HDR_FULL)
+ return false;
+
+ int8_t protoVer = stream.ReadInt8();
+
+ if (protoVer != IGNITE_PROTO_VER)
+ return false;
+
+ // Skipping flags
+ stream.ReadInt16();
+
+ // Skipping typeId
+ stream.ReadInt32();
+
+ // Skipping hash code
+ stream.ReadInt32();
+
+ len = stream.ReadInt32();
+
+ return true;
+ }
+
+ /**
+ * Read column header and restores position if the column is of
+ * complex type.
+ * @return Column type header.
+ */
+ int8_t ReadColumnHeader(ignite::impl::interop::InteropInputStream& stream)
+ {
+ using namespace ignite::impl::binary;
+
+ int32_t headerPos = stream.Position();
+
+ int8_t hdr = stream.ReadInt8();
+
+ // Check if we need to restore position - to read complex types
+ // stream should have unread header, but for primitive types it
+ // should not.
+ switch (hdr)
+ {
+ case IGNITE_TYPE_BYTE:
+ case IGNITE_TYPE_SHORT:
+ case IGNITE_TYPE_CHAR:
+ case IGNITE_TYPE_INT:
+ case IGNITE_TYPE_LONG:
+ case IGNITE_TYPE_FLOAT:
+ case IGNITE_TYPE_DOUBLE:
+ case IGNITE_TYPE_BOOL:
+ case IGNITE_HDR_NULL:
+ {
+ // No-op.
+ break;
+ }
+
+ default:
+ {
+ // Restoring position.
+ stream.Position(headerPos);
+ break;
+ }
+ }
+
+ return hdr;
+ }
+}
+
+namespace ignite
+{
+ namespace odbc
+ {
+ Column::Column() :
+ type(0), startPos(-1), endPos(-1), offset(0), size(0)
+ {
+ // No-op.
+ }
+
+ Column::Column(const Column& other) :
+ type(other.type), startPos(other.startPos), endPos(other.endPos),
+ offset(other.offset), size(other.size)
+ {
+ // No-op.
+ }
+
+ Column& Column::operator=(const Column& other)
+ {
+ type = other.type;
+ startPos = other.startPos;
+ endPos = other.endPos;
+ offset = other.offset;
+ size = other.size;
+
+ return *this;
+ }
+
+ Column::~Column()
+ {
+ // No-op.
+ }
+
+ Column::Column(ignite::impl::binary::BinaryReaderImpl& reader) :
+ type(0), startPos(-1), endPos(-1), offset(0), size(0)
+ {
+ ignite::impl::interop::InteropInputStream* stream = reader.GetStream();
+
+ if (!stream)
+ return;
+
+ InteropStreamPositionGuard<InteropInputStream> guard(*stream);
+
+ int32_t sizeTmp = 0;
+
+ int8_t hdr = ReadColumnHeader(*stream);
+
+ int32_t startPosTmp = stream->Position();
+
+ switch (hdr)
+ {
+ case IGNITE_HDR_NULL:
+ {
+ sizeTmp = 1;
+
+ break;
+ }
+
+ case IGNITE_TYPE_BYTE:
+ {
+ reader.ReadInt8();
+
+ sizeTmp = 1;
+
+ break;
+ }
+
+ case IGNITE_TYPE_BOOL:
+ {
+ reader.ReadBool();
+
+ sizeTmp = 1;
+
+ break;
+ }
+
+ case IGNITE_TYPE_SHORT:
+ case IGNITE_TYPE_CHAR:
+ {
+ reader.ReadInt16();
+
+ sizeTmp = 2;
+
+ break;
+ }
+
+ case IGNITE_TYPE_FLOAT:
+ {
+ reader.ReadFloat();
+
+ sizeTmp = 4;
+
+ break;
+ }
+
+ case IGNITE_TYPE_INT:
+ {
+ reader.ReadInt32();
+
+ sizeTmp = 4;
+
+ break;
+ }
+
+ case IGNITE_TYPE_DOUBLE:
+ {
+ reader.ReadDouble();
+
+ sizeTmp = 8;
+
+ break;
+ }
+
+ case IGNITE_TYPE_LONG:
+ {
+ reader.ReadInt64();
+
+ sizeTmp = 8;
+
+ break;
+ }
+
+ case IGNITE_TYPE_STRING:
+ {
+ std::string str;
+ utility::ReadString(reader, str);
+
+ sizeTmp = static_cast<int32_t>(str.size());
+
+ break;
+ }
+
+ case IGNITE_TYPE_UUID:
+ {
+ reader.ReadGuid();
+
+ sizeTmp = 16;
+
+ break;
+ }
+
+ case IGNITE_HDR_FULL:
+ {
+ int32_t len;
+
+ if (!GetObjectLength(*stream, len))
+ return;
+
+ sizeTmp = len;
+
+ stream->Position(stream->Position() + len);
+
+ break;
+ }
+
+ case IGNITE_TYPE_DECIMAL:
+ {
+ Decimal res;
+
+ utility::ReadDecimal(reader, res);
+
+ sizeTmp = res.GetLength() + 8;
+
+ break;
+ }
+
+ case IGNITE_TYPE_DATE:
+ default:
+ {
+ // This is a fail case.
+ return;
+ }
+ }
+
+ type = hdr;
+ startPos = startPosTmp;
+ endPos = stream->Position();
+ size = sizeTmp;
+ }
+
+ SqlResult Column::ReadToBuffer(ignite::impl::binary::BinaryReaderImpl& reader,
+ app::ApplicationDataBuffer& dataBuf)
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::impl::interop;
+
+ if (!IsValid())
+ return SQL_RESULT_ERROR;
+
+ if (GetUnreadDataLength() == 0)
+ {
+ dataBuf.PutNull();
+
+ return SQL_RESULT_NO_DATA;
+ }
+
+ ignite::impl::interop::InteropInputStream* stream = reader.GetStream();
+
+ if (!stream)
+ return SQL_RESULT_ERROR;
+
+ InteropStreamPositionGuard<InteropInputStream> guard(*stream);
+
+ stream->Position(startPos);
+
+ switch (type)
+ {
+ case IGNITE_TYPE_BYTE:
+ {
+ dataBuf.PutInt8(reader.ReadInt8());
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_SHORT:
+ case IGNITE_TYPE_CHAR:
+ {
+ dataBuf.PutInt16(reader.ReadInt16());
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_INT:
+ {
+ dataBuf.PutInt32(reader.ReadInt32());
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_LONG:
+ {
+ dataBuf.PutInt64(reader.ReadInt64());
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_FLOAT:
+ {
+ dataBuf.PutFloat(reader.ReadFloat());
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_DOUBLE:
+ {
+ dataBuf.PutDouble(reader.ReadDouble());
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_BOOL:
+ {
+ dataBuf.PutInt8(reader.ReadBool() ? 1 : 0);
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_STRING:
+ {
+ std::string str;
+ utility::ReadString(reader, str);
+
+ int32_t written = dataBuf.PutString(str.substr(offset));
+
+ IncreaseOffset(written);
+
+ break;
+ }
+
+ case IGNITE_TYPE_UUID:
+ {
+ Guid guid = reader.ReadGuid();
+
+ dataBuf.PutGuid(guid);
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_HDR_NULL:
+ {
+ dataBuf.PutNull();
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_HDR_FULL:
+ {
+ int32_t len;
+
+ if (!GetObjectLength(*stream, len))
+ return SQL_RESULT_ERROR;
+
+ std::vector<int8_t> data(len);
+
+ stream->ReadInt8Array(&data[0], static_cast<int32_t>(data.size()));
+
+ int32_t written = dataBuf.PutBinaryData(data.data() + offset, static_cast<size_t>(len - offset));
+
+ IncreaseOffset(written);
+
+ break;
+ }
+
+ case IGNITE_TYPE_DECIMAL:
+ {
+ Decimal res;
+
+ utility::ReadDecimal(reader, res);
+
+ dataBuf.PutDecimal(res);
+
+ IncreaseOffset(size);
+
+ break;
+ }
+
+ case IGNITE_TYPE_DATE:
+ default:
+ {
+ // This is a fail case. Return false.
+ return SQL_RESULT_ERROR;
+ }
+ }
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ void Column::IncreaseOffset(int32_t value)
+ {
+ offset += value;
+
+ if (offset > size)
+ offset = size;
+ }
+ }
+}
+
[10/28] ignite git commit: IGNITE-2441: Fixed ToolsVersion for C++ VS
projects.
Posted by vo...@apache.org.
IGNITE-2441: Fixed ToolsVersion for C++ VS projects.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f58ceb64
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f58ceb64
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f58ceb64
Branch: refs/heads/ignite-1786
Commit: f58ceb64fa3c491eaf0d38820013d29a1a54a1c6
Parents: 9abee12
Author: isapego <is...@gridgain.com>
Authored: Tue Jan 26 13:27:16 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Jan 26 13:27:16 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/binary/project/vs/binary.vcxproj | 2 +-
modules/platforms/cpp/common/project/vs/common.vcxproj | 2 +-
modules/platforms/cpp/ignite/project/vs/ignite.vcxproj | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f58ceb64/modules/platforms/cpp/binary/project/vs/binary.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/project/vs/binary.vcxproj b/modules/platforms/cpp/binary/project/vs/binary.vcxproj
index 67415ef..ae463e8 100644
--- a/modules/platforms/cpp/binary/project/vs/binary.vcxproj
+++ b/modules/platforms/cpp/binary/project/vs/binary.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f58ceb64/modules/platforms/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj b/modules/platforms/cpp/common/project/vs/common.vcxproj
index ff77730..9bc23c2 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f58ceb64/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj b/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
index dc1d43f..dd5cd6f 100644
--- a/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
+++ b/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
[26/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
IGNITE-2442: ODBC projects moved to main cpp solution.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e8287063
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e8287063
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e8287063
Branch: refs/heads/ignite-1786
Commit: e8287063908ec918f5afa72032854e7bf5a54f20
Parents: 57822b6
Author: isapego <is...@gridgain.com>
Authored: Tue Jan 26 16:43:39 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Jan 26 16:43:39 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/Makefile.am | 55 +
modules/platforms/cpp/odbc-test/README.TXT | 1 +
modules/platforms/cpp/odbc-test/configure.ac | 62 +
.../cpp/odbc-test/include/teamcity_messages.h | 55 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 189 ++
.../project/vs/odbc-test.vcxproj.filters | 79 +
.../src/application_data_buffer_test.cpp | 630 +++++++
.../platforms/cpp/odbc-test/src/column_test.cpp | 290 +++
.../cpp/odbc-test/src/configuration_test.cpp | 206 +++
.../cpp/odbc-test/src/connection_info_test.cpp | 219 +++
.../platforms/cpp/odbc-test/src/cursor_test.cpp | 166 ++
.../platforms/cpp/odbc-test/src/parser_test.cpp | 94 +
.../platforms/cpp/odbc-test/src/row_test.cpp | 167 ++
.../cpp/odbc-test/src/teamcity_boost.cpp | 159 ++
.../cpp/odbc-test/src/teamcity_messages.cpp | 150 ++
.../cpp/odbc-test/src/utility_test.cpp | 81 +
modules/platforms/cpp/odbc/Makefile.am | 67 +
modules/platforms/cpp/odbc/configure.ac | 62 +
modules/platforms/cpp/odbc/ignite-odbc.pc.in | 9 +
.../ignite/odbc/app/application_data_buffer.h | 342 ++++
.../odbc/include/ignite/odbc/app/parameter.h | 113 ++
.../cpp/odbc/include/ignite/odbc/column.h | 149 ++
.../cpp/odbc/include/ignite/odbc/common_types.h | 225 +++
.../include/ignite/odbc/config/configuration.h | 164 ++
.../ignite/odbc/config/connection_info.h | 98 +
.../cpp/odbc/include/ignite/odbc/connection.h | 258 +++
.../cpp/odbc/include/ignite/odbc/cursor.h | 108 ++
.../cpp/odbc/include/ignite/odbc/decimal.h | 126 ++
.../ignite/odbc/diagnostic/diagnosable.h | 82 +
.../odbc/diagnostic/diagnosable_adapter.h | 107 ++
.../ignite/odbc/diagnostic/diagnostic_record.h | 165 ++
.../odbc/diagnostic/diagnostic_record_storage.h | 198 ++
.../cpp/odbc/include/ignite/odbc/environment.h | 137 ++
.../cpp/odbc/include/ignite/odbc/message.h | 630 +++++++
.../odbc/include/ignite/odbc/meta/column_meta.h | 210 +++
.../include/ignite/odbc/meta/primary_key_meta.h | 188 ++
.../odbc/include/ignite/odbc/meta/table_meta.h | 166 ++
.../cpp/odbc/include/ignite/odbc/parser.h | 141 ++
.../ignite/odbc/query/column_metadata_query.h | 146 ++
.../odbc/include/ignite/odbc/query/data_query.h | 152 ++
.../ignite/odbc/query/foreign_keys_query.h | 143 ++
.../ignite/odbc/query/primary_keys_query.h | 137 ++
.../cpp/odbc/include/ignite/odbc/query/query.h | 119 ++
.../ignite/odbc/query/special_columns_query.h | 142 ++
.../ignite/odbc/query/table_metadata_query.h | 150 ++
.../include/ignite/odbc/query/type_info_query.h | 118 ++
.../cpp/odbc/include/ignite/odbc/result_page.h | 101 ++
.../cpp/odbc/include/ignite/odbc/row.h | 132 ++
.../cpp/odbc/include/ignite/odbc/statement.h | 525 ++++++
.../include/ignite/odbc/system/odbc_constants.h | 45 +
.../include/ignite/odbc/system/socket_client.h | 92 +
.../cpp/odbc/include/ignite/odbc/type_traits.h | 313 ++++
.../cpp/odbc/include/ignite/odbc/utility.h | 171 ++
.../platforms/cpp/odbc/odbc-driver/Makefile.am | 67 -
.../platforms/cpp/odbc/odbc-driver/configure.ac | 62 -
.../cpp/odbc/odbc-driver/ignite-odbc.pc.in | 9 -
.../ignite/odbc/app/application_data_buffer.h | 342 ----
.../include/ignite/odbc/app/parameter.h | 113 --
.../odbc-driver/include/ignite/odbc/column.h | 149 --
.../include/ignite/odbc/common_types.h | 225 ---
.../include/ignite/odbc/config/configuration.h | 164 --
.../ignite/odbc/config/connection_info.h | 98 -
.../include/ignite/odbc/connection.h | 258 ---
.../odbc-driver/include/ignite/odbc/cursor.h | 108 --
.../odbc-driver/include/ignite/odbc/decimal.h | 126 --
.../ignite/odbc/diagnostic/diagnosable.h | 82 -
.../odbc/diagnostic/diagnosable_adapter.h | 107 --
.../ignite/odbc/diagnostic/diagnostic_record.h | 165 --
.../odbc/diagnostic/diagnostic_record_storage.h | 198 --
.../include/ignite/odbc/environment.h | 137 --
.../odbc-driver/include/ignite/odbc/message.h | 630 -------
.../include/ignite/odbc/meta/column_meta.h | 210 ---
.../include/ignite/odbc/meta/primary_key_meta.h | 188 --
.../include/ignite/odbc/meta/table_meta.h | 166 --
.../odbc-driver/include/ignite/odbc/parser.h | 141 --
.../ignite/odbc/query/column_metadata_query.h | 146 --
.../include/ignite/odbc/query/data_query.h | 152 --
.../ignite/odbc/query/foreign_keys_query.h | 143 --
.../ignite/odbc/query/primary_keys_query.h | 137 --
.../include/ignite/odbc/query/query.h | 119 --
.../ignite/odbc/query/special_columns_query.h | 142 --
.../ignite/odbc/query/table_metadata_query.h | 150 --
.../include/ignite/odbc/query/type_info_query.h | 118 --
.../include/ignite/odbc/result_page.h | 101 --
.../odbc/odbc-driver/include/ignite/odbc/row.h | 132 --
.../odbc-driver/include/ignite/odbc/statement.h | 525 ------
.../include/ignite/odbc/system/odbc_constants.h | 45 -
.../include/ignite/odbc/system/socket_client.h | 92 -
.../include/ignite/odbc/type_traits.h | 313 ----
.../odbc-driver/include/ignite/odbc/utility.h | 171 --
.../os/linux/src/system/socket_client.cpp | 120 --
.../os/win/src/system/socket_client.cpp | 133 --
.../cpp/odbc/odbc-driver/project/README.TXT | 1 -
.../cpp/odbc/odbc-driver/project/vs/README.TXT | 1 -
.../cpp/odbc/odbc-driver/project/vs/module.def | 69 -
.../odbc-driver/project/vs/odbc-driver.vcxproj | 233 ---
.../project/vs/odbc-driver.vcxproj.filters | 229 ---
.../src/app/application_data_buffer.cpp | 834 ---------
.../cpp/odbc/odbc-driver/src/app/parameter.cpp | 147 --
.../cpp/odbc/odbc-driver/src/column.cpp | 454 -----
.../cpp/odbc/odbc-driver/src/common_types.cpp | 120 --
.../odbc-driver/src/config/configuration.cpp | 245 ---
.../odbc-driver/src/config/connection_info.cpp | 419 -----
.../cpp/odbc/odbc-driver/src/connection.cpp | 269 ---
.../cpp/odbc/odbc-driver/src/cursor.cpp | 78 -
.../cpp/odbc/odbc-driver/src/decimal.cpp | 117 --
.../src/diagnostic/diagnosable_adapter.cpp | 49 -
.../src/diagnostic/diagnostic_record.cpp | 241 ---
.../diagnostic/diagnostic_record_storage.cpp | 242 ---
.../cpp/odbc/odbc-driver/src/environment.cpp | 172 --
.../odbc/odbc-driver/src/meta/column_meta.cpp | 275 ---
.../odbc/odbc-driver/src/meta/table_meta.cpp | 50 -
.../platforms/cpp/odbc/odbc-driver/src/odbc.cpp | 1687 ------------------
.../src/query/column_metadata_query.cpp | 317 ----
.../odbc/odbc-driver/src/query/data_query.cpp | 277 ---
.../src/query/foreign_keys_query.cpp | 131 --
.../src/query/primary_keys_query.cpp | 210 ---
.../src/query/special_columns_query.cpp | 121 --
.../src/query/table_metadata_query.cpp | 242 ---
.../odbc-driver/src/query/type_info_query.cpp | 394 ----
.../cpp/odbc/odbc-driver/src/result_page.cpp | 58 -
.../platforms/cpp/odbc/odbc-driver/src/row.cpp | 120 --
.../cpp/odbc/odbc-driver/src/statement.cpp | 529 ------
.../cpp/odbc/odbc-driver/src/type_traits.cpp | 657 -------
.../cpp/odbc/odbc-driver/src/utility.cpp | 105 --
.../platforms/cpp/odbc/odbc-test/Makefile.am | 55 -
modules/platforms/cpp/odbc/odbc-test/README.TXT | 1 -
.../platforms/cpp/odbc/odbc-test/configure.ac | 62 -
.../odbc/odbc-test/include/teamcity_messages.h | 55 -
.../odbc/odbc-test/project/vs/odbc-test.vcxproj | 189 --
.../project/vs/odbc-test.vcxproj.filters | 79 -
.../src/application_data_buffer_test.cpp | 630 -------
.../cpp/odbc/odbc-test/src/column_test.cpp | 290 ---
.../odbc/odbc-test/src/configuration_test.cpp | 206 ---
.../odbc/odbc-test/src/connection_info_test.cpp | 219 ---
.../cpp/odbc/odbc-test/src/cursor_test.cpp | 166 --
.../cpp/odbc/odbc-test/src/parser_test.cpp | 94 -
.../cpp/odbc/odbc-test/src/row_test.cpp | 167 --
.../cpp/odbc/odbc-test/src/teamcity_boost.cpp | 159 --
.../odbc/odbc-test/src/teamcity_messages.cpp | 150 --
.../cpp/odbc/odbc-test/src/utility_test.cpp | 81 -
.../odbc/os/linux/src/system/socket_client.cpp | 120 ++
.../odbc/os/win/src/system/socket_client.cpp | 133 ++
modules/platforms/cpp/odbc/project/README.TXT | 1 +
.../platforms/cpp/odbc/project/vs/README.TXT | 1 +
.../platforms/cpp/odbc/project/vs/module.def | 69 +
modules/platforms/cpp/odbc/project/vs/odbc.sln | 56 -
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 233 +++
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 229 +++
.../odbc/src/app/application_data_buffer.cpp | 834 +++++++++
.../platforms/cpp/odbc/src/app/parameter.cpp | 147 ++
modules/platforms/cpp/odbc/src/column.cpp | 454 +++++
modules/platforms/cpp/odbc/src/common_types.cpp | 120 ++
.../cpp/odbc/src/config/configuration.cpp | 245 +++
.../cpp/odbc/src/config/connection_info.cpp | 419 +++++
modules/platforms/cpp/odbc/src/connection.cpp | 269 +++
modules/platforms/cpp/odbc/src/cursor.cpp | 78 +
modules/platforms/cpp/odbc/src/decimal.cpp | 117 ++
.../odbc/src/diagnostic/diagnosable_adapter.cpp | 49 +
.../odbc/src/diagnostic/diagnostic_record.cpp | 241 +++
.../diagnostic/diagnostic_record_storage.cpp | 242 +++
modules/platforms/cpp/odbc/src/environment.cpp | 172 ++
.../platforms/cpp/odbc/src/meta/column_meta.cpp | 275 +++
.../platforms/cpp/odbc/src/meta/table_meta.cpp | 50 +
modules/platforms/cpp/odbc/src/odbc.cpp | 1687 ++++++++++++++++++
.../odbc/src/query/column_metadata_query.cpp | 317 ++++
.../platforms/cpp/odbc/src/query/data_query.cpp | 277 +++
.../cpp/odbc/src/query/foreign_keys_query.cpp | 131 ++
.../cpp/odbc/src/query/primary_keys_query.cpp | 210 +++
.../odbc/src/query/special_columns_query.cpp | 121 ++
.../cpp/odbc/src/query/table_metadata_query.cpp | 242 +++
.../cpp/odbc/src/query/type_info_query.cpp | 394 ++++
modules/platforms/cpp/odbc/src/result_page.cpp | 58 +
modules/platforms/cpp/odbc/src/row.cpp | 120 ++
modules/platforms/cpp/odbc/src/statement.cpp | 529 ++++++
modules/platforms/cpp/odbc/src/type_traits.cpp | 657 +++++++
modules/platforms/cpp/odbc/src/utility.cpp | 105 ++
modules/platforms/cpp/project/vs/ignite.sln | 20 +
178 files changed, 18200 insertions(+), 18236 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
new file mode 100644
index 0000000..32ca6b2
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -0,0 +1,55 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+SUBDIRS = .
+DIST_SUBDIRS = .
+
+AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/../odbc-driver/include -DIGNITE_IMPL
+AM_CXXFLAGS = -Wall -std=c++0x
+
+noinst_PROGRAMS = ignite-odbc-tests
+
+ignite_odbc_tests_SOURCES = src/teamcity_boost.cpp \
+ src/teamcity_messages.cpp \
+ src/parser_test.cpp \
+ src/cursor_test.cpp \
+ src/connection_info_test.cpp \
+ src/application_data_buffer_test.cpp \
+ src/configuration_test.cpp \
+ src/row_test.cpp \
+ src/utility_test.cpp \
+ ../odbc-driver/src/cursor.cpp \
+ ../odbc-driver/src/config/connection_info.cpp \
+ ../odbc-driver/src/app/application_data_buffer.cpp \
+ ../odbc-driver/src/config/configuration.cpp \
+ ../odbc-driver/src/row.cpp \
+ ../odbc-driver/src/decimal.cpp \
+ ../odbc-driver/src/utility.cpp \
+ ../odbc-driver/src/result_page.cpp
+
+ignite_odbc_tests_LDFLAGS = -static-libtool-libs -L/usr/local/lib -lignite-binary -ldl
+
+run-check: check
+ ./ignite-odbc-tests -p
+
+clean-local: clean-check
+ $(RM) *.gcno *.gcda
+
+clean-docs:
+ $(RM) $(ignite_odbc_tests_OBJECTS)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/README.TXT b/modules/platforms/cpp/odbc-test/README.TXT
new file mode 100644
index 0000000..97f4c64
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/README.TXT
@@ -0,0 +1 @@
+Contains IDE projects artifacts.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/configure.ac b/modules/platforms/cpp/odbc-test/configure.ac
new file mode 100644
index 0000000..abb7adc
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/configure.ac
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([Apache Ignite ODBC Test], [1.5.1.7927], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_CONFIG_SRCDIR(src)
+
+AC_CANONICAL_SYSTEM
+AC_CONFIG_MACRO_DIR([m4])
+AC_LANG([C++])
+
+# Initialize automake
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_CONFIG_HEADER(config.h)
+
+AM_PROG_AR
+
+# Checks for programs.
+GXX="-g -O2"
+
+AC_PROG_CXX
+
+# Initialize Libtool
+LT_INIT
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_lock])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+
+AC_CONFIG_FILES(Makefile)
+
+AC_OUTPUT
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/include/teamcity_messages.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/teamcity_messages.h b/modules/platforms/cpp/odbc-test/include/teamcity_messages.h
new file mode 100644
index 0000000..8cf23d0
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/include/teamcity_messages.h
@@ -0,0 +1,55 @@
+/* Copyright 2011 JetBrains s.r.o.
+ *
+ * Licensed 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.
+ *
+ * $Revision: 88625 $
+*/
+
+#ifndef H_TEAMCITY_MESSAGES
+#define H_TEAMCITY_MESSAGES
+
+#include <string>
+#include <iostream>
+
+namespace JetBrains {
+
+std::string getFlowIdFromEnvironment();
+bool underTeamcity();
+
+class TeamcityMessages {
+ std::ostream *m_out;
+
+protected:
+ std::string escape(std::string s);
+
+ void openMsg(const std::string &name);
+ void writeProperty(std::string name, std::string value);
+ void closeMsg();
+
+public:
+ TeamcityMessages();
+
+ void setOutput(std::ostream &);
+
+ void suiteStarted(std::string name, std::string flowid = "");
+ void suiteFinished(std::string name, std::string flowid = "");
+
+ void testStarted(std::string name, std::string flowid = "");
+ void testFailed(std::string name, std::string message, std::string details, std::string flowid = "");
+ void testIgnored(std::string name, std::string message, std::string flowid = "");
+ void testFinished(std::string name, int durationMs = -1, std::string flowid = "");
+};
+
+}
+
+#endif /* H_TEAMCITY_MESSAGES */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
new file mode 100644
index 0000000..f39e071
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{309BEA40-495D-463F-98D5-4657F03F6D8F}</ProjectGuid>
+ <RootNamespace>odbctest</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-gd-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>$(BOOST_HOME)\lib64-msvc-10.0\libboost_unit_test_framework-vc100-mt-1_58.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\odbc\src\app\application_data_buffer.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\column.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\config\configuration.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\config\connection_info.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\cursor.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\decimal.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\result_page.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\row.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\utility.cpp" />
+ <ClCompile Include="..\..\src\application_data_buffer_test.cpp" />
+ <ClCompile Include="..\..\src\column_test.cpp" />
+ <ClCompile Include="..\..\src\configuration_test.cpp" />
+ <ClCompile Include="..\..\src\connection_info_test.cpp" />
+ <ClCompile Include="..\..\src\cursor_test.cpp" />
+ <ClCompile Include="..\..\src\parser_test.cpp" />
+ <ClCompile Include="..\..\src\row_test.cpp" />
+ <ClCompile Include="..\..\src\teamcity_boost.cpp" />
+ <ClCompile Include="..\..\src\teamcity_messages.cpp" />
+ <ClCompile Include="..\..\src\utility_test.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\teamcity_messages.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj">
+ <Project>{4f15669b-92eb-49f0-b774-8f19bae0b960}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
+ <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
new file mode 100644
index 0000000..cf44ba9
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Code">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Externals">
+ <UniqueIdentifier>{cc75fc86-c08d-428a-8ae3-f9979e4588ab}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\teamcity">
+ <UniqueIdentifier>{5438a56d-1009-412a-86e3-ceb1112af275}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\configuration_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\utility.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\connection_info_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\parser_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\teamcity_boost.cpp">
+ <Filter>Code\teamcity</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\teamcity_messages.cpp">
+ <Filter>Code\teamcity</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\application_data_buffer_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\row_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\row.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\result_page.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\cursor_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\cursor.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\utility_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\config\configuration.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\config\connection_info.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\app\application_data_buffer.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\decimal.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\odbc-driver\src\column.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\column_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\teamcity_messages.h">
+ <Filter>Code\teamcity</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
new file mode 100644
index 0000000..632f05f
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
@@ -0,0 +1,630 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/guid.h>
+#include <ignite/odbc/decimal.h>
+#include <ignite/odbc/app/application_data_buffer.h>
+
+#define FLOAT_PRECISION 0.0000001f
+
+using namespace ignite;
+using namespace ignite::odbc;
+using namespace ignite::odbc::app;
+using namespace ignite::odbc::type_traits;
+
+BOOST_AUTO_TEST_SUITE(ApplicationDataBufferTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestPutIntToString)
+{
+ char buffer[1024];
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
+
+ appBuf.PutInt8(12);
+ BOOST_REQUIRE(!strcmp(buffer, "12"));
+ BOOST_REQUIRE(reslen == strlen("12"));
+
+ appBuf.PutInt8(-12);
+ BOOST_REQUIRE(!strcmp(buffer, "-12"));
+ BOOST_REQUIRE(reslen == strlen("-12"));
+
+ appBuf.PutInt16(9876);
+ BOOST_REQUIRE(!strcmp(buffer, "9876"));
+ BOOST_REQUIRE(reslen == strlen("9876"));
+
+ appBuf.PutInt16(-9876);
+ BOOST_REQUIRE(!strcmp(buffer, "-9876"));
+ BOOST_REQUIRE(reslen == strlen("-9876"));
+
+ appBuf.PutInt32(1234567);
+ BOOST_REQUIRE(!strcmp(buffer, "1234567"));
+ BOOST_REQUIRE(reslen == strlen("1234567"));
+
+ appBuf.PutInt32(-1234567);
+ BOOST_REQUIRE(!strcmp(buffer, "-1234567"));
+ BOOST_REQUIRE(reslen == strlen("-1234567"));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutFloatToString)
+{
+ char buffer[1024];
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
+
+ appBuf.PutFloat(12.42f);
+ BOOST_REQUIRE(!strcmp(buffer, "12.42"));
+ BOOST_REQUIRE(reslen == strlen("12.42"));
+
+ appBuf.PutFloat(-12.42f);
+ BOOST_REQUIRE(!strcmp(buffer, "-12.42"));
+ BOOST_REQUIRE(reslen == strlen("-12.42"));
+
+ appBuf.PutDouble(1000.21);
+ BOOST_REQUIRE(!strcmp(buffer, "1000.21"));
+ BOOST_REQUIRE(reslen == strlen("1000.21"));
+
+ appBuf.PutDouble(-1000.21);
+ BOOST_REQUIRE(!strcmp(buffer, "-1000.21"));
+ BOOST_REQUIRE(reslen == strlen("-1000.21"));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutGuidToString)
+{
+ char buffer[1024];
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
+
+ ignite::Guid guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL);
+
+ appBuf.PutGuid(guid);
+
+ BOOST_REQUIRE(!strcmp(buffer, "1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
+ BOOST_REQUIRE(reslen == strlen("1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutBinaryToString)
+{
+ char buffer[1024];
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
+
+ uint8_t binary[] = { 0x21, 0x84, 0xF4, 0xDC, 0x01, 0x00, 0xFF, 0xF0 };
+
+ appBuf.PutBinaryData(binary, sizeof(binary));
+
+ BOOST_REQUIRE(!strcmp(buffer, "2184f4dc0100fff0"));
+ BOOST_REQUIRE(reslen == strlen("2184f4dc0100fff0"));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutStringToString)
+{
+ char buffer[1024];
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
+
+ std::string testString("Test string");
+
+ appBuf.PutString(testString);
+
+ BOOST_REQUIRE(!strcmp(buffer, testString.c_str()));
+ BOOST_REQUIRE(reslen == testString.size());
+}
+
+BOOST_AUTO_TEST_CASE(TestPutStringToWstring)
+{
+ wchar_t buffer[1024];
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_WCHAR, buffer, sizeof(buffer), &reslen, &offset);
+
+ std::string testString("Test string");
+
+ appBuf.PutString(testString);
+ BOOST_REQUIRE(!wcscmp(buffer, L"Test string"));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutStringToLong)
+{
+ long numBuf;
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, &offset);
+
+ appBuf.PutString("424242424");
+ BOOST_REQUIRE(numBuf == 424242424L);
+
+ appBuf.PutString("-424242424");
+ BOOST_REQUIRE(numBuf == -424242424L);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutStringToTiny)
+{
+ int8_t numBuf;
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_TINYINT, &numBuf, sizeof(numBuf), &reslen, &offset);
+
+ appBuf.PutString("12");
+ BOOST_REQUIRE(numBuf == 12);
+
+ appBuf.PutString("-12");
+ BOOST_REQUIRE(numBuf == -12);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutStringToFloat)
+{
+ float numBuf;
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset);
+
+ appBuf.PutString("12.21");
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 12.21, FLOAT_PRECISION);
+
+ appBuf.PutString("-12.21");
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -12.21, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutIntToFloat)
+{
+ float numBuf;
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset);
+
+ appBuf.PutInt8(5);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 5.0, FLOAT_PRECISION);
+
+ appBuf.PutInt8(-5);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -5.0, FLOAT_PRECISION);
+
+ appBuf.PutInt16(4242);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 4242.0, FLOAT_PRECISION);
+
+ appBuf.PutInt16(-4242);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -4242.0, FLOAT_PRECISION);
+
+ appBuf.PutInt32(1234567);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 1234567.0, FLOAT_PRECISION);
+
+ appBuf.PutInt32(-1234567);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -1234567.0, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutFloatToShort)
+{
+ short numBuf;
+ SqlLen reslen;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &numBuf, sizeof(numBuf), &reslen, &offset);
+
+ appBuf.PutDouble(5.42);
+ BOOST_REQUIRE(numBuf == 5);
+
+ appBuf.PutDouble(-5.42);
+ BOOST_REQUIRE(numBuf == -5.0);
+
+ appBuf.PutFloat(42.99f);
+ BOOST_REQUIRE(numBuf == 42);
+
+ appBuf.PutFloat(-42.99f);
+ BOOST_REQUIRE(numBuf == -42);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutDecimalToDouble)
+{
+ double numBuf;
+ SqlLen reslen;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &numBuf, sizeof(numBuf), &reslen, 0);
+
+ Decimal decimal;
+
+ BOOST_REQUIRE_CLOSE_FRACTION(static_cast<double>(decimal), 0.0, FLOAT_PRECISION);
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 0.0, FLOAT_PRECISION);
+
+ int8_t mag1[] = { 1, 0 };
+
+ decimal = Decimal(0, mag1, sizeof(mag1));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 256.0, FLOAT_PRECISION);
+
+ int8_t mag2[] = { 2, 23 };
+
+ decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -53.5, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutDecimalToLong)
+{
+ long numBuf;
+ SqlLen reslen;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, 0);
+
+ Decimal decimal;
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE(numBuf == 0);
+
+ int8_t mag1[] = { 1, 0 };
+
+ decimal = Decimal(0, mag1, sizeof(mag1));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE(numBuf == 256);
+
+ int8_t mag2[] = { 2, 23 };
+
+ decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE(numBuf == -53);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutDecimalToString)
+{
+ char strBuf[64];
+ SqlLen reslen;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
+
+ Decimal decimal;
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE(std::string(strBuf, reslen) == "0");
+
+ int8_t mag1[] = { 1, 0 };
+
+ decimal = Decimal(0, mag1, sizeof(mag1));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE(std::string(strBuf, reslen) == "256");
+
+ int8_t mag2[] = { 2, 23 };
+
+ decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_REQUIRE(std::string(strBuf, reslen) == "-53.5");
+}
+
+BOOST_AUTO_TEST_CASE(TestGetStringFromLong)
+{
+ long numBuf = 42;
+ SqlLen reslen = sizeof(numBuf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, reslen, &reslen, &offset);
+
+ std::string res = appBuf.GetString(32);
+
+ BOOST_REQUIRE(res == "42");
+
+ numBuf = -77;
+
+ res = appBuf.GetString(32);
+
+ BOOST_REQUIRE(res == "-77");
+}
+
+BOOST_AUTO_TEST_CASE(TestGetStringFromDouble)
+{
+ double numBuf = 43.36;
+ SqlLen reslen = sizeof(numBuf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &numBuf, reslen, &reslen, &offset);
+
+ std::string res = appBuf.GetString(32);
+
+ BOOST_REQUIRE(res == "43.36");
+
+ numBuf = -58.91;
+
+ res = appBuf.GetString(32);
+
+ BOOST_REQUIRE(res == "-58.91");
+}
+
+BOOST_AUTO_TEST_CASE(TestGetStringFromString)
+{
+ char buf[] = "Some data 32d2d5hs";
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset);
+
+ std::string res = appBuf.GetString(reslen);
+
+ BOOST_REQUIRE(res.compare(buf));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetFloatFromUshort)
+{
+ unsigned short numBuf = 7162;
+ SqlLen reslen = sizeof(numBuf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT, &numBuf, reslen, &reslen, &offset);
+
+ float resFloat = appBuf.GetFloat();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 7162.0f, FLOAT_PRECISION);
+
+ double resDouble = appBuf.GetDouble();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 7162.0, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetFloatFromString)
+{
+ char buf[] = "28.562";
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset);
+
+ float resFloat = appBuf.GetFloat();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 28.562f, FLOAT_PRECISION);
+
+ double resDouble = appBuf.GetDouble();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 28.562, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetFloatFromFloat)
+{
+ float buf = 207.49f;
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &buf, reslen, &reslen, &offset);
+
+ float resFloat = appBuf.GetFloat();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 207.49f, FLOAT_PRECISION);
+
+ double resDouble = appBuf.GetDouble();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 207.49, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetFloatFromDouble)
+{
+ double buf = 893.162;
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &buf, reslen, &reslen, &offset);
+
+ float resFloat = appBuf.GetFloat();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 893.162f, FLOAT_PRECISION);
+
+ double resDouble = appBuf.GetDouble();
+
+ BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 893.162, FLOAT_PRECISION);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetIntFromString)
+{
+ char buf[] = "39";
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf, reslen, &reslen, &offset);
+
+ int64_t resInt64 = appBuf.GetInt64();
+
+ BOOST_REQUIRE(resInt64 == 39);
+
+ int32_t resInt32 = appBuf.GetInt32();
+
+ BOOST_REQUIRE(resInt32 == 39);
+
+ int16_t resInt16 = appBuf.GetInt16();
+
+ BOOST_REQUIRE(resInt16 == 39);
+
+ int8_t resInt8 = appBuf.GetInt8();
+
+ BOOST_REQUIRE(resInt8 == 39);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetIntFromFloat)
+{
+ float buf = -107.49f;
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &buf, reslen, &reslen, &offset);
+
+ int64_t resInt64 = appBuf.GetInt64();
+
+ BOOST_REQUIRE(resInt64 == -107);
+
+ int32_t resInt32 = appBuf.GetInt32();
+
+ BOOST_REQUIRE(resInt32 == -107);
+
+ int16_t resInt16 = appBuf.GetInt16();
+
+ BOOST_REQUIRE(resInt16 == -107);
+
+ int8_t resInt8 = appBuf.GetInt8();
+
+ BOOST_REQUIRE(resInt8 == -107);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetIntFromDouble)
+{
+ double buf = 42.97f;
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_DOUBLE, &buf, reslen, &reslen, &offset);
+
+ int64_t resInt64 = appBuf.GetInt64();
+
+ BOOST_REQUIRE(resInt64 == 42);
+
+ int32_t resInt32 = appBuf.GetInt32();
+
+ BOOST_REQUIRE(resInt32 == 42);
+
+ int16_t resInt16 = appBuf.GetInt16();
+
+ BOOST_REQUIRE(resInt16 == 42);
+
+ int8_t resInt8 = appBuf.GetInt8();
+
+ BOOST_REQUIRE(resInt8 == 42);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetIntFromBigint)
+{
+ uint64_t buf = 19;
+ SqlLen reslen = sizeof(buf);
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT, &buf, reslen, &reslen, &offset);
+
+ int64_t resInt64 = appBuf.GetInt64();
+
+ BOOST_REQUIRE(resInt64 == 19);
+
+ int32_t resInt32 = appBuf.GetInt32();
+
+ BOOST_REQUIRE(resInt32 == 19);
+
+ int16_t resInt16 = appBuf.GetInt16();
+
+ BOOST_REQUIRE(resInt16 == 19);
+
+ int8_t resInt8 = appBuf.GetInt8();
+
+ BOOST_REQUIRE(resInt8 == 19);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetIntWithOffset)
+{
+ struct TestStruct
+ {
+ uint64_t val;
+ SqlLen reslen;
+ };
+
+ TestStruct buf[2] = {
+ { 12, sizeof(uint64_t) },
+ { 42, sizeof(uint64_t) }
+ };
+
+ size_t offset = 0;
+ size_t* offsetPtr = &offset;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT, &buf[0].val, sizeof(buf[0].val), &buf[0].reslen, &offsetPtr);
+
+ int64_t val = appBuf.GetInt64();
+
+ BOOST_REQUIRE(val == 12);
+
+ offset += sizeof(TestStruct);
+
+ val = appBuf.GetInt64();
+
+ BOOST_REQUIRE(val == 42);
+
+ offsetPtr = 0;
+
+ val = appBuf.GetInt64();
+
+ BOOST_REQUIRE(val == 12);
+}
+
+BOOST_AUTO_TEST_CASE(TestSetStringWithOffset)
+{
+ struct TestStruct
+ {
+ char val[64];
+ SqlLen reslen;
+ };
+
+ TestStruct buf[2] = {
+ { "", 0 },
+ { "", 0 }
+ };
+
+ size_t offset = 0;
+ size_t* offsetPtr = &offset;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf[0].val, sizeof(buf[0].val), &buf[0].reslen, &offsetPtr);
+
+ appBuf.PutString("Hello Ignite!");
+
+ std::string res(buf[0].val, buf[0].reslen);
+
+ BOOST_REQUIRE(buf[0].reslen == strlen("Hello Ignite!"));
+ BOOST_REQUIRE(res == "Hello Ignite!");
+ BOOST_REQUIRE(res.size() == strlen("Hello Ignite!"));
+
+ offset += sizeof(TestStruct);
+
+ appBuf.PutString("Hello with offset!");
+
+ res.assign(buf[0].val, buf[0].reslen);
+
+ BOOST_REQUIRE(res == "Hello Ignite!");
+ BOOST_REQUIRE(res.size() == strlen("Hello Ignite!"));
+ BOOST_REQUIRE(buf[0].reslen == strlen("Hello Ignite!"));
+
+ res.assign(buf[1].val, buf[1].reslen);
+
+ BOOST_REQUIRE(res == "Hello with offset!");
+ BOOST_REQUIRE(res.size() == strlen("Hello with offset!"));
+ BOOST_REQUIRE(buf[1].reslen == strlen("Hello with offset!"));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/column_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/column_test.cpp b/modules/platforms/cpp/odbc-test/src/column_test.cpp
new file mode 100644
index 0000000..4864a6a
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/column_test.cpp
@@ -0,0 +1,290 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/impl/binary/binary_common.h>
+#include <ignite/impl/binary/binary_writer_impl.h>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/column.h"
+
+using namespace ignite::impl::binary;
+using namespace ignite::odbc::app;
+using namespace ignite::odbc;
+
+BOOST_AUTO_TEST_SUITE(ColumnTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestColumnDefaultConstruction)
+{
+ Column column;
+
+ BOOST_REQUIRE(!column.IsValid());
+}
+
+BOOST_AUTO_TEST_CASE(TestColumnShort)
+{
+ ignite::impl::interop::InteropUnpooledMemory mem(4096);
+ ignite::impl::interop::InteropOutputStream outStream(&mem);
+ ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
+
+ int16_t data = 42;
+
+ writer.WriteInt8(IGNITE_TYPE_SHORT);
+ writer.WriteInt16(data);
+
+ outStream.Synchronize();
+
+ ignite::impl::interop::InteropInputStream inStream(&mem);
+ ignite::impl::binary::BinaryReaderImpl reader(&inStream);
+
+ Column column(reader);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == 2);
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 2);
+
+ short shortBuf = 0;
+ SqlLen reslen = 0;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &shortBuf, sizeof(shortBuf), &reslen, &offset);
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == 2);
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
+
+ BOOST_REQUIRE(shortBuf == data);
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == 2);
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestColumnString)
+{
+ ignite::impl::interop::InteropUnpooledMemory mem(4096);
+ ignite::impl::interop::InteropOutputStream outStream(&mem);
+ ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
+
+ std::string data("Some test data.");
+
+ writer.WriteString(data.data(), static_cast<int32_t>(data.size()));
+
+ outStream.Synchronize();
+
+ ignite::impl::interop::InteropInputStream inStream(&mem);
+ ignite::impl::binary::BinaryReaderImpl reader(&inStream);
+
+ Column column(reader);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == data.size());
+
+ char strBuf[1024] = {};
+ SqlLen reslen = 0;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset);
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
+
+ BOOST_REQUIRE(std::string(strBuf) == data);
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestColumnStringSeveral)
+{
+ ignite::impl::interop::InteropUnpooledMemory mem(4096);
+ ignite::impl::interop::InteropOutputStream outStream(&mem);
+ ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
+
+ std::string data("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+
+ writer.WriteString(data.data(), static_cast<int32_t>(data.size()));
+
+ outStream.Synchronize();
+
+ ignite::impl::interop::InteropInputStream inStream(&mem);
+ ignite::impl::binary::BinaryReaderImpl reader(&inStream);
+
+ Column column(reader);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == data.size());
+
+ std::string res;
+
+ std::string strBuf(data.size() / 3 + 2, 0);
+ SqlLen reslen = 0;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf[0], strBuf.size(), &reslen, &offset);
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - (strBuf.size() - 1));
+
+ res.append(strBuf.c_str());
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - 2 * (strBuf.size() - 1));
+
+ res.append(strBuf.c_str());
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
+
+ res.append(strBuf.c_str());
+
+ BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
+
+ BOOST_REQUIRE(column.IsValid());
+
+ BOOST_REQUIRE(column.GetSize() == data.size());
+
+ BOOST_REQUIRE(column.GetUnreadDataLength() == 0);
+
+ BOOST_REQUIRE(res == data);
+}
+
+BOOST_AUTO_TEST_CASE(TestColumnMultiString)
+{
+ ignite::impl::interop::InteropUnpooledMemory mem(4096);
+ ignite::impl::interop::InteropOutputStream outStream(&mem);
+ ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0);
+
+ std::string data1("Some test data.");
+ std::string data2("Other TEST DATA.");
+
+ writer.WriteString(data1.data(), static_cast<int32_t>(data1.size()));
+ writer.WriteString(data2.data(), static_cast<int32_t>(data2.size()));
+
+ outStream.Synchronize();
+
+ ignite::impl::interop::InteropInputStream inStream(&mem);
+ ignite::impl::binary::BinaryReaderImpl reader(&inStream);
+
+ Column column1(reader);
+
+ inStream.Position(column1.GetEndPosition());
+
+ Column column2(reader);
+
+ BOOST_REQUIRE(column1.IsValid());
+
+ BOOST_REQUIRE(column1.GetSize() == data1.size());
+
+ BOOST_REQUIRE(column1.GetUnreadDataLength() == data1.size());
+
+ BOOST_REQUIRE(column2.IsValid());
+
+ BOOST_REQUIRE(column2.GetSize() == data2.size());
+
+ BOOST_REQUIRE(column2.GetUnreadDataLength() == data2.size());
+
+ char strBuf[1024] = {};
+ SqlLen reslen = 0;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset);
+
+ BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column1.IsValid());
+
+ BOOST_REQUIRE(column1.GetSize() == data1.size());
+
+ BOOST_REQUIRE(column1.GetUnreadDataLength() == 0);
+
+ BOOST_REQUIRE(std::string(strBuf) == data1);
+
+ BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
+
+ BOOST_REQUIRE(column1.IsValid());
+
+ BOOST_REQUIRE(column1.GetSize() == data1.size());
+
+ BOOST_REQUIRE(column1.GetUnreadDataLength() == 0);
+
+ BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(column2.IsValid());
+
+ BOOST_REQUIRE(column2.GetSize() == data2.size());
+
+ BOOST_REQUIRE(column2.GetUnreadDataLength() == 0);
+
+ BOOST_REQUIRE(std::string(strBuf) == data2);
+
+ BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA);
+
+ BOOST_REQUIRE(column2.IsValid());
+
+ BOOST_REQUIRE(column2.GetSize() == data2.size());
+
+ BOOST_REQUIRE(column2.GetUnreadDataLength() == 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
new file mode 100644
index 0000000..fba46cc
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
@@ -0,0 +1,206 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <iostream>
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/odbc/config/configuration.h>
+
+using namespace ignite::odbc::config;
+
+namespace
+{
+ const char* testDriverName = "Ignite";
+ const char* testServerHost = "testhost.com";
+ const uint16_t testServerPort = 4242;
+ const char* testCacheName = "TestCache";
+ const char* testDsn = "Ignite DSN";
+}
+
+BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
+
+void CheckConnectionConfig(const Configuration& cfg)
+{
+ BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
+ BOOST_REQUIRE(cfg.GetHost() == testServerHost);
+ BOOST_REQUIRE(cfg.GetPort() == testServerPort);
+ BOOST_REQUIRE(cfg.GetCache() == testCacheName);
+ BOOST_REQUIRE(cfg.GetDsn().empty());
+
+ std::stringstream constructor;
+
+ constructor << "driver={" << testDriverName << "};"
+ << "server=" << testServerHost << ";"
+ << "port=" << testServerPort << ";"
+ << "cache=" << testCacheName << ";";
+
+ const std::string& expectedStr = constructor.str();
+
+ BOOST_REQUIRE(cfg.ToConnectString() == expectedStr);
+}
+
+void CheckDsnConfig(const Configuration& cfg)
+{
+ BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
+ BOOST_REQUIRE(cfg.GetDsn() == testDsn);
+ BOOST_REQUIRE(cfg.GetHost().empty());
+ BOOST_REQUIRE(cfg.GetCache().empty());
+ BOOST_REQUIRE(cfg.GetPort() == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "DRIVER={" << testDriverName << "};"
+ << "SERVER=" << testServerHost <<";"
+ << "PORT=" << testServerPort << ";"
+ << "CACHE=" << testCacheName;
+
+ const std::string& connectStr = constructor.str();
+
+ cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+
+ CheckConnectionConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringLowercase)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "driver={" << testDriverName << "};"
+ << "server=" << testServerHost << ";"
+ << "port=" << testServerPort << ";"
+ << "cache=" << testCacheName;
+
+ const std::string& connectStr = constructor.str();
+
+ cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+
+ CheckConnectionConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringMixed)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "Driver={" << testDriverName << "};"
+ << "Server=" << testServerHost << ";"
+ << "Port=" << testServerPort << ";"
+ << "Cache=" << testCacheName;
+
+ const std::string& connectStr = constructor.str();
+
+ cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+
+ CheckConnectionConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "DRIVER = {" << testDriverName << "} ;\n"
+ << " SERVER =" << testServerHost << " ; \n"
+ << "PORT= " << testServerPort << "; "
+ << "CACHE = \n\r" << testCacheName;
+
+ const std::string& connectStr = constructor.str();
+
+ cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+
+ CheckConnectionConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestDsnStringUppercase)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "DRIVER=" << testDriverName << '\0'
+ << "DSN={" << testDsn << "}" << '\0' << '\0';
+
+ const std::string& configStr = constructor.str();
+
+ cfg.FillFromConfigAttributes(configStr.data());
+
+ CheckDsnConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "driver=" << testDriverName << '\0'
+ << "dsn={" << testDsn << "}" << '\0' << '\0';
+
+ const std::string& configStr = constructor.str();
+
+ cfg.FillFromConfigAttributes(configStr.data());
+
+ CheckDsnConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestDsnStrinMixed)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "Driver=" << testDriverName << '\0'
+ << "Dsn={" << testDsn << "}" << '\0' << '\0';
+
+ const std::string& configStr = constructor.str();
+
+ cfg.FillFromConfigAttributes(configStr.data());
+
+ CheckDsnConfig(cfg);
+}
+
+BOOST_AUTO_TEST_CASE(TestDsnStrinWhitespaces)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << " DRIVER = " << testDriverName << "\r\n" << '\0'
+ << "DSN= {" << testDsn << "} \n" << '\0' << '\0';
+
+ const std::string& configStr = constructor.str();
+
+ cfg.FillFromConfigAttributes(configStr.data());
+
+ CheckDsnConfig(cfg);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp b/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp
new file mode 100644
index 0000000..dd8d1f6
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/connection_info_test.cpp
@@ -0,0 +1,219 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <iostream>
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/config/connection_info.h"
+
+using namespace ignite::odbc;
+using namespace ignite::odbc::config;
+
+BOOST_AUTO_TEST_SUITE(ConnectionInfoTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestConnectionInfoSupportedInfo)
+{
+ char buffer[4096];
+ short reslen = 0;
+
+ ConnectionInfo info;
+
+ SqlResult result;
+
+#ifdef SQL_DRIVER_NAME
+ result = info.GetInfo(SQL_DRIVER_NAME, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_DRIVER_NAME
+
+#ifdef SQL_DBMS_NAME
+ result = info.GetInfo(SQL_DBMS_NAME, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_DBMS_NAME
+
+#ifdef SQL_DRIVER_ODBC_VER
+ result = info.GetInfo(SQL_DRIVER_ODBC_VER, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_DRIVER_ODBC_VER
+
+#ifdef SQL_DBMS_VER
+ result = info.GetInfo(SQL_DBMS_VER, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_DBMS_VER
+
+#ifdef SQL_DRIVER_VER
+ result = info.GetInfo(SQL_DRIVER_VER, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_DRIVER_VER
+
+#ifdef SQL_COLUMN_ALIAS
+ result = info.GetInfo(SQL_COLUMN_ALIAS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_COLUMN_ALIAS
+
+#ifdef SQL_IDENTIFIER_QUOTE_CHAR
+ result = info.GetInfo(SQL_IDENTIFIER_QUOTE_CHAR, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_IDENTIFIER_QUOTE_CHAR
+
+#ifdef SQL_CATALOG_NAME_SEPARATOR
+ result = info.GetInfo(SQL_CATALOG_NAME_SEPARATOR, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_CATALOG_NAME_SEPARATOR
+
+#ifdef SQL_SPECIAL_CHARACTERS
+ result = info.GetInfo(SQL_SPECIAL_CHARACTERS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_SPECIAL_CHARACTERS
+
+#ifdef SQL_CATALOG_TERM
+ result = info.GetInfo(SQL_CATALOG_TERM, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_CATALOG_TERM
+
+#ifdef SQL_TABLE_TERM
+ result = info.GetInfo(SQL_TABLE_TERM, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_TABLE_TERM
+
+#ifdef SQL_SCHEMA_TERM
+ result = info.GetInfo(SQL_SCHEMA_TERM, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_SCHEMA_TERM
+
+#ifdef SQL_ASYNC_DBC_FUNCTIONS
+ result = info.GetInfo(SQL_ASYNC_DBC_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_ASYNC_DBC_FUNCTIONS
+
+#ifdef SQL_GETDATA_EXTENSIONS
+ result = info.GetInfo(SQL_GETDATA_EXTENSIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_GETDATA_EXTENSIONS
+
+#ifdef SQL_ODBC_INTERFACE_CONFORMANCE
+ result = info.GetInfo(SQL_ODBC_INTERFACE_CONFORMANCE, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_ODBC_INTERFACE_CONFORMANCE
+
+#ifdef SQL_SQL_CONFORMANCE
+ result = info.GetInfo(SQL_SQL_CONFORMANCE, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_SQL_CONFORMANCE
+
+#ifdef SQL_CATALOG_USAGE
+ result = info.GetInfo(SQL_CATALOG_USAGE, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_CATALOG_USAGE
+
+#ifdef SQL_SCHEMA_USAGE
+ result = info.GetInfo(SQL_SCHEMA_USAGE, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_SCHEMA_USAGE
+
+#ifdef SQL_MAX_IDENTIFIER_LEN
+ result = info.GetInfo(SQL_MAX_IDENTIFIER_LEN, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_MAX_IDENTIFIER_LEN
+
+#ifdef SQL_AGGREGATE_FUNCTIONS
+ result = info.GetInfo(SQL_AGGREGATE_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_AGGREGATE_FUNCTIONS
+
+#ifdef SQL_AGGREGATE_FUNCTIONS
+ result = info.GetInfo(SQL_NUMERIC_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_AGGREGATE_FUNCTIONS
+
+#ifdef SQL_STRING_FUNCTIONS
+ result = info.GetInfo(SQL_STRING_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_STRING_FUNCTIONS
+
+#ifdef SQL_TIMEDATE_FUNCTIONS
+ result = info.GetInfo(SQL_TIMEDATE_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_TIMEDATE_FUNCTIONS
+
+#ifdef SQL_TIMEDATE_ADD_INTERVALS
+ result = info.GetInfo(SQL_TIMEDATE_ADD_INTERVALS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_TIMEDATE_ADD_INTERVALS
+
+#ifdef SQL_TIMEDATE_DIFF_INTERVALS
+ result = info.GetInfo(SQL_TIMEDATE_DIFF_INTERVALS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_TIMEDATE_DIFF_INTERVALS
+
+#ifdef SQL_DATETIME_LITERALS
+ result = info.GetInfo(SQL_DATETIME_LITERALS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_DATETIME_LITERALS
+
+#ifdef SQL_SYSTEM_FUNCTIONS
+ result = info.GetInfo(SQL_SYSTEM_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_SYSTEM_FUNCTIONS
+
+#ifdef SQL_CONVERT_FUNCTIONS
+ result = info.GetInfo(SQL_CONVERT_FUNCTIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_CONVERT_FUNCTIONS
+
+#ifdef SQL_OJ_CAPABILITIES
+ result = info.GetInfo(SQL_OJ_CAPABILITIES, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_OJ_CAPABILITIES
+
+#ifdef SQL_POS_OPERATIONS
+ result = info.GetInfo(SQL_POS_OPERATIONS, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_POS_OPERATIONS
+
+#ifdef SQL_MAX_CONCURRENT_ACTIVITIES
+ result = info.GetInfo(SQL_MAX_CONCURRENT_ACTIVITIES, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_MAX_CONCURRENT_ACTIVITIES
+
+#ifdef SQL_CURSOR_COMMIT_BEHAVIOR
+ result = info.GetInfo(SQL_CURSOR_COMMIT_BEHAVIOR, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_CURSOR_COMMIT_BEHAVIOR
+
+#ifdef SQL_CURSOR_ROLLBACK_BEHAVIOR
+ result = info.GetInfo(SQL_CURSOR_ROLLBACK_BEHAVIOR, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_CURSOR_ROLLBACK_BEHAVIOR
+
+#ifdef SQL_TXN_CAPABLE
+ result = info.GetInfo(SQL_TXN_CAPABLE, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_TXN_CAPABLE
+
+#ifdef SQL_QUOTED_IDENTIFIER_CASE
+ result = info.GetInfo(SQL_QUOTED_IDENTIFIER_CASE, buffer, sizeof(buffer), &reslen);
+ BOOST_REQUIRE(result == SQL_RESULT_SUCCESS);
+#endif //SQL_QUOTED_IDENTIFIER_CASE
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/cursor_test.cpp b/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
new file mode 100644
index 0000000..af841e7
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
@@ -0,0 +1,166 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/impl/binary/binary_writer_impl.h>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/cursor.h"
+
+using namespace ignite::odbc;
+
+const int64_t testQueryId = 42;
+
+std::auto_ptr<ResultPage> CreateTestPage(bool last, int32_t size)
+{
+ using namespace ignite::impl::binary;
+ using namespace ignite::impl::interop;
+
+ ignite::impl::interop::InteropUnpooledMemory mem(1024);
+ InteropOutputStream outStream(&mem);
+ BinaryWriterImpl writer(&outStream, 0);
+
+ // Last page flag.
+ writer.WriteBool(last);
+
+ //Page size.
+ writer.WriteInt32(size);
+
+ for (int32_t i = 0; i < size; ++i)
+ {
+ // Writing row size = 1 column.
+ writer.WriteInt32(1);
+
+ // Writing column type.
+ writer.WriteInt8(IGNITE_TYPE_INT);
+
+ // Column value.
+ writer.WriteInt32(i);
+ }
+
+ outStream.Synchronize();
+
+ std::auto_ptr<ResultPage> res(new ResultPage());
+
+ InteropInputStream inStream(&mem);
+ BinaryReaderImpl reader(&inStream);
+
+ res->Read(reader);
+
+ BOOST_REQUIRE(res->GetSize() == size);
+ BOOST_REQUIRE(res->IsLast() == last);
+
+ return res;
+}
+
+void CheckCursorNeedUpdate(Cursor& cursor)
+{
+ BOOST_REQUIRE(cursor.NeedDataUpdate());
+
+ BOOST_REQUIRE(cursor.HasNext());
+
+ BOOST_REQUIRE(!cursor.Increment());
+}
+
+void CheckCursorReady(Cursor& cursor)
+{
+ BOOST_REQUIRE(!cursor.NeedDataUpdate());
+
+ BOOST_REQUIRE(cursor.HasNext());
+
+ BOOST_REQUIRE(cursor.GetRow());
+}
+
+void CheckCursorEnd(Cursor& cursor)
+{
+ BOOST_REQUIRE(!cursor.NeedDataUpdate());
+
+ BOOST_REQUIRE(!cursor.HasNext());
+
+ BOOST_REQUIRE(!cursor.Increment());
+
+ BOOST_REQUIRE(cursor.GetRow());
+}
+
+BOOST_AUTO_TEST_SUITE(CursorTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestCursorEmpty)
+{
+ Cursor cursor(testQueryId);
+
+ BOOST_REQUIRE(cursor.GetQueryId() == testQueryId);
+
+ CheckCursorNeedUpdate(cursor);
+}
+
+BOOST_AUTO_TEST_CASE(TestCursorLast)
+{
+ const int32_t pageSize = 16;
+
+ Cursor cursor(testQueryId);
+
+ std::auto_ptr<ResultPage> resultPage = CreateTestPage(true, pageSize);
+
+ cursor.UpdateData(resultPage);
+
+ BOOST_REQUIRE(cursor.GetQueryId() == testQueryId);
+
+ CheckCursorReady(cursor);
+
+ for (int32_t i = 0; i < pageSize - 1; ++i)
+ BOOST_REQUIRE(cursor.Increment());
+
+ CheckCursorEnd(cursor);
+}
+
+BOOST_AUTO_TEST_CASE(TestCursorUpdate)
+{
+ const int32_t pageSize = 16;
+
+ Cursor cursor(testQueryId);
+
+ std::auto_ptr<ResultPage> resultPage = CreateTestPage(false, pageSize);
+
+ cursor.UpdateData(resultPage);
+
+ BOOST_REQUIRE(cursor.GetQueryId() == testQueryId);
+
+ CheckCursorReady(cursor);
+
+ for (int32_t i = 0; i < pageSize - 1; ++i)
+ BOOST_REQUIRE(cursor.Increment());
+
+ CheckCursorNeedUpdate(cursor);
+
+ resultPage = CreateTestPage(true, pageSize);
+
+ cursor.UpdateData(resultPage);
+
+ CheckCursorReady(cursor);
+
+ for (int32_t i = 0; i < pageSize - 1; ++i)
+ BOOST_REQUIRE(cursor.Increment());
+
+ CheckCursorEnd(cursor);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/parser_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/parser_test.cpp b/modules/platforms/cpp/odbc-test/src/parser_test.cpp
new file mode 100644
index 0000000..ad8a5b4
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/parser_test.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/odbc/parser.h>
+
+using namespace ignite::odbc;
+
+struct TestMessage
+{
+ TestMessage()
+ {
+ // No-op.
+ }
+
+ TestMessage(int32_t a, const std::string& b) : a(a), b(b)
+ {
+ // No-op.
+ }
+
+ ~TestMessage()
+ {
+ // No-op.
+ }
+
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt32(a);
+ writer.WriteString(b.data(), static_cast<int32_t>(b.size()));
+ }
+
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ a = reader.ReadInt32();
+
+ b.resize(reader.ReadString(0, 0));
+ reader.ReadString(&b[0], static_cast<int32_t>(b.size()));
+ }
+
+ int32_t a;
+ std::string b;
+};
+
+bool operator==(const TestMessage& lhs, const TestMessage& rhs)
+{
+ return lhs.a == rhs.a &&
+ lhs.b == rhs.b;
+}
+
+BOOST_AUTO_TEST_SUITE(ParserTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestParserEncodeDecode)
+{
+ Parser parser;
+
+ std::vector<int8_t> outBuffer;
+ std::vector<int8_t> inBuffer;
+
+ TestMessage outMsg(42, "Test message");
+ TestMessage inMsg;
+
+ parser.Encode(outMsg, outBuffer);
+
+ inBuffer.reserve(outBuffer.size());
+
+ // First 4 bytes contain message size after encoding but are not expected
+ // during decoding.
+ std::copy(outBuffer.begin() + 4, outBuffer.end(), std::back_inserter(inBuffer));
+
+ parser.Decode(inMsg, inBuffer);
+
+ BOOST_REQUIRE(outMsg == inMsg);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc-test/src/row_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/row_test.cpp b/modules/platforms/cpp/odbc-test/src/row_test.cpp
new file mode 100644
index 0000000..e655cf7
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/row_test.cpp
@@ -0,0 +1,167 @@
+/*
+ * 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 _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/impl/binary/binary_writer_impl.h>
+
+#include "ignite/odbc/system/odbc_constants.h"
+#include "ignite/odbc/row.h"
+
+using namespace ignite::odbc::app;
+using namespace ignite::odbc;
+
+
+std::string GetStrColumnValue(size_t rowIdx)
+{
+ std::stringstream generator("Column 2 test string, row num: ");
+ generator << rowIdx << ". Some trailing bytes";
+
+ return generator.str();
+}
+
+void FillMemWithData(ignite::impl::interop::InteropUnpooledMemory& mem, size_t rowNum)
+{
+ using namespace ignite::impl::binary;
+ using namespace ignite::impl::interop;
+
+ InteropOutputStream stream(&mem);
+ BinaryWriterImpl writer(&stream, 0);
+
+ for (size_t i = 0; i < rowNum; ++i)
+ {
+ // Number of columns in page.
+ writer.WriteInt32(4);
+
+ // First column is int.
+ writer.WriteInt8(IGNITE_TYPE_LONG);
+ writer.WriteInt64(static_cast<int64_t>(i * 10));
+
+ // Second column is string.
+ const std::string& str(GetStrColumnValue(i));
+
+ writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
+
+ // Third column is GUID.
+ ignite::Guid guid(0x2b218f63642a4a64ULL, 0x9674098f388ac298ULL + i);
+
+ writer.WriteGuid(guid);
+
+ // The last column is bool.
+ writer.WriteInt8(IGNITE_TYPE_BOOL);
+ writer.WriteBool(i % 2 == 1);
+ }
+
+ stream.Synchronize();
+}
+
+void CheckRowData(Row& row, size_t rowIdx)
+{
+ SqlLen reslen;
+
+ long longBuf;
+ char strBuf[1024];
+ SQLGUID guidBuf;
+ char bitBuf;
+ size_t* offset = 0;
+
+ ApplicationDataBuffer appLongBuf(type_traits::IGNITE_ODBC_C_TYPE_SIGNED_LONG, &longBuf, sizeof(longBuf), &reslen, &offset);
+ ApplicationDataBuffer appStrBuf(type_traits::IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, &offset);
+ ApplicationDataBuffer appGuidBuf(type_traits::IGNITE_ODBC_C_TYPE_GUID, &guidBuf, sizeof(guidBuf), &reslen, &offset);
+ ApplicationDataBuffer appBitBuf(type_traits::IGNITE_ODBC_C_TYPE_BIT, &bitBuf, sizeof(bitBuf), &reslen, &offset);
+
+ // Checking size.
+ BOOST_REQUIRE(row.GetSize() == 4);
+
+ // Checking 1st column.
+ BOOST_REQUIRE(row.ReadColumnToBuffer(1, appLongBuf) == SQL_RESULT_SUCCESS);
+ BOOST_REQUIRE(longBuf == rowIdx * 10);
+
+ // Checking 2nd column.
+ BOOST_REQUIRE(row.ReadColumnToBuffer(2, appStrBuf) == SQL_RESULT_SUCCESS);
+
+ std::string strReal(strBuf, static_cast<size_t>(reslen));
+ std::string strExpected(GetStrColumnValue(rowIdx));
+
+ BOOST_REQUIRE(strReal == strExpected);
+
+ // Checking 3rd column.
+ BOOST_REQUIRE(row.ReadColumnToBuffer(3, appGuidBuf) == SQL_RESULT_SUCCESS);
+
+ BOOST_REQUIRE(guidBuf.Data1 == 0x2b218f63UL);
+ BOOST_REQUIRE(guidBuf.Data2 == 0x642aU);
+ BOOST_REQUIRE(guidBuf.Data3 == 0x4a64U);
+
+ BOOST_REQUIRE(guidBuf.Data4[0] == 0x96);
+ BOOST_REQUIRE(guidBuf.Data4[1] == 0x74);
+ BOOST_REQUIRE(guidBuf.Data4[2] == 0x09);
+ BOOST_REQUIRE(guidBuf.Data4[3] == 0x8f);
+ BOOST_REQUIRE(guidBuf.Data4[4] == 0x38);
+ BOOST_REQUIRE(guidBuf.Data4[5] == 0x8a);
+ BOOST_REQUIRE(guidBuf.Data4[6] == 0xc2);
+ BOOST_REQUIRE(guidBuf.Data4[7] == 0x98 + rowIdx);
+
+ // Checking 4th column.
+ BOOST_REQUIRE(row.ReadColumnToBuffer(4, appBitBuf) == SQL_RESULT_SUCCESS);
+ BOOST_REQUIRE(bitBuf == rowIdx % 2);
+}
+
+
+BOOST_AUTO_TEST_SUITE(RowTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestRowMoveToNext)
+{
+ ignite::impl::interop::InteropUnpooledMemory mem(4096);
+
+ const size_t rowNum = 32;
+
+ FillMemWithData(mem, rowNum);
+
+ Row row(mem);
+
+ for (size_t i = 0; i < rowNum - 1; ++i)
+ {
+ BOOST_REQUIRE(row.GetSize() == 4);
+ BOOST_REQUIRE(row.MoveToNext());
+ }
+}
+
+BOOST_AUTO_TEST_CASE(TestRowRead)
+{
+ ignite::impl::interop::InteropUnpooledMemory mem(4096);
+
+ const size_t rowNum = 8;
+
+ FillMemWithData(mem, rowNum);
+
+ Row row(mem);
+
+ BOOST_REQUIRE(row.GetSize() == 4);
+
+ for (size_t i = 0; i < rowNum - 1; ++i)
+ {
+ CheckRowData(row, i);
+
+ BOOST_REQUIRE(row.MoveToNext());
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
[04/28] ignite git commit: IGNITE-2447: Moved all ODBC classes into
org.apache.ignite.internal.processors.odbc package.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java
deleted file mode 100644
index a5da36a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryExecuteRequest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query execute request.
- */
-public class OdbcQueryExecuteRequest extends OdbcRequest {
- /** Cache name. */
- private String cacheName;
-
- /** Sql query. */
- private String sqlQry;
-
- /** Sql query arguments. */
- private Object[] args;
-
- /**
- * @param cacheName Cache name.
- * @param sqlQry SQL query.
- * @param args Arguments list.
- */
- public OdbcQueryExecuteRequest(String cacheName, String sqlQry, Object[] args) {
- super(EXECUTE_SQL_QUERY);
- this.cacheName = cacheName;
- this.sqlQry = sqlQry;
- this.args = args;
- }
-
- /**
- * @param sqlQry Sql query.
- */
- public void sqlQuery(String sqlQry) {
- this.sqlQry = sqlQry;
- }
-
- /**
- * @return Sql query.
- */
- public String sqlQuery() {
- return sqlQry;
- }
-
- /**
- * @param args Sql query arguments.
- */
- public void arguments(Object[] args) {
- this.args = args;
- }
-
- /**
- * @return Sql query arguments.
- */
- public Object[] arguments() {
- return args;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java
deleted file mode 100644
index d30ecf7..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryFetchRequest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query fetch request.
- */
-public class OdbcQueryFetchRequest extends OdbcRequest {
- /** Query ID. */
- private long queryId;
-
- /** Page size - maximum number of rows to return. */
- private Integer pageSize;
-
- /**
- * @param queryId Query ID.
- * @param pageSize Page size.
- */
- public OdbcQueryFetchRequest(long queryId, int pageSize) {
- super(FETCH_SQL_QUERY);
- this.queryId = queryId;
- this.pageSize = pageSize;
- }
-
- /**
- * @param pageSize Page size.
- */
- public void pageSize(Integer pageSize) {
- this.pageSize = pageSize;
- }
-
- /**
- * @return Page size.
- */
- public int pageSize() {
- return pageSize;
- }
-
- /**
- * @param queryId Query ID.
- */
- public void cacheName(long queryId) {
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long queryId() {
- return queryId;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java
deleted file mode 100644
index 3ab2a16..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetColumnsMetaRequest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query get columns meta request.
- */
-public class OdbcQueryGetColumnsMetaRequest extends OdbcRequest {
- /** Cache name. */
- private String cacheName;
-
- /** Table name. */
- private String tableName;
-
- /** Column name. */
- private String columnName;
-
- /**
- * @param cacheName Cache name.
- */
- public OdbcQueryGetColumnsMetaRequest(String cacheName, String tableName, String columnName) {
- super(GET_COLUMNS_META);
-
- this.cacheName = cacheName;
- this.tableName = tableName;
- this.columnName = columnName;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-
- /**
- * @param tableName Table name.
- */
- public void tableName(String tableName) {
- this.tableName = tableName;
- }
-
- /**
- * @return Table name.
- */
- public String tableName() {
- return tableName;
- }
-
- /**
- * @param columnName Column name.
- */
- public void columnName(String columnName) {
- this.columnName = columnName;
- }
-
- /**
- * @return Column name.
- */
- public String columnName() {
- return columnName;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java
deleted file mode 100644
index 811091c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcQueryGetTablesMetaRequest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC query get tables meta request.
- */
-public class OdbcQueryGetTablesMetaRequest extends OdbcRequest {
- /** Catalog search pattern. */
- private String catalog;
-
- /** Schema search pattern. */
- private String schema;
-
- /** Table search pattern. */
- private String table;
-
- /** Table type search pattern. */
- private String tableType;
-
- /**
- * @param catalog Catalog search pattern.
- * @param schema Schema search pattern.
- * @param table Table search pattern.
- * @param tableType Table type search pattern.
- */
- public OdbcQueryGetTablesMetaRequest(String catalog, String schema, String table, String tableType) {
- super(GET_TABLES_META);
-
- this.catalog = catalog;
- this.schema = schema;
- this.table = table;
- this.tableType = tableType;
- }
-
- /**
- * @param catalog Catalog search pattern.
- */
- public void catalog(String catalog) {
- this.catalog = catalog;
- }
-
- /**
- * @return catalog search pattern.
- */
- public String catalog() {
- return catalog;
- }
-
- /**
- * @param schema Schema search pattern.
- */
- public void schema(String schema) {
- this.schema = schema;
- }
-
- /**
- * @return Schema search pattern.
- */
- public String schema() {
- return schema;
- }
-
- /**
- * @param table Schema search pattern.
- */
- public void table(String table) {
- this.table = table;
- }
-
- /**
- * @return Table search pattern.
- */
- public String table() {
- return table;
- }
-
- /**
- * @param tableType Table type search pattern.
- */
- public void tableType(String tableType) {
- this.tableType = tableType;
- }
-
- /**
- * @return Table type search pattern.
- */
- public String tableType() {
- return tableType;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java
deleted file mode 100644
index 63bd747..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/request/OdbcRequest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.request;
-
-/**
- * ODBC command request.
- */
-public class OdbcRequest {
- /** Execute sql query. */
- public static final int EXECUTE_SQL_QUERY = 1;
-
- /** Fetch query results. */
- public static final int FETCH_SQL_QUERY = 2;
-
- /** Close query. */
- public static final int CLOSE_SQL_QUERY = 3;
-
- /** Get columns meta query. */
- public static final int GET_COLUMNS_META = 4;
-
- /** Get columns meta query. */
- public static final int GET_TABLES_META = 5;
-
- /** Command. */
- private int cmd;
-
- /**
- * @param cmd Command type.
- */
- public OdbcRequest(int cmd) {
- this.cmd = cmd;
- }
-
- /**
- * @return Command.
- */
- public int command() {
- return cmd;
- }
-
- /**
- * @param cmd Command.
- */
- public void command(int cmd) {
- this.cmd = cmd;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java
deleted file mode 100644
index c8cdd2c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryCloseResult.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-/**
- * Query result.
- */
-public class OdbcQueryCloseResult {
- /** Query ID. */
- private long queryId;
-
- /**
- * @param queryId Query ID.
- */
- public OdbcQueryCloseResult(long queryId){
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java
deleted file mode 100644
index 119470e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryExecuteResult.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
-
-import java.util.Collection;
-
-/**
- * Query execute result.
- */
-public class OdbcQueryExecuteResult {
- /** Query ID. */
- private long queryId;
-
- /** Fields metadata. */
- private Collection<OdbcColumnMeta> columnsMeta;
-
- /**
- * @param queryId Query ID.
- * @param columnsMeta Columns metadata.
- */
- public OdbcQueryExecuteResult(long queryId, Collection<OdbcColumnMeta> columnsMeta){
- this.queryId = queryId;
- this.columnsMeta = columnsMeta;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-
- /**
- * @return Columns metadata.
- */
- public Collection<OdbcColumnMeta> getColumnsMetadata() {
- return columnsMeta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java
deleted file mode 100644
index 8385301..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryFetchResult.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import java.util.Collection;
-
-/**
- * Query fetch result.
- */
-public class OdbcQueryFetchResult {
- /** Query ID. */
- private long queryId;
-
- /** Query result rows. */
- private Collection<?> items = null;
-
- /** Flag indicating the query has no unfetched results. */
- private boolean last = false;
-
- /**
- * @param queryId Query ID.
- */
- public OdbcQueryFetchResult(long queryId){
- this.queryId = queryId;
- }
-
- /**
- * @return Query ID.
- */
- public long getQueryId() {
- return queryId;
- }
-
- /**
- * @param items Query result rows.
- */
- public void setItems(Collection<?> items) {
- this.items = items;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<?> getItems() {
- return items;
- }
-
- /**
- * @param last Flag indicating the query has no unfetched results.
- */
- public void setLast(boolean last) {
- this.last = last;
- }
-
- /**
- * @return Flag indicating the query has no unfetched results.
- */
- public boolean getLast() {
- return last;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java
deleted file mode 100644
index 46373ba..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetColumnsMetaResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.processors.odbc.OdbcColumnMeta;
-
-import java.util.Collection;
-
-/**
- * Query get columns meta result.
- */
-public class OdbcQueryGetColumnsMetaResult {
- /** Query result rows. */
- private Collection<OdbcColumnMeta> meta;
-
- /**
- * @param meta Column metadata.
- */
- public OdbcQueryGetColumnsMetaResult(Collection<OdbcColumnMeta> meta) {
- this.meta = meta;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<OdbcColumnMeta> getMeta() {
- return meta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java
deleted file mode 100644
index 3d3cb86..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcQueryGetTablesMetaResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.processors.odbc.OdbcTableMeta;
-
-import java.util.Collection;
-
-/**
- * Query get columns meta result.
- */
-public class OdbcQueryGetTablesMetaResult {
- /** Query result rows. */
- private Collection<OdbcTableMeta> meta;
-
- /**
- * @param meta Column metadata.
- */
- public OdbcQueryGetTablesMetaResult(Collection<OdbcTableMeta> meta) {
- this.meta = meta;
- }
-
- /**
- * @return Query result rows.
- */
- public Collection<OdbcTableMeta> getMeta() {
- return meta;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a756311/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java
deleted file mode 100644
index 038275d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/response/OdbcResponse.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.
- */
-package org.apache.ignite.internal.processors.odbc.response;
-
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * ODBC protocol response.
- */
-public class OdbcResponse {
-
- /** Command succeeded. */
- public static final int STATUS_SUCCESS = 0;
-
- /** Command failed. */
- public static final int STATUS_FAILED = 1;
-
- /** Success status. */
- @SuppressWarnings("RedundantFieldInitialization")
- private int successStatus = STATUS_SUCCESS;
-
- /** Error. */
- private String err;
-
- /** Response object. */
- @GridToStringInclude
- private Object obj;
-
- /**
- * Constructs successful rest response.
- *
- * @param obj Response object.
- */
- public OdbcResponse(Object obj) {
- successStatus = STATUS_SUCCESS;
- this.obj = obj;
- }
-
- /**
- * Constructs failed rest response.
- *
- * @param status Response status.
- * @param err Error, {@code null} if success is {@code true}.
- */
- public OdbcResponse(int status, @Nullable String err) {
- assert status != STATUS_SUCCESS;
-
- successStatus = status;
- this.err = err;
- }
-
- /**
- * @return Success flag.
- */
- public int getSuccessStatus() {
- return successStatus;
- }
-
- /**
- * @return Response object.
- */
- public Object getResponse() {
- return obj;
- }
-
- /**
- * @param obj Response object.
- */
- public void setResponse(@Nullable Object obj) {
- this.obj = obj;
- }
-
- /**
- * @return Error.
- */
- public String getError() {
- return err;
- }
-
- /**
- * @param err Error.
- */
- public void setError(String err) {
- this.err = err;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(OdbcResponse.class, this);
- }
-}
[07/28] ignite git commit: IGNITE-1786: System output replaced with
logging.
Posted by vo...@apache.org.
IGNITE-1786: System output replaced with logging.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e200771d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e200771d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e200771d
Branch: refs/heads/ignite-1786
Commit: e200771d597eecf537356db47915cee13b2970aa
Parents: 73127ef
Author: isapego <is...@gridgain.com>
Authored: Mon Jan 25 20:58:53 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Mon Jan 25 20:58:53 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/OdbcCommandHandler.java | 17 +++---
.../internal/processors/odbc/OdbcParser.java | 56 +++++++++++---------
.../processors/odbc/OdbcTcpNioListener.java | 8 +--
.../internal/processors/odbc/OdbcTcpServer.java | 2 +-
4 files changed, 46 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e200771d/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
index 73858d7..5fc2727 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcCommandHandler.java
@@ -36,10 +36,10 @@ import static org.apache.ignite.internal.processors.odbc.OdbcRequest.*;
* SQL query handler.
*/
public class OdbcCommandHandler {
- /** Kernal context. */
+ /** Kernel context. */
protected final GridKernalContext ctx;
- /** Log. */
+ /** Logger. */
protected final IgniteLogger log;
/** Query ID sequence. */
@@ -112,12 +112,15 @@ public class OdbcCommandHandler {
* @param meta Internal query field metadata.
* @return Odbc query field metadata.
*/
- private static Collection<OdbcColumnMeta> convertMetadata(Collection<GridQueryFieldMetadata> meta) {
+ private static Collection<OdbcColumnMeta> convertMetadata(Collection<?> meta) {
List<OdbcColumnMeta> res = new ArrayList<>();
if (meta != null) {
- for (GridQueryFieldMetadata info : meta)
- res.add(new OdbcColumnMeta(info));
+ for (Object info : meta) {
+ assert info instanceof GridQueryFieldMetadata;
+
+ res.add(new OdbcColumnMeta((GridQueryFieldMetadata)info));
+ }
}
return res;
@@ -176,9 +179,9 @@ public class OdbcCommandHandler {
qryCurs.put(qryId, new IgniteBiTuple<>(qryCur, cur));
- List<GridQueryFieldMetadata> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
+ List<?> fieldsMeta = ((QueryCursorImpl) qryCur).fieldsMeta();
- System.out.println("Field meta: " + fieldsMeta);
+ log.debug("Field meta: " + fieldsMeta);
OdbcQueryExecuteResult res = new OdbcQueryExecuteResult(qryId, convertMetadata(fieldsMeta));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e200771d/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
index 222293a..322cb1c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcParser.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.odbc;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.*;
import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
@@ -47,13 +48,18 @@ public class OdbcParser implements GridNioParser {
/** Marshaller. */
private final GridBinaryMarshaller marsh;
+ /** Logger. */
+ protected final IgniteLogger log;
+
/**
- * @param context Kernel context.
+ * @param ctx Kernel context.
*/
- public OdbcParser(GridKernalContext context) {
- CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)context.cacheObjects();
+ public OdbcParser(GridKernalContext ctx) {
+ CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
marsh = cacheObjProc.marshaller();
+
+ log = ctx.log(getClass());
}
/**
@@ -127,7 +133,7 @@ public class OdbcParser implements GridNioParser {
assert msg != null;
assert msg instanceof OdbcResponse;
- System.out.println("Encoding query processing result");
+ log.debug("Encoding query processing result");
BinaryRawWriterEx writer = marsh.writer(new BinaryHeapOutputStream(INIT_CAP));
@@ -171,10 +177,10 @@ public class OdbcParser implements GridNioParser {
String sql = reader.readString();
int argsNum = reader.readInt();
- System.out.println("Message EXECUTE_SQL_QUERY:");
- System.out.println("cache: " + cache);
- System.out.println("query: " + sql);
- System.out.println("argsNum: " + argsNum);
+ log.debug("Message EXECUTE_SQL_QUERY:");
+ log.debug("cache: " + cache);
+ log.debug("query: " + sql);
+ log.debug("argsNum: " + argsNum);
Object[] params = new Object[argsNum];
@@ -191,9 +197,9 @@ public class OdbcParser implements GridNioParser {
long queryId = reader.readLong();
int pageSize = reader.readInt();
- System.out.println("Message FETCH_SQL_QUERY:");
- System.out.println("queryId: " + queryId);
- System.out.println("pageSize: " + pageSize);
+ log.debug("Message FETCH_SQL_QUERY:");
+ log.debug("queryId: " + queryId);
+ log.debug("pageSize: " + pageSize);
res = new OdbcQueryFetchRequest(queryId, pageSize);
@@ -204,8 +210,8 @@ public class OdbcParser implements GridNioParser {
long queryId = reader.readLong();
- System.out.println("Message CLOSE_SQL_QUERY:");
- System.out.println("queryId: " + queryId);
+ log.debug("Message CLOSE_SQL_QUERY:");
+ log.debug("queryId: " + queryId);
res = new OdbcQueryCloseRequest(queryId);
@@ -218,10 +224,10 @@ public class OdbcParser implements GridNioParser {
String table = reader.readString();
String column = reader.readString();
- System.out.println("Message GET_COLUMNS_META:");
- System.out.println("cache: " + cache);
- System.out.println("table: " + table);
- System.out.println("column: " + column);
+ log.debug("Message GET_COLUMNS_META:");
+ log.debug("cache: " + cache);
+ log.debug("table: " + table);
+ log.debug("column: " + column);
res = new OdbcQueryGetColumnsMetaRequest(cache, table, column);
@@ -235,11 +241,11 @@ public class OdbcParser implements GridNioParser {
String table = reader.readString();
String tableType = reader.readString();
- System.out.println("Message GET_COLUMNS_META:");
- System.out.println("catalog: " + catalog);
- System.out.println("schema: " + schema);
- System.out.println("table: " + table);
- System.out.println("tableType: " + tableType);
+ log.debug("Message GET_COLUMNS_META:");
+ log.debug("catalog: " + catalog);
+ log.debug("schema: " + schema);
+ log.debug("table: " + table);
+ log.debug("tableType: " + tableType);
res = new OdbcQueryGetTablesMetaRequest(catalog, schema, table, tableType);
@@ -277,7 +283,7 @@ public class OdbcParser implements GridNioParser {
if (res0 instanceof OdbcQueryExecuteResult) {
OdbcQueryExecuteResult res = (OdbcQueryExecuteResult) res0;
- System.out.println("Resulting query ID: " + res.getQueryId());
+ log.debug("Resulting query ID: " + res.getQueryId());
writer.writeLong(res.getQueryId());
@@ -294,7 +300,7 @@ public class OdbcParser implements GridNioParser {
else if (res0 instanceof OdbcQueryFetchResult) {
OdbcQueryFetchResult res = (OdbcQueryFetchResult) res0;
- System.out.println("Resulting query ID: " + res.queryId());
+ log.debug("Resulting query ID: " + res.queryId());
writer.writeLong(res.queryId());
@@ -323,7 +329,7 @@ public class OdbcParser implements GridNioParser {
else if (res0 instanceof OdbcQueryCloseResult) {
OdbcQueryCloseResult res = (OdbcQueryCloseResult) res0;
- System.out.println("Resulting query ID: " + res.getQueryId());
+ log.debug("Resulting query ID: " + res.getQueryId());
writer.writeLong(res.getQueryId());
http://git-wip-us.apache.org/repos/asf/ignite/blob/e200771d/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
index ffd425a..8bf3633 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpNioListener.java
@@ -45,12 +45,12 @@ public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest
/** {@inheritDoc} */
@Override public void onConnected(GridNioSession ses) {
- System.out.println("Driver connected");
+ log.debug("Driver connected");
}
/** {@inheritDoc} */
@Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) {
- System.out.println("Driver disconnected");
+ log.debug("Driver disconnected");
if (e != null) {
if (e instanceof RuntimeException)
@@ -64,7 +64,7 @@ public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest
@Override public void onMessage(GridNioSession ses, OdbcRequest msg) {
assert msg != null;
- System.out.println("Query: " + msg.command());
+ log.debug("Query: " + msg.command());
OdbcResponse res;
@@ -78,7 +78,7 @@ public class OdbcTcpNioListener extends GridNioServerListenerAdapter<OdbcRequest
"Failed to process client request: " + e.getMessage());
}
- System.out.println("Resulting success status: " + res.status());
+ log.debug("Resulting success status: " + res.status());
GridNioFuture<?> sf = ses.send(res);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e200771d/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
index 8c69e3a..648be56 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTcpServer.java
@@ -76,7 +76,7 @@ public class OdbcTcpServer {
int port = cfg.getPort();
if (startTcpServer(host, port, listener, parser, cfg)) {
- System.out.println("ODBC Server has started on TCP port " + port);
+ log.debug("ODBC Server has started on TCP port " + port);
return;
}
[27/28] ignite git commit: IGNITE-2442: Fix for autotools build
system.
Posted by vo...@apache.org.
IGNITE-2442: Fix for autotools build system.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/de100551
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/de100551
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/de100551
Branch: refs/heads/ignite-1786
Commit: de100551cd5e1eca6a643d2f5fd7d5e52a21c41c
Parents: e828706
Author: isapego <is...@gridgain.com>
Authored: Tue Jan 26 17:18:19 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Jan 26 17:18:19 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/Makefile.am | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/de100551/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index 32ca6b2..c582c20 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -20,7 +20,7 @@ ACLOCAL_AMFLAGS = "-Im4"
SUBDIRS = .
DIST_SUBDIRS = .
-AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/../odbc-driver/include -DIGNITE_IMPL
+AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/../odbc/include -DIGNITE_IMPL
AM_CXXFLAGS = -Wall -std=c++0x
noinst_PROGRAMS = ignite-odbc-tests
@@ -34,14 +34,14 @@ ignite_odbc_tests_SOURCES = src/teamcity_boost.cpp \
src/configuration_test.cpp \
src/row_test.cpp \
src/utility_test.cpp \
- ../odbc-driver/src/cursor.cpp \
- ../odbc-driver/src/config/connection_info.cpp \
- ../odbc-driver/src/app/application_data_buffer.cpp \
- ../odbc-driver/src/config/configuration.cpp \
- ../odbc-driver/src/row.cpp \
- ../odbc-driver/src/decimal.cpp \
- ../odbc-driver/src/utility.cpp \
- ../odbc-driver/src/result_page.cpp
+ ../odbc/src/cursor.cpp \
+ ../odbc/src/config/connection_info.cpp \
+ ../odbc/src/app/application_data_buffer.cpp \
+ ../odbc/src/config/configuration.cpp \
+ ../odbc/src/row.cpp \
+ ../odbc/src/decimal.cpp \
+ ../odbc/src/utility.cpp \
+ ../odbc/src/result_page.cpp
ignite_odbc_tests_LDFLAGS = -static-libtool-libs -L/usr/local/lib -lignite-binary -ldl
[17/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index 78e1464..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/foreign_keys_query.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/message.h"
-#include "ignite/odbc/query/foreign_keys_query.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- ForeignKeysQuery::ForeignKeysQuery(diagnostic::Diagnosable& diag, Connection& connection,
- const std::string& primaryCatalog, const std::string& primarySchema,
- const std::string& primaryTable, const std::string& foreignCatalog,
- const std::string& foreignSchema, const std::string& foreignTable) :
- Query(diag),
- connection(connection),
- primaryCatalog(primaryCatalog),
- primarySchema(primarySchema),
- primaryTable(primaryTable),
- foreignCatalog(foreignCatalog),
- foreignSchema(foreignSchema),
- foreignTable(foreignTable),
- executed(false),
- columnsMeta()
- {
- using namespace ignite::impl::binary;
- using namespace ignite::odbc::type_traits;
-
- using meta::ColumnMeta;
-
- columnsMeta.reserve(14);
-
- const std::string sch("");
- const std::string tbl("");
-
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PKTABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PKTABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PKTABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PKCOLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "FKTABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "FKTABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "FKTABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "FKCOLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "KEY_SEQ", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "UPDATE_RULE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "DELETE_RULE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "FK_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PK_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "DEFERRABILITY", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- }
-
- ForeignKeysQuery::~ForeignKeysQuery()
- {
- // No-op.
- }
-
- SqlResult ForeignKeysQuery::Execute()
- {
- executed = true;
-
- return SQL_RESULT_SUCCESS;
- }
-
- const meta::ColumnMetaVector & ForeignKeysQuery::GetMeta() const
- {
- return columnsMeta;
- }
-
- 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;
- }
-
- SqlResult ForeignKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_NO_DATA;
- }
-
- SqlResult ForeignKeysQuery::Close()
- {
- executed = false;
-
- return SQL_RESULT_SUCCESS;
- }
-
- bool ForeignKeysQuery::DataAvailable() const
- {
- return false;
- }
- int64_t ForeignKeysQuery::AffectedRows() const
- {
- return 0;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index b616db3..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/primary_keys_query.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/message.h"
-#include "ignite/odbc/query/primary_keys_query.h"
-
-namespace
-{
- enum ResultColumn
- {
- /** Catalog name. NULL if not applicable to the data source. */
- TABLE_CAT = 1,
-
- /** Schema name. NULL if not applicable to the data source. */
- TABLE_SCHEM,
-
- /** Table name. */
- TABLE_NAME,
-
- /** Column name. */
- COLUMN_NAME,
-
- /** Column sequence number in key. */
- KEY_SEQ,
-
- /** Primary key name. */
- PK_NAME
- };
-}
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- PrimaryKeysQuery::PrimaryKeysQuery(diagnostic::Diagnosable& diag,
- Connection& connection, const std::string& catalog,
- const std::string& schema, const std::string& table) :
- Query(diag),
- connection(connection),
- catalog(catalog),
- schema(schema),
- table(table),
- executed(false),
- columnsMeta()
- {
- using namespace ignite::impl::binary;
- using namespace ignite::odbc::type_traits;
-
- using meta::ColumnMeta;
-
- columnsMeta.reserve(6);
-
- const std::string sch("");
- const std::string tbl("");
-
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "KEY_SEQ", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PK_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- }
-
- PrimaryKeysQuery::~PrimaryKeysQuery()
- {
- // No-op.
- }
-
- SqlResult PrimaryKeysQuery::Execute()
- {
- if (executed)
- Close();
-
- meta.push_back(meta::PrimaryKeyMeta(catalog, schema, table, "_KEY", 1, "_KEY"));
-
- executed = true;
-
- cursor = meta.begin();
-
- return SQL_RESULT_SUCCESS;
- }
-
- const meta::ColumnMetaVector & PrimaryKeysQuery::GetMeta() const
- {
- return columnsMeta;
- }
-
- SqlResult PrimaryKeysQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cursor == meta.end())
- return SQL_RESULT_NO_DATA;
-
- app::ColumnBindingMap::iterator it;
-
- for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
- GetColumn(it->first, it->second);
-
- ++cursor;
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult PrimaryKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cursor == meta.end())
- return SQL_RESULT_NO_DATA;
-
- const meta::PrimaryKeyMeta& currentColumn = *cursor;
-
- switch (columnIdx)
- {
- case TABLE_CAT:
- {
- buffer.PutString(currentColumn.GetCatalogName());
- break;
- }
-
- case TABLE_SCHEM:
- {
- buffer.PutString(currentColumn.GetSchemaName());
- break;
- }
-
- case TABLE_NAME:
- {
- buffer.PutString(currentColumn.GetTableName());
- break;
- }
-
- case COLUMN_NAME:
- {
- buffer.PutString(currentColumn.GetColumnName());
- break;
- }
-
- case KEY_SEQ:
- {
- buffer.PutInt16(currentColumn.GetKeySeq());
- break;
- }
-
- case PK_NAME:
- {
- buffer.PutString(currentColumn.GetKeyName());
- break;
- }
-
- default:
- break;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult PrimaryKeysQuery::Close()
- {
- meta.clear();
-
- executed = false;
-
- return SQL_RESULT_SUCCESS;
- }
-
- bool PrimaryKeysQuery::DataAvailable() const
- {
- return cursor != meta.end();
- }
-
- int64_t PrimaryKeysQuery::AffectedRows() const
- {
- return 0;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp
deleted file mode 100644
index 43d6842..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/query/special_columns_query.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- SpecialColumnsQuery::SpecialColumnsQuery(diagnostic::Diagnosable& diag,
- int16_t type, const std::string& catalog, const std::string& schema,
- const std::string& table, int16_t scope, int16_t nullable) :
- Query(diag),
- type(type),
- catalog(catalog),
- schema(schema),
- table(table),
- scope(scope),
- nullable(nullable),
- executed(false),
- columnsMeta()
- {
- using namespace ignite::impl::binary;
- using namespace ignite::odbc::type_traits;
-
- using meta::ColumnMeta;
-
- columnsMeta.reserve(8);
-
- const std::string sch("");
- const std::string tbl("");
-
- columnsMeta.push_back(ColumnMeta(sch, tbl, "SCOPE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_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, "TYPE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_SIZE", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "BUFFER_LENGTH", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "DECIMAL_DIGITS", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "PSEUDO_COLUMN", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
- }
-
- SpecialColumnsQuery::~SpecialColumnsQuery()
- {
- // No-op.
- }
-
- SqlResult SpecialColumnsQuery::Execute()
- {
- executed = true;
-
- return SQL_RESULT_SUCCESS;
- }
-
- const meta::ColumnMetaVector& SpecialColumnsQuery::GetMeta() const
- {
- return columnsMeta;
- }
-
- SqlResult SpecialColumnsQuery::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;
- }
-
- SqlResult SpecialColumnsQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_NO_DATA;
- }
-
- SqlResult SpecialColumnsQuery::Close()
- {
- executed = false;
-
- return SQL_RESULT_SUCCESS;
- }
-
- bool SpecialColumnsQuery::DataAvailable() const
- {
- return false;
- }
-
- int64_t SpecialColumnsQuery::AffectedRows() const
- {
- return 0;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/query/table_metadata_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/table_metadata_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/table_metadata_query.cpp
deleted file mode 100644
index 42850cf..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/table_metadata_query.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/type_traits.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/message.h"
-#include "ignite/odbc/query/table_metadata_query.h"
-
-namespace
-{
- enum ResultColumn
- {
- /** Catalog name. NULL if not applicable to the data source. */
- TABLE_CAT = 1,
-
- /** Schema name. NULL if not applicable to the data source. */
- TABLE_SCHEM,
-
- /** Table name. */
- TABLE_NAME,
-
- /** Table type. */
- TABLE_TYPE,
-
- /** A description of the column. */
- REMARKS
- };
-}
-
-namespace ignite
-{
- namespace odbc
- {
- namespace query
- {
- TableMetadataQuery::TableMetadataQuery(diagnostic::Diagnosable& diag,
- Connection& connection, const std::string& catalog,const std::string& schema,
- const std::string& table, const std::string& tableType) :
- Query(diag),
- connection(connection),
- catalog(catalog),
- schema(schema),
- table(table),
- tableType(tableType),
- executed(false),
- meta(),
- columnsMeta()
- {
- using namespace ignite::impl::binary;
- using namespace ignite::odbc::type_traits;
-
- using meta::ColumnMeta;
-
- columnsMeta.reserve(5);
-
- const std::string sch("");
- const std::string tbl("");
-
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_CAT", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_SCHEM", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "TABLE_TYPE", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- columnsMeta.push_back(ColumnMeta(sch, tbl, "REMARKS", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
- }
-
- TableMetadataQuery::~TableMetadataQuery()
- {
- // No-op.
- }
-
- SqlResult TableMetadataQuery::Execute()
- {
- if (executed)
- Close();
-
- SqlResult result = MakeRequestGetTablesMeta();
-
- if (result == SQL_RESULT_SUCCESS)
- {
- executed = true;
-
- cursor = meta.begin();
- }
-
- return result;
- }
-
- const meta::ColumnMetaVector& TableMetadataQuery::GetMeta() const
- {
- return columnsMeta;
- }
-
- SqlResult TableMetadataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cursor == meta.end())
- return SQL_RESULT_NO_DATA;
-
- app::ColumnBindingMap::iterator it;
-
- for (it = columnBindings.begin(); it != columnBindings.end(); ++it)
- GetColumn(it->first, it->second);
-
- ++cursor;
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult TableMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
- {
- if (!executed)
- {
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (cursor == meta.end())
- return SQL_RESULT_NO_DATA;
-
- const meta::TableMeta& currentColumn = *cursor;
-
- switch (columnIdx)
- {
- case TABLE_CAT:
- {
- buffer.PutString(currentColumn.GetCatalogName());
- break;
- }
-
- case TABLE_SCHEM:
- {
- buffer.PutString(currentColumn.GetSchemaName());
- break;
- }
-
- case TABLE_NAME:
- {
- buffer.PutString(currentColumn.GetTableName());
- break;
- }
-
- case TABLE_TYPE:
- {
- buffer.PutString(currentColumn.GetTableType());
- break;
- }
-
- case REMARKS:
- {
- buffer.PutNull();
- break;
- }
-
- default:
- break;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult TableMetadataQuery::Close()
- {
- meta.clear();
-
- executed = false;
-
- return SQL_RESULT_SUCCESS;
- }
-
- bool TableMetadataQuery::DataAvailable() const
- {
- return cursor != meta.end();
- }
-
- int64_t TableMetadataQuery::AffectedRows() const
- {
- return 0;
- }
-
- SqlResult TableMetadataQuery::MakeRequestGetTablesMeta()
- {
- QueryGetTablesMetaRequest req(catalog, schema, table, tableType);
- QueryGetTablesMetaResponse rsp;
-
- bool success = connection.SyncMessage(req, rsp);
-
- if (!success)
- {
- diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, "Connection terminated.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
- {
- LOG_MSG("Error: %s\n", rsp.GetError().c_str());
-
- diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
-
- return SQL_RESULT_ERROR;
- }
-
- meta = rsp.GetMeta();
-
- for (size_t i = 0; i < meta.size(); ++i)
- {
- LOG_MSG("[%d] CatalogName: %s\n", i, meta[i].GetCatalogName().c_str());
- LOG_MSG("[%d] SchemaName: %s\n", i, meta[i].GetSchemaName().c_str());
- LOG_MSG("[%d] TableName: %s\n", i, meta[i].GetTableName().c_str());
- LOG_MSG("[%d] TableType: %s\n", i, meta[i].GetTableType().c_str());
- LOG_MSG("\n");
- }
-
- return SQL_RESULT_SUCCESS;
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index efba734..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/query/type_info_query.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * 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)
- {
- 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)
- GetColumn(it->first, it->second);
-
- ++cursor;
-
- return SQL_RESULT_SUCCESS;
- }
-
- SqlResult TypeInfoQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
- {
- 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;
-
- 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;
- }
-
- 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/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/result_page.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/result_page.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/result_page.cpp
deleted file mode 100644
index 4464481..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/result_page.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 <ignite/impl/interop/interop_input_stream.h>
-
-#include "ignite/odbc/result_page.h"
-#include "ignite/odbc/utility.h"
-
-namespace ignite
-{
- namespace odbc
- {
- ResultPage::ResultPage() :
- last(false), size(0), data(DEFAULT_ALLOCATED_MEMORY)
- {
- //No-op.
- }
-
- ResultPage::~ResultPage()
- {
- //No-op.
- }
-
- void ResultPage::Read(ignite::impl::binary::BinaryReaderImpl& reader)
- {
- last = reader.ReadBool();
- size = reader.ReadInt32();
-
- ignite::impl::interop::InteropInputStream& stream = *reader.GetStream();
-
- int32_t dataToRead = stream.Remaining();
-
- data.Length(dataToRead);
-
- if (dataToRead)
- {
- data.Reallocate(dataToRead);
-
- reader.GetStream()->ReadInt8Array(data.Data(), dataToRead);
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/row.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/row.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/row.cpp
deleted file mode 100644
index 5e5a00e..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/row.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 <ignite/impl/interop/interop_stream_position_guard.h>
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/row.h"
-
-namespace ignite
-{
- namespace odbc
- {
- Row::Row(ignite::impl::interop::InteropUnpooledMemory& pageData) :
- rowBeginPos(0), pos(rowBeginPos), size(0), pageData(pageData),
- stream(&pageData), reader(&stream), columns()
- {
- if (pageData.Length() >= 4)
- {
- Reinit();
- }
- }
-
- Row::~Row()
- {
- // No-op.
- }
-
- bool Row::EnsureColumnDiscovered(uint16_t columnIdx)
- {
- if (columns.size() >= columnIdx)
- return true;
-
- if (columnIdx > GetSize() || columnIdx < 1)
- return false;
-
- if (columns.empty())
- {
- Column newColumn(reader);
-
- if (!newColumn.IsValid())
- return false;
-
- columns.push_back(newColumn);
- }
-
- while (columns.size() < columnIdx)
- {
- Column& column = columns.back();
-
- stream.Position(column.GetEndPosition());
-
- Column newColumn(reader);
-
- if (!newColumn.IsValid())
- return false;
-
- columns.push_back(newColumn);
- }
-
- return true;
- }
-
- SqlResult Row::ReadColumnToBuffer(uint16_t columnIdx, app::ApplicationDataBuffer& dataBuf)
- {
- using namespace ignite::impl::binary;
- using namespace ignite::impl::interop;
-
- if (!EnsureColumnDiscovered(columnIdx))
- return SQL_RESULT_ERROR;
-
- Column& column = GetColumn(columnIdx);
-
- return column.ReadToBuffer(reader, dataBuf);
- }
-
- bool Row::MoveToNext()
- {
- int32_t lastColumnIdx = GetSize();
-
- if (!EnsureColumnDiscovered(lastColumnIdx))
- return false;
-
- Column& lastColumn = GetColumn(lastColumnIdx);
-
- stream.Position(lastColumn.GetEndPosition());
-
- Reinit();
-
- return true;
- }
-
- void Row::Reinit()
- {
- size = stream.ReadInt32();
-
- rowBeginPos = stream.Position();
-
- columns.clear();
-
- columns.reserve(size);
-
- pos = 0;
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
deleted file mode 100644
index 4bf0db9..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * 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 "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/query/data_query.h"
-#include "ignite/odbc/query/column_metadata_query.h"
-#include "ignite/odbc/query/table_metadata_query.h"
-#include "ignite/odbc/query/foreign_keys_query.h"
-#include "ignite/odbc/query/primary_keys_query.h"
-#include "ignite/odbc/query/type_info_query.h"
-#include "ignite/odbc/query/special_columns_query.h"
-#include "ignite/odbc/connection.h"
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/message.h"
-#include "ignite/odbc/statement.h"
-
-namespace ignite
-{
- namespace odbc
- {
- Statement::Statement(Connection& parent) :
- connection(parent), columnBindings(), currentQuery(),
- rowsFetched(0), rowStatuses(0), paramBindOffset(0), columnBindOffset(0)
- {
- // No-op.
- }
-
- Statement::~Statement()
- {
- // No-op.
- }
-
- void Statement::BindColumn(uint16_t columnIdx, const app::ApplicationDataBuffer& buffer)
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- columnBindings[columnIdx] = buffer;
-
- columnBindings[columnIdx].SetPtrToOffsetPtr(&columnBindOffset);
- }
-
- void Statement::UnbindColumn(uint16_t columnIdx)
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- columnBindings.erase(columnIdx);
- }
-
- void Statement::UnbindAllColumns()
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- columnBindings.clear();
- }
-
- void Statement::SetColumnBindOffsetPtr(size_t * ptr)
- {
- columnBindOffset = ptr;
- }
-
- size_t * Statement::GetColumnBindOffsetPtr()
- {
- return columnBindOffset;
- }
-
- int32_t Statement::GetColumnNumber()
- {
- int32_t res;
-
- IGNITE_ODBC_API_CALL(InternalGetColumnNumber(res));
-
- return res;
- }
-
- SqlResult Statement::InternalGetColumnNumber(int32_t &res)
- {
- const meta::ColumnMetaVector* meta = GetMeta();
-
- if (!meta)
- {
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- res = static_cast<int32_t>(meta->size());
-
- return SQL_RESULT_SUCCESS;
- }
-
- void Statement::BindParameter(uint16_t paramIdx, const app::Parameter& param)
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- paramBindings[paramIdx] = param;
-
- paramBindings[paramIdx].GetBuffer().SetPtrToOffsetPtr(¶mBindOffset);
- }
-
- void Statement::UnbindParameter(uint16_t paramIdx)
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- paramBindings.erase(paramIdx);
- }
-
- void Statement::UnbindAllParameters()
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- paramBindings.clear();
- }
-
- uint16_t Statement::GetParametersNumber()
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- return static_cast<uint16_t>(paramBindings.size());
- }
-
- void Statement::SetParamBindOffsetPtr(size_t* ptr)
- {
- IGNITE_ODBC_API_CALL_ALWAYS_SUCCESS;
-
- paramBindOffset = ptr;
- }
-
- size_t * Statement::GetParamBindOffsetPtr()
- {
- return paramBindOffset;
- }
-
- void Statement::GetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
- {
- IGNITE_ODBC_API_CALL(InternalGetColumnData(columnIdx, buffer));
- }
-
- SqlResult Statement::InternalGetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
- {
- if (!currentQuery.get())
- {
- AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE, "Cursor is not in the open state.");
-
- return SQL_RESULT_ERROR;
- }
-
- SqlResult res = currentQuery->GetColumn(columnIdx, buffer);
-
- return res;
- }
-
- void Statement::PrepareSqlQuery(const std::string& query)
- {
- return PrepareSqlQuery(query.data(), query.size());
- }
-
- void Statement::PrepareSqlQuery(const char* query, size_t len)
- {
- IGNITE_ODBC_API_CALL(InternalPrepareSqlQuery(query, len));
- }
-
- SqlResult Statement::InternalPrepareSqlQuery(const char* query, size_t len)
- {
- if (currentQuery.get())
- currentQuery->Close();
-
- std::string sql(query, len);
-
- currentQuery.reset(new query::DataQuery(*this, connection, sql, paramBindings));
-
- return SQL_RESULT_SUCCESS;
- }
-
- void Statement::ExecuteSqlQuery(const std::string& query)
- {
- ExecuteSqlQuery(query.data(), query.size());
- }
-
- void Statement::ExecuteSqlQuery(const char* query, size_t len)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteSqlQuery(query, len));
- }
-
- SqlResult Statement::InternalExecuteSqlQuery(const char* query, size_t len)
- {
- SqlResult result = InternalPrepareSqlQuery(query, len);
-
- if (result != SQL_RESULT_SUCCESS)
- return result;
-
- return InternalExecuteSqlQuery();
- }
-
- void Statement::ExecuteSqlQuery()
- {
- IGNITE_ODBC_API_CALL(InternalExecuteSqlQuery());
- }
-
- SqlResult Statement::InternalExecuteSqlQuery()
- {
- if (!currentQuery.get())
- {
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not prepared.");
-
- return SQL_RESULT_ERROR;
- }
-
- return currentQuery->Execute();
- }
-
- void Statement::ExecuteGetColumnsMetaQuery(const std::string& schema,
- const std::string& table, const std::string& column)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteGetColumnsMetaQuery(schema, table, column));
- }
-
- SqlResult Statement::InternalExecuteGetColumnsMetaQuery(const std::string& schema,
- const std::string& table, const std::string& column)
- {
- if (currentQuery.get())
- currentQuery->Close();
-
- std::string cache(schema);
-
- if (cache.empty())
- cache = connection.GetCache();
-
- currentQuery.reset(new query::ColumnMetadataQuery(*this, connection, cache, table, column));
-
- return currentQuery->Execute();
- }
-
- void Statement::ExecuteGetTablesMetaQuery(const std::string& catalog,
- const std::string& schema, const std::string& table, const std::string& tableType)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteGetTablesMetaQuery(catalog, schema, table, tableType));
- }
-
- SqlResult Statement::InternalExecuteGetTablesMetaQuery(const std::string& catalog,
- const std::string& schema, const std::string& table, const std::string& tableType)
- {
- if (currentQuery.get())
- currentQuery->Close();
-
- std::string cache(schema);
-
- if (cache.empty())
- cache = connection.GetCache();
-
- currentQuery.reset(new query::TableMetadataQuery(*this, connection, catalog, cache, table, tableType));
-
- return currentQuery->Execute();
- }
-
- void Statement::ExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
- const std::string& primarySchema, const std::string& primaryTable,
- const std::string& foreignCatalog, const std::string& foreignSchema,
- const std::string& foreignTable)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteGetForeignKeysQuery(primaryCatalog,
- primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable));
- }
-
- SqlResult Statement::InternalExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
- const std::string& primarySchema, const std::string& primaryTable,
- const std::string& foreignCatalog, const std::string& foreignSchema,
- const std::string& foreignTable)
- {
- if (currentQuery.get())
- currentQuery->Close();
-
- currentQuery.reset(new query::ForeignKeysQuery(*this, connection, primaryCatalog, primarySchema,
- primaryTable, foreignCatalog, foreignSchema, foreignTable));
-
- return currentQuery->Execute();
- }
-
- void Statement::ExecuteGetPrimaryKeysQuery(const std::string& catalog, const std::string& schema,
- const std::string& table)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteGetPrimaryKeysQuery(catalog, schema, table));
- }
-
- SqlResult Statement::InternalExecuteGetPrimaryKeysQuery(const std::string& catalog, const std::string& schema,
- const std::string& table)
- {
- if (currentQuery.get())
- currentQuery->Close();
-
- currentQuery.reset(new query::PrimaryKeysQuery(*this, connection, catalog, schema, table));
-
- return currentQuery->Execute();
- }
-
- void Statement::ExecuteSpecialColumnsQuery(int16_t type,
- const std::string& catalog, const std::string& schema,
- const std::string& table, int16_t scope, int16_t nullable)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteSpecialColumnsQuery(type,
- catalog, schema, table, scope, nullable));
- }
-
- SqlResult Statement::InternalExecuteSpecialColumnsQuery(int16_t type,
- const std::string& catalog, const std::string& schema,
- const std::string& table, int16_t scope, int16_t nullable)
- {
- if (type != SQL_BEST_ROWID && type != SQL_ROWVER)
- {
- AddStatusRecord(SQL_STATE_HY097_COLUMN_TYPE_OUT_OF_RANGE,
- "An invalid IdentifierType value was specified.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (currentQuery.get())
- currentQuery->Close();
-
- currentQuery.reset(new query::SpecialColumnsQuery(*this, type,
- catalog, schema, table, scope, nullable));
-
- return currentQuery->Execute();
- }
-
- void Statement::ExecuteGetTypeInfoQuery(int16_t sqlType)
- {
- IGNITE_ODBC_API_CALL(InternalExecuteGetTypeInfoQuery(sqlType));
- }
-
- SqlResult Statement::InternalExecuteGetTypeInfoQuery(int16_t sqlType)
- {
- if (!type_traits::IsSqlTypeSupported(sqlType))
- {
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Data type is not supported.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (currentQuery.get())
- currentQuery->Close();
-
- currentQuery.reset(new query::TypeInfoQuery(*this, sqlType));
-
- return currentQuery->Execute();
- }
-
- void Statement::Close()
- {
- IGNITE_ODBC_API_CALL(InternalClose());
- }
-
- SqlResult Statement::InternalClose()
- {
- if (!currentQuery.get())
- {
- AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE, "Cursor is not in the open state.");
-
- return SQL_RESULT_ERROR;
- }
-
- SqlResult result = currentQuery->Close();
-
- if (result == SQL_RESULT_SUCCESS)
- currentQuery.reset();
-
- return result;
- }
-
- void Statement::FetchRow()
- {
- IGNITE_ODBC_API_CALL(InternalFetchRow());
- }
-
- SqlResult Statement::InternalFetchRow()
- {
- if (rowsFetched)
- *rowsFetched = 0;
-
- if (!currentQuery.get())
- {
- AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE, "Cursor is not in the open state.");
-
- return SQL_RESULT_ERROR;
- }
-
- SqlResult res = currentQuery->FetchNextRow(columnBindings);
-
- if (res == SQL_RESULT_SUCCESS)
- {
- if (rowsFetched)
- *rowsFetched = 1;
-
- if (rowStatuses)
- rowStatuses[0] = SQL_ROW_SUCCESS;
- }
-
- return res;
- }
-
- const meta::ColumnMetaVector* Statement::GetMeta() const
- {
- if (!currentQuery.get())
- return 0;
-
- return ¤tQuery->GetMeta();
- }
-
- bool Statement::DataAvailable() const
- {
- return currentQuery.get() && currentQuery->DataAvailable();
- }
-
- void Statement::GetColumnAttribute(uint16_t colIdx, uint16_t attrId,
- char* strbuf, int16_t buflen, int16_t* reslen, SqlLen* numbuf)
- {
- IGNITE_ODBC_API_CALL(InternalGetColumnAttribute(colIdx, attrId,
- strbuf, buflen, reslen, numbuf));
- }
-
- SqlResult Statement::InternalGetColumnAttribute(uint16_t colIdx,
- uint16_t attrId, char* strbuf, int16_t buflen, int16_t* reslen,
- SqlLen* numbuf)
- {
- const meta::ColumnMetaVector *meta = GetMeta();
-
- if (!meta)
- {
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- if (colIdx > meta->size() + 1 || colIdx < 1)
- {
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Column index is out of range.", 0, colIdx);
-
- return SQL_RESULT_ERROR;
- }
-
- const meta::ColumnMeta& columnMeta = meta->at(colIdx - 1);
-
- bool found = false;
-
- if (numbuf)
- found = columnMeta.GetAttribute(attrId, *numbuf);
-
- if (!found)
- {
- std::string out;
-
- found = columnMeta.GetAttribute(attrId, out);
-
- size_t outSize = out.size();
-
- if (found && strbuf)
- outSize = utility::CopyStringToBuffer(out, strbuf, buflen);
-
- if (found && strbuf)
- *reslen = static_cast<int16_t>(outSize);
- }
-
- if (!found)
- {
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Unknown attribute.");
-
- return SQL_RESULT_ERROR;
- }
-
- return SQL_RESULT_SUCCESS;
- }
-
- int64_t Statement::AffectedRows()
- {
- int64_t rowCnt = 0;
-
- IGNITE_ODBC_API_CALL(InternalAffectedRows(rowCnt));
-
- return rowCnt;
- }
-
- SqlResult Statement::InternalAffectedRows(int64_t& rowCnt)
- {
- if (!currentQuery.get())
- {
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
-
- return SQL_RESULT_ERROR;
- }
-
- rowCnt = currentQuery->AffectedRows();
-
- return SQL_RESULT_SUCCESS;
- }
-
- void Statement::SetRowsFetchedPtr(size_t* ptr)
- {
- rowsFetched = ptr;
- }
-
- size_t* Statement::GetRowsFetchedPtr()
- {
- return rowsFetched;
- }
-
- void Statement::SetRowStatusesPtr(uint16_t* ptr)
- {
- rowStatuses = ptr;
- }
-
- uint16_t * Statement::GetRowStatusesPtr()
- {
- return rowStatuses;
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/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
deleted file mode 100644
index 03e525f..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/type_traits.cpp
+++ /dev/null
@@ -1,657 +0,0 @@
-/*
- * 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 <ignite/impl/binary/binary_common.h>
-
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/type_traits.h"
-
-namespace
-{
- /** Default display size. */
- enum { DEFAULT_DISPLAY_SIZE = 34 };
-
- /** Default variable size data display size. */
- enum { DEFAULT_VARDATA_DISPLAY_SIZE = 64 };
-}
-
-namespace ignite
-{
- namespace odbc
- {
- namespace type_traits
- {
- const std::string SqlTypeName::VARCHAR("LONG VARCHAR");
-
- const std::string SqlTypeName::SMALLINT("SMALLINT");
-
- const std::string SqlTypeName::INTEGER("INTEGER");
-
- const std::string SqlTypeName::DECIMAL("DECIMAL");
-
- const std::string SqlTypeName::FLOAT("FLOAT");
-
- const std::string SqlTypeName::DOUBLE("DOUBLE");
-
- const std::string SqlTypeName::BIT("BIT");
-
- const std::string SqlTypeName::TINYINT("TINYINT");
-
- const std::string SqlTypeName::BIGINT("BIGINT");
-
- const std::string SqlTypeName::BINARY("LONG VARBINARY");
-
- const std::string SqlTypeName::DATE("DATE");
-
- const std::string SqlTypeName::GUID("GUID");
-
-#ifdef ODBC_DEBUG
-
-#define DBG_STR_CASE(x) case x: return #x
-
- const char* StatementAttrIdToString(long id)
- {
- switch (id)
- {
- DBG_STR_CASE(SQL_ATTR_APP_PARAM_DESC);
- DBG_STR_CASE(SQL_ATTR_APP_ROW_DESC);
- DBG_STR_CASE(SQL_ATTR_ASYNC_ENABLE);
- DBG_STR_CASE(SQL_ATTR_CONCURRENCY);
- DBG_STR_CASE(SQL_ATTR_CURSOR_SCROLLABLE);
- DBG_STR_CASE(SQL_ATTR_CURSOR_SENSITIVITY);
- DBG_STR_CASE(SQL_ATTR_CURSOR_TYPE);
- DBG_STR_CASE(SQL_ATTR_ENABLE_AUTO_IPD);
- DBG_STR_CASE(SQL_ATTR_FETCH_BOOKMARK_PTR);
- DBG_STR_CASE(SQL_ATTR_IMP_PARAM_DESC);
- DBG_STR_CASE(SQL_ATTR_IMP_ROW_DESC);
- DBG_STR_CASE(SQL_ATTR_KEYSET_SIZE);
- DBG_STR_CASE(SQL_ATTR_MAX_LENGTH);
- DBG_STR_CASE(SQL_ATTR_MAX_ROWS);
- DBG_STR_CASE(SQL_ATTR_METADATA_ID);
- DBG_STR_CASE(SQL_ATTR_NOSCAN);
- DBG_STR_CASE(SQL_ATTR_PARAM_BIND_OFFSET_PTR);
- DBG_STR_CASE(SQL_ATTR_PARAM_BIND_TYPE);
- DBG_STR_CASE(SQL_ATTR_PARAM_OPERATION_PTR);
- DBG_STR_CASE(SQL_ATTR_PARAM_STATUS_PTR);
- DBG_STR_CASE(SQL_ATTR_PARAMS_PROCESSED_PTR);
- DBG_STR_CASE(SQL_ATTR_PARAMSET_SIZE);
- DBG_STR_CASE(SQL_ATTR_QUERY_TIMEOUT);
- DBG_STR_CASE(SQL_ATTR_RETRIEVE_DATA);
- DBG_STR_CASE(SQL_ATTR_ROW_ARRAY_SIZE);
- DBG_STR_CASE(SQL_ATTR_ROW_BIND_OFFSET_PTR);
- DBG_STR_CASE(SQL_ATTR_ROW_BIND_TYPE);
- DBG_STR_CASE(SQL_ATTR_ROW_NUMBER);
- DBG_STR_CASE(SQL_ATTR_ROW_OPERATION_PTR);
- DBG_STR_CASE(SQL_ATTR_ROW_STATUS_PTR);
- DBG_STR_CASE(SQL_ATTR_ROWS_FETCHED_PTR);
- DBG_STR_CASE(SQL_ATTR_SIMULATE_CURSOR);
- DBG_STR_CASE(SQL_ATTR_USE_BOOKMARKS);
- default:
- break;
- }
- return "<< UNKNOWN ID >>";
- }
-
-#undef DBG_STR_CASE
-#endif
-
- const std::string& BinaryTypeToSqlTypeName(int8_t binaryType)
- {
- using namespace ignite::impl::binary;
-
- switch (binaryType)
- {
- case IGNITE_TYPE_STRING:
- return SqlTypeName::VARCHAR;
-
- case IGNITE_TYPE_SHORT:
- return SqlTypeName::SMALLINT;
-
- case IGNITE_TYPE_INT:
- return SqlTypeName::INTEGER;
-
- case IGNITE_TYPE_DECIMAL:
- return SqlTypeName::DECIMAL;
-
- case IGNITE_TYPE_FLOAT:
- return SqlTypeName::FLOAT;
-
- case IGNITE_TYPE_DOUBLE:
- return SqlTypeName::DOUBLE;
-
- case IGNITE_TYPE_BOOL:
- return SqlTypeName::BIT;
-
- case IGNITE_TYPE_BYTE:
- case IGNITE_TYPE_CHAR:
- return SqlTypeName::TINYINT;
-
- case IGNITE_TYPE_LONG:
- return SqlTypeName::BIGINT;
-
- case IGNITE_TYPE_UUID:
- return SqlTypeName::GUID;
-
- case IGNITE_TYPE_DATE:
- return SqlTypeName::DATE;
-
- case IGNITE_TYPE_OBJECT:
- case IGNITE_TYPE_ARRAY_BYTE:
- case IGNITE_TYPE_ARRAY_SHORT:
- case IGNITE_TYPE_ARRAY_INT:
- case IGNITE_TYPE_ARRAY_LONG:
- case IGNITE_TYPE_ARRAY_FLOAT:
- case IGNITE_TYPE_ARRAY_DOUBLE:
- case IGNITE_TYPE_ARRAY_CHAR:
- case IGNITE_TYPE_ARRAY_BOOL:
- case IGNITE_TYPE_ARRAY_DECIMAL:
- case IGNITE_TYPE_ARRAY_STRING:
- case IGNITE_TYPE_ARRAY_UUID:
- case IGNITE_TYPE_ARRAY_DATE:
- case IGNITE_TYPE_ARRAY:
- case IGNITE_TYPE_COLLECTION:
- case IGNITE_TYPE_MAP:
- case IGNITE_TYPE_MAP_ENTRY:
- case IGNITE_TYPE_BINARY:
- default:
- return SqlTypeName::BINARY;
- }
-
- return SqlTypeName::BINARY;
- }
-
- bool IsApplicationTypeSupported(int16_t type)
- {
- return ToDriverType(type) != IGNITE_ODBC_C_TYPE_UNSUPPORTED;
- }
-
- bool IsSqlTypeSupported(int16_t type)
- {
- switch (type)
- {
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_LONGVARCHAR:
- case SQL_SMALLINT:
- case SQL_INTEGER:
- case SQL_FLOAT:
- case SQL_DOUBLE:
- case SQL_BIT:
- case SQL_TINYINT:
- case SQL_BIGINT:
- case SQL_BINARY:
- 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_NUMERIC:
- case SQL_TYPE_DATE:
- case SQL_TYPE_TIME:
- case SQL_TYPE_TIMESTAMP:
- case SQL_INTERVAL_MONTH:
- case SQL_INTERVAL_YEAR:
- case SQL_INTERVAL_YEAR_TO_MONTH:
- case SQL_INTERVAL_DAY:
- case SQL_INTERVAL_HOUR:
- case SQL_INTERVAL_MINUTE:
- case SQL_INTERVAL_SECOND:
- case SQL_INTERVAL_DAY_TO_HOUR:
- case SQL_INTERVAL_DAY_TO_MINUTE:
- case SQL_INTERVAL_DAY_TO_SECOND:
- case SQL_INTERVAL_HOUR_TO_MINUTE:
- case SQL_INTERVAL_HOUR_TO_SECOND:
- case SQL_INTERVAL_MINUTE_TO_SECOND:
- default:
- return false;
- }
- }
-
- 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)
- {
- case SQL_C_CHAR:
- return IGNITE_ODBC_C_TYPE_CHAR;
-
- case SQL_C_WCHAR:
- return IGNITE_ODBC_C_TYPE_WCHAR;
-
- case SQL_C_SSHORT:
- return IGNITE_ODBC_C_TYPE_SIGNED_SHORT;
-
- case SQL_C_USHORT:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT;
-
- case SQL_C_SLONG:
- return IGNITE_ODBC_C_TYPE_SIGNED_LONG;
-
- case SQL_C_ULONG:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_LONG;
-
- case SQL_C_FLOAT:
- return IGNITE_ODBC_C_TYPE_FLOAT;
-
- case SQL_C_DOUBLE:
- return IGNITE_ODBC_C_TYPE_DOUBLE;
-
- case SQL_C_BIT:
- return IGNITE_ODBC_C_TYPE_BIT;
-
- case SQL_C_STINYINT:
- return IGNITE_ODBC_C_TYPE_SIGNED_TINYINT;
-
- case SQL_C_UTINYINT:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT;
-
- case SQL_C_SBIGINT:
- return IGNITE_ODBC_C_TYPE_SIGNED_BIGINT;
-
- case SQL_C_UBIGINT:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT;
-
- case SQL_C_BINARY:
- return IGNITE_ODBC_C_TYPE_BINARY;
-
- case SQL_C_TYPE_DATE:
- return IGNITE_ODBC_C_TYPE_TDATE;
-
- case SQL_C_TYPE_TIME:
- return IGNITE_ODBC_C_TYPE_TTIME;
-
- case SQL_C_TYPE_TIMESTAMP:
- return IGNITE_ODBC_C_TYPE_TTIMESTAMP;
-
- case SQL_C_NUMERIC:
- return IGNITE_ODBC_C_TYPE_NUMERIC;
-
- case SQL_C_GUID:
- return IGNITE_ODBC_C_TYPE_GUID;
-
- case SQL_C_DEFAULT:
- return IGNITE_ODBC_C_TYPE_DEFAULT;
-
- default:
- return IGNITE_ODBC_C_TYPE_UNSUPPORTED;
- }
- }
-
- int16_t BinaryToSqlType(int8_t binaryType)
- {
- using namespace ignite::impl::binary;
- switch (binaryType)
- {
- case IGNITE_TYPE_BYTE:
- case IGNITE_TYPE_CHAR:
- return SQL_TINYINT;
-
- case IGNITE_TYPE_SHORT:
- return SQL_SMALLINT;
-
- case IGNITE_TYPE_INT:
- return SQL_INTEGER;
-
- case IGNITE_TYPE_LONG:
- return SQL_BIGINT;
-
- case IGNITE_TYPE_FLOAT:
- return SQL_FLOAT;
-
- case IGNITE_TYPE_DOUBLE:
- return SQL_DOUBLE;
-
- case IGNITE_TYPE_BOOL:
- return SQL_BIT;
-
- case IGNITE_TYPE_DECIMAL:
- return SQL_DECIMAL;
-
- case IGNITE_TYPE_STRING:
- return SQL_VARCHAR;
-
- case IGNITE_TYPE_UUID:
- return SQL_GUID;
-
- case IGNITE_TYPE_DATE:
- return SQL_TYPE_DATE;
-
- case IGNITE_TYPE_ARRAY_BYTE:
- case IGNITE_TYPE_ARRAY_SHORT:
- case IGNITE_TYPE_ARRAY_INT:
- case IGNITE_TYPE_ARRAY_LONG:
- case IGNITE_TYPE_ARRAY_FLOAT:
- case IGNITE_TYPE_ARRAY_DOUBLE:
- case IGNITE_TYPE_ARRAY_CHAR:
- case IGNITE_TYPE_ARRAY_BOOL:
- case IGNITE_TYPE_ARRAY_DECIMAL:
- case IGNITE_TYPE_ARRAY_STRING:
- case IGNITE_TYPE_ARRAY_UUID:
- case IGNITE_TYPE_ARRAY_DATE:
- case IGNITE_TYPE_ARRAY:
- case IGNITE_TYPE_COLLECTION:
- case IGNITE_TYPE_MAP:
- case IGNITE_TYPE_MAP_ENTRY:
- case IGNITE_TYPE_BINARY:
- case IGNITE_TYPE_OBJECT:
- default:
- return SQL_BINARY;
- }
- }
-
- int16_t BinaryTypeNullability(int8_t binaryType)
- {
- return SQL_NULLABLE_UNKNOWN;
- }
-
- int32_t SqlTypeDisplaySize(int16_t type)
- {
- switch (type)
- {
- case SQL_VARCHAR:
- case SQL_CHAR:
- case SQL_WCHAR:
- case SQL_BINARY:
- return DEFAULT_VARDATA_DISPLAY_SIZE;
-
- case SQL_BIT:
- return 1;
-
- case SQL_TINYINT:
- return 4;
-
- case SQL_SMALLINT:
- return 6;
-
- case SQL_INTEGER:
- return 11;
-
- case SQL_BIGINT:
- return 20;
-
- case SQL_REAL:
- return 14;
-
- case SQL_FLOAT:
- case SQL_DOUBLE:
- return 24;
-
- case SQL_TYPE_DATE:
- return 10;
-
- case SQL_TYPE_TIME:
- return 8;
-
- case SQL_TYPE_TIMESTAMP:
- return 19;
-
- case SQL_GUID:
- return 36;
-
- case SQL_DECIMAL:
- case SQL_NUMERIC:
- default:
- return DEFAULT_DISPLAY_SIZE;
- }
- }
-
- int32_t BinaryTypeDisplaySize(int8_t type)
- {
- int16_t sqlType = BinaryToSqlType(type);
-
- return SqlTypeDisplaySize(sqlType);
- }
-
- int32_t SqlTypeColumnSize(int16_t type)
- {
- switch (type)
- {
- case SQL_VARCHAR:
- case SQL_CHAR:
- case SQL_WCHAR:
- case SQL_BINARY:
- return DEFAULT_VARDATA_DISPLAY_SIZE;
-
- case SQL_BIT:
- return 1;
-
- case SQL_TINYINT:
- return 3;
-
- case SQL_SMALLINT:
- return 5;
-
- case SQL_INTEGER:
- return 10;
-
- case SQL_BIGINT:
- return 19;
-
- case SQL_REAL:
- return 7;
-
- case SQL_FLOAT:
- case SQL_DOUBLE:
- return 15;
-
- case SQL_TYPE_DATE:
- return 10;
-
- case SQL_TYPE_TIME:
- return 8;
-
- case SQL_TYPE_TIMESTAMP:
- return 19;
-
- case SQL_GUID:
- return 36;
-
- case SQL_DECIMAL:
- case SQL_NUMERIC:
- default:
- return DEFAULT_DISPLAY_SIZE;
- }
- }
-
- int32_t BinaryTypeColumnSize(int8_t type)
- {
- int16_t sqlType = BinaryToSqlType(type);
-
- return SqlTypeColumnSize(sqlType);
- }
-
- int32_t SqlTypeTransferLength(int16_t type)
- {
- switch (type)
- {
- case SQL_VARCHAR:
- case SQL_CHAR:
- case SQL_WCHAR:
- case SQL_BINARY:
- return DEFAULT_VARDATA_DISPLAY_SIZE;
-
- case SQL_BIT:
- case SQL_TINYINT:
- return 1;
-
- case SQL_SMALLINT:
- return 2;
-
- case SQL_INTEGER:
- return 4;
-
- case SQL_BIGINT:
- return 8;
-
- case SQL_REAL:
- case SQL_FLOAT:
- return 4;
-
- case SQL_DOUBLE:
- return 8;
-
- case SQL_TYPE_DATE:
- case SQL_TYPE_TIME:
- return 6;
-
- case SQL_TYPE_TIMESTAMP:
- return 16;
-
- case SQL_GUID:
- return 16;
-
- case SQL_DECIMAL:
- case SQL_NUMERIC:
- default:
- return DEFAULT_DISPLAY_SIZE;
- }
- }
-
- int32_t BinaryTypeTransferLength(int8_t type)
- {
- int16_t sqlType = BinaryToSqlType(type);
-
- return SqlTypeTransferLength(sqlType);
- }
-
- int32_t SqlTypeNumPrecRadix(int16_t type)
- {
- switch (type)
- {
- case SQL_REAL:
- case SQL_FLOAT:
- case SQL_DOUBLE:
- return 2;
-
- case SQL_BIT:
- case SQL_TINYINT:
- case SQL_SMALLINT:
- case SQL_INTEGER:
- case SQL_BIGINT:
- return 10;
-
- default:
- return 0;
- }
- }
-
- int32_t BinaryTypeNumPrecRadix(int8_t type)
- {
- int16_t sqlType = BinaryToSqlType(type);
-
- return SqlTypeNumPrecRadix(sqlType);
- }
-
- int32_t SqlTypeDecimalDigits(int16_t type)
- {
- // Not implemented for the NUMERIC and DECIMAL data types.
- return -1;
- }
-
- int32_t BinaryTypeDecimalDigits(int8_t type)
- {
- int16_t sqlType = BinaryToSqlType(type);
-
- return SqlTypeDecimalDigits(sqlType);
- }
-
- bool SqlTypeUnsigned(int16_t type)
- {
- switch (type)
- {
- case SQL_BIT:
- case SQL_TINYINT:
- case SQL_SMALLINT:
- case SQL_INTEGER:
- case SQL_BIGINT:
- case SQL_REAL:
- case SQL_FLOAT:
- case SQL_DOUBLE:
- return false;
-
- default:
- return true;
- }
- }
-
- bool BinaryTypeUnsigned(int8_t type)
- {
- int16_t sqlType = BinaryToSqlType(type);
-
- return SqlTypeUnsigned(sqlType);
- }
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
deleted file mode 100644
index 6f4ac22..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/src/utility.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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_utils.h>
-
-#include "ignite/odbc/utility.h"
-#include "ignite/odbc/system/odbc_constants.h"
-
-namespace ignite
-{
- namespace utility
- {
- size_t CopyStringToBuffer(const std::string& str, char* buf, size_t buflen)
- {
- if (!buf || !buflen)
- return 0;
-
- size_t bytesToCopy = std::min(str.size(), static_cast<size_t>(buflen - 1));
-
- memcpy(buf, str.data(), bytesToCopy);
- buf[bytesToCopy] = 0;
-
- return bytesToCopy;
- }
-
- void ReadString(ignite::impl::binary::BinaryReaderImpl& reader, std::string& str)
- {
- int32_t strLen = reader.ReadString(0, 0);
- if (!strLen)
- {
- str.clear();
-
- char dummy;
-
- reader.ReadString(&dummy, sizeof(dummy));
- }
- else
- {
- str.resize(strLen);
-
- reader.ReadString(&str[0], static_cast<int32_t>(str.size()));
- }
- }
-
- void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string & str)
- {
- writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
- }
-
- void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal& decimal)
- {
- int8_t hdr = reader.ReadInt8();
-
- assert(hdr == ignite::impl::binary::IGNITE_TYPE_DECIMAL);
-
- int32_t scale = reader.ReadInt32();
-
- int32_t len = reader.ReadInt32();
-
- std::vector<int8_t> mag;
-
- mag.resize(len);
-
- impl::binary::BinaryUtils::ReadInt8Array(reader.GetStream(), mag.data(), static_cast<int32_t>(mag.size()));
-
- Decimal res(scale, mag.data(), static_cast<int32_t>(mag.size()));
-
- swap(decimal, res);
- }
-
- std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen)
- {
- std::string res;
-
- const char* sqlStrC = reinterpret_cast<const char*>(sqlStr);
-
- if (!sqlStr || !sqlStrLen)
- return res;
-
- if (sqlStrLen == SQL_NTS)
- res.assign(sqlStrC);
- else
- res.assign(sqlStrC, sqlStrLen);
-
- return res;
- }
- }
-}
-
[23/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/table_metadata_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/table_metadata_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/table_metadata_query.h
new file mode 100644
index 0000000..1b05377
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/table_metadata_query.h
@@ -0,0 +1,150 @@
+/*
+ * 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_TABLE_METADATA_QUERY
+#define _IGNITE_ODBC_DRIVER_TABLE_METADATA_QUERY
+
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/meta/table_meta.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Connection forward-declaration. */
+ class Connection;
+
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class TableMetadataQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Associated connection.
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableType Table type search pattern.
+ */
+ TableMetadataQuery(diagnostic::Diagnosable& diag, Connection& connection,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, const std::string& tableType);
+
+ /**
+ * Destructor.
+ */
+ virtual ~TableMetadataQuery();
+
+ /**
+ * 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);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * 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(TableMetadataQuery);
+
+ /**
+ * Make get columns metadata requets and use response to set internal state.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestGetTablesMeta();
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Catalog search pattern. */
+ std::string catalog;
+
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Table type search pattern. */
+ std::string tableType;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Fetched metadata. */
+ meta::TableMetaVector meta;
+
+ /** Metadata cursor. */
+ meta::TableMetaVector::iterator cursor;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/type_info_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/type_info_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/type_info_query.h
new file mode 100644
index 0000000..ffef3e4
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/type_info_query.h
@@ -0,0 +1,118 @@
+/*
+ * 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);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * 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/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h b/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
new file mode 100644
index 0000000..5c8cac3
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/result_page.h
@@ -0,0 +1,101 @@
+/*
+ * 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_RESULT_PAGE
+#define _IGNITE_ODBC_DRIVER_RESULT_PAGE
+
+#include <stdint.h>
+
+#include <ignite/impl/binary/binary_reader_impl.h>
+
+#include "ignite/odbc/app/application_data_buffer.h"
+#include "ignite/odbc/common_types.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Query result page.
+ */
+ class ResultPage
+ {
+ enum { DEFAULT_ALLOCATED_MEMORY = 1024 };
+
+ public:
+ // Default result page size.
+ enum { DEFAULT_SIZE = 32 };
+
+ /**
+ * Constructor.
+ */
+ ResultPage();
+
+ /**
+ * Destructor.
+ */
+ ~ResultPage();
+
+ /**
+ * Read result page using provided reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader);
+
+ /**
+ * Get page size.
+ * @return Page size.
+ */
+ int32_t GetSize() const
+ {
+ return size;
+ }
+
+ /**
+ * Check if the page is last.
+ * @return True if the page is last.
+ */
+ bool IsLast() const
+ {
+ return last;
+ }
+
+ /**
+ * Get page data.
+ * @return Page data.
+ */
+ ignite::impl::interop::InteropUnpooledMemory& GetData()
+ {
+ return data;
+ }
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(ResultPage);
+
+ /** Last page flag. */
+ bool last;
+
+ /** Page size in rows. */
+ int32_t size;
+
+ /** Memory that contains current row page data. */
+ ignite::impl::interop::InteropUnpooledMemory data;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/row.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/row.h b/modules/platforms/cpp/odbc/include/ignite/odbc/row.h
new file mode 100644
index 0000000..7673555
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/row.h
@@ -0,0 +1,132 @@
+/*
+ * 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_ROW
+#define _IGNITE_ODBC_DRIVER_ROW
+
+#include <stdint.h>
+#include <vector>
+
+#include "ignite/odbc/column.h"
+#include "ignite/odbc/app/application_data_buffer.h"
+
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Query result row.
+ */
+ class Row
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Row(ignite::impl::interop::InteropUnpooledMemory& pageData);
+
+ /**
+ * Destructor.
+ */
+ ~Row();
+
+ /**
+ * Get row size in columns.
+ *
+ * @return Row size.
+ */
+ int32_t GetSize() const
+ {
+ return size;
+ }
+
+ /**
+ * Read column data and store it in application data buffer.
+ *
+ * @param dataBuf Application data buffer.
+ * @return True on success.
+ */
+ SqlResult ReadColumnToBuffer(uint16_t columnIdx, app::ApplicationDataBuffer& dataBuf);
+
+ /**
+ * Move to next row.
+ *
+ * @return True on success.
+ */
+ bool MoveToNext();
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Row);
+
+ /**
+ * Reinitialize row state using stream data.
+ * @note Stream must be positioned at the beginning of the row.
+ */
+ void Reinit();
+
+ /**
+ * Get columns by its index.
+ *
+ * Column indexing starts at 1.
+ *
+ * @note This operation is private because it's unsafe to use:
+ * It is neccessary to ensure that column is discovered prior
+ * to calling this method using EnsureColumnDiscovered().
+ *
+ * @param columnIdx Column index.
+ * @return Reference to specified column.
+ */
+ Column& GetColumn(uint16_t columnIdx)
+ {
+ return columns[columnIdx - 1];
+ }
+
+ /**
+ * Ensure that column data is discovered.
+ *
+ * @param columnIdx Column index.
+ * @return True if the column is discovered and false if it can not
+ * be discovered.
+ */
+ bool EnsureColumnDiscovered(uint16_t columnIdx);
+
+ /** Row position in current page. */
+ int32_t rowBeginPos;
+
+ /** Current position in row. */
+ int32_t pos;
+
+ /** Row size in columns. */
+ int32_t size;
+
+ /** Memory that contains current row data. */
+ ignite::impl::interop::InteropUnpooledMemory& pageData;
+
+ /** Page data input stream. */
+ ignite::impl::interop::InteropInputStream stream;
+
+ /** Data reader. */
+ ignite::impl::binary::BinaryReaderImpl reader;
+
+ /** Columns. */
+ std::vector<Column> columns;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h b/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
new file mode 100644
index 0000000..bbe5da5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
@@ -0,0 +1,525 @@
+/*
+ * 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_STATEMENT
+#define _IGNITE_ODBC_DRIVER_STATEMENT
+
+#include <stdint.h>
+
+#include <map>
+#include <memory>
+
+#include <ignite/impl/interop/interop_output_stream.h>
+#include <ignite/impl/interop/interop_input_stream.h>
+#include <ignite/impl/binary/binary_writer_impl.h>
+
+#include "ignite/odbc/meta/column_meta.h"
+#include "ignite/odbc/meta/table_meta.h"
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/app/application_data_buffer.h"
+#include "ignite/odbc/app/parameter.h"
+#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/cursor.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ class Connection;
+
+ /**
+ * SQL-statement abstraction. Holds SQL query user buffers data and
+ * call result.
+ */
+ class Statement : public diagnostic::DiagnosableAdapter
+ {
+ friend class Connection;
+ public:
+ /**
+ * Destructor.
+ */
+ ~Statement();
+
+ /**
+ * Bind result column to specified data buffer.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ */
+ void BindColumn(uint16_t columnIdx, const app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Unbind specified column buffer.
+ *
+ * @param columnIdx Column index.
+ */
+ void UnbindColumn(uint16_t columnIdx);
+
+ /**
+ * Unbind all column buffers.
+ */
+ void UnbindAllColumns();
+
+ /**
+ * Set column binding offset pointer.
+ *
+ * @param ptr Column binding offset pointer.
+ */
+ void SetColumnBindOffsetPtr(size_t* ptr);
+
+ /**
+ * Get column binding offset pointer.
+ *
+ * @return Column binding offset pointer.
+ */
+ size_t* GetColumnBindOffsetPtr();
+
+ /**
+ * Get number of columns in the result set.
+ *
+ * @return Columns number.
+ */
+ int32_t GetColumnNumber();
+
+ /**
+ * Bind parameter.
+ *
+ * @param paramIdx Parameter index.
+ * @param param Parameter.
+ */
+ void BindParameter(uint16_t paramIdx, const app::Parameter& param);
+
+ /**
+ * Unbind specified parameter.
+ *
+ * @param paramIdx Parameter index.
+ */
+ void UnbindParameter(uint16_t paramIdx);
+
+ /**
+ * Unbind all parameters.
+ */
+ void UnbindAllParameters();
+
+ /**
+ * Get number of binded parameters.
+ *
+ * @return Number of binded parameters.
+ */
+ uint16_t GetParametersNumber();
+
+ /**
+ * Set parameter binding offset pointer.
+ *
+ * @param ptr Parameter binding offset pointer.
+ */
+ void SetParamBindOffsetPtr(size_t* ptr);
+
+ /**
+ * Get parameter binding offset pointer.
+ *
+ * @return Parameter binding offset pointer.
+ */
+ size_t* GetParamBindOffsetPtr();
+
+ /**
+ * Get value of the column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ */
+ void GetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Prepare SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @param query SQL query.
+ */
+ void PrepareSqlQuery(const std::string& query);
+
+ /**
+ * Prepare SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @param query SQL query.
+ * @param len Query length.
+ */
+ void PrepareSqlQuery(const char* query, size_t len);
+
+ /**
+ * Execute SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @param query SQL query.
+ */
+ void ExecuteSqlQuery(const std::string& query);
+
+ /**
+ * Execute SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @param query SQL query.
+ * @param len Query length.
+ */
+ void ExecuteSqlQuery(const char* query, size_t len);
+
+ /**
+ * Execute SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ */
+ void ExecuteSqlQuery();
+
+ /**
+ * Get columns metadata.
+ *
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param column Column search pattern.
+ */
+ void ExecuteGetColumnsMetaQuery(const std::string& schema,
+ const std::string& table, const std::string& column);
+
+ /**
+ * Get tables metadata.
+ *
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableType Table type search pattern.
+ */
+ void ExecuteGetTablesMetaQuery(const std::string& catalog,
+ const std::string& schema, const std::string& table,
+ const std::string& tableType);
+
+ /**
+ * Get foreign keys.
+ *
+ * @param primaryCatalog Primary key catalog name.
+ * @param primarySchema Primary key schema name.
+ * @param primaryTable Primary key table name.
+ * @param foreignCatalog Foreign key catalog name.
+ * @param foreignSchema Foreign key schema name.
+ * @param foreignTable Foreign key table name.
+ */
+ void ExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
+ const std::string& primarySchema, const std::string& primaryTable,
+ const std::string& foreignCatalog, const std::string& foreignSchema,
+ const std::string& foreignTable);
+
+ /**
+ * Get primary keys.
+ *
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ */
+ void ExecuteGetPrimaryKeysQuery(const std::string& catalog,
+ const std::string& schema, const std::string& table);
+
+ /**
+ * Get special columns.
+ *
+ * @param type Special column type.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param scope Minimum required scope of the rowid.
+ * @param type Determines whether to return special columns that
+ * can have a NULL value.
+ */
+ void ExecuteSpecialColumnsQuery(int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable);
+
+ /**
+ * Get type info.
+ *
+ * @param sqlType SQL type for which to return info or SQL_ALL_TYPES.
+ */
+ void ExecuteGetTypeInfoQuery(int16_t sqlType);
+
+ /**
+ * Close statement.
+ */
+ void Close();
+
+ /**
+ * Fetch query result row.
+ */
+ void FetchRow();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ const meta::ColumnMetaVector* GetMeta() const;
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ bool DataAvailable() const;
+
+ /**
+ * Get column attribute.
+ *
+ * @param colIdx Column index.
+ * @param attrId Attribute ID.
+ * @param strbuf Buffer for string attribute value.
+ * @param buflen String buffer size.
+ * @param reslen Buffer to put resulting string length to.
+ * @param numbuf Numeric value buffer.
+ */
+ void GetColumnAttribute(uint16_t colIdx, uint16_t attrId, char* strbuf,
+ int16_t buflen, int16_t* reslen, SqlLen* numbuf);
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ int64_t AffectedRows();
+
+ /**
+ * Set rows fetched buffer pointer.
+ *
+ * @param ptr Rows fetched buffer pointer.
+ */
+ void SetRowsFetchedPtr(size_t* ptr);
+
+ /**
+ * Get rows fetched buffer pointer.
+ *
+ * @return Rows fetched buffer pointer.
+ */
+ size_t* GetRowsFetchedPtr();
+
+ /**
+ * Set row statuses array pointer.
+ *
+ * @param ptr Row statuses array pointer.
+ */
+ void SetRowStatusesPtr(uint16_t* ptr);
+
+ /**
+ * Get row statuses array pointer.
+ *
+ * @return Row statuses array pointer.
+ */
+ uint16_t* GetRowStatusesPtr();
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Statement);
+
+ /**
+ * Get value of the column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ SqlResult InternalGetColumnData(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close statement.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalClose();
+
+ /**
+ * Prepare SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @param query SQL query.
+ * @param len Query length.
+ * @return Operation result.
+ */
+ SqlResult InternalPrepareSqlQuery(const char* query, size_t len);
+
+ /**
+ * Execute SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @param query SQL query.
+ * @param len Query length.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteSqlQuery(const char* query, size_t len);
+
+ /**
+ * Execute SQL query.
+ *
+ * @note Only SELECT queries are supported currently.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteSqlQuery();
+
+ /**
+ * Fetch query result row.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalFetchRow();
+
+ /**
+ * Get number of columns in the result set.
+ *
+ * @param res Columns number.
+ * @return Operation result.
+ */
+ SqlResult InternalGetColumnNumber(int32_t &res);
+
+ /**
+ * Get columns metadata.
+ *
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param column Column search pattern.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteGetColumnsMetaQuery(const std::string& schema,
+ const std::string& table, const std::string& column);
+
+ /**
+ * Get tables metadata.
+ *
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableType Table type search pattern.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteGetTablesMetaQuery(const std::string& catalog,
+ const std::string& schema, const std::string& table,
+ const std::string& tableType);
+
+ /**
+ * Get foreign keys.
+ *
+ * @param primaryCatalog Primary key catalog name.
+ * @param primarySchema Primary key schema name.
+ * @param primaryTable Primary key table name.
+ * @param foreignCatalog Foreign key catalog name.
+ * @param foreignSchema Foreign key schema name.
+ * @param foreignTable Foreign key table name.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
+ const std::string& primarySchema, const std::string& primaryTable,
+ const std::string& foreignCatalog, const std::string& foreignSchema,
+ const std::string& foreignTable);
+
+ /**
+ * Get primary keys.
+ *
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteGetPrimaryKeysQuery(const std::string& catalog,
+ const std::string& schema, const std::string& table);
+
+ /**
+ * Get special columns.
+ *
+ * @param type Special column type.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param scope Minimum required scope of the rowid.
+ * @param nullable Determines whether to return special columns
+ * that can have a NULL value.
+ * @return Operation result.
+ */
+ SqlResult InternalExecuteSpecialColumnsQuery(int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable);
+
+ /**
+ * Get type info.
+ *
+ * @param sqlType SQL type for which to return info or SQL_ALL_TYPES.
+ */
+ SqlResult InternalExecuteGetTypeInfoQuery(int16_t sqlType);
+
+ /**
+ * Get column attribute.
+ *
+ * @param colIdx Column index.
+ * @param attrId Attribute ID.
+ * @param strbuf Buffer for string attribute value.
+ * @param buflen String buffer size.
+ * @param reslen Buffer to put resulting string length to.
+ * @param numbuf Numeric value buffer.
+ * @return Operation result.
+ */
+ SqlResult InternalGetColumnAttribute(uint16_t colIdx, uint16_t attrId,
+ char* strbuf, int16_t buflen, int16_t* reslen, SqlLen* numbuf);
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @param rowCnt Number of rows affected by the statement.
+ * @return Operation result.
+ */
+ SqlResult InternalAffectedRows(int64_t& rowCnt);
+
+ /**
+ * Constructor.
+ * Called by friend classes.
+ *
+ * @param parent Connection associated with the statement.
+ */
+ Statement(Connection& parent);
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Column bindings. */
+ app::ColumnBindingMap columnBindings;
+
+ /** Parameter bindings. */
+ app::ParameterBindingMap paramBindings;
+
+ /** Underlying query. */
+ std::auto_ptr<query::Query> currentQuery;
+
+ /** Buffer to store number of rows fetched by the last fetch. */
+ size_t* rowsFetched;
+
+ /** Array to store statuses of rows fetched by the last fetch. */
+ uint16_t* rowStatuses;
+
+ /** Offset added to pointers to change binding of parameters. */
+ size_t* paramBindOffset;
+
+ /* Offset added to pointers to change binding of column data. */
+ size_t* columnBindOffset;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
new file mode 100644
index 0000000..0262be5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
@@ -0,0 +1,45 @@
+/*
+ * 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_ODBC_CONSTANTS
+#define _IGNITE_ODBC_DRIVER_ODBC_CONSTANTS
+
+#ifdef _WIN32
+
+#define _WINSOCKAPI_
+#include <windows.h>
+
+#ifdef min
+# undef min
+#endif // min
+
+#ifdef GetMessage
+# undef GetMessage
+#endif // GetMessage
+
+#endif //_WIN32
+
+#define ODBCVER 0x0380
+
+#include <sqlext.h>
+#include <odbcinst.h>
+
+#ifndef UNREFERENCED_PARAMETER
+#define UNREFERENCED_PARAMETER(x) (void)(x)
+#endif // UNREFERENCED_PARAMETER
+
+#endif //_IGNITE_ODBC_DRIVER_ODBC_CONSTANTS
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/system/socket_client.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/socket_client.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/socket_client.h
new file mode 100644
index 0000000..8a59e15
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/socket_client.h
@@ -0,0 +1,92 @@
+/*
+ * 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_SOCKET_CLIENT
+#define _IGNITE_ODBC_DRIVER_SOCKET_CLIENT
+
+#include <stdint.h>
+
+#include "ignite/common/common.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace tcp
+ {
+ /**
+ * Socket client implementation.
+ */
+ class SocketClient
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ SocketClient();
+
+ /**
+ * Destructor.
+ */
+ ~SocketClient();
+
+ /**
+ * Establish connection with remote TCP service.
+ *
+ * @param hostname Remote host name.
+ * @param port TCP service port.
+ * @return True on success.
+ */
+ bool Connect(const char* hostname, uint16_t port);
+
+ /**
+ * Close established connection.
+ *
+ * @return True on success.
+ */
+ void Close();
+
+ /**
+ * Send data by established connection.
+ *
+ * @param data Pointer to data to be sent.
+ * @param size Size of the data in bytes.
+ * @return Number of bytes that have been sent on success and negative
+ * value on failure.
+ */
+ int Send(const int8_t* data, size_t size);
+
+ /**
+ * Receive data from established connection.
+ *
+ * @param data Pointer to data buffer.
+ * @param size Size of the buffer in bytes.
+ * @return Number of bytes that have been received on success and negative
+ * value on failure.
+ */
+ int Receive(int8_t* buffer, size_t size);
+
+ private:
+ intptr_t socketHandle;
+
+ IGNITE_NO_COPY_ASSIGNMENT(SocketClient)
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h b/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
new file mode 100644
index 0000000..230a4ec
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
@@ -0,0 +1,313 @@
+/*
+ * 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_TRAITS
+#define _IGNITE_ODBC_DRIVER_TYPE_TRAITS
+
+#include <stdint.h>
+
+#include <string>
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace type_traits
+ {
+#ifdef ODBC_DEBUG
+ /**
+ * Convert statement attribute ID to string containing its name.
+ * Debug function.
+ * @param type Attribute ID.
+ * @return Null-terminated string containing attribute name.
+ */
+ const char* StatementAttrIdToString(long id);
+#endif
+
+ /**
+ * ODBC type aliases.
+ * We use these so we will not be needed to include system-specific
+ * headers in our header files.
+ */
+ enum IgniteSqlType
+ {
+ /** Alias for the SQL_C_CHAR type. */
+ IGNITE_ODBC_C_TYPE_CHAR,
+
+ /** Alias for the SQL_C_WCHAR type. */
+ IGNITE_ODBC_C_TYPE_WCHAR,
+
+ /** Alias for the SQL_C_SSHORT type. */
+ IGNITE_ODBC_C_TYPE_SIGNED_SHORT,
+
+ /** Alias for the SQL_C_USHORT type. */
+ IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT,
+
+ /** Alias for the SQL_C_SLONG type. */
+ IGNITE_ODBC_C_TYPE_SIGNED_LONG,
+
+ /** Alias for the SQL_C_ULONG type. */
+ IGNITE_ODBC_C_TYPE_UNSIGNED_LONG,
+
+ /** Alias for the SQL_C_FLOAT type. */
+ IGNITE_ODBC_C_TYPE_FLOAT,
+
+ /** Alias for the SQL_C_DOUBLE type. */
+ IGNITE_ODBC_C_TYPE_DOUBLE,
+
+ /** Alias for the SQL_C_BIT type. */
+ IGNITE_ODBC_C_TYPE_BIT,
+
+ /** Alias for the SQL_C_STINYINT type. */
+ IGNITE_ODBC_C_TYPE_SIGNED_TINYINT,
+
+ /** Alias for the SQL_C_UTINYINT type. */
+ IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT,
+
+ /** Alias for the SQL_C_SBIGINT type. */
+ IGNITE_ODBC_C_TYPE_SIGNED_BIGINT,
+
+ /** Alias for the SQL_C_UBIGINT type. */
+ IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT,
+
+ /** Alias for the SQL_C_BINARY type. */
+ IGNITE_ODBC_C_TYPE_BINARY,
+
+ /** Alias for the SQL_C_TDATE type. */
+ IGNITE_ODBC_C_TYPE_TDATE,
+
+ /** Alias for the SQL_C_TTIME type. */
+ IGNITE_ODBC_C_TYPE_TTIME,
+
+ /** Alias for the SQL_C_TTIMESTAMP type. */
+ IGNITE_ODBC_C_TYPE_TTIMESTAMP,
+
+ /** Alias for the SQL_C_NUMERIC type. */
+ IGNITE_ODBC_C_TYPE_NUMERIC,
+
+ /** Alias for the SQL_C_GUID type. */
+ IGNITE_ODBC_C_TYPE_GUID,
+
+ /** Alias for the SQL_DEFAULT. */
+ IGNITE_ODBC_C_TYPE_DEFAULT,
+
+ /** Alias for all unsupported types. */
+ IGNITE_ODBC_C_TYPE_UNSUPPORTED
+ };
+
+ /**
+ * SQL type name constants.
+ */
+ class SqlTypeName
+ {
+ public:
+ /** VARCHAR SQL type name constant. */
+ static const std::string VARCHAR;
+
+ /** SMALLINT SQL type name constant. */
+ static const std::string SMALLINT;
+
+ /** INTEGER SQL type name constant. */
+ static const std::string INTEGER;
+
+ /** DECIMAL SQL type name constant. */
+ static const std::string DECIMAL;
+
+ /** FLOAT SQL type name constant. */
+ static const std::string FLOAT;
+
+ /** DOUBLE SQL type name constant. */
+ static const std::string DOUBLE;
+
+ /** BIT SQL type name constant. */
+ static const std::string BIT;
+
+ /** TINYINT SQL type name constant. */
+ static const std::string TINYINT;
+
+ /** BIGINT SQL type name constant. */
+ static const std::string BIGINT;
+
+ /** BINARY SQL type name constant. */
+ static const std::string BINARY;
+
+ /** DATE SQL type name constant. */
+ static const std::string DATE;
+
+ /** GUID SQL type name constant. */
+ static const std::string GUID;
+ };
+
+ /**
+ * Get SQL type name for the binary type.
+ *
+ * @param binaryType Binary type.
+ * @return Corresponding SQL type name.
+ */
+ const std::string& BinaryTypeToSqlTypeName(int8_t binaryType);
+
+ /**
+ * Check if the C type supported by the current implementation.
+ *
+ * @param type Application type.
+ * @return True if the type is supported.
+ */
+ bool IsApplicationTypeSupported(int16_t type);
+
+ /**
+ * Check if the SQL type supported by the current implementation.
+ *
+ * @param type Application type.
+ * @return True if the type is supported.
+ */
+ 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;
+ * @return Internal driver type.
+ */
+ IgniteSqlType ToDriverType(int16_t type);
+
+ /**
+ * Convert binary data type to SQL data type.
+ *
+ * @param binaryType Binary data type.
+ * @return SQL data type.
+ */
+ int16_t BinaryToSqlType(int8_t binaryType);
+
+ /**
+ * Get binary type SQL nullability.
+ *
+ * @param binaryType Binary data type.
+ * @return SQL_NO_NULLS if the column could not include NULL values.
+ * SQL_NULLABLE if the column accepts NULL values.
+ * SQL_NULLABLE_UNKNOWN if it is not known whether the
+ * column accepts NULL values.
+ */
+ int16_t BinaryTypeNullability(int8_t binaryType);
+
+ /**
+ * Get SQL type display size.
+ *
+ * @param type SQL type.
+ * @return Display size.
+ */
+ int32_t SqlTypeDisplaySize(int16_t type);
+
+ /**
+ * Get binary type display size.
+ *
+ * @param type Binary type.
+ * @return Display size.
+ */
+ int32_t BinaryTypeDisplaySize(int8_t type);
+
+ /**
+ * Get SQL type column size.
+ *
+ * @param type SQL type.
+ * @return Column size.
+ */
+ int32_t SqlTypeColumnSize(int16_t type);
+
+ /**
+ * Get binary type column size.
+ *
+ * @param type Binary type.
+ * @return Column size.
+ */
+ int32_t BinaryTypeColumnSize(int8_t type);
+
+ /**
+ * Get SQL type transfer octet length.
+ *
+ * @param type SQL type.
+ * @return Transfer octet length.
+ */
+ int32_t SqlTypeTransferLength(int16_t type);
+
+ /**
+ * Get binary type transfer octet length.
+ *
+ * @param type Binary type.
+ * @return Transfer octet length.
+ */
+ int32_t BinaryTypeTransferLength(int8_t type);
+
+ /**
+ * Get SQL type numeric precision radix.
+ *
+ * @param type SQL type.
+ * @return Numeric precision radix.
+ */
+ int32_t SqlTypeNumPrecRadix(int8_t type);
+
+ /**
+ * Get binary type numeric precision radix.
+ *
+ * @param type Binary type.
+ * @return Numeric precision radix.
+ */
+ int32_t BinaryTypeNumPrecRadix(int8_t type);
+
+ /**
+ * Get SQL type decimal digits.
+ *
+ * @param type SQL type.
+ * @return Decimal digits.
+ */
+ int32_t SqlTypeDecimalDigits(int16_t type);
+
+ /**
+ * Get binary type decimal digits.
+ *
+ * @param type Binary type.
+ * @return Decimal digits.
+ */
+ int32_t BinaryTypeDecimalDigits(int8_t type);
+
+ /**
+ * Checks if the SQL type is unsigned.
+ *
+ * @param type SQL type.
+ * @return True if unsigned or non-numeric.
+ */
+ bool SqlTypeUnsigned(int16_t type);
+
+ /**
+ * Checks if the binary type is unsigned.
+ *
+ * @param type Binary type.
+ * @return True if unsigned or non-numeric.
+ */
+ bool BinaryTypeUnsigned(int8_t type);
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
new file mode 100644
index 0000000..4a2e928
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
@@ -0,0 +1,171 @@
+/*
+ * 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_UTILITY
+#define _IGNITE_ODBC_DRIVER_UTILITY
+
+#include <string>
+#include <stdint.h>
+
+#ifdef min
+# undef min
+#endif //min
+
+#include <algorithm>
+
+#include <ignite/common/utils.h>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/impl/binary/binary_writer_impl.h"
+
+#include "ignite/odbc/decimal.h"
+
+#ifdef ODBC_DEBUG
+
+extern FILE* log_file;
+void logInit(const char*);
+
+# define LOG_MSG(fmt, ...) \
+ do { \
+ logInit(ODBC_LOG_PATH); \
+ fprintf(log_file, "%s: " fmt, __FUNCTION__, __VA_ARGS__); \
+ fflush(log_file); \
+ } while (false)
+
+#else
+# define LOG_MSG(...)
+#endif
+
+namespace ignite
+{
+ namespace utility
+ {
+ /** Using common version of the util. */
+ using ignite::common::utils::IntoLower;
+
+ /**
+ * Skip leading spaces.
+ *
+ * @param begin Iterator to the beginning of the character sequence.
+ * @param end Iterator to the end of the character sequence.
+ * @return Iterator to first non-blanc character.
+ */
+ template<typename Iterator>
+ Iterator SkipLeadingSpaces(Iterator begin, Iterator end)
+ {
+ Iterator res = begin;
+
+ while (isspace(*res) && res != end)
+ ++res;
+
+ return res;
+ }
+
+ /**
+ * Skip trailing spaces.
+ *
+ * @param begin Iterator to the beginning of the character sequence.
+ * @param end Iterator to the end of the character sequence.
+ * @return Iterator to last non-blanc character.
+ */
+ template<typename Iterator>
+ Iterator SkipTrailingSpaces(Iterator begin, Iterator end)
+ {
+ Iterator res = end - 1;
+
+ while (isspace(*res) && res != begin - 1)
+ --res;
+
+ return res + 1;
+ }
+
+ /**
+ * Remove leading and trailing spaces.
+ *
+ * @param begin Iterator to the beginning of the character sequence.
+ * @param end Iterator to the end of the character sequence.
+ * @return String without leading and trailing spaces.
+ */
+ template<typename Iterator>
+ std::string RemoveSurroundingSpaces(Iterator begin, Iterator end)
+ {
+ std::string res;
+
+ if (begin >= end)
+ return res;
+
+ Iterator skipped_leading = SkipLeadingSpaces(begin, end);
+ Iterator skipped_trailing = SkipTrailingSpaces(skipped_leading, end);
+
+ res.reserve(skipped_trailing - skipped_leading);
+
+ std::copy(skipped_leading, skipped_trailing, std::back_insert_iterator<std::string>(res));
+
+ return res;
+ }
+
+ template<typename T>
+ T* GetPointerWithOffset(T* ptr, size_t offset)
+ {
+ uint8_t* ptrBytes = (uint8_t*)ptr;
+
+ return (T*)(ptrBytes + offset);
+ }
+
+ /**
+ * Copy string to buffer of the specific length.
+ * @param str String to copy data from.
+ * @param buf Buffer to copy data to.
+ * @param buflen Length of the buffer.
+ * @return Length of the resulting string in buffer.
+ */
+ size_t CopyStringToBuffer(const std::string& str, char* buf, size_t buflen);
+
+ /**
+ * Read string from reader.
+ * @param reader Reader.
+ * @param str String.
+ */
+ void ReadString(ignite::impl::binary::BinaryReaderImpl& reader, std::string& str);
+
+ /**
+ * Write string using writer.
+ * @param writer Writer.
+ * @param str String.
+ */
+ void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string& str);
+
+ /**
+ * Read decimal value using reader.
+ *
+ * @param reader Reader.
+ * @param decimal Decimal value.
+ */
+ void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal& decimal);
+
+ /**
+ * Convert SQL string buffer to std::string.
+ *
+ * @param sqlStr SQL string buffer.
+ * @param sqlStrLen SQL string length.
+ * @return Standard string containing the same data.
+ */
+ std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen);
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/Makefile.am b/modules/platforms/cpp/odbc/odbc-driver/Makefile.am
deleted file mode 100644
index 09f35fd..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/Makefile.am
+++ /dev/null
@@ -1,67 +0,0 @@
-##
-## 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.
-##
-
-ACLOCAL_AMFLAGS = "-Im4"
-
-SUBDIRS = .
-DIST_SUBDIRS = .
-
-AM_CPPFLAGS = -I$(srcdir)/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
-AM_CXXFLAGS = -Wall -std=c++0x
-LIB_LDFLAGS = -no-undefined -version-info 1
-
-COMMON_SRC = os/linux/src/system/socket_client.cpp \
- src/app/application_data_buffer.cpp \
- src/app/parameter.cpp \
- src/common_types.cpp \
- src/config/configuration.cpp \
- src/config/connection_info.cpp \
- src/connection.cpp \
- src/cursor.cpp \
- src/decimal.cpp \
- src/diagnostic/diagnosable_adapter.cpp \
- src/diagnostic/diagnostic_record.cpp \
- src/diagnostic/diagnostic_record_storage.cpp \
- src/environment.cpp \
- src/meta/column_meta.cpp \
- src/meta/table_meta.cpp \
- src/odbc.cpp \
- src/query/column_metadata_query.cpp \
- src/query/data_query.cpp \
- src/query/foreign_keys_query.cpp \
- src/query/primary_keys_query.cpp \
- src/query/table_metadata_query.cpp \
- src/query/type_info_query.cpp \
- src/result_page.cpp \
- src/row.cpp \
- src/statement.cpp \
- src/type_traits.cpp \
- src/utility.cpp
-
-
-lib_LTLIBRARIES = libignite-odbc.la
-libignite_odbc_la_SOURCES = $(COMMON_SRC)
-libignite_odbc_la_LDFLAGS = $(LIB_LDFLAGS) -L/usr/local/lib -lignite-common -lignite-binary -ldl -version-info 0:0:0 -release $(PACKAGE_VERSION)
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = ignite-odbc.pc
-
-clean-local:
- $(RM) *.gcno *.gcda
-
-clean-docs:
- $(RM) $(DX_CLEANFILES)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/configure.ac b/modules/platforms/cpp/odbc/odbc-driver/configure.ac
deleted file mode 100644
index e69d73c..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/configure.ac
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# 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.
-#
-
-# -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ([2.69])
-AC_INIT([Apache Ignite ODBC driver], [1.5.1.7927], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
-AC_CONFIG_SRCDIR(src)
-
-AC_CANONICAL_SYSTEM
-AC_CONFIG_MACRO_DIR([m4])
-AC_LANG([C++])
-
-# Initialize automake
-AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
-AC_CONFIG_HEADER(config.h)
-
-AM_PROG_AR
-
-# Checks for programs.
-GXX="-g -O2"
-
-AC_PROG_CXX
-
-# Initialize Libtool
-LT_INIT
-
-# Checks for libraries.
-AC_CHECK_LIB([pthread], [pthread_mutex_lock])
-
-# Checks for header files.
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_INLINE
-AC_TYPE_INT16_T
-AC_TYPE_INT32_T
-AC_TYPE_INT64_T
-AC_TYPE_INT8_T
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-
-# Checks for library functions.
-AC_FUNC_ERROR_AT_LINE
-
-AC_CONFIG_FILES(Makefile ignite-odbc.pc)
-
-AC_OUTPUT
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/ignite-odbc.pc.in
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/ignite-odbc.pc.in b/modules/platforms/cpp/odbc/odbc-driver/ignite-odbc.pc.in
deleted file mode 100644
index 13cd7e9..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/ignite-odbc.pc.in
+++ /dev/null
@@ -1,9 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: ignite-odbc
-Description: Apache Ignite ODBC driver.
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lignite-odbc
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
deleted file mode 100644
index 051f459..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * 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_APPLICATION_DATA_BUFFER
-#define _IGNITE_ODBC_DRIVER_APPLICATION_DATA_BUFFER
-
-#include <stdint.h>
-
-#include <map>
-
-#include <ignite/guid.h>
-
-#include "ignite/odbc/decimal.h"
-#include "ignite/odbc/common_types.h"
-#include "ignite/odbc/type_traits.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace app
- {
- /**
- * User application data buffer.
- */
- class ApplicationDataBuffer
- {
- public:
- /**
- * Default constructor.
- */
- ApplicationDataBuffer();
-
- /**
- * Constructor.
- *
- * @param type Underlying data type.
- * @param buffer Data buffer pointer.
- * @param buflen Data buffer length.
- * @param reslen Resulting data length.
- * @param offset Pointer to buffer and reslen offset pointer.
- */
- ApplicationDataBuffer(type_traits::IgniteSqlType type, void* buffer, SqlLen buflen, SqlLen* reslen, size_t** offset = 0);
-
- /**
- * Copy constructor.
- *
- * @param other Other instance.
- */
- ApplicationDataBuffer(const ApplicationDataBuffer& other);
-
- /**
- * Destructor.
- */
- ~ApplicationDataBuffer();
-
- /**
- * Copy assigment operator.
- *
- * @param other Other instance.
- * @return This.
- */
- ApplicationDataBuffer& operator=(const ApplicationDataBuffer& other);
-
- /**
- * Set pointer to offset pointer.
- *
- * @param offset Pointer to offset pointer.
- */
- void SetPtrToOffsetPtr(size_t** offset)
- {
- this->offset = offset;
- }
-
- /**
- * Put in buffer value of type int8_t.
- *
- * @param value Value.
- */
- void PutInt8(int8_t value);
-
- /**
- * Put in buffer value of type int16_t.
- *
- * @param value Value.
- */
- void PutInt16(int16_t value);
-
- /**
- * Put in buffer value of type int32_t.
- *
- * @param value Value.
- */
- void PutInt32(int32_t value);
-
- /**
- * Put in buffer value of type int64_t.
- *
- * @param value Value.
- */
- void PutInt64(int64_t value);
-
- /**
- * Put in buffer value of type float.
- *
- * @param value Value.
- */
- void PutFloat(float value);
-
- /**
- * Put in buffer value of type double.
- *
- * @param value Value.
- */
- void PutDouble(double value);
-
- /**
- * Put in buffer value of type string.
- *
- * @param value Value.
- * @return Number of bytes that have been put in buffer.
- */
- int32_t PutString(const std::string& value);
-
- /**
- * Put in buffer value of type GUID.
- *
- * @param value Value.
- */
- void PutGuid(const Guid& value);
-
- /**
- * Put binary data in buffer.
- *
- * @param data Data pointer.
- * @param len Data length.
- * @return Number of bytes that have been put in buffer.
- */
- int32_t PutBinaryData(void* data, size_t len);
-
- /**
- * Put NULL.
- */
- void PutNull();
-
- /**
- * Put decimal value to buffer.
- *
- * @param value Value to put.
- */
- void PutDecimal(const Decimal& value);
-
- /**
- * Get string.
- *
- * @return String value of buffer.
- */
- std::string GetString(size_t maxLen) const;
-
- /**
- * Get value of type int8_t.
- *
- * @return Integer value of type int8_t.
- */
- int8_t GetInt8() const;
-
- /**
- * Get value of type int16_t.
- *
- * @return Integer value of type int16_t.
- */
- int16_t GetInt16() const;
-
- /**
- * Get value of type int32_t.
- *
- * @return Integer value of type int32_t.
- */
- int32_t GetInt32() const;
-
- /**
- * Get value of type int64_t.
- *
- * @return Integer value of type int64_t.
- */
- int64_t GetInt64() const;
-
- /**
- * Get value of type float.
- *
- * @return Integer value of type float.
- */
- float GetFloat() const;
-
- /**
- * Get value of type double.
- *
- * @return Integer value of type double.
- */
- double GetDouble() const;
-
- /**
- * Get raw data.
- *
- * @return Buffer data.
- */
- const void* GetData() const;
-
- /**
- * Get result data length.
- *
- * @return Data length pointer.
- */
- const SqlLen* GetResLen() const;
-
- /**
- * Get buffer size in bytes.
- *
- * @return Buffer size.
- */
- SqlLen GetSize() const
- {
- return buflen;
- }
-
- private:
- /**
- * Get raw data.
- *
- * @return Buffer data.
- */
- void* GetData();
-
- /**
- * Get result data length.
- *
- * @return Data length pointer.
- */
- SqlLen* GetResLen();
-
- /**
- * Put value of numeric type in the buffer.
- *
- * @param value Numeric value to put.
- */
- template<typename T>
- void PutNum(T value);
-
- /**
- * Put numeric value to numeric buffer.
- *
- * @param value Numeric value.
- */
- template<typename Tbuf, typename Tin>
- void PutNumToNumBuffer(Tin value);
-
- /**
- * Put value to string buffer.
- *
- * @param value Value that can be converted to string.
- */
- template<typename CharT, typename Tin>
- void PutValToStrBuffer(const Tin& value);
-
- /**
- * Put value to string buffer.
- * Specialisation for int8_t.
- * @param value Value that can be converted to string.
- */
- template<typename CharT>
- void PutValToStrBuffer(const int8_t & value);
-
- /**
- * Put string to string buffer.
- *
- * @param value String value.
- */
- template<typename OutCharT, typename InCharT>
- void PutStrToStrBuffer(const std::basic_string<InCharT>& value);
-
- /**
- * Put raw data to any buffer.
- *
- * @param data Data pointer.
- * @param len Data length.
- */
- void PutRawDataToBuffer(void *data, size_t len);
-
- /**
- * Get int of type T.
- *
- * @return Integer value of specified type.
- */
- template<typename T>
- T GetNum() const;
-
- /**
- * Apply buffer offset to pointer.
- * Adds offset to pointer if offset pointer is not null.
- * @param ptr Pointer.
- * @return Pointer with applied offset.
- */
- template<typename T>
- T* ApplyOffset(T* ptr) const;
-
- /** Underlying data type. */
- type_traits::IgniteSqlType type;
-
- /** Buffer pointer. */
- void* buffer;
-
- /** Buffer length. */
- SqlLen buflen;
-
- /** Result length. */
- SqlLen* reslen;
-
- /** Pointer to implementation pointer to application offset */
- size_t** offset;
- };
-
- /** Column binging map type alias. */
- typedef std::map<uint16_t, ApplicationDataBuffer> ColumnBindingMap;
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/parameter.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/parameter.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/parameter.h
deleted file mode 100644
index 8756f48..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/parameter.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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_APP_PARAMETER
-#define _IGNITE_ODBC_DRIVER_APP_PARAMETER
-
-#include <stdint.h>
-
-#include <map>
-
-#include <ignite/guid.h>
-#include <ignite/impl/binary/binary_writer_impl.h>
-#include <ignite/impl/binary/binary_reader_impl.h>
-
-#include "ignite/odbc/app/application_data_buffer.h"
-#include "ignite/odbc/type_traits.h"
-
-namespace ignite
-{
- namespace odbc
- {
- namespace app
- {
- /**
- * Statement parameter.
- */
- class Parameter
- {
- public:
- /**
- * Default constructor.
- */
- Parameter();
-
- /**
- * Constructor.
- *
- * @param buffer Underlying data buffer.
- * @param sqlType IPD type.
- * @param columnSize IPD column size.
- * @param decDigits IPD decimal digits.
- */
- Parameter(const ApplicationDataBuffer& buffer, int16_t sqlType,
- size_t columnSize, int16_t decDigits);
-
- /**
- * Copy constructor.
- *
- * @param other Other instance.
- */
- Parameter(const Parameter& other);
-
- /**
- * Destructor.
- */
- ~Parameter();
-
- /**
- * Copy assigment operator.
- *
- * @param other Other instance.
- * @return This.
- */
- Parameter& operator=(const Parameter& other);
-
- /**
- * Write request using provided writer.
- * @param writer Writer.
- */
- void Write(ignite::impl::binary::BinaryWriterImpl& writer) const;
-
- /**
- * Get data buffer.
- *
- * @return underlying ApplicationDataBuffer instance.
- */
- ApplicationDataBuffer& GetBuffer();
-
- private:
- /** Underlying data buffer. */
- ApplicationDataBuffer buffer;
-
- /** IPD type. */
- int16_t sqlType;
-
- /** IPD column size. */
- size_t columnSize;
-
- /** IPD decimal digits. */
- int16_t decDigits;
- };
-
- /** Parameter binging map type alias. */
- typedef std::map<uint16_t, Parameter> ParameterBindingMap;
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/column.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/column.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/column.h
deleted file mode 100644
index dc0b6d9..0000000
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/column.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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_COLUMN
-#define _IGNITE_ODBC_DRIVER_COLUMN
-
-#include <stdint.h>
-
-#include <ignite/impl/binary/binary_reader_impl.h>
-
-#include "ignite/odbc/app/application_data_buffer.h"
-
-namespace ignite
-{
- namespace odbc
- {
- /**
- * Result set column.
- */
- class Column
- {
- public:
- /**
- * Default constructor.
- */
- Column();
-
- /**
- * Copy constructor.
- *
- * @param other Another instance.
- */
- Column(const Column& other);
-
- /**
- * Copy operator.
- *
- * @param other Another instance.
- * @return This.
- */
- Column& operator=(const Column& other);
-
- /**
- * Destructor.
- */
- ~Column();
-
- /**
- * Constructor.
- *
- * @param reader Reader to be used to retrieve column data.
- */
- Column(ignite::impl::binary::BinaryReaderImpl& reader);
-
- /**
- * Get column size in bytes.
- *
- * @return Column size.
- */
- int32_t GetSize() const
- {
- return size;
- }
-
- /**
- * Read column data and store it in application data buffer.
- *
- * @param dataBuf Application data buffer.
- * @return Operation result.
- */
- SqlResult ReadToBuffer(ignite::impl::binary::BinaryReaderImpl& reader,
- app::ApplicationDataBuffer& dataBuf);
-
- /**
- * Check if the column is in valid state.
- *
- * @return True if valid.
- */
- bool IsValid() const
- {
- return startPos >= 0;
- }
-
- /**
- * Get unread data length.
- * Find out how many bytes of data are left unread.
- *
- * @return Lengh of unread data in bytes.
- */
- int32_t GetUnreadDataLength() const
- {
- return size - offset;
- }
-
- /**
- * Get unread data length.
- * Find out how many bytes of data are left unread.
- *
- * @return Lengh of unread data in bytes.
- */
- int32_t GetEndPosition() const
- {
- return endPos;
- }
-
- private:
- /**
- * Increase offset.
- *
- * Increases offset on specified value and makes sure resulting
- * offset does not exceed column size.
- *
- * @param value Offset is incremented on this value.
- */
- void IncreaseOffset(int32_t value);
-
- /** Column type */
- int8_t type;
-
- /** Column position in current row. */
- int32_t startPos;
-
- /** Column end position in current row. */
- int32_t endPos;
-
- /** Current offset in column. */
- int32_t offset;
-
- /** Column data size in bytes. */
- int32_t size;
- };
- }
-}
-
-#endif
\ No newline at end of file