Exemplo n.º 1
0
        SqlResult Environment::InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer)
        {
            EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr);

            switch (attribute)
            {
                case IGNITE_SQL_ENV_ATTR_ODBC_VERSION:
                {
                    buffer.PutInt32(odbcVersion);

                    return SQL_RESULT_SUCCESS;
                }

                case IGNITE_SQL_ENV_ATTR_OUTPUT_NTS:
                {
                    buffer.PutInt32(odbcNts);

                    return SQL_RESULT_SUCCESS;
                }

                case IGNITE_SQL_ENV_ATTR_UNKNOWN:
                default:
                    break;
            }

            AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
                "Attribute is not supported.");

            return SQL_RESULT_ERROR;
        }
Exemplo n.º 2
0
            SqlResult::Type TableMetadataQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer & buffer)
            {
                if (!executed)
                {
                    diag.AddStatusRecord(SqlState::SHY010_SEQUENCE_ERROR, "Query was not executed.");

                    return SqlResult::AI_ERROR;
                }

                if (cursor == meta.end())
                {
                    diag.AddStatusRecord(SqlState::S24000_INVALID_CURSOR_STATE,
                        "Cursor has reached end of the result set.");

                    return SqlResult::AI_ERROR;
                }

                const meta::TableMeta& currentColumn = *cursor;

                switch (columnIdx)
                {
                    case ResultColumn::TABLE_CAT:
                    {
                        buffer.PutString(currentColumn.GetCatalogName());
                        break;
                    }

                    case ResultColumn::TABLE_SCHEM:
                    {
                        buffer.PutString(currentColumn.GetSchemaName());
                        break;
                    }

                    case ResultColumn::TABLE_NAME:
                    {
                        buffer.PutString(currentColumn.GetTableName());
                        break;
                    }

                    case ResultColumn::TABLE_TYPE:
                    {
                        buffer.PutString(currentColumn.GetTableType());
                        break;
                    }

                    case ResultColumn::REMARKS:
                    {
                        buffer.PutNull();
                        break;
                    }

                    default:
                        break;
                }

                return SqlResult::AI_SUCCESS;
            }
Exemplo n.º 3
0
            SqlResult PrimaryKeysQuery::GetColumn(uint16_t columnIdx, app::ApplicationDataBuffer& buffer)
            {
                if (!executed)
                {
                    diag.AddStatusRecord(SQL_STATE_HY010_SEQUENCE_ERROR, "Query was not executed.");

                    return SQL_RESULT_ERROR;
                }

                if (cursor == meta.end())
                    return SQL_RESULT_NO_DATA;

                const meta::PrimaryKeyMeta& currentColumn = *cursor;

                switch (columnIdx)
                {
                    case TABLE_CAT:
                    {
                        buffer.PutString(currentColumn.GetCatalogName());
                        break;
                    }

                    case TABLE_SCHEM:
                    {
                        buffer.PutString(currentColumn.GetSchemaName());
                        break;
                    }

                    case TABLE_NAME:
                    {
                        buffer.PutString(currentColumn.GetTableName());
                        break;
                    }

                    case COLUMN_NAME:
                    {
                        buffer.PutString(currentColumn.GetColumnName());
                        break;
                    }

                    case KEY_SEQ:
                    {
                        buffer.PutInt16(currentColumn.GetKeySeq());
                        break;
                    }

                    case PK_NAME:
                    {
                        buffer.PutString(currentColumn.GetKeyName());
                        break;
                    }

                    default:
                        break;
                }

                return SQL_RESULT_SUCCESS;
            }
