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/25 12:55:45 UTC
[43/50] ignite git commit: IGNITE-2248: Added SpecialColumnsQuery
(returns empty result set).
IGNITE-2248: Added SpecialColumnsQuery (returns empty result set).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d86a82c8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d86a82c8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d86a82c8
Branch: refs/heads/ignite-1786
Commit: d86a82c8693eecbc1e3e3939b2a2b8452fb880b9
Parents: a5d824c
Author: isapego <is...@gridgain.com>
Authored: Thu Jan 21 17:18:13 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Thu Jan 21 17:18:13 2016 +0300
----------------------------------------------------------------------
.../ignite/odbc/query/special_columns_query.h | 142 +++++++++++++++++++
.../odbc-driver/include/ignite/odbc/statement.h | 8 +-
.../odbc-driver/project/vs/odbc-driver.vcxproj | 2 +
.../project/vs/odbc-driver.vcxproj.filters | 6 +
.../platforms/cpp/odbc/odbc-driver/src/odbc.cpp | 2 +-
.../src/query/special_columns_query.cpp | 121 ++++++++++++++++
.../cpp/odbc/odbc-driver/src/statement.cpp | 6 +-
7 files changed, 279 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/query/special_columns_query.h
new file mode 100644
index 0000000..ad45791
--- /dev/null
+++ b/modules/platforms/cpp/odbc/odbc-driver/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 : Query
+ {
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param diag Diagnostics collector.
+ * @param catalog Catalog name.
+ * @param schema Schema name.
+ * @param table Table name.
+ * @param scope Minimum required scope of the rowid.
+ * @param nullable Determines whether to return special columns
+ * that can have a NULL value.
+ */
+ SpecialColumnsQuery(diagnostic::Diagnosable& diag, int16_t type,
+ const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable);
+
+ /**
+ * Destructor.
+ */
+ virtual ~SpecialColumnsQuery();
+
+ /**
+ * Execute query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Execute();
+
+ /**
+ * Fetch next result row to application buffers.
+ *
+ * @param columnBindings Application buffers to put data to.
+ * @return Operation result.
+ */
+ virtual SqlResult FetchNextRow(app::ColumnBindingMap& columnBindings);
+
+ /**
+ * Get data of the specified column in the result set.
+ *
+ * @param columnIdx Column index.
+ * @param buffer Buffer to put column data to.
+ * @return Operation result.
+ */
+ virtual SqlResult GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer);
+
+ /**
+ * Close query.
+ *
+ * @return True on success.
+ */
+ virtual SqlResult Close();
+
+ /**
+ * Get column metadata.
+ *
+ * @return Column metadata.
+ */
+ virtual const meta::ColumnMetaVector& GetMeta() const;
+
+ /**
+ * Check if data is available.
+ *
+ * @return True if data is available.
+ */
+ virtual bool DataAvailable() const;
+
+ /**
+ * Get number of rows affected by the statement.
+ *
+ * @return Number of rows affected by the statement.
+ */
+ virtual int64_t AffectedRows() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(SpecialColumnsQuery);
+
+ /** Query type. */
+ int16_t type;
+
+ /** Catalog name. */
+ std::string catalog;
+
+ /** Schema name. */
+ std::string schema;
+
+ /** Table name. */
+ std::string table;
+
+ /** Minimum required scope of the rowid. */
+ int16_t scope;
+
+ /**
+ * Determines whether to return special columns that can have
+ * a NULL value.
+ */
+ int16_t nullable;
+
+ /** Query executed. */
+ bool executed;
+
+ /** Columns metadata. */
+ meta::ColumnMetaVector columnsMeta;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
index 4c49a76..bbe5da5 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
+++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/statement.h
@@ -245,7 +245,7 @@ namespace ignite
* @param type Determines whether to return special columns that
* can have a NULL value.
*/
- void ExecuteGetSpecialColumnsQuery(int16_t type,
+ void ExecuteSpecialColumnsQuery(int16_t type,
const std::string& catalog, const std::string& schema,
const std::string& table, int16_t scope, int16_t nullable);
@@ -450,11 +450,11 @@ namespace ignite
* @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.
+ * @param nullable Determines whether to return special columns
+ * that can have a NULL value.
* @return Operation result.
*/
- SqlResult InternalExecuteGetSpecialColumnsQuery(int16_t type,
+ SqlResult InternalExecuteSpecialColumnsQuery(int16_t type,
const std::string& catalog, const std::string& schema,
const std::string& table, int16_t scope, int16_t nullable);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
index cff9f3f..b327ffd 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
+++ b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj
@@ -170,6 +170,7 @@
<ClCompile Include="..\..\src\query\column_metadata_query.cpp" />
<ClCompile Include="..\..\src\query\foreign_keys_query.cpp" />
<ClCompile Include="..\..\src\query\primary_keys_query.cpp" />
+ <ClCompile Include="..\..\src\query\special_columns_query.cpp" />
<ClCompile Include="..\..\src\query\table_metadata_query.cpp" />
<ClCompile Include="..\..\src\query\type_info_query.cpp" />
<ClCompile Include="..\..\src\result_page.cpp" />
@@ -206,6 +207,7 @@
<ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\primary_keys_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\query.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\query\special_columns_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\table_metadata_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\type_info_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\result_page.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
index 8083def..d47684a 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/odbc-driver/project/vs/odbc-driver.vcxproj.filters
@@ -112,6 +112,9 @@
<ClCompile Include="..\..\src\column.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\query\special_columns_query.cpp">
+ <Filter>Code\query</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="module.def">
@@ -219,5 +222,8 @@
<ClInclude Include="..\..\include\ignite\odbc\column.h">
<Filter>Code</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\query\special_columns_query.h">
+ <Filter>Code\query</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
index 7199ad3..84e312a 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp
@@ -1368,7 +1368,7 @@ SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt,
LOG_MSG("schema: %s\n", schema.c_str());
LOG_MSG("table: %s\n", table.c_str());
- statement->ExecuteGetSpecialColumnsQuery(idType, catalog, schema, table, scope, nullable);
+ statement->ExecuteSpecialColumnsQuery(idType, catalog, schema, table, scope, nullable);
return statement->GetDiagnosticRecords().GetReturnCode();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp
new file mode 100644
index 0000000..43d6842
--- /dev/null
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/query/special_columns_query.cpp
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ignite/impl/binary/binary_common.h>
+
+#include "ignite/odbc/type_traits.h"
+#include "ignite/odbc/query/special_columns_query.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace query
+ {
+ SpecialColumnsQuery::SpecialColumnsQuery(diagnostic::Diagnosable& diag,
+ int16_t type, const std::string& catalog, const std::string& schema,
+ const std::string& table, int16_t scope, int16_t nullable) :
+ Query(diag),
+ type(type),
+ catalog(catalog),
+ schema(schema),
+ table(table),
+ scope(scope),
+ nullable(nullable),
+ executed(false),
+ columnsMeta()
+ {
+ using namespace ignite::impl::binary;
+ using namespace ignite::odbc::type_traits;
+
+ using meta::ColumnMeta;
+
+ columnsMeta.reserve(8);
+
+ const std::string sch("");
+ const std::string tbl("");
+
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "SCOPE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "DATA_TYPE", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "TYPE_NAME", SqlTypeName::VARCHAR, IGNITE_TYPE_STRING));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "COLUMN_SIZE", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "BUFFER_LENGTH", SqlTypeName::INTEGER, IGNITE_TYPE_INT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "DECIMAL_DIGITS", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ columnsMeta.push_back(ColumnMeta(sch, tbl, "PSEUDO_COLUMN", SqlTypeName::SMALLINT, IGNITE_TYPE_SHORT));
+ }
+
+ SpecialColumnsQuery::~SpecialColumnsQuery()
+ {
+ // No-op.
+ }
+
+ SqlResult SpecialColumnsQuery::Execute()
+ {
+ executed = true;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ const meta::ColumnMetaVector& SpecialColumnsQuery::GetMeta() const
+ {
+ return columnsMeta;
+ }
+
+ SqlResult SpecialColumnsQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_NO_DATA;
+ }
+
+ SqlResult SpecialColumnsQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
+ {
+ if (!executed)
+ {
+ diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+
+ return SQL_RESULT_ERROR;
+ }
+
+ return SQL_RESULT_NO_DATA;
+ }
+
+ SqlResult SpecialColumnsQuery::Close()
+ {
+ executed = false;
+
+ return SQL_RESULT_SUCCESS;
+ }
+
+ bool SpecialColumnsQuery::DataAvailable() const
+ {
+ return false;
+ }
+
+ int64_t SpecialColumnsQuery::AffectedRows() const
+ {
+ return 0;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d86a82c8/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
index d23c276..d7ea288 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/statement.cpp
@@ -305,15 +305,15 @@ namespace ignite
return currentQuery->Execute();
}
- void Statement::ExecuteGetSpecialColumnsQuery(int16_t type,
+ void Statement::ExecuteSpecialColumnsQuery(int16_t type,
const std::string& catalog, const std::string& schema,
const std::string& table, int16_t scope, int16_t nullable)
{
- IGNITE_ODBC_API_CALL(InternalExecuteGetSpecialColumnsQuery(type,
+ IGNITE_ODBC_API_CALL(InternalExecuteSpecialColumnsQuery(type,
catalog, schema, table, scope, nullable));
}
- SqlResult Statement::InternalExecuteGetSpecialColumnsQuery(int16_t type,
+ SqlResult Statement::InternalExecuteSpecialColumnsQuery(int16_t type,
const std::string& catalog, const std::string& schema,
const std::string& table, int16_t scope, int16_t nullable)
{