You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by is...@apache.org on 2017/04/13 11:47:59 UTC
[2/8] ignite git commit: IGNITE-3581: Implemented for enums from ODBC
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4b7b03/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/type_info_query.cpp b/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
index 2de2a7c..280477b 100644
--- a/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
+++ b/modules/platforms/cpp/odbc/src/query/type_info_query.cpp
@@ -25,87 +25,90 @@
namespace
{
- enum ResultColumn
+ struct ResultColumn
{
- /** Data source\ufffddependent data-type name. */
- TYPE_NAME = 1,
-
- /** SQL data type. */
- DATA_TYPE,
-
- /** The maximum column size that the server supports for this data type. */
- COLUMN_SIZE,
-
- /** Character or characters used to prefix a literal. */
- LITERAL_PREFIX,
-
- /** Character or characters used to terminate a literal. */
- LITERAL_SUFFIX,
-
- /**
- * A list of keywords, separated by commas, corresponding to each
- * parameter that the application may specify in parentheses when using
- * the name that is returned in the TYPE_NAME field.
- */
- CREATE_PARAMS,
-
- /** Whether the data type accepts a NULL value. */
- NULLABLE,
-
- /**
- * Whether a character data type is case-sensitive in collations and
- * comparisons.
- */
- CASE_SENSITIVE,
-
- /** How the data type is used in a WHERE clause. */
- SEARCHABLE,
-
- /** Whether the data type is unsigned. */
- UNSIGNED_ATTRIBUTE,
-
- /** Whether the data type has predefined fixed precision and scale. */
- FIXED_PREC_SCALE,
-
- /** Whether the data type is autoincrementing. */
- AUTO_UNIQUE_VALUE,
-
- /**
- * Localized version of the data source\ufffddependent name of the data
- * type.
- */
- LOCAL_TYPE_NAME,
-
- /** The minimum scale of the data type on the data source. */
- MINIMUM_SCALE,
-
- /** The maximum scale of the data type on the data source. */
- MAXIMUM_SCALE,
-
- /**
- * The value of the SQL data type as it appears in the SQL_DESC_TYPE
- * field of the descriptor.
- */
- SQL_DATA_TYPE,
-
- /**
- * When the value of SQL_DATA_TYPE is SQL_DATETIME or SQL_INTERVAL,
- * this column contains the datetime/interval subcode.
- */
- SQL_DATETIME_SUB,
-
- /**
- * If the data type is an approximate numeric type, this column
- * contains the value 2 to indicate that COLUMN_SIZE specifies a number
- * of bits.
- */
- NUM_PREC_RADIX,
-
- /**
- * If the data type is an interval data type, then this column contains
- * the value of the interval leading precision.
- */
- INTERVAL_PRECISION
+ enum Type
+ {
+ /** Data source\ufffddependent data-type name. */
+ TYPE_NAME = 1,
+
+ /** SQL data type. */
+ DATA_TYPE,
+
+ /** The maximum column size that the server supports for this data type. */
+ COLUMN_SIZE,
+
+ /** Character or characters used to prefix a literal. */
+ LITERAL_PREFIX,
+
+ /** Character or characters used to terminate a literal. */
+ LITERAL_SUFFIX,
+
+ /**
+ * A list of keywords, separated by commas, corresponding to each
+ * parameter that the application may specify in parentheses when using
+ * the name that is returned in the TYPE_NAME field.
+ */
+ CREATE_PARAMS,
+
+ /** Whether the data type accepts a NULL value. */
+ NULLABLE,
+
+ /**
+ * Whether a character data type is case-sensitive in collations and
+ * comparisons.
+ */
+ CASE_SENSITIVE,
+
+ /** How the data type is used in a WHERE clause. */
+ SEARCHABLE,
+
+ /** Whether the data type is unsigned. */
+ UNSIGNED_ATTRIBUTE,
+
+ /** Whether the data type has predefined fixed precision and scale. */
+ FIXED_PREC_SCALE,
+
+ /** Whether the data type is autoincrementing. */
+ AUTO_UNIQUE_VALUE,
+
+ /**
+ * Localized version of the data source\ufffddependent name of the data
+ * type.
+ */
+ LOCAL_TYPE_NAME,
+
+ /** The minimum scale of the data type on the data source. */
+ MINIMUM_SCALE,
+
+ /** The maximum scale of the data type on the data source. */
+ MAXIMUM_SCALE,
+
+ /**
+ * The value of the SQL data type as it appears in the SQL_DESC_TYPE
+ * field of the descriptor.
+ */
+ SQL_DATA_TYPE,
+
+ /**
+ * When the value of SQL_DATA_TYPE is SQL_DATETIME or SQL_INTERVAL,
+ * this column contains the datetime/interval subcode.
+ */
+ SQL_DATETIME_SUB,
+
+ /**
+ * If the data type is an approximate numeric type, this column
+ * contains the value 2 to indicate that COLUMN_SIZE specifies a number
+ * of bits.
+ */
+ NUM_PREC_RADIX,
+
+ /**
+ * If the data type is an interval data type, then this column contains
+ * the value of the interval leading precision.
+ */
+ INTERVAL_PRECISION
+ };
};
}
@@ -116,7 +119,7 @@ namespace ignite
namespace query
{
TypeInfoQuery::TypeInfoQuery(diagnostic::Diagnosable& diag, int16_t sqlType) :
- Query(diag, TYPE_INFO),
+ Query(diag, QueryType::TYPE_INFO),
columnsMeta(),
executed(false),
types(),
@@ -177,13 +180,13 @@ namespace ignite
// No-op.
}
- SqlResult TypeInfoQuery::Execute()
+ SqlResult::Type TypeInfoQuery::Execute()
{
cursor = types.begin();
executed = true;
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
const meta::ColumnMetaVector & TypeInfoQuery::GetMeta() const
@@ -191,17 +194,17 @@ namespace ignite
return columnsMeta;
}
- SqlResult TypeInfoQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
+ SqlResult::Type TypeInfoQuery::FetchNextRow(app::ColumnBindingMap & columnBindings)
{
if (!executed)
{
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+ diag.AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query was not executed.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (cursor == types.end())
- return SQL_RESULT_NO_DATA;
+ return SqlResult::AI_NO_DATA;
app::ColumnBindingMap::iterator it;
@@ -210,50 +213,50 @@ namespace ignite
++cursor;
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
- SqlResult TypeInfoQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
+ SqlResult::Type TypeInfoQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
{
using namespace ignite::impl::binary;
if (!executed)
{
- diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");
+ diag.AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query was not executed.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (cursor == types.end())
- return SQL_RESULT_NO_DATA;
+ return SqlResult::AI_NO_DATA;
int8_t currentType = *cursor;
switch (columnIdx)
{
- case TYPE_NAME:
+ case ResultColumn::TYPE_NAME:
{
buffer.PutString(type_traits::BinaryTypeToSqlTypeName(currentType));
break;
}
- case DATA_TYPE:
- case SQL_DATA_TYPE:
+ case ResultColumn::DATA_TYPE:
+ case ResultColumn::SQL_DATA_TYPE:
{
buffer.PutInt16(type_traits::BinaryToSqlType(currentType));
break;
}
- case COLUMN_SIZE:
+ case ResultColumn::COLUMN_SIZE:
{
buffer.PutInt32(type_traits::BinaryTypeColumnSize(currentType));
break;
}
- case LITERAL_PREFIX:
+ case ResultColumn::LITERAL_PREFIX:
{
if (currentType == IGNITE_TYPE_STRING)
buffer.PutString("'");
@@ -265,7 +268,7 @@ namespace ignite
break;
}
- case LITERAL_SUFFIX:
+ case ResultColumn::LITERAL_SUFFIX:
{
if (currentType == IGNITE_TYPE_STRING)
buffer.PutString("'");
@@ -275,21 +278,21 @@ namespace ignite
break;
}
- case CREATE_PARAMS:
+ case ResultColumn::CREATE_PARAMS:
{
buffer.PutNull();
break;
}
- case NULLABLE:
+ case ResultColumn::NULLABLE:
{
buffer.PutInt32(type_traits::BinaryTypeNullability(currentType));
break;
}
- case CASE_SENSITIVE:
+ case ResultColumn::CASE_SENSITIVE:
{
if (currentType == IGNITE_TYPE_STRING)
buffer.PutInt16(SQL_TRUE);
@@ -299,64 +302,64 @@ namespace ignite
break;
}
- case SEARCHABLE:
+ case ResultColumn::SEARCHABLE:
{
buffer.PutInt16(SQL_SEARCHABLE);
break;
}
- case UNSIGNED_ATTRIBUTE:
+ case ResultColumn::UNSIGNED_ATTRIBUTE:
{
buffer.PutInt16(type_traits::BinaryTypeUnsigned(currentType));
break;
}
- case FIXED_PREC_SCALE:
+ case ResultColumn::FIXED_PREC_SCALE:
{
buffer.PutInt16(SQL_FALSE);
break;
}
- case AUTO_UNIQUE_VALUE:
+ case ResultColumn::AUTO_UNIQUE_VALUE:
{
buffer.PutInt16(SQL_FALSE);
break;
}
- case LOCAL_TYPE_NAME:
+ case ResultColumn::LOCAL_TYPE_NAME:
{
buffer.PutNull();
break;
}
- case MINIMUM_SCALE:
- case MAXIMUM_SCALE:
+ case ResultColumn::MINIMUM_SCALE:
+ case ResultColumn::MAXIMUM_SCALE:
{
buffer.PutInt16(type_traits::BinaryTypeDecimalDigits(currentType));
break;
}
- case SQL_DATETIME_SUB:
+ case ResultColumn::SQL_DATETIME_SUB:
{
buffer.PutNull();
break;
}
- case NUM_PREC_RADIX:
+ case ResultColumn::NUM_PREC_RADIX:
{
buffer.PutInt32(type_traits::BinaryTypeNumPrecRadix(currentType));
break;
}
- case INTERVAL_PRECISION:
+ case ResultColumn::INTERVAL_PRECISION:
{
buffer.PutNull();
@@ -367,16 +370,16 @@ namespace ignite
break;
}
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
- SqlResult TypeInfoQuery::Close()
+ SqlResult::Type TypeInfoQuery::Close()
{
cursor = types.end();
executed = false;
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
bool TypeInfoQuery::DataAvailable() const
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4b7b03/modules/platforms/cpp/odbc/src/row.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/row.cpp b/modules/platforms/cpp/odbc/src/row.cpp
index 5e5a00e..34b061b 100644
--- a/modules/platforms/cpp/odbc/src/row.cpp
+++ b/modules/platforms/cpp/odbc/src/row.cpp
@@ -74,13 +74,13 @@ namespace ignite
return true;
}
- SqlResult Row::ReadColumnToBuffer(uint16_t columnIdx, app::ApplicationDataBuffer& dataBuf)
+ SqlResult::Type Row::ReadColumnToBuffer(uint16_t columnIdx, app::ApplicationDataBuffer& dataBuf)
{
using namespace ignite::impl::binary;
using namespace ignite::impl::interop;
if (!EnsureColumnDiscovered(columnIdx))
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
Column& column = GetColumn(columnIdx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4b7b03/modules/platforms/cpp/odbc/src/statement.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/statement.cpp b/modules/platforms/cpp/odbc/src/statement.cpp
index 2395d66..99ec42e 100644
--- a/modules/platforms/cpp/odbc/src/statement.cpp
+++ b/modules/platforms/cpp/odbc/src/statement.cpp
@@ -56,24 +56,24 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalBindColumn(columnIdx, targetType, targetValue, bufferLength, strLengthOrIndicator));
}
- SqlResult Statement::InternalBindColumn(uint16_t columnIdx, int16_t targetType, void* targetValue, SqlLen bufferLength, SqlLen* strLengthOrIndicator)
+ SqlResult::Type Statement::InternalBindColumn(uint16_t columnIdx, int16_t targetType, void* targetValue, SqlLen bufferLength, SqlLen* strLengthOrIndicator)
{
using namespace odbc::type_traits;
- IgniteSqlType driverType = ToDriverType(targetType);
+ OdbcNativeType::Type driverType = ToDriverType(targetType);
- if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
+ if (driverType == OdbcNativeType::AI_UNSUPPORTED)
{
- AddStatusRecord(odbc::SQL_STATE_HY003_INVALID_APPLICATION_BUFFER_TYPE, "The argument TargetType was not a valid data type.");
+ AddStatusRecord(odbc::SqlState::SHY003_INVALID_APPLICATION_BUFFER_TYPE, "The argument TargetType was not a valid data type.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (bufferLength < 0)
{
- AddStatusRecord(odbc::SQL_STATE_HY090_INVALID_STRING_OR_BUFFER_LENGTH,
+ AddStatusRecord(odbc::SqlState::SHY090_INVALID_STRING_OR_BUFFER_LENGTH,
"The value specified for the argument BufferLength was less than 0.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (targetValue || strLengthOrIndicator)
@@ -85,7 +85,7 @@ namespace ignite
else
SafeUnbindColumn(columnIdx);
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::SafeBindColumn(uint16_t columnIdx, const app::ApplicationDataBuffer& buffer)
@@ -124,20 +124,20 @@ namespace ignite
return res;
}
- SqlResult Statement::InternalGetColumnNumber(int32_t &res)
+ SqlResult::Type Statement::InternalGetColumnNumber(int32_t &res)
{
const meta::ColumnMetaVector* meta = GetMeta();
if (!meta)
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not executed.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
res = static_cast<int32_t>(meta->size());
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::BindParameter(uint16_t paramIdx, int16_t ioType, int16_t bufferType, int16_t paramSqlType,
@@ -146,7 +146,7 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalBindParameter(paramIdx, ioType, bufferType, paramSqlType, columnSize, decDigits, buffer, bufferLen, resLen));
}
- SqlResult Statement::InternalBindParameter(uint16_t paramIdx, int16_t ioType, int16_t bufferType, int16_t paramSqlType,
+ SqlResult::Type Statement::InternalBindParameter(uint16_t paramIdx, int16_t ioType, int16_t bufferType, int16_t paramSqlType,
SqlUlen columnSize, int16_t decDigits, void* buffer, SqlLen bufferLen, SqlLen* resLen)
{
using namespace odbc::type_traits;
@@ -157,36 +157,36 @@ namespace ignite
if (paramIdx == 0)
{
- AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE,
+ AddStatusRecord(SqlState::S24000_INVALID_CURSOR_STATE,
"The value specified for the argument ParameterNumber was less than 1.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (ioType != SQL_PARAM_INPUT)
{
- AddStatusRecord(SQL_STATE_HY105_INVALID_PARAMETER_TYPE,
+ AddStatusRecord(SqlState::SHY105_INVALID_PARAMETER_TYPE,
"The value specified for the argument InputOutputType was not SQL_PARAM_INPUT.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (!IsSqlTypeSupported(paramSqlType))
{
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
"Data type is not supported.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
- IgniteSqlType driverType = ToDriverType(bufferType);
+ OdbcNativeType::Type driverType = ToDriverType(bufferType);
- if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
+ if (driverType == OdbcNativeType::AI_UNSUPPORTED)
{
- AddStatusRecord(odbc::SQL_STATE_HY003_INVALID_APPLICATION_BUFFER_TYPE,
+ AddStatusRecord(odbc::SqlState::SHY003_INVALID_APPLICATION_BUFFER_TYPE,
"The argument TargetType was not a valid data type.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (buffer)
@@ -200,7 +200,7 @@ namespace ignite
else
SafeUnbindParameter(paramIdx);
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::SafeBindParameter(uint16_t paramIdx, const app::Parameter& param)
@@ -225,7 +225,7 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalSetAttribute(attr, value, valueLen));
}
- SqlResult Statement::InternalSetAttribute(int attr, void* value, SQLINTEGER valueLen)
+ SqlResult::Type Statement::InternalSetAttribute(int attr, void* value, SQLINTEGER valueLen)
{
switch (attr)
{
@@ -237,10 +237,10 @@ namespace ignite
if (val != 1)
{
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
"Fetching of more than one row by call is not supported.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
break;
@@ -276,14 +276,14 @@ namespace ignite
default:
{
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
"Specified attribute is not supported.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
}
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::GetAttribute(int attr, void* buf, SQLINTEGER bufLen, SQLINTEGER* valueLen)
@@ -291,13 +291,13 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalGetAttribute(attr, buf, bufLen, valueLen));
}
- SqlResult Statement::InternalGetAttribute(int attr, void* buf, SQLINTEGER bufLen, SQLINTEGER* valueLen)
+ SqlResult::Type Statement::InternalGetAttribute(int attr, void* buf, SQLINTEGER bufLen, SQLINTEGER* valueLen)
{
if (!buf)
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Data buffer is NULL.");
+ AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Data buffer is NULL.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
switch (attr)
@@ -361,14 +361,14 @@ namespace ignite
default:
{
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
"Specified attribute is not supported.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
}
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
uint16_t Statement::GetParametersNumber()
@@ -395,18 +395,18 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalGetColumnData(columnIdx, buffer));
}
- SqlResult Statement::InternalGetColumnData(uint16_t columnIdx,
+ SqlResult::Type Statement::InternalGetColumnData(uint16_t columnIdx,
app::ApplicationDataBuffer& buffer)
{
if (!currentQuery.get())
{
- AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE,
+ AddStatusRecord(SqlState::S24000_INVALID_CURSOR_STATE,
"Cursor is not in the open state.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
- SqlResult res = currentQuery->GetColumn(columnIdx, buffer);
+ SqlResult::Type res = currentQuery->GetColumn(columnIdx, buffer);
return res;
}
@@ -416,7 +416,7 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalPrepareSqlQuery(query));
}
- SqlResult Statement::InternalPrepareSqlQuery(const std::string& query)
+ SqlResult::Type Statement::InternalPrepareSqlQuery(const std::string& query)
{
if (currentQuery.get())
currentQuery->Close();
@@ -426,7 +426,7 @@ namespace ignite
// Resetting parameters types as we are changing the query.
paramTypes.clear();
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::ExecuteSqlQuery(const std::string& query)
@@ -434,11 +434,11 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalExecuteSqlQuery(query));
}
- SqlResult Statement::InternalExecuteSqlQuery(const std::string& query)
+ SqlResult::Type Statement::InternalExecuteSqlQuery(const std::string& query)
{
- SqlResult result = InternalPrepareSqlQuery(query);
+ SqlResult::Type result = InternalPrepareSqlQuery(query);
- if (result != SQL_RESULT_SUCCESS)
+ if (result != SqlResult::AI_SUCCESS)
return result;
return InternalExecuteSqlQuery();
@@ -449,13 +449,13 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalExecuteSqlQuery());
}
- SqlResult Statement::InternalExecuteSqlQuery()
+ SqlResult::Type Statement::InternalExecuteSqlQuery()
{
if (!currentQuery.get())
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not prepared.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not prepared.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
bool paramDataReady = true;
@@ -471,7 +471,7 @@ namespace ignite
}
if (!paramDataReady)
- return SQL_RESULT_NEED_DATA;
+ return SqlResult::AI_NEED_DATA;
return currentQuery->Execute();
}
@@ -482,7 +482,7 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalExecuteGetColumnsMetaQuery(schema, table, column));
}
- SqlResult Statement::InternalExecuteGetColumnsMetaQuery(const std::string& schema,
+ SqlResult::Type Statement::InternalExecuteGetColumnsMetaQuery(const std::string& schema,
const std::string& table, const std::string& column)
{
if (currentQuery.get())
@@ -506,7 +506,7 @@ namespace ignite
catalog, schema, table, tableType));
}
- SqlResult Statement::InternalExecuteGetTablesMetaQuery(const std::string& catalog,
+ SqlResult::Type Statement::InternalExecuteGetTablesMetaQuery(const std::string& catalog,
const std::string& schema, const std::string& table, const std::string& tableType)
{
if (currentQuery.get())
@@ -527,7 +527,7 @@ namespace ignite
primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable));
}
- SqlResult Statement::InternalExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
+ SqlResult::Type Statement::InternalExecuteGetForeignKeysQuery(const std::string& primaryCatalog,
const std::string& primarySchema, const std::string& primaryTable,
const std::string& foreignCatalog, const std::string& foreignSchema,
const std::string& foreignTable)
@@ -547,7 +547,7 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalExecuteGetPrimaryKeysQuery(catalog, schema, table));
}
- SqlResult Statement::InternalExecuteGetPrimaryKeysQuery(const std::string& catalog,
+ SqlResult::Type Statement::InternalExecuteGetPrimaryKeysQuery(const std::string& catalog,
const std::string& schema, const std::string& table)
{
if (currentQuery.get())
@@ -567,16 +567,16 @@ namespace ignite
catalog, schema, table, scope, nullable));
}
- SqlResult Statement::InternalExecuteSpecialColumnsQuery(int16_t type,
+ SqlResult::Type Statement::InternalExecuteSpecialColumnsQuery(int16_t type,
const std::string& catalog, const std::string& schema,
const std::string& table, int16_t scope, int16_t nullable)
{
if (type != SQL_BEST_ROWID && type != SQL_ROWVER)
{
- AddStatusRecord(SQL_STATE_HY097_COLUMN_TYPE_OUT_OF_RANGE,
+ AddStatusRecord(SqlState::SHY097_COLUMN_TYPE_OUT_OF_RANGE,
"An invalid IdentifierType value was specified.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (currentQuery.get())
@@ -593,14 +593,14 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalExecuteGetTypeInfoQuery(sqlType));
}
- SqlResult Statement::InternalExecuteGetTypeInfoQuery(int16_t sqlType)
+ SqlResult::Type Statement::InternalExecuteGetTypeInfoQuery(int16_t sqlType)
{
if (!type_traits::IsSqlTypeSupported(sqlType))
{
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
"Data type is not supported.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (currentQuery.get())
@@ -616,15 +616,15 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalFreeResources(option));
}
- SqlResult Statement::InternalFreeResources(int16_t option)
+ SqlResult::Type Statement::InternalFreeResources(int16_t option)
{
switch (option)
{
case SQL_DROP:
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Deprecated, call SQLFreeHandle instead");
+ AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Deprecated, call SQLFreeHandle instead");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
case SQL_CLOSE:
@@ -648,11 +648,11 @@ namespace ignite
default:
{
- AddStatusRecord(SQL_STATE_HY092_OPTION_TYPE_OUT_OF_RANGE, "The value specified for the argument Option was invalid");
- return SQL_RESULT_ERROR;
+ AddStatusRecord(SqlState::SHY092_OPTION_TYPE_OUT_OF_RANGE, "The value specified for the argument Option was invalid");
+ return SqlResult::AI_ERROR;
}
}
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::Close()
@@ -660,14 +660,14 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalClose());
}
- SqlResult Statement::InternalClose()
+ SqlResult::Type Statement::InternalClose()
{
if (!currentQuery.get())
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
- SqlResult result = currentQuery->Close();
+ SqlResult::Type result = currentQuery->Close();
- if (result == SQL_RESULT_SUCCESS)
+ if (result == SqlResult::AI_SUCCESS)
currentQuery.reset();
return result;
@@ -678,14 +678,14 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalFetchScroll(orientation, offset));
}
- SqlResult Statement::InternalFetchScroll(int16_t orientation, int64_t offset)
+ SqlResult::Type Statement::InternalFetchScroll(int16_t orientation, int64_t offset)
{
UNREFERENCED_PARAMETER(offset);
if (orientation != SQL_FETCH_NEXT)
{
- AddStatusRecord(SQL_STATE_HY106_FETCH_TYPE_OUT_OF_RANGE, "The value specified for the argument FetchOrientation was not SQL_FETCH_NEXT.");
- return SQL_RESULT_ERROR;
+ AddStatusRecord(SqlState::SHY106_FETCH_TYPE_OUT_OF_RANGE, "The value specified for the argument FetchOrientation was not SQL_FETCH_NEXT.");
+ return SqlResult::AI_ERROR;
}
return InternalFetchRow();
@@ -696,22 +696,22 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalFetchRow());
}
- SqlResult Statement::InternalFetchRow()
+ SqlResult::Type Statement::InternalFetchRow()
{
if (rowsFetched)
*rowsFetched = 0;
if (!currentQuery.get())
{
- AddStatusRecord(SQL_STATE_24000_INVALID_CURSOR_STATE,
+ AddStatusRecord(SqlState::S24000_INVALID_CURSOR_STATE,
"Cursor is not in the open state.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
- SqlResult res = currentQuery->FetchNextRow(columnBindings);
+ SqlResult::Type res = currentQuery->FetchNextRow(columnBindings);
- if (res == SQL_RESULT_SUCCESS)
+ if (res == SqlResult::AI_SUCCESS)
{
if (rowsFetched)
*rowsFetched = 1;
@@ -741,14 +741,14 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalNextResults());
}
- SqlResult Statement::InternalNextResults()
+ SqlResult::Type Statement::InternalNextResults()
{
if (!currentQuery.get())
- return SQL_RESULT_NO_DATA;
+ return SqlResult::AI_NO_DATA;
- SqlResult result = currentQuery->Close();
+ SqlResult::Type result = currentQuery->Close();
- return result == SQL_RESULT_SUCCESS ? SQL_RESULT_NO_DATA : result;
+ return result == SqlResult::AI_SUCCESS ? SqlResult::AI_NO_DATA : result;
}
void Statement::GetColumnAttribute(uint16_t colIdx, uint16_t attrId,
@@ -758,7 +758,7 @@ namespace ignite
strbuf, buflen, reslen, numbuf));
}
- SqlResult Statement::InternalGetColumnAttribute(uint16_t colIdx,
+ SqlResult::Type Statement::InternalGetColumnAttribute(uint16_t colIdx,
uint16_t attrId, char* strbuf, int16_t buflen, int16_t* reslen,
SqlLen* numbuf)
{
@@ -766,17 +766,17 @@ namespace ignite
if (!meta)
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not executed.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (colIdx > meta->size() + 1 || colIdx < 1)
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR,
+ AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Column index is out of range.", 0, colIdx);
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
const meta::ColumnMeta& columnMeta = meta->at(colIdx - 1);
@@ -803,13 +803,13 @@ namespace ignite
if (!found)
{
- AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+ AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
"Unknown attribute.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
int64_t Statement::AffectedRows()
@@ -821,18 +821,18 @@ namespace ignite
return rowCnt;
}
- SqlResult Statement::InternalAffectedRows(int64_t& rowCnt)
+ SqlResult::Type Statement::InternalAffectedRows(int64_t& rowCnt)
{
if (!currentQuery.get())
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not executed.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not executed.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
rowCnt = currentQuery->AffectedRows();
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::SetRowsFetchedPtr(size_t* ptr)
@@ -860,21 +860,21 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalSelectParam(paramPtr));
}
- SqlResult Statement::InternalSelectParam(void** paramPtr)
+ SqlResult::Type Statement::InternalSelectParam(void** paramPtr)
{
if (!paramPtr)
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR,
+ AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Invalid parameter: ValuePtrPtr is null.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (!currentQuery.get())
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not prepared.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not prepared.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
app::ParameterBindingMap::iterator it;
@@ -885,11 +885,11 @@ namespace ignite
if (it != paramBindings.end() && !it->second.IsDataReady())
{
- AddStatusRecord(SQL_STATE_22026_DATA_LENGTH_MISMATCH,
+ AddStatusRecord(SqlState::S22026_DATA_LENGTH_MISMATCH,
"Less data was sent for a parameter than was specified with "
"the StrLen_or_IndPtr argument in SQLBindParameter.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
}
@@ -904,14 +904,14 @@ namespace ignite
currentParamIdx = paramIdx;
- return SQL_RESULT_NEED_DATA;
+ return SqlResult::AI_NEED_DATA;
}
}
- SqlResult res = currentQuery->Execute();
+ SqlResult::Type res = currentQuery->Execute();
- if (res != SQL_RESULT_SUCCESS)
- res = SQL_RESULT_SUCCESS_WITH_INFO;
+ if (res != SqlResult::AI_SUCCESS)
+ res = SqlResult::AI_SUCCESS_WITH_INFO;
return res;
}
@@ -921,40 +921,40 @@ namespace ignite
IGNITE_ODBC_API_CALL(InternalPutData(data, len));
}
- SqlResult Statement::InternalPutData(void* data, SqlLen len)
+ SqlResult::Type Statement::InternalPutData(void* data, SqlLen len)
{
if (!data && len != 0 && len != SQL_DEFAULT_PARAM && len != SQL_NULL_DATA)
{
- AddStatusRecord(SQL_STATE_HY009_INVALID_USE_OF_NULL_POINTER,
+ AddStatusRecord(SqlState::SHY009_INVALID_USE_OF_NULL_POINTER,
"Invalid parameter: DataPtr is null StrLen_or_Ind is not 0, "
"SQL_DEFAULT_PARAM, or SQL_NULL_DATA.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
if (currentParamIdx == 0)
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR,
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR,
"Parameter is not selected with the SQLParamData.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
app::ParameterBindingMap::iterator it = paramBindings.find(currentParamIdx);
if (it == paramBindings.end())
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR,
+ AddStatusRecord(SqlState::SHY000_GENERAL_ERROR,
"Selected parameter has been unbound.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
app::Parameter& param = it->second;
param.PutData(data, len);
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
void Statement::DescribeParam(int16_t paramNum, int16_t* dataType,
@@ -964,22 +964,22 @@ namespace ignite
dataType, paramSize, decimalDigits, nullable));
}
- SqlResult Statement::InternalDescribeParam(int16_t paramNum, int16_t* dataType,
+ SqlResult::Type Statement::InternalDescribeParam(int16_t paramNum, int16_t* dataType,
SqlUlen* paramSize, int16_t* decimalDigits, int16_t* nullable)
{
query::Query *qry = currentQuery.get();
if (!qry)
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not prepared.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not prepared.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
- if (qry->GetType() != query::Query::DATA)
+ if (qry->GetType() != query::QueryType::DATA)
{
- AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query is not SQL data query.");
+ AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query is not SQL data query.");
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
int8_t type = 0;
@@ -991,9 +991,9 @@ namespace ignite
if (!type)
{
- SqlResult res = UpdateParamsMeta();
+ SqlResult::Type res = UpdateParamsMeta();
- if (res != SQL_RESULT_SUCCESS)
+ if (res != SqlResult::AI_SUCCESS)
return res;
if (paramNum < 1 || static_cast<size_t>(paramNum) > paramTypes.size())
@@ -1014,15 +1014,15 @@ namespace ignite
if (nullable)
*nullable = type_traits::BinaryTypeNullability(type);
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
- SqlResult Statement::UpdateParamsMeta()
+ SqlResult::Type Statement::UpdateParamsMeta()
{
query::Query *qry0 = currentQuery.get();
assert(qry0 != 0);
- assert(qry0->GetType() == query::Query::DATA);
+ assert(qry0->GetType() == query::QueryType::DATA);
query::DataQuery* qry = static_cast<query::DataQuery*>(qry0);
@@ -1038,18 +1038,18 @@ namespace ignite
}
catch (const IgniteError& err)
{
- AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, err.GetText());
+ AddStatusRecord(SqlState::SHYT01_CONNECTIOIN_TIMEOUT, err.GetText());
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
- if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS)
+ if (rsp.GetStatus() != ResponseStatus::SUCCESS)
{
LOG_MSG("Error: " << rsp.GetError());
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError());
+ AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, rsp.GetError());
- return SQL_RESULT_ERROR;
+ return SqlResult::AI_ERROR;
}
paramTypes = rsp.GetTypeIds();
@@ -1059,7 +1059,7 @@ namespace ignite
LOG_MSG("[" << i << "] Parameter type: " << paramTypes[i]);
}
- return SQL_RESULT_SUCCESS;
+ return SqlResult::AI_SUCCESS;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4b7b03/modules/platforms/cpp/odbc/src/type_traits.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/type_traits.cpp b/modules/platforms/cpp/odbc/src/type_traits.cpp
index e4ce10f..bff21d1 100644
--- a/modules/platforms/cpp/odbc/src/type_traits.cpp
+++ b/modules/platforms/cpp/odbc/src/type_traits.cpp
@@ -187,7 +187,7 @@ namespace ignite
bool IsApplicationTypeSupported(int16_t type)
{
- return ToDriverType(type) != IGNITE_ODBC_C_TYPE_UNSUPPORTED;
+ return ToDriverType(type) != OdbcNativeType::AI_UNSUPPORTED;
}
bool IsSqlTypeSupported(int16_t type)
@@ -296,75 +296,75 @@ namespace ignite
return -1;
}
- IgniteSqlType ToDriverType(int16_t type)
+ OdbcNativeType::Type ToDriverType(int16_t type)
{
switch (type)
{
case SQL_C_CHAR:
- return IGNITE_ODBC_C_TYPE_CHAR;
+ return OdbcNativeType::AI_CHAR;
case SQL_C_WCHAR:
- return IGNITE_ODBC_C_TYPE_WCHAR;
+ return OdbcNativeType::AI_WCHAR;
case SQL_C_SSHORT:
case SQL_C_SHORT:
- return IGNITE_ODBC_C_TYPE_SIGNED_SHORT;
+ return OdbcNativeType::AI_SIGNED_SHORT;
case SQL_C_USHORT:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT;
+ return OdbcNativeType::AI_UNSIGNED_SHORT;
case SQL_C_SLONG:
case SQL_C_LONG:
- return IGNITE_ODBC_C_TYPE_SIGNED_LONG;
+ return OdbcNativeType::AI_SIGNED_LONG;
case SQL_C_ULONG:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_LONG;
+ return OdbcNativeType::AI_UNSIGNED_LONG;
case SQL_C_FLOAT:
- return IGNITE_ODBC_C_TYPE_FLOAT;
+ return OdbcNativeType::AI_FLOAT;
case SQL_C_DOUBLE:
- return IGNITE_ODBC_C_TYPE_DOUBLE;
+ return OdbcNativeType::AI_DOUBLE;
case SQL_C_BIT:
- return IGNITE_ODBC_C_TYPE_BIT;
+ return OdbcNativeType::AI_BIT;
case SQL_C_STINYINT:
case SQL_C_TINYINT:
- return IGNITE_ODBC_C_TYPE_SIGNED_TINYINT;
+ return OdbcNativeType::AI_SIGNED_TINYINT;
case SQL_C_UTINYINT:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT;
+ return OdbcNativeType::AI_UNSIGNED_TINYINT;
case SQL_C_SBIGINT:
- return IGNITE_ODBC_C_TYPE_SIGNED_BIGINT;
+ return OdbcNativeType::AI_SIGNED_BIGINT;
case SQL_C_UBIGINT:
- return IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT;
+ return OdbcNativeType::AI_UNSIGNED_BIGINT;
case SQL_C_BINARY:
- return IGNITE_ODBC_C_TYPE_BINARY;
+ return OdbcNativeType::AI_BINARY;
case SQL_C_TYPE_DATE:
- return IGNITE_ODBC_C_TYPE_TDATE;
+ return OdbcNativeType::AI_TDATE;
case SQL_C_TYPE_TIME:
- return IGNITE_ODBC_C_TYPE_TTIME;
+ return OdbcNativeType::AI_TTIME;
case SQL_C_TYPE_TIMESTAMP:
- return IGNITE_ODBC_C_TYPE_TTIMESTAMP;
+ return OdbcNativeType::AI_TTIMESTAMP;
case SQL_C_NUMERIC:
- return IGNITE_ODBC_C_TYPE_NUMERIC;
+ return OdbcNativeType::AI_NUMERIC;
case SQL_C_GUID:
- return IGNITE_ODBC_C_TYPE_GUID;
+ return OdbcNativeType::AI_GUID;
case SQL_C_DEFAULT:
- return IGNITE_ODBC_C_TYPE_DEFAULT;
+ return OdbcNativeType::AI_DEFAULT;
default:
- return IGNITE_ODBC_C_TYPE_UNSUPPORTED;
+ return OdbcNativeType::AI_UNSUPPORTED;
}
}