http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp index c075567..4b90e44 100644 --- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp +++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp @@ -30,7 +30,7 @@ namespace ignite rowCount(0), dynamicFunction(), dynamicFunctionCode(0), - result(SQL_RESULT_SUCCESS), + result(SqlResult::AI_SUCCESS), rowsAffected(0) { // No-op. @@ -41,7 +41,7 @@ namespace ignite // No-op. } - void DiagnosticRecordStorage::SetHeaderRecord(SqlResult result) + void DiagnosticRecordStorage::SetHeaderRecord(SqlResult::Type result) { rowCount = 0; dynamicFunction.clear(); @@ -57,12 +57,12 @@ namespace ignite void DiagnosticRecordStorage::Reset() { - SetHeaderRecord(SQL_RESULT_ERROR); + SetHeaderRecord(SqlResult::AI_ERROR); statusRecords.clear(); } - SqlResult DiagnosticRecordStorage::GetOperaionResult() const + SqlResult::Type DiagnosticRecordStorage::GetOperaionResult() const { return result; } @@ -122,55 +122,55 @@ namespace ignite bool DiagnosticRecordStorage::IsSuccessful() const { - return result == SQL_RESULT_SUCCESS || - result == SQL_RESULT_SUCCESS_WITH_INFO; + return result == SqlResult::AI_SUCCESS || + result == SqlResult::AI_SUCCESS_WITH_INFO; } - SqlResult DiagnosticRecordStorage::GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const + SqlResult::Type DiagnosticRecordStorage::GetField(int32_t recNum, DiagnosticField::Type field, app::ApplicationDataBuffer& buffer) const { // Header record. switch (field) { - case IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT: + case DiagnosticField::HEADER_CURSOR_ROW_COUNT: { buffer.PutInt64(GetRowCount()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION: + case DiagnosticField::HEADER_DYNAMIC_FUNCTION: { buffer.PutString(GetDynamicFunction()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE: + case DiagnosticField::HEADER_DYNAMIC_FUNCTION_CODE: { buffer.PutInt32(GetDynamicFunctionCode()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_HEADER_NUMBER: + case DiagnosticField::HEADER_NUMBER: { buffer.PutInt32(GetStatusRecordsNumber()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_HEADER_RETURNCODE: + case DiagnosticField::HEADER_RETURNCODE: { buffer.PutInt32(GetReturnCode()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_HEADER_ROW_COUNT: + case DiagnosticField::HEADER_ROW_COUNT: { buffer.PutInt64(GetRowsAffected()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } default: @@ -178,81 +178,81 @@ namespace ignite } if (recNum < 1 || static_cast<size_t>(recNum) > statusRecords.size()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; // Status record. const DiagnosticRecord& record = GetStatusRecord(recNum); switch (field) { - case IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN: + case DiagnosticField::STATUS_CLASS_ORIGIN: { buffer.PutString(record.GetClassOrigin()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER: + case DiagnosticField::STATUS_COLUMN_NUMBER: { buffer.PutInt32(record.GetColumnNumber()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME: + case DiagnosticField::STATUS_CONNECTION_NAME: { buffer.PutString(record.GetConnectionName()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT: + case DiagnosticField::STATUS_MESSAGE_TEXT: { buffer.PutString(record.GetMessageText()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_NATIVE: + case DiagnosticField::STATUS_NATIVE: { buffer.PutInt32(0); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_ROW_NUMBER: + case DiagnosticField::STATUS_ROW_NUMBER: { buffer.PutInt64(record.GetRowNumber()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_SERVER_NAME: + case DiagnosticField::STATUS_SERVER_NAME: { buffer.PutString(record.GetServerName()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_SQLSTATE: + case DiagnosticField::STATUS_SQLSTATE: { buffer.PutString(record.GetSqlState()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN: + case DiagnosticField::STATUS_SUBCLASS_ORIGIN: { buffer.PutString(record.GetSubclassOrigin()); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } default: break; } - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } }
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/environment.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/environment.cpp b/modules/platforms/cpp/odbc/src/environment.cpp index 3928295..6182fa2 100644 --- a/modules/platforms/cpp/odbc/src/environment.cpp +++ b/modules/platforms/cpp/odbc/src/environment.cpp @@ -43,18 +43,18 @@ namespace ignite return connection; } - SqlResult Environment::InternalCreateConnection(Connection*& connection) + SqlResult::Type Environment::InternalCreateConnection(Connection*& connection) { connection = new Connection; if (!connection) { - AddStatusRecord(SQL_STATE_HY001_MEMORY_ALLOCATION, "Not enough memory."); + AddStatusRecord(SqlState::SHY001_MEMORY_ALLOCATION, "Not enough memory."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } void Environment::TransactionCommit() @@ -62,9 +62,9 @@ namespace ignite IGNITE_ODBC_API_CALL(InternalTransactionCommit()); } - SqlResult Environment::InternalTransactionCommit() + SqlResult::Type Environment::InternalTransactionCommit() { - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } void Environment::TransactionRollback() @@ -72,12 +72,12 @@ namespace ignite IGNITE_ODBC_API_CALL(InternalTransactionRollback()); } - SqlResult Environment::InternalTransactionRollback() + SqlResult::Type Environment::InternalTransactionRollback() { - AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, + AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Rollback operation is not supported."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } void Environment::SetAttribute(int32_t attr, void* value, int32_t len) @@ -85,51 +85,51 @@ namespace ignite IGNITE_ODBC_API_CALL(InternalSetAttribute(attr, value, len)); } - SqlResult Environment::InternalSetAttribute(int32_t attr, void* value, int32_t len) + SqlResult::Type Environment::InternalSetAttribute(int32_t attr, void* value, int32_t len) { - EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr); + EnvironmentAttribute::Type attribute = EnvironmentAttributeToInternal(attr); switch (attribute) { - case IGNITE_SQL_ENV_ATTR_ODBC_VERSION: + case EnvironmentAttribute::ODBC_VERSION: { int32_t version = static_cast<int32_t>(reinterpret_cast<intptr_t>(value)); if (version != odbcVersion) { - AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED, + AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, "ODBC version is not supported."); - return SQL_RESULT_SUCCESS_WITH_INFO; + return SqlResult::AI_SUCCESS_WITH_INFO; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS: + case EnvironmentAttribute::OUTPUT_NTS: { int32_t nts = static_cast<int32_t>(reinterpret_cast<intptr_t>(value)); if (nts != odbcNts) { - AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED, + AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, "Only null-termination of strings is supported."); - return SQL_RESULT_SUCCESS_WITH_INFO; + return SqlResult::AI_SUCCESS_WITH_INFO; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_ENV_ATTR_UNKNOWN: + case EnvironmentAttribute::UNKNOWN: default: break; } - AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, + AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Attribute is not supported."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } void Environment::GetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer) @@ -137,35 +137,35 @@ namespace ignite IGNITE_ODBC_API_CALL(InternalGetAttribute(attr, buffer)); } - SqlResult Environment::InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer) + SqlResult::Type Environment::InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer) { - EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr); + EnvironmentAttribute::Type attribute = EnvironmentAttributeToInternal(attr); switch (attribute) { - case IGNITE_SQL_ENV_ATTR_ODBC_VERSION: + case EnvironmentAttribute::ODBC_VERSION: { buffer.PutInt32(odbcVersion); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS: + case EnvironmentAttribute::OUTPUT_NTS: { buffer.PutInt32(odbcNts); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - case IGNITE_SQL_ENV_ATTR_UNKNOWN: + case EnvironmentAttribute::UNKNOWN: default: break; } - AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, + AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Attribute is not supported."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/odbc.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp index 542e64c..ed5e362 100644 --- a/modules/platforms/cpp/odbc/src/odbc.cpp +++ b/modules/platforms/cpp/odbc/src/odbc.cpp @@ -85,7 +85,7 @@ namespace ignite *result = 0; connection->GetDiagnosticRecords().Reset(); - connection->AddStatusRecord(odbc::SQL_STATE_IM001_FUNCTION_NOT_SUPPORTED, + connection->AddStatusRecord(odbc::SqlState::SIM001_FUNCTION_NOT_SUPPORTED, "The HandleType argument was SQL_HANDLE_DESC, and " "the driver does not support allocating a descriptor handle"); @@ -919,11 +919,11 @@ namespace ignite LOG_MSG("SQLGetDiagField called: " << recNum); SqlLen outResLen; - ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, buffer, bufferLen, &outResLen); + ApplicationDataBuffer outBuffer(OdbcNativeType::AI_DEFAULT, buffer, bufferLen, &outResLen); - SqlResult result; + SqlResult::Type result; - DiagnosticField field = DiagnosticFieldToInternal(diagId); + DiagnosticField::Type field = DiagnosticFieldToInternal(diagId); switch (handleType) { @@ -940,12 +940,12 @@ namespace ignite default: { - result = SQL_RESULT_NO_DATA; + result = SqlResult::AI_NO_DATA; break; } } - if (resLen && result == SQL_RESULT_SUCCESS) + if (resLen && result == SqlResult::AI_SUCCESS) *resLen = static_cast<SQLSMALLINT>(outResLen); return SqlResultToReturnCode(result); @@ -1000,7 +1000,7 @@ namespace ignite *nativeError = 0; SqlLen outResLen; - ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen); + ApplicationDataBuffer outBuffer(OdbcNativeType::AI_CHAR, msgBuffer, msgBufferLen, &outResLen); outBuffer.PutString(record.GetMessageText()); @@ -1100,7 +1100,7 @@ namespace ignite if (!statement) return SQL_INVALID_HANDLE; - IgniteSqlType driverType = ToDriverType(targetType); + OdbcNativeType::Type driverType = ToDriverType(targetType); ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator); @@ -1147,7 +1147,7 @@ namespace ignite return SQL_INVALID_HANDLE; SqlLen outResLen; - ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, valueBuf, + ApplicationDataBuffer outBuffer(OdbcNativeType::AI_DEFAULT, valueBuf, static_cast<int32_t>(valueBufLen), &outResLen); environment->GetAttribute(attr, outBuffer); @@ -1295,7 +1295,7 @@ namespace ignite *error = 0; SqlLen outResLen; - ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuf, msgBufLen, &outResLen); + ApplicationDataBuffer outBuffer(OdbcNativeType::AI_CHAR, msgBuf, msgBufLen, &outResLen); outBuffer.PutString(record.GetMessageText()); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp b/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp index 9aa5f7d..cca3eb5 100644 --- a/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp +++ b/modules/platforms/cpp/odbc/src/query/column_metadata_query.cpp @@ -25,43 +25,46 @@ namespace { - enum ResultColumn + struct ResultColumn { - /** Catalog name. NULL if not applicable to the data source. */ - TABLE_CAT = 1, + enum Type + { + /** Catalog name. NULL if not applicable to the data source. */ + TABLE_CAT = 1, - /** Schema name. NULL if not applicable to the data source. */ - TABLE_SCHEM, + /** Schema name. NULL if not applicable to the data source. */ + TABLE_SCHEM, - /** Table name. */ - TABLE_NAME, + /** Table name. */ + TABLE_NAME, - /** Column name. */ - COLUMN_NAME, + /** Column name. */ + COLUMN_NAME, - /** SQL data type. */ - DATA_TYPE, + /** SQL data type. */ + DATA_TYPE, - /** Data source�dependent data type name. */ - TYPE_NAME, + /** Data source�dependent data type name. */ + TYPE_NAME, - /** Column size. */ - COLUMN_SIZE, + /** Column size. */ + COLUMN_SIZE, - /** The length in bytes of data transferred on fetch. */ - BUFFER_LENGTH, + /** The length in bytes of data transferred on fetch. */ + BUFFER_LENGTH, - /** The total number of significant digits to the right of the decimal point. */ - DECIMAL_DIGITS, + /** The total number of significant digits to the right of the decimal point. */ + DECIMAL_DIGITS, - /** Precision. */ - NUM_PREC_RADIX, + /** Precision. */ + NUM_PREC_RADIX, - /** Nullability of the data in column. */ - NULLABLE, + /** Nullability of the data in column. */ + NULLABLE, - /** A description of the column. */ - REMARKS + /** A description of the column. */ + REMARKS + }; }; } @@ -74,7 +77,7 @@ namespace ignite ColumnMetadataQuery::ColumnMetadataQuery(diagnostic::Diagnosable& diag, Connection& connection, const std::string& schema, const std::string& table, const std::string& column) : - Query(diag, COLUMN_METADATA), + Query(diag, QueryType::COLUMN_METADATA), connection(connection), schema(schema), table(table), @@ -112,14 +115,14 @@ namespace ignite // No-op. } - SqlResult ColumnMetadataQuery::Execute() + SqlResult::Type ColumnMetadataQuery::Execute() { if (executed) Close(); - SqlResult result = MakeRequestGetColumnsMeta(); + SqlResult::Type result = MakeRequestGetColumnsMeta(); - if (result == SQL_RESULT_SUCCESS) + if (result == SqlResult::AI_SUCCESS) { executed = true; @@ -134,17 +137,17 @@ namespace ignite return columnsMeta; } - SqlResult ColumnMetadataQuery::FetchNextRow(app::ColumnBindingMap & columnBindings) + SqlResult::Type ColumnMetadataQuery::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 == meta.end()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; app::ColumnBindingMap::iterator it; @@ -153,75 +156,75 @@ namespace ignite ++cursor; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult ColumnMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer) + SqlResult::Type ColumnMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer) { 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 == meta.end()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; const meta::ColumnMeta& currentColumn = *cursor; uint8_t columnType = currentColumn.GetDataType(); switch (columnIdx) { - case TABLE_CAT: + case ResultColumn::TABLE_CAT: { buffer.PutNull(); break; } - case TABLE_SCHEM: + case ResultColumn::TABLE_SCHEM: { buffer.PutString(currentColumn.GetSchemaName()); break; } - case TABLE_NAME: + case ResultColumn::TABLE_NAME: { buffer.PutString(currentColumn.GetTableName()); break; } - case COLUMN_NAME: + case ResultColumn::COLUMN_NAME: { buffer.PutString(currentColumn.GetColumnName()); break; } - case DATA_TYPE: + case ResultColumn::DATA_TYPE: { buffer.PutInt16(type_traits::BinaryToSqlType(columnType)); break; } - case TYPE_NAME: + case ResultColumn::TYPE_NAME: { buffer.PutString(type_traits::BinaryTypeToSqlTypeName(currentColumn.GetDataType())); break; } - case COLUMN_SIZE: + case ResultColumn::COLUMN_SIZE: { buffer.PutInt16(type_traits::BinaryTypeColumnSize(columnType)); break; } - case BUFFER_LENGTH: + case ResultColumn::BUFFER_LENGTH: { buffer.PutInt16(type_traits::BinaryTypeTransferLength(columnType)); break; } - case DECIMAL_DIGITS: + case ResultColumn::DECIMAL_DIGITS: { int32_t decDigits = type_traits::BinaryTypeDecimalDigits(columnType); if (decDigits < 0) @@ -231,19 +234,19 @@ namespace ignite break; } - case NUM_PREC_RADIX: + case ResultColumn::NUM_PREC_RADIX: { buffer.PutInt16(type_traits::BinaryTypeNumPrecRadix(columnType)); break; } - case NULLABLE: + case ResultColumn::NULLABLE: { buffer.PutInt16(type_traits::BinaryTypeNullability(columnType)); break; } - case REMARKS: + case ResultColumn::REMARKS: { buffer.PutNull(); break; @@ -253,16 +256,16 @@ namespace ignite break; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult ColumnMetadataQuery::Close() + SqlResult::Type ColumnMetadataQuery::Close() { meta.clear(); executed = false; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } bool ColumnMetadataQuery::DataAvailable() const @@ -275,7 +278,7 @@ namespace ignite return 0; } - SqlResult ColumnMetadataQuery::MakeRequestGetColumnsMeta() + SqlResult::Type ColumnMetadataQuery::MakeRequestGetColumnsMeta() { QueryGetColumnsMetaRequest req(schema, table, column); QueryGetColumnsMetaResponse rsp; @@ -286,17 +289,17 @@ namespace ignite } catch (const IgniteError& err) { - diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, err.GetText()); + diag.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()); - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError()); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, rsp.GetError()); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } meta = rsp.GetMeta(); @@ -309,7 +312,7 @@ namespace ignite << "\n[" << i << "] ColumnType: " << meta[i].GetDataType()); } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/query/data_query.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/query/data_query.cpp b/modules/platforms/cpp/odbc/src/query/data_query.cpp index c9762ad..33e763f 100644 --- a/modules/platforms/cpp/odbc/src/query/data_query.cpp +++ b/modules/platforms/cpp/odbc/src/query/data_query.cpp @@ -29,7 +29,7 @@ namespace ignite DataQuery::DataQuery(diagnostic::Diagnosable& diag, Connection& connection, const std::string& sql, const app::ParameterBindingMap& params) : - Query(diag, DATA), + Query(diag, QueryType::DATA), connection(connection), sql(sql), params(params) @@ -42,13 +42,13 @@ namespace ignite Close(); } - SqlResult DataQuery::Execute() + SqlResult::Type DataQuery::Execute() { if (cursor.get()) { - diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query cursor is in open state already."); + diag.AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query cursor is in open state already."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } return MakeRequestExecute(); @@ -59,38 +59,38 @@ namespace ignite return resultMeta; } - SqlResult DataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings) + SqlResult::Type DataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings) { if (!cursor.get()) { - 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->HasData()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; cursor->Increment(); if (cursor->NeedDataUpdate()) { - SqlResult result = MakeRequestFetch(); + SqlResult::Type result = MakeRequestFetch(); - if (result != SQL_RESULT_SUCCESS) + if (result != SqlResult::AI_SUCCESS) return result; } if (!cursor->HasData()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; Row* row = cursor->GetRow(); if (!row) { - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown error."); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Unknown error."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } for (int32_t i = 1; i < row->GetSize() + 1; ++i) @@ -100,53 +100,53 @@ namespace ignite if (it == columnBindings.end()) continue; - SqlResult result = row->ReadColumnToBuffer(i, it->second); + SqlResult::Type result = row->ReadColumnToBuffer(i, it->second); - if (result == SQL_RESULT_ERROR) + if (result == SqlResult::AI_ERROR) { - diag.AddStatusRecord(SQL_STATE_01S01_ERROR_IN_ROW, "Can not retrieve row column.", 0, i); + diag.AddStatusRecord(SqlState::S01S01_ERROR_IN_ROW, "Can not retrieve row column.", 0, i); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult DataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) + SqlResult::Type DataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) { if (!cursor.get()) { - 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; } Row* row = cursor->GetRow(); if (!row) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; - SqlResult result = row->ReadColumnToBuffer(columnIdx, buffer); + SqlResult::Type result = row->ReadColumnToBuffer(columnIdx, buffer); - if (result == SQL_RESULT_ERROR) + if (result == SqlResult::AI_ERROR) { - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown column type."); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Unknown column type."); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } return result; } - SqlResult DataQuery::Close() + SqlResult::Type DataQuery::Close() { if (!cursor.get()) - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; - SqlResult result = MakeRequestClose(); + SqlResult::Type result = MakeRequestClose(); - if (result == SQL_RESULT_SUCCESS) + if (result == SqlResult::AI_SUCCESS) { cursor.reset(); @@ -167,7 +167,7 @@ namespace ignite return 0; } - SqlResult DataQuery::MakeRequestExecute() + SqlResult::Type DataQuery::MakeRequestExecute() { const std::string& cacheName = connection.GetCache(); @@ -180,18 +180,18 @@ namespace ignite } catch (const IgniteError& err) { - diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, err.GetText()); + diag.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()); - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError()); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, rsp.GetError()); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } cursor.reset(new Cursor(rsp.GetQueryId())); @@ -207,10 +207,10 @@ namespace ignite << "\n[" << i << "] ColumnType: " << rsp.GetMeta()[i].GetDataType()); } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult DataQuery::MakeRequestClose() + SqlResult::Type DataQuery::MakeRequestClose() { QueryCloseRequest req(cursor->GetQueryId()); QueryCloseResponse rsp; @@ -221,26 +221,26 @@ namespace ignite } catch (const IgniteError& err) { - diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, err.GetText()); + diag.AddStatusRecord(SqlState::SHYT01_CONNECTIOIN_TIMEOUT, err.GetText()); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } LOG_MSG("Query id: " << rsp.GetQueryId()); - if (rsp.GetStatus() != RESPONSE_STATUS_SUCCESS) + if (rsp.GetStatus() != ResponseStatus::SUCCESS) { LOG_MSG("Error: " << rsp.GetError()); - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError()); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, rsp.GetError()); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult DataQuery::MakeRequestFetch() + SqlResult::Type DataQuery::MakeRequestFetch() { std::auto_ptr<ResultPage> resultPage(new ResultPage()); @@ -253,23 +253,23 @@ namespace ignite } catch (const IgniteError& err) { - diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, err.GetText()); + diag.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()); - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError()); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, rsp.GetError()); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } cursor->UpdateData(resultPage); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp b/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp index 5813767..4ca7709 100644 --- a/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp +++ b/modules/platforms/cpp/odbc/src/query/foreign_keys_query.cpp @@ -32,7 +32,7 @@ namespace ignite const std::string& primaryCatalog, const std::string& primarySchema, const std::string& primaryTable, const std::string& foreignCatalog, const std::string& foreignSchema, const std::string& foreignTable) : - Query(diag, FOREIGN_KEYS), + Query(diag, QueryType::FOREIGN_KEYS), connection(connection), primaryCatalog(primaryCatalog), primarySchema(primarySchema), @@ -74,11 +74,11 @@ namespace ignite // No-op. } - SqlResult ForeignKeysQuery::Execute() + SqlResult::Type ForeignKeysQuery::Execute() { executed = true; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } const meta::ColumnMetaVector & ForeignKeysQuery::GetMeta() const @@ -86,35 +86,35 @@ namespace ignite return columnsMeta; } - SqlResult ForeignKeysQuery::FetchNextRow(app::ColumnBindingMap & columnBindings) + SqlResult::Type ForeignKeysQuery::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; } - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; } - SqlResult ForeignKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) + SqlResult::Type ForeignKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) { 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; } - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; } - SqlResult ForeignKeysQuery::Close() + SqlResult::Type ForeignKeysQuery::Close() { executed = false; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } bool ForeignKeysQuery::DataAvailable() const http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp b/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp index a24670d..ef99db3 100644 --- a/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp +++ b/modules/platforms/cpp/odbc/src/query/primary_keys_query.cpp @@ -24,25 +24,28 @@ namespace { - enum ResultColumn + struct ResultColumn { - /** Catalog name. NULL if not applicable to the data source. */ - TABLE_CAT = 1, + enum Type + { + /** Catalog name. NULL if not applicable to the data source. */ + TABLE_CAT = 1, - /** Schema name. NULL if not applicable to the data source. */ - TABLE_SCHEM, + /** Schema name. NULL if not applicable to the data source. */ + TABLE_SCHEM, - /** Table name. */ - TABLE_NAME, + /** Table name. */ + TABLE_NAME, - /** Column name. */ - COLUMN_NAME, + /** Column name. */ + COLUMN_NAME, - /** Column sequence number in key. */ - KEY_SEQ, + /** Column sequence number in key. */ + KEY_SEQ, - /** Primary key name. */ - PK_NAME + /** Primary key name. */ + PK_NAME + }; }; } @@ -55,7 +58,7 @@ namespace ignite PrimaryKeysQuery::PrimaryKeysQuery(diagnostic::Diagnosable& diag, Connection& connection, const std::string& catalog, const std::string& schema, const std::string& table) : - Query(diag, PRIMARY_KEYS), + Query(diag, QueryType::PRIMARY_KEYS), connection(connection), catalog(catalog), schema(schema), @@ -86,7 +89,7 @@ namespace ignite // No-op. } - SqlResult PrimaryKeysQuery::Execute() + SqlResult::Type PrimaryKeysQuery::Execute() { if (executed) Close(); @@ -97,7 +100,7 @@ namespace ignite cursor = meta.begin(); - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } const meta::ColumnMetaVector & PrimaryKeysQuery::GetMeta() const @@ -105,17 +108,17 @@ namespace ignite return columnsMeta; } - SqlResult PrimaryKeysQuery::FetchNextRow(app::ColumnBindingMap & columnBindings) + SqlResult::Type PrimaryKeysQuery::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 == meta.end()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; app::ColumnBindingMap::iterator it; @@ -124,56 +127,56 @@ namespace ignite ++cursor; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult PrimaryKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) + SqlResult::Type PrimaryKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) { 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 == meta.end()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; const meta::PrimaryKeyMeta& currentColumn = *cursor; switch (columnIdx) { - case TABLE_CAT: + case ResultColumn::TABLE_CAT: { buffer.PutString(currentColumn.GetCatalogName()); break; } - case TABLE_SCHEM: + case ResultColumn::TABLE_SCHEM: { buffer.PutString(currentColumn.GetSchemaName()); break; } - case TABLE_NAME: + case ResultColumn::TABLE_NAME: { buffer.PutString(currentColumn.GetTableName()); break; } - case COLUMN_NAME: + case ResultColumn::COLUMN_NAME: { buffer.PutString(currentColumn.GetColumnName()); break; } - case KEY_SEQ: + case ResultColumn::KEY_SEQ: { buffer.PutInt16(currentColumn.GetKeySeq()); break; } - case PK_NAME: + case ResultColumn::PK_NAME: { buffer.PutString(currentColumn.GetKeyName()); break; @@ -183,16 +186,16 @@ namespace ignite break; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult PrimaryKeysQuery::Close() + SqlResult::Type PrimaryKeysQuery::Close() { meta.clear(); executed = false; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } bool PrimaryKeysQuery::DataAvailable() const http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp b/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp index f507c52..b0f534c 100644 --- a/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp +++ b/modules/platforms/cpp/odbc/src/query/special_columns_query.cpp @@ -29,7 +29,7 @@ namespace ignite 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, SPECIAL_COLUMNS), + Query(diag, QueryType::SPECIAL_COLUMNS), type(type), catalog(catalog), schema(schema), @@ -64,11 +64,11 @@ namespace ignite // No-op. } - SqlResult SpecialColumnsQuery::Execute() + SqlResult::Type SpecialColumnsQuery::Execute() { executed = true; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } const meta::ColumnMetaVector& SpecialColumnsQuery::GetMeta() const @@ -76,35 +76,35 @@ namespace ignite return columnsMeta; } - SqlResult SpecialColumnsQuery::FetchNextRow(app::ColumnBindingMap & columnBindings) + SqlResult::Type SpecialColumnsQuery::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; } - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; } - SqlResult SpecialColumnsQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) + SqlResult::Type SpecialColumnsQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer) { 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; } - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; } - SqlResult SpecialColumnsQuery::Close() + SqlResult::Type SpecialColumnsQuery::Close() { executed = false; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } bool SpecialColumnsQuery::DataAvailable() const http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp b/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp index 4fd5f7b..401a1d2 100644 --- a/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp +++ b/modules/platforms/cpp/odbc/src/query/table_metadata_query.cpp @@ -25,22 +25,25 @@ namespace { - enum ResultColumn + struct ResultColumn { - /** Catalog name. NULL if not applicable to the data source. */ - TABLE_CAT = 1, + enum Type + { + /** Catalog name. NULL if not applicable to the data source. */ + TABLE_CAT = 1, - /** Schema name. NULL if not applicable to the data source. */ - TABLE_SCHEM, + /** Schema name. NULL if not applicable to the data source. */ + TABLE_SCHEM, - /** Table name. */ - TABLE_NAME, + /** Table name. */ + TABLE_NAME, - /** Table type. */ - TABLE_TYPE, + /** Table type. */ + TABLE_TYPE, - /** A description of the column. */ - REMARKS + /** A description of the column. */ + REMARKS + }; }; } @@ -53,7 +56,7 @@ namespace ignite TableMetadataQuery::TableMetadataQuery(diagnostic::Diagnosable& diag, Connection& connection, const std::string& catalog,const std::string& schema, const std::string& table, const std::string& tableType) : - Query(diag, TABLE_METADATA), + Query(diag, QueryType::TABLE_METADATA), connection(connection), catalog(catalog), schema(schema), @@ -85,14 +88,14 @@ namespace ignite // No-op. } - SqlResult TableMetadataQuery::Execute() + SqlResult::Type TableMetadataQuery::Execute() { if (executed) Close(); - SqlResult result = MakeRequestGetTablesMeta(); + SqlResult::Type result = MakeRequestGetTablesMeta(); - if (result == SQL_RESULT_SUCCESS) + if (result == SqlResult::AI_SUCCESS) { executed = true; @@ -107,17 +110,17 @@ namespace ignite return columnsMeta; } - SqlResult TableMetadataQuery::FetchNextRow(app::ColumnBindingMap& columnBindings) + SqlResult::Type TableMetadataQuery::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 == meta.end()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; app::ColumnBindingMap::iterator it; @@ -126,50 +129,50 @@ namespace ignite ++cursor; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult TableMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer) + SqlResult::Type TableMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer) { 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 == meta.end()) - return SQL_RESULT_NO_DATA; + return SqlResult::AI_NO_DATA; const meta::TableMeta& currentColumn = *cursor; switch (columnIdx) { - case TABLE_CAT: + case ResultColumn::TABLE_CAT: { buffer.PutString(currentColumn.GetCatalogName()); break; } - case TABLE_SCHEM: + case ResultColumn::TABLE_SCHEM: { buffer.PutString(currentColumn.GetSchemaName()); break; } - case TABLE_NAME: + case ResultColumn::TABLE_NAME: { buffer.PutString(currentColumn.GetTableName()); break; } - case TABLE_TYPE: + case ResultColumn::TABLE_TYPE: { buffer.PutString(currentColumn.GetTableType()); break; } - case REMARKS: + case ResultColumn::REMARKS: { buffer.PutNull(); break; @@ -179,16 +182,16 @@ namespace ignite break; } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } - SqlResult TableMetadataQuery::Close() + SqlResult::Type TableMetadataQuery::Close() { meta.clear(); executed = false; - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } bool TableMetadataQuery::DataAvailable() const @@ -201,7 +204,7 @@ namespace ignite return 0; } - SqlResult TableMetadataQuery::MakeRequestGetTablesMeta() + SqlResult::Type TableMetadataQuery::MakeRequestGetTablesMeta() { QueryGetTablesMetaRequest req(catalog, schema, table, tableType); QueryGetTablesMetaResponse rsp; @@ -212,18 +215,18 @@ namespace ignite } catch (const IgniteError& err) { - diag.AddStatusRecord(SQL_STATE_HYT01_CONNECTIOIN_TIMEOUT, err.GetText()); + diag.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()); - diag.AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, rsp.GetError()); + diag.AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, rsp.GetError()); - return SQL_RESULT_ERROR; + return SqlResult::AI_ERROR; } meta = rsp.GetMeta(); @@ -236,7 +239,7 @@ namespace ignite << "\n[" << i << "] TableType: " << meta[i].GetTableType()); } - return SQL_RESULT_SUCCESS; + return SqlResult::AI_SUCCESS; } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e106cd0/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�dependent 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�dependent 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�dependent 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�dependent 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/7e106cd0/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);
