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:57 UTC
[24/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/diagnostic/diagnostic_record_storage.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
new file mode 100644
index 0000000..c92c7a5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record_storage.h
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_DIAGNOSTIC_RECORD_STORAGE
+#define _IGNITE_ODBC_DRIVER_DIAGNOSTIC_RECORD_STORAGE
+
+#include <stdint.h>
+
+#include <vector>
+
+#include <ignite/common/common.h>
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/app/application_data_buffer.h"
+#include "ignite/odbc/diagnostic/diagnostic_record.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace diagnostic
+ {
+ /**
+ * Diagnostic record.
+ *
+ * Associated with each environment, connection, statement, and
+ * descriptor handle are diagnostic records. These records contain
+ * diagnostic information about the last function called that used
+ * a particular handle. The records are replaced only when another
+ * function is called using that handle. There is no limit to the
+ * number of diagnostic records that can be stored at any one time.
+ *
+ * This class provides interface for interaction with all handle
+ * diagnostic records. That means both header and status records.
+ */
+ class DiagnosticRecordStorage
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ DiagnosticRecordStorage();
+
+ /**
+ * Destructor.
+ */
+ ~DiagnosticRecordStorage();
+
+ /**
+ * Set header record values.
+ *
+ * @param retCode Operation return code.
+ */
+ void SetHeaderRecord(SqlResult result);
+
+ /**
+ * Add status record to diagnostic records.
+ *
+ * @param record Status record.
+ */
+ void AddStatusRecord(const DiagnosticRecord& record);
+
+ /**
+ * Reset diagnostic records state.
+ */
+ void Reset();
+
+ /**
+ * Get result of the last operation.
+ *
+ * @return Result of the last operation.
+ */
+ SqlResult GetOperaionResult() const;
+
+ /**
+ * Get return code of the last operation.
+ *
+ * @return Return code of the last operation.
+ */
+ int GetReturnCode() const;
+
+ /**
+ * Get row count.
+ *
+ * @return Count of rows in cursor.
+ */
+ int64_t GetRowCount() const;
+
+ /**
+ * Get dynamic function.
+ *
+ * @return String that describes the SQL statement
+ * that the underlying function executed.
+ */
+ const std::string& GetDynamicFunction() const;
+
+ /**
+ * Get dynamic function code.
+ *
+ * @return Numeric code that describes the
+ * SQL statement that was executed.
+ */
+ int32_t GetDynamicFunctionCode() const;
+
+ /**
+ * Get number of rows affected.
+ *
+ * @return The number of rows affected by an insert,
+ * delete, or update performed by the last operation.
+ */
+ int32_t GetRowsAffected() const;
+
+ /**
+ * Get status records number.
+ *
+ * @return Number of status records.
+ */
+ int32_t GetStatusRecordsNumber() const;
+
+ /**
+ * Get specified status record.
+ *
+ * @param idx Status record index.
+ * @return Status record instance reference.
+ */
+ const DiagnosticRecord& GetStatusRecord(int32_t idx) const;
+
+ /**
+ * Check if the record is in the success state.
+ *
+ * @return True if the record is in the success state.
+ */
+ bool IsSuccessful() const;
+
+ /**
+ * Get value of the field and put it in buffer.
+ *
+ * @param recNum Diagnostic record number.
+ * @param field Record field.
+ * @param buffer Buffer to put data to.
+ * @return Operation result.
+ */
+ SqlResult GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(DiagnosticRecordStorage);
+
+ /**
+ * Header record field. This field contains the count of rows
+ * in the cursor.
+ */
+ int64_t rowCount;
+
+ /**
+ * Header record field. String that describes the SQL statement
+ * that the underlying function executed.
+ */
+ std::string dynamicFunction;
+
+ /**
+ * Header record field. Numeric code that describes the
+ * SQL statement that was executed.
+ */
+ int32_t dynamicFunctionCode;
+
+ /**
+ * Operation result. This field is mapped to "Return code" header
+ * record field.
+ */
+ SqlResult result;
+
+ /**
+ * Header record field. The number of rows affected by an insert,
+ * delete, or update performed by the last operation.
+ */
+ int32_t rowsAffected;
+
+ /** Status records. */
+ std::vector<DiagnosticRecord> statusRecords;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h b/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h
new file mode 100644
index 0000000..7168aa3
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/environment.h
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_ENVIRONMENT
+#define _IGNITE_ODBC_DRIVER_ENVIRONMENT
+
+#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ class Connection;
+
+ /**
+ * ODBC environment.
+ */
+ class Environment : public diagnostic::DiagnosableAdapter
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Environment();
+
+ /**
+ * Destructor.
+ */
+ ~Environment();
+
+ /**
+ * Create connection associated with the environment.
+ *
+ * @return Pointer to valid instance on success or NULL on failure.
+ */
+ Connection* CreateConnection();
+
+ /**
+ * Perform transaction commit on all the associated connections.
+ */
+ void TransactionCommit();
+
+ /**
+ * Perform transaction rollback on all the associated connections.
+ */
+ void TransactionRollback();
+
+ /**
+ * Set attribute.
+ *
+ * @param attr Attribute to set.
+ * @param value Value.
+ * @param len Value length if the attribute is of string type.
+ */
+ void SetAttribute(int32_t attr, void* value, int32_t len);
+
+ /**
+ * Get attribute.
+ *
+ * @param attr Attribute to set.
+ * @param buffer Buffer to put value to.
+ */
+ void GetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer);
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Environment);
+
+ /**
+ * Create connection associated with the environment.
+ * Internal call.
+ *
+ * @return Pointer to valid instance on success or NULL on failure.
+ * @return Operation result.
+ */
+ SqlResult InternalCreateConnection(Connection*& connection);
+
+ /**
+ * Perform transaction commit on all the associated connections.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalTransactionCommit();
+
+ /**
+ * Perform transaction rollback on all the associated connections.
+ * Internal call.
+ *
+ * @return Operation result.
+ */
+ SqlResult InternalTransactionRollback();
+
+ /**
+ * Set attribute.
+ * Internal call.
+ *
+ * @param attr Attribute to set.
+ * @param value Value.
+ * @param len Value length if the attribute is of string type.
+ * @return Operation result.
+ */
+ SqlResult InternalSetAttribute(int32_t attr, void* value, int32_t len);
+
+ /**
+ * Get attribute.
+ * Internal call.
+ *
+ * @param attr Attribute to set.
+ * @param buffer Buffer to put value to.
+ * @return Operation result.
+ */
+ SqlResult InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer);
+
+ /** ODBC version. */
+ int32_t odbcVersion;
+
+ /** ODBC null-termintaion of string behaviour. */
+ int32_t odbcNts;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
new file mode 100644
index 0000000..f4d1e3c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
@@ -0,0 +1,630 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_MESSAGE
+#define _IGNITE_ODBC_DRIVER_MESSAGE
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/result_page.h"
+#include "ignite/odbc/meta/column_meta.h"
+#include "ignite/odbc/meta/table_meta.h"
+#include "ignite/odbc/app/parameter.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ enum RequestType
+ {
+ REQUEST_TYPE_EXECUTE_SQL_QUERY = 1,
+
+ REQUEST_TYPE_FETCH_SQL_QUERY = 2,
+
+ REQUEST_TYPE_CLOSE_SQL_QUERY = 3,
+
+ REQUEST_TYPE_GET_COLUMNS_METADATA = 4,
+
+ REQUEST_TYPE_GET_TABLES_METADATA = 5
+ };
+
+ enum ResponseStatus
+ {
+ RESPONSE_STATUS_SUCCESS = 0,
+
+ RESPONSE_STATUS_FAILED = 1
+ };
+
+ /**
+ * Query execute request.
+ */
+ class QueryExecuteRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param cache Cache name.
+ * @param sql SQL query.
+ * @param argsNum Number of arguments.
+ */
+ QueryExecuteRequest(const std::string& cache, const std::string& sql,
+ const app::ParameterBindingMap& params) :
+ cache(cache), sql(sql), params(params)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryExecuteRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_EXECUTE_SQL_QUERY);
+ utility::WriteString(writer, cache);
+ utility::WriteString(writer, sql);
+
+ writer.WriteInt32(static_cast<int32_t>(params.size()));
+
+ app::ParameterBindingMap::const_iterator i;
+
+ for (i = params.begin(); i != params.end(); ++i)
+ i->second.Write(writer);
+ }
+
+ private:
+ /** Cache name. */
+ std::string cache;
+
+ /** SQL query. */
+ std::string sql;
+
+ /** Parameters bindings. */
+ const app::ParameterBindingMap& params;
+ };
+
+ /**
+ * Query close request.
+ */
+ class QueryCloseRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param queryId Query ID.
+ */
+ QueryCloseRequest(int64_t queryId) : queryId(queryId)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryCloseRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_CLOSE_SQL_QUERY);
+ writer.WriteInt64(queryId);
+ }
+
+ private:
+ /** Query ID. */
+ int64_t queryId;
+ };
+
+ /**
+ * Query fetch request.
+ */
+ class QueryFetchRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param queryId Query ID.
+ * @param pageSize Required page size.
+ */
+ QueryFetchRequest(int64_t queryId, int32_t pageSize) :
+ queryId(queryId), pageSize(pageSize)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryFetchRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_FETCH_SQL_QUERY);
+ writer.WriteInt64(queryId);
+ writer.WriteInt32(pageSize);
+ }
+
+ private:
+ /** Query ID. */
+ int64_t queryId;
+
+ /** SQL query. */
+ int32_t pageSize;
+ };
+
+ /**
+ * Query get columns metadata request.
+ */
+ class QueryGetColumnsMetaRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param column Column name.
+ */
+ QueryGetColumnsMetaRequest(const std::string& schema, const std::string& table, const std::string& column) :
+ schema(schema), table(table), column(column)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetColumnsMetaRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_GET_COLUMNS_METADATA);
+
+ utility::WriteString(writer, schema);
+ utility::WriteString(writer, table);
+ utility::WriteString(writer, column);
+ }
+
+ private:
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Column search pattern. */
+ std::string column;
+ };
+
+ /**
+ * Query get tables metadata request.
+ */
+ class QueryGetTablesMetaRequest
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param catalog Catalog search pattern.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param tableTypes Table types search pattern.
+ */
+ QueryGetTablesMetaRequest(const std::string& catalog, const std::string& schema,
+ const std::string& table, const std::string& tableTypes) :
+ catalog(catalog), schema(schema), table(table), tableTypes(tableTypes)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetTablesMetaRequest()
+ {
+ // No-op.
+ }
+
+ /**
+ * Write request using provided writer.
+ * @param writer Writer.
+ */
+ void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+ {
+ writer.WriteInt8(REQUEST_TYPE_GET_TABLES_METADATA);
+
+ utility::WriteString(writer, catalog);
+ utility::WriteString(writer, schema);
+ utility::WriteString(writer, table);
+ utility::WriteString(writer, tableTypes);
+ }
+
+ private:
+ /** Column search pattern. */
+ std::string catalog;
+
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Column search pattern. */
+ std::string tableTypes;
+ };
+
+ /**
+ * Query close response.
+ */
+ class QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryResponse() : status(RESPONSE_STATUS_FAILED), error()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ status = reader.ReadInt8();
+
+ if (status == RESPONSE_STATUS_SUCCESS)
+ {
+ ReadOnSuccess(reader);
+ }
+ else
+ {
+ int32_t errorLen = reader.ReadString(0, 0);
+ error.resize(errorLen);
+
+ reader.ReadString(&error[0], static_cast<int32_t>(error.size()));
+ }
+ }
+
+ /**
+ * Get request processing status.
+ * @return Status.
+ */
+ int8_t GetStatus() const
+ {
+ return status;
+ }
+
+ /**
+ * Get resulting error.
+ * @return Error.
+ */
+ const std::string& GetError() const
+ {
+ return error;
+ }
+
+ protected:
+ /**
+ * Read data if response status is RESPONSE_STATUS_SUCCESS.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader) = 0;
+
+ private:
+ /** Request processing status. */
+ int8_t status;
+
+ /** Error message. */
+ std::string error;
+ };
+
+
+ /**
+ * Query close response.
+ */
+ class QueryCloseResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryCloseResponse() : queryId(0)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryCloseResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ queryId = reader.ReadInt64();
+ }
+
+ /** Query ID. */
+ int64_t queryId;
+ };
+
+ /**
+ * Query execute response.
+ */
+ class QueryExecuteResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryExecuteResponse() : queryId(0), meta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryExecuteResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ /**
+ * Get column metadata.
+ * @return Column metadata.
+ */
+ const meta::ColumnMetaVector& GetMeta() const
+ {
+ return meta;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ queryId = reader.ReadInt64();
+
+ meta::ReadColumnMetaVector(reader, meta);
+ }
+
+ /** Query ID. */
+ int64_t queryId;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector meta;
+ };
+
+ /**
+ * Query fetch response.
+ */
+ class QueryFetchResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ * @param resultPage Result page.
+ */
+ QueryFetchResponse(ResultPage& resultPage) : queryId(0), resultPage(resultPage)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryFetchResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get query ID.
+ * @return Query ID.
+ */
+ int64_t GetQueryId() const
+ {
+ return queryId;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ queryId = reader.ReadInt64();
+
+ resultPage.Read(reader);
+ }
+
+ /** Query ID. */
+ int64_t queryId;
+
+ /** Result page. */
+ ResultPage& resultPage;
+ };
+
+ /**
+ * Query get column metadata response.
+ */
+ class QueryGetColumnsMetaResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryGetColumnsMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetColumnsMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get column metadata.
+ * @return Column metadata.
+ */
+ const meta::ColumnMetaVector& GetMeta() const
+ {
+ return meta;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ meta::ReadColumnMetaVector(reader, meta);
+ }
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector meta;
+ };
+
+ /**
+ * Query get table metadata response.
+ */
+ class QueryGetTablesMetaResponse : public QueryResponse
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QueryGetTablesMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueryGetTablesMetaResponse()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get column metadata.
+ * @return Column metadata.
+ */
+ const meta::TableMetaVector& GetMeta() const
+ {
+ return meta;
+ }
+
+ private:
+ /**
+ * Read response using provided reader.
+ * @param reader Reader.
+ */
+ virtual void ReadOnSuccess(ignite::impl::binary::BinaryReaderImpl& reader)
+ {
+ meta::ReadTableMetaVector(reader, meta);
+ }
+
+ /** Columns metadata. */
+ meta::TableMetaVector meta;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h
new file mode 100644
index 0000000..9bc7227
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/column_meta.h
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_COLUMN_META
+#define _IGNITE_ODBC_COLUMN_META
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ /**
+ * Column metadata.
+ */
+ class ColumnMeta
+ {
+ public:
+#ifdef ODBC_DEBUG
+ /**
+ * Convert attribute ID to string containing its name.
+ * Debug function.
+ * @param type Attribute ID.
+ * @return Null-terminated string containing attribute name.
+ */
+ static const char* AttrIdToString(uint16_t id);
+#endif
+
+ /**
+ * Default constructor.
+ */
+ ColumnMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param schemaName Schema name.
+ * @param tableName Table name.
+ * @param columnName Column name.
+ * @param typeName Type name.
+ * @param dataType Data type.
+ */
+ ColumnMeta(const std::string& schemaName, const std::string& tableName,
+ const std::string& columnName, const std::string& typeName, int8_t dataType) :
+ schemaName(schemaName), tableName(tableName), columnName(columnName),
+ typeName(typeName), dataType(dataType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~ColumnMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ */
+ ColumnMeta(const ColumnMeta& other) :
+ schemaName(other.schemaName),
+ tableName(other.tableName),
+ columnName(other.columnName),
+ typeName(other.typeName),
+ dataType(other.dataType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy operator.
+ */
+ ColumnMeta& operator=(const ColumnMeta& other)
+ {
+ schemaName = other.schemaName;
+ tableName = other.tableName;
+ columnName = other.columnName;
+ typeName = other.typeName;
+ dataType = other.dataType;
+
+ return *this;
+ }
+
+ /**
+ * Read using reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader);
+
+ /**
+ * Get schema name.
+ * @return Schema name.
+ */
+ const std::string& GetSchemaName() const
+ {
+ return schemaName;
+ }
+
+ /**
+ * Get table name.
+ * @return Table name.
+ */
+ const std::string& GetTableName() const
+ {
+ return tableName;
+ }
+
+ /**
+ * Get column name.
+ * @return Column name.
+ */
+ const std::string& GetColumnName() const
+ {
+ return columnName;
+ }
+
+ /**
+ * Get column type name.
+ * @return Column type name.
+ */
+ const std::string& GetColumnTypeName() const
+ {
+ return typeName;
+ }
+
+ /**
+ * Get data type.
+ * @return Data type.
+ */
+ int8_t GetDataType() const
+ {
+ return dataType;
+ }
+
+ /**
+ * Try to get attribute of a string type.
+ *
+ * @param fieldId Field ID.
+ * @param value Output attribute value.
+ * @return True if the attribute supported and false otherwise.
+ */
+ bool GetAttribute(uint16_t fieldId, std::string& value) const;
+
+ /**
+ * Try to get attribute of a integer type.
+ *
+ * @param fieldId Field ID.
+ * @param value Output attribute value.
+ * @return True if the attribute supported and false otherwise.
+ */
+ bool GetAttribute(uint16_t fieldId, SqlLen& value) const;
+
+ private:
+ /** Schema name. */
+ std::string schemaName;
+
+ /** Table name. */
+ std::string tableName;
+
+ /** Column name. */
+ std::string columnName;
+
+ /** Type name. */
+ std::string typeName;
+
+ /** Data type. */
+ int8_t dataType;
+ };
+
+ /** Column metadata vector alias. */
+ typedef std::vector<ColumnMeta> ColumnMetaVector;
+
+ /**
+ * Read columns metadata collection.
+ * @param reader Reader.
+ * @param meta Collection.
+ */
+ void ReadColumnMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, ColumnMetaVector& meta);
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h
new file mode 100644
index 0000000..e479e10
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/primary_key_meta.h
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_PRIMARY_KEY_META
+#define _IGNITE_ODBC_PRIMARY_KEY_META
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ /**
+ * Primary key metadata.
+ */
+ class PrimaryKeyMeta
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ PrimaryKeyMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param column Column name.
+ * @param keySeq Column sequence number in key (starting with 1).
+ * @param keyName Key name.
+ */
+ PrimaryKeyMeta(const std::string& catalog, const std::string& schema,
+ const std::string& table, const std::string& column, int16_t keySeq,
+ const std::string& keyName) :
+ catalog(catalog),
+ schema(schema),
+ table(table),
+ column(column),
+ keySeq(keySeq),
+ keyName(keyName)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~PrimaryKeyMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ */
+ PrimaryKeyMeta(const PrimaryKeyMeta& other) :
+ catalog(other.catalog),
+ schema(other.schema),
+ table(other.table),
+ column(other.column),
+ keySeq(other.keySeq),
+ keyName(other.keyName)
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy operator.
+ */
+ PrimaryKeyMeta& operator=(const PrimaryKeyMeta& other)
+ {
+ catalog = other.catalog;
+ schema = other.schema;
+ table = other.table;
+ column = other.column;
+ keySeq = other.keySeq;
+ keyName = other.keyName;
+
+ return *this;
+ }
+
+ /**
+ * Get catalog name.
+ * @return Catalog name.
+ */
+ const std::string& GetCatalogName() const
+ {
+ return catalog;
+ }
+
+ /**
+ * Get schema name.
+ * @return Schema name.
+ */
+ const std::string& GetSchemaName() const
+ {
+ return schema;
+ }
+
+ /**
+ * Get table name.
+ * @return Table name.
+ */
+ const std::string& GetTableName() const
+ {
+ return table;
+ }
+
+ /**
+ * Get column name.
+ * @return Column name.
+ */
+ const std::string& GetColumnName() const
+ {
+ return table;
+ }
+
+ /**
+ * Get column sequence number in key.
+ * @return Sequence number in key.
+ */
+ int16_t GetKeySeq() const
+ {
+ return keySeq;
+ }
+
+ /**
+ * Get key name.
+ * @return Key name.
+ */
+ const std::string& GetKeyName() const
+ {
+ return keyName;
+ }
+
+ private:
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Collumn name. */
+ std::string column;
+
+ /** Column sequence number in key. */
+ int16_t keySeq;
+
+ /** Key name. */
+ std::string keyName;
+ };
+
+ /** Table metadata vector alias. */
+ typedef std::vector<PrimaryKeyMeta> PrimaryKeyMetaVector;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h
new file mode 100644
index 0000000..0618217
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/meta/table_meta.h
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_TABLE_META
+#define _IGNITE_ODBC_TABLE_META
+
+#include <stdint.h>
+#include <string>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace meta
+ {
+ /**
+ * Table metadata.
+ */
+ class TableMeta
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ TableMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param catalogName Catalog name.
+ * @param schemaName Schema name.
+ * @param tableName Table name.
+ * @param tableType Table type.
+ */
+ TableMeta(const std::string& catalogName, const std::string& schemaName,
+ const std::string& tableName, const std::string& tableType) :
+ catalogName(catalogName), schemaName(schemaName), tableName(tableName),
+ tableType(tableType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~TableMeta()
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ */
+ TableMeta(const TableMeta& other) :
+ catalogName(other.catalogName),
+ schemaName(other.schemaName),
+ tableName(other.tableName),
+ tableType(other.tableType)
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy operator.
+ */
+ TableMeta& operator=(const TableMeta& other)
+ {
+ catalogName = other.catalogName;
+ schemaName = other.schemaName;
+ tableName = other.tableName;
+ tableType = other.tableType;
+
+ return *this;
+ }
+
+ /**
+ * Read using reader.
+ * @param reader Reader.
+ */
+ void Read(ignite::impl::binary::BinaryReaderImpl& reader);
+
+ /**
+ * Get catalog name.
+ * @return Catalog name.
+ */
+ const std::string& GetCatalogName() const
+ {
+ return catalogName;
+ }
+
+ /**
+ * Get schema name.
+ * @return Schema name.
+ */
+ const std::string& GetSchemaName() const
+ {
+ return schemaName;
+ }
+
+ /**
+ * Get table name.
+ * @return Table name.
+ */
+ const std::string& GetTableName() const
+ {
+ return tableName;
+ }
+
+ /**
+ * Get table type.
+ * @return Table type.
+ */
+ const std::string& GetTableType() const
+ {
+ return tableType;
+ }
+
+ private:
+ /** Catalog name. */
+ std::string catalogName;
+
+ /** Schema name. */
+ std::string schemaName;
+
+ /** Table name. */
+ std::string tableName;
+
+ /** Table type. */
+ std::string tableType;
+ };
+
+ /** Table metadata vector alias. */
+ typedef std::vector<TableMeta> TableMetaVector;
+
+ /**
+ * Read tables metadata collection.
+ * @param reader Reader.
+ * @param meta Collection.
+ */
+ void ReadTableMetaVector(ignite::impl::binary::BinaryReaderImpl& reader, TableMetaVector& meta);
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
new file mode 100644
index 0000000..8b8f277
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_PARSER
+#define _IGNITE_ODBC_DRIVER_PARSER
+
+#include <stdint.h>
+
+#include <vector>
+
+#include <ignite/impl/interop/interop_output_stream.h>
+#include <ignite/impl/interop/interop_input_stream.h>
+#include <ignite/impl/binary/binary_writer_impl.h>
+#include <ignite/impl/binary/binary_reader_impl.h>
+
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Message parser.
+ */
+ class Parser
+ {
+ public:
+ /** Default initial size of operational memory. */
+ enum { DEFAULT_MEM_ALLOCATION = 4096 };
+
+ /**
+ * Constructor.
+ */
+ Parser(int32_t cap = DEFAULT_MEM_ALLOCATION) : inMem(cap), outMem(cap), outStream(&outMem)
+ {
+ //No-op.
+ }
+
+ /**
+ * Destructor.
+ */
+ ~Parser()
+ {
+ //No-op.
+ }
+
+ /**
+ * Encode message and place encoded data in buffer.
+ *
+ * @param msg Message to encode.
+ * @param buf Data buffer.
+ */
+ template<typename MsgT>
+ void Encode(const MsgT& msg, std::vector<int8_t>& buf)
+ {
+ using namespace ignite::impl::binary;
+
+ ResetState();
+
+ BinaryWriterImpl writer(&outStream, 0);
+
+ int32_t msgLenPos = outStream.Reserve(4);
+
+ msg.Write(writer);
+
+ outStream.WriteInt32(msgLenPos, outStream.Position() - 4);
+
+ buf.resize(outStream.Position());
+
+ memcpy(&buf[0], outMem.Data(), outStream.Position());
+ }
+
+ /**
+ * Decode message from data in buffer.
+ *
+ * @param msg Message to decode.
+ * @param buf Data buffer.
+ * @note Can be optimized after InteropMemory refactoring.
+ */
+ template<typename MsgT>
+ void Decode(MsgT& msg, const std::vector<int8_t>& buf)
+ {
+ using namespace ignite::impl::binary;
+
+ //for (size_t i = 0; i < buf.size(); ++i)
+ // LOG_MSG("Data[%0.4d] : %0.3d, %c\n", i, (int)buf[i], buf[i] > 64 && buf[i] < 128 ? buf[i] : '.');
+
+ if (inMem.Capacity() < static_cast<int32_t>(buf.size()))
+ inMem.Reallocate(static_cast<int32_t>(buf.size()));
+
+ memcpy(inMem.Data(), buf.data(), buf.size());
+
+ inMem.Length(static_cast<int32_t>(buf.size()));
+
+ ignite::impl::interop::InteropInputStream inStream(&inMem);
+
+ BinaryReaderImpl reader(&inStream);
+
+ msg.Read(reader);
+ }
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Parser);
+
+ /**
+ * Reset internal state of the parser.
+ */
+ void ResetState()
+ {
+ outMem.Length(0);
+
+ outStream.Position(0);
+ }
+
+ /** Input operational memory. */
+ ignite::impl::interop::InteropUnpooledMemory inMem;
+
+ /** Output operational memory. */
+ ignite::impl::interop::InteropUnpooledMemory outMem;
+
+ /** Output stream. */
+ ignite::impl::interop::InteropOutputStream outStream;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h
new file mode 100644
index 0000000..378e95c
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/column_metadata_query.h
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_COLUMN_METADATA_QUERY
+#define _IGNITE_ODBC_DRIVER_COLUMN_METADATA_QUERY
+
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/meta/column_meta.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Connection forward-declaration. */
+ class Connection;
+
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class ColumnMetadataQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Associated connection.
+ * @param schema Schema search pattern.
+ * @param table Table search pattern.
+ * @param column Column search pattern.
+ */
+ ColumnMetadataQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& schema,
+ const std::string& table, const std::string& column);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ColumnMetadataQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(ColumnMetadataQuery);
+
+ /**
+ * Make get columns metadata requets and use response to set internal state.
+ *
+ * @return Operation result.
+ */
+ SqlResult MakeRequestGetColumnsMeta();
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Schema search pattern. */
+ std::string schema;
+
+ /** Table search pattern. */
+ std::string table;
+
+ /** Column search pattern. */
+ std::string column;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Fetched metadata. */
+ meta::ColumnMetaVector meta;
+
+ /** Metadata cursor. */
+ meta::ColumnMetaVector::iterator cursor;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
new file mode 100644
index 0000000..88550d0
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_DATA_QUERY
+#define _IGNITE_ODBC_DRIVER_DATA_QUERY
+
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/app/parameter.h"
+#include "ignite/odbc/cursor.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Connection forward-declaration. */
+ class Connection;
+
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class DataQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Associated connection.
+ * @param sql SQL query string.
+ * @param params SQL params.
+ */
+ DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
+ const std::string& sql, const app::ParameterBindingMap& params);
+
+ /**
+ * Destructor.
+ */
+ virtual ~DataQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(DataQuery);
+
+ /**
+ * Make query execute request and use response to set internal
+ * state.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestExecute();
+
+ /**
+ * Make query close request.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestClose();
+
+ /**
+ * Make data fetch request and use response to set internal state.
+ *
+ * @return True on success.
+ */
+ SqlResult MakeRequestFetch();
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** SQL Query. */
+ std::string sql;
+
+ /** Parameter bindings. */
+ const app::ParameterBindingMap& params;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector resultMeta;
+
+ /** Cursor. */
+ std::auto_ptr<Cursor> cursor;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h
new file mode 100644
index 0000000..abd13bc
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/foreign_keys_query.h
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_FOREIGN_KEYS_QUERY
+#define _IGNITE_ODBC_DRIVER_FOREIGN_KEYS_QUERY
+
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/query/query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Foreign keys query.
+ */
+ class ForeignKeysQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Statement-associated connection.
+ * @param primaryCatalog Primary key catalog name.
+ * @param primarySchema Primary key schema name.
+ * @param primaryTable Primary key table name.
+ * @param foreignCatalog Foreign key catalog name.
+ * @param foreignSchema Foreign key schema name.
+ * @param foreignTable Foreign key table name.
+ */
+ ForeignKeysQuery(diagnostic::Diagnosable& diag, Connection& connection,
+ const std::string& primaryCatalog, const std::string& primarySchema,
+ const std::string& primaryTable, const std::string& foreignCatalog,
+ const std::string& foreignSchema, const std::string& foreignTable);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ForeignKeysQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(ForeignKeysQuery);
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Primary key catalog name. */
+ std::string primaryCatalog;
+
+ /** Primary key schema name. */
+ std::string primarySchema;
+
+ /** Primary key table name. */
+ std::string primaryTable;
+
+ /** Foreign key catalog name. */
+ std::string foreignCatalog;
+
+ /** Foreign key schema name. */
+ std::string foreignSchema;
+
+ /** Foreign key table name. */
+ std::string foreignTable;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h
new file mode 100644
index 0000000..22e1359
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/primary_keys_query.h
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_PRIMARY_KEYS_QUERY
+#define _IGNITE_ODBC_DRIVER_PRIMARY_KEYS_QUERY
+
+#include "ignite/odbc/connection.h"
+#include "ignite/odbc/query/query.h"
+#include "ignite/odbc/meta/primary_key_meta.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Primary keys query.
+ */
+ class PrimaryKeysQuery : public Query
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param connection Statement-associated connection.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ */
+ PrimaryKeysQuery(diagnostic::Diagnosable& diag,
+ Connection& connection, const std::string& catalog,
+ const std::string& schema, const std::string& table);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PrimaryKeysQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(PrimaryKeysQuery);
+
+ /** Connection associated with the statement. */
+ Connection& connection;
+
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+
+ /** Primary keys metadata. */
+ meta::PrimaryKeyMetaVector meta;
+
+ /** Resultset cursor. */
+ meta::PrimaryKeyMetaVector::iterator cursor;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h
new file mode 100644
index 0000000..93da5c9
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/query.h
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_QUERY
+#define _IGNITE_ODBC_DRIVER_QUERY
+
+#include <stdint.h>
+
+#include <map>
+
+#include "ignite/odbc/diagnostic/diagnosable.h"
+#include "ignite/odbc/meta/column_meta.h"
+#include "ignite/odbc/common_types.h"
+#include "ignite/odbc/row.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Query.
+ */
+ class Query
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~Query()
+ {
+ // No-op.
+ }
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute() = 0;
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings) = 0;
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) = 0;
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close() = 0;
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const = 0;
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const = 0;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const = 0;
+
+ protected:
+ /**
+ * Constructor.
+ */
+ Query(diagnostic::Diagnosable& diag) :
+ diag(diag)
+ {
+ // No-op.
+ }
+
+ /** Diagnostics collector. */
+ diagnostic::Diagnosable& diag;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8287063/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h
new file mode 100644
index 0000000..f5affad
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/special_columns_query.h
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_DRIVER_SPECIAL_COLUMNS_QUERY
+#define _IGNITE_ODBC_DRIVER_SPECIAL_COLUMNS_QUERY
+
+#include "ignite/odbc/query/query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ /**
+ * Special columns query.
+ */
+ class SpecialColumnsQuery : public Query
+ {
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param scope Minimum required scope of the rowid.
+ * @param nullable Determines whether to return special columns
+ * that can have a NULL value.
+ */
+ SpecialColumnsQuery(diagnostic::Diagnosable& diag, int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable);
+
+ /**
+ * Destructor.
+ */
+ virtual ~SpecialColumnsQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(SpecialColumnsQuery);
+
+ /** Query type. */
+ int16_t type;
+
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Minimum required scope of the rowid. */
+ int16_t scope;
+
+ /**
+ * Determines whether to return special columns that can have
+ * a NULL value.
+ */
+ int16_t nullable;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file