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:56 UTC
[23/28] ignite git commit: IGNITE-2442: ODBC projects moved to main
cpp solution.
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