You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/05/12 06:42:01 UTC
[07/60] [abbrv] ignite git commit: IGNITE-1786: Implemented ODBC
driver.
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..a2f5318
--- /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_META_PRIMARY_KEY_META
+#define _IGNITE_ODBC_META_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 //_IGNITE_ODBC_META_PRIMARY_KEY_META
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..b02d43c
--- /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_META_TABLE_META
+#define _IGNITE_ODBC_META_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 //_IGNITE_ODBC_META_TABLE_META
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..c19e08c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.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_PARSER
+#define _IGNITE_ODBC_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 };
+
+ /** ODBC communication protocol version. */
+ enum { PROTOCOL_VERSION = 1 };
+
+ /**
+ * 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);
+
+ msg.Write(writer);
+
+ 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;
+
+ 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 //_IGNITE_ODBC_PARSER
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..85a9474
--- /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_QUERY_COLUMN_METADATA_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_COLUMN_METADATA_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..3db3b46
--- /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_QUERY_DATA_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_DATA_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..0fb1e5f
--- /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_QUERY_FOREIGN_KEYS_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_FOREIGN_KEYS_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..5cb7b6e
--- /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_QUERY_PRIMARY_KEYS_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_PRIMARY_KEYS_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..1b3512d
--- /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_QUERY_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..1d2f339
--- /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_QUERY_SPECIAL_COLUMNS_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_SPECIAL_COLUMNS_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..6322435
--- /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_QUERY_TABLE_METADATA_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_TABLE_METADATA_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..d337d03
--- /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_QUERY_TYPE_INFO_QUERY
+#define _IGNITE_ODBC_QUERY_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 //_IGNITE_ODBC_QUERY_TYPE_INFO_QUERY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..3533229
--- /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_RESULT_PAGE
+#define _IGNITE_ODBC_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 //_IGNITE_ODBC_RESULT_PAGE
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..888432e
--- /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_ROW
+#define _IGNITE_ODBC_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 //_IGNITE_ODBC_ROW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..97d586f
--- /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_STATEMENT
+#define _IGNITE_ODBC_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 //_IGNITE_ODBC_STATEMENT
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/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..60a6552
--- /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_SYSTEM_ODBC_CONSTANTS
+#define _IGNITE_ODBC_SYSTEM_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_SYSTEM_ODBC_CONSTANTS