Esempio n. 1
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;
            }
Esempio n. 2
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;
            }