Exemplo n.º 4
0
            SqlResult DiagnosticRecordStorage::GetField(int32_t recNum, DiagnosticField field, app::ApplicationDataBuffer& buffer) const
            {
                // Header record.
                switch (field)
                {
                    case IGNITE_SQL_DIAG_HEADER_CURSOR_ROW_COUNT:
                    {
                        buffer.PutInt64(GetRowCount());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION:
                    {
                        buffer.PutString(GetDynamicFunction());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_HEADER_DYNAMIC_FUNCTION_CODE:
                    {
                        buffer.PutInt32(GetDynamicFunctionCode());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_HEADER_NUMBER:
                    {
                        buffer.PutInt32(GetStatusRecordsNumber());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_HEADER_RETURNCODE:
                    {
                        buffer.PutInt32(GetReturnCode());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_HEADER_ROW_COUNT:
                    {
                        buffer.PutInt64(GetRowsAffected());

                        return SQL_RESULT_SUCCESS;
                    }

                    default:
                        break;
                }

                if (recNum < 1 || static_cast<size_t>(recNum) > statusRecords.size())
                    return SQL_RESULT_NO_DATA;

                // Status record.
                const DiagnosticRecord& record = GetStatusRecord(recNum);

                switch (field)
                {
                    case IGNITE_SQL_DIAG_STATUS_CLASS_ORIGIN:
                    {
                        buffer.PutString(record.GetClassOrigin());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_COLUMN_NUMBER:
                    {
                        buffer.PutInt32(record.GetColumnNumber());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_CONNECTION_NAME:
                    {
                        buffer.PutString(record.GetConnectionName());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT:
                    {
                        buffer.PutString(record.GetMessageText());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_NATIVE:
                    {
                        buffer.PutInt32(0);

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_ROW_NUMBER:
                    {
                        buffer.PutInt64(record.GetRowNumber());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_SERVER_NAME:
                    {
                        buffer.PutString(record.GetServerName());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_SQLSTATE:
                    {
                        buffer.PutString(record.GetSqlState());

                        return SQL_RESULT_SUCCESS;
                    }

                    case IGNITE_SQL_DIAG_STATUS_SUBCLASS_ORIGIN:
                    {
                        buffer.PutString(record.GetSubclassOrigin());

                        return SQL_RESULT_SUCCESS;
                    }

                    default:
                        break;
                }

                return SQL_RESULT_ERROR;
            }
Exemplo n.º 5
0
            SqlResult 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.");

                    return SQL_RESULT_ERROR;
                }

                if (cursor == types.end())
                    return SQL_RESULT_NO_DATA;

                int8_t currentType = *cursor;

                switch (columnIdx)
                {
                    case TYPE_NAME:
                    {
                        buffer.PutString(type_traits::BinaryTypeToSqlTypeName(currentType));

                        break;
                    }

                    case DATA_TYPE:
                    case SQL_DATA_TYPE:
                    {
                        buffer.PutInt16(type_traits::BinaryToSqlType(currentType));

                        break;
                    }

                    case COLUMN_SIZE:
                    {
                        buffer.PutInt32(type_traits::BinaryTypeColumnSize(currentType));

                        break;
                    }

                    case LITERAL_PREFIX:
                    {
                        if (currentType == IGNITE_TYPE_STRING)
                            buffer.PutString("'");
                        else if (currentType == IGNITE_TYPE_BINARY)
                            buffer.PutString("0x");
                        else
                            buffer.PutNull();

                        break;
                    }

                    case LITERAL_SUFFIX:
                    {
                        if (currentType == IGNITE_TYPE_STRING)
                            buffer.PutString("'");
                        else
                            buffer.PutNull();

                        break;
                    }

                    case CREATE_PARAMS:
                    {
                        buffer.PutNull();

                        break;
                    }

                    case NULLABLE:
                    {
                        buffer.PutInt32(type_traits::BinaryTypeNullability(currentType));

                        break;
                    }

                    case CASE_SENSITIVE:
                    {
                        if (currentType == IGNITE_TYPE_STRING)
                            buffer.PutInt16(SQL_TRUE);
                        else
                            buffer.PutInt16(SQL_FALSE);

                        break;
                    }

                    case SEARCHABLE:
                    {
                        buffer.PutInt16(SQL_SEARCHABLE);

                        break;
                    }

                    case UNSIGNED_ATTRIBUTE:
                    {
                        buffer.PutInt16(type_traits::BinaryTypeUnsigned(currentType));

                        break;
                    }

                    case FIXED_PREC_SCALE:
                    {
                        buffer.PutInt16(SQL_FALSE);

                        break;
                    }

                    case AUTO_UNIQUE_VALUE:
                    {
                        buffer.PutInt16(SQL_FALSE);

                        break;
                    }

                    case LOCAL_TYPE_NAME:
                    {
                        buffer.PutNull();

                        break;
                    }

                    case MINIMUM_SCALE:
                    case MAXIMUM_SCALE:
                    {
                        buffer.PutInt16(type_traits::BinaryTypeDecimalDigits(currentType));

                        break;
                    }

                    case SQL_DATETIME_SUB:
                    {
                        buffer.PutNull();

                        break;
                    }

                    case NUM_PREC_RADIX:
                    {
                        buffer.PutInt32(type_traits::BinaryTypeNumPrecRadix(currentType));

                        break;
                    }

                    case INTERVAL_PRECISION:
                    {
                        buffer.PutNull();

                        break;
                    }

                    default:
                        break;
                }

                return SQL_RESULT_SUCCESS;
            }