Exemplo n.º 1
0
CDB_Object* CMySQL_RowResult::GetItem(CDB_Object* item_buf, I_Result::EGetItem policy)
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum()) {
        return 0;
    }

    CDB_Object* r =
        s_GetItem(policy, GetDefineParams().GetDataType(m_CurrItem), item_buf,
                  item_buf ? item_buf->GetType() : eDB_UnsupportedType,
                  m_Row[m_CurrItem], m_Lengths[m_CurrItem]);
    ++m_CurrItem;
    return r;
}
Exemplo n.º 2
0
size_t CDBL_ComputeResult::ReadItem(void* buffer, size_t buffer_size,
                                    bool* is_null)
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum()) {
        if (is_null)
            *is_null = true;
        return 0;
    }

    const BYTE* d_ptr = Check(dbadata(GetCmd(), m_ComputeId, m_CurrItem + 1));
    DBINT d_len = Check(dbadlen(GetCmd(), m_ComputeId, m_CurrItem + 1));

    if (d_ptr == 0 || d_len < 1) { // NULL value
        ++m_CurrItem;
        m_Offset = 0;
        if (is_null)
            *is_null = true;
        return 0;
    }

    if (is_null)
        *is_null = false;
    if ((size_t) d_len - m_Offset < buffer_size)
        buffer_size = (size_t) d_len - m_Offset;
    memcpy(buffer, d_ptr + m_Offset, buffer_size);
    m_Offset += buffer_size;
    if (m_Offset >= (size_t) d_len) {
        m_Offset = 0;
        ++m_CurrItem;
    }
    return buffer_size;
}
Exemplo n.º 3
0
bool CTL_RowResult::Fetch()
{
    SetCurrentItemNum(-1);
    if ( m_EOR ) {
        return false;
    }

    // Reset NullValue flags ...
    for (unsigned int nof_items = 0;  nof_items < GetDefineParams().GetNum();  ++nof_items) {
        m_NullValue[nof_items] = eNullUnknown;
    }

    CheckIsDead();

    switch ( Check(ct_fetch(x_GetSybaseCmd(), CS_UNUSED, CS_UNUSED, CS_UNUSED, 0)) ) {
    case CS_SUCCEED:
        SetCurrentItemNum(0);
        return true;
    case CS_END_DATA:
        m_EOR = true;
        return false;
    case CS_ROW_FAIL:
        DATABASE_DRIVER_ERROR( "Error while fetching the row." + GetDbgInfo(), 130003 );
    case CS_FAIL:
        DATABASE_DRIVER_ERROR("ct_fetch has failed. "
                              "You need to cancel the command." +
                              GetDbgInfo(),
                              130006 );
    case CS_CANCELED:
        DATABASE_DRIVER_ERROR( "The command has been canceled." + GetDbgInfo(), 130004 );
    default:
        DATABASE_DRIVER_ERROR( "The connection is busy." + GetDbgInfo(), 130005 );
    }
}
Exemplo n.º 4
0
bool CODBC_RowResult::SkipItem()
{
    if ((unsigned int) m_CurrItem < GetDefineParams().GetNum()) {
        ++m_CurrItem;
        return true;
    }
    return false;
}
Exemplo n.º 5
0
bool CTL_RowResult::SkipItem()
{
    if (GetCurrentItemNum() < (int) GetDefineParams().GetNum()) {
        IncCurrentItemNum();
        return true;
    }

    return false;
}
Exemplo n.º 6
0
bool CDBL_ResultBase::SkipItem()
{
    if ((unsigned int) m_CurrItem < GetDefineParams().GetNum()) {
        ++m_CurrItem;
        m_Offset = 0;
        return true;
    }
    return false;
}
Exemplo n.º 7
0
CDB_Object* CODBC_RowResult::GetItem(CDB_Object* item_buf, I_Result::EGetItem policy)
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum()  ||  m_CurrItem == -1) {
        return 0;
    }

    CDB_Object* item = item_buf? x_LoadItem(policy, item_buf) : x_MakeItem();

    ++m_CurrItem;
    return item;
}
Exemplo n.º 8
0
CDB_Object* CDBL_ComputeResult::GetItem(CDB_Object* item_buff, I_Result::EGetItem /*policy*/)
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum()) {
        return 0;
    }
    CDB_Object* r = AltGetItem(m_ComputeId,
                               m_CurrItem + 1,
                               &m_ColFmt[m_CurrItem],
                               item_buff);
    ++m_CurrItem;
    m_Offset = 0;
    return r;
}
Exemplo n.º 9
0
CDB_Object* CDBL_RowResult::GetItem(CDB_Object* item_buff, I_Result::EGetItem policy)
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum()) {
        return 0;
    }
    CDB_Object* r = GetItemInternal(policy,
                                    m_CurrItem + 1,
                                    &m_ColFmt[m_CurrItem],
                                    item_buff);
    ++m_CurrItem;
    m_Offset = 0;
    return r;
}
Exemplo n.º 10
0
CDB_Object* CTL_RowResult::GetItem(CDB_Object* item_buf, I_Result::EGetItem policy)
{
    if ((unsigned int) CurrentItemNo() >= GetDefineParams().GetNum()  ||  CurrentItemNo() == -1) {
        return 0;
    }

    CDB_Object* item = GetItemInternal(
        policy, 
        x_GetSybaseCmd(), 
        CurrentItemNo() + 1, 
        m_ColFmt[CurrentItemNo()],
        item_buf);

    IncCurrentItemNum();

    return item;
}
Exemplo n.º 11
0
bool CTL_CursorResult::SkipItem()
{
    if (GetCurrentItemNum() < (int) GetDefineParams().GetNum()) {
        IncCurrentItemNum();
        char dummy[4];
        bool is_null = false;

        switch ( my_ct_get_data(x_GetSybaseCmd(), GetCurrentItemNum(), dummy, 0, 0, is_null) ) {
        case CS_END_ITEM:
        case CS_END_DATA:
        case CS_SUCCEED:
            break;
        case CS_CANCELED:
            DATABASE_DRIVER_ERROR( "The command has been canceled." + GetDbgInfo(), 130004 );
        default:
            DATABASE_DRIVER_ERROR( "ct_get_data failed." + GetDbgInfo(), 130000 );
        }

        return true;
    }

    return false;
}
Exemplo n.º 12
0
I_ITDescriptor*
CTL_RowResult::GetImageOrTextDescriptor(int item_num)
{
    bool is_null = false;

    if ((unsigned int) item_num >= GetDefineParams().GetNum()  ||  item_num < 0) {
        return 0;
    }

    char dummy[4];
    CS_INT outlen = 0;

    switch (my_ct_get_data(x_GetSybaseCmd(), item_num + 1, dummy, 0, &outlen, is_null) ) {
    case CS_END_ITEM:
    case CS_END_DATA:
    case CS_SUCCEED:
        break;
    case CS_CANCELED:
        DATABASE_DRIVER_ERROR( "The command has been canceled." + GetDbgInfo(), 130004 );
    default:
        DATABASE_DRIVER_ERROR( "ct_get_data failed." + GetDbgInfo(), 130000 );
    }

    if (is_null)
        m_NullValue[item_num] = eIsNull;

    auto_ptr<CTL_ITDescriptor> desc(new CTL_ITDescriptor);

    bool rc = (Check(ct_data_info(x_GetSybaseCmd(),
                                  CS_GET,
                                  item_num + 1,
                                  &desc->m_Desc))
        != CS_SUCCEED);
    CHECK_DRIVER_ERROR( rc, "ct_data_info failed." + GetDbgInfo(), 130010 );

    return desc.release();
}
Exemplo n.º 13
0
size_t CTL_RowResult::ReadItem(void* buffer, size_t buffer_size,
                               bool* is_null)
{
    if ((unsigned int) CurrentItemNo() >= GetDefineParams().GetNum()  ||  CurrentItemNo() == -1) {
        return 0;
    }

    if (m_NullValue[GetCurrentItemNum()] == eIsNull) {
        if (is_null)
            *is_null = true;
        IncCurrentItemNum();
        return 0;
    }

    CS_INT outlen = 0;

    if((buffer == 0) && (buffer_size == 0)) {
        buffer= (void*)(&buffer_size);
    }

    bool is_null_tmp;
    const CS_RETCODE rc = my_ct_get_data(
            x_GetSybaseCmd(),
            GetCurrentItemNum() + 1,
            buffer,
            (CS_INT) buffer_size,
            &outlen,
            is_null_tmp
            );

    switch (rc) {
    case CS_END_ITEM:
        // This is not the last column in the row.
    case CS_END_DATA:
        // This is the last column in the row.
        if (m_NullValue[GetCurrentItemNum()] == eNullUnknown) {
            m_NullValue[GetCurrentItemNum()] = (is_null_tmp ? eIsNull : eIsNotNull);
        }

        if (is_null) {
            if (m_NullValue[GetCurrentItemNum()] != eNullUnknown) {
                *is_null = (m_NullValue[GetCurrentItemNum()] == eIsNull);
            } else {
                *is_null = (outlen == 0);
            }
        }

#ifdef FTDS_IN_USE
        if (rc == CS_END_ITEM) {
            IncCurrentItemNum();
        }
#else
        IncCurrentItemNum(); // That won't work with the ftds64 driver
#endif

        break;
    case CS_SUCCEED:
        // ct_get_data successfully retrieved a chunk of data that is
        // not the last chunk of data for this column.
        break;
    case CS_CANCELED:
        DATABASE_DRIVER_ERROR( "The command has been canceled." + GetDbgInfo(), 130004 );
    default:
        DATABASE_DRIVER_ERROR( "ct_get_data failed." + GetDbgInfo(), 130000 );
    }

    return (size_t) outlen;
}
Exemplo n.º 14
0
size_t CODBC_RowResult::ReadItem(void* buffer,size_t buffer_size,bool* is_null)
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum()  ||  m_CurrItem == -1 ||
        buffer == 0 || buffer_size == 0) {
        return 0;
    }

    SQLLEN f = 0;

    if(is_null) *is_null= false;

    SQLSMALLINT data_type = m_ColFmt[m_CurrItem].DataType;

    while (m_HasMoreData  &&  m_LastReadData.size() < buffer_size) {
        m_HasMoreData = false;

        string next_data;
        size_t next_len = 0;

        switch(SQLGetData(GetHandle(), m_CurrItem + 1, SQL_C_BINARY, buffer, buffer_size, &f)) {
        case SQL_SUCCESS_WITH_INFO:
            switch(f) {
            case SQL_NO_TOTAL:
                next_data.append((char*) buffer, buffer_size);
                m_HasMoreData = true;
                break;
            case SQL_NULL_DATA:
                if(is_null) *is_null= true;
                break;
            default:
                if ( f < 0 ) {
                    ReportErrors();
                    return 0;
                }
                m_HasMoreData = true;
                next_len = static_cast<size_t>(f);
                if (next_len >= buffer_size) {
                    next_len = buffer_size;
                }
                next_data.append((char*) buffer, next_len);
                break;
            }
            break;
        case SQL_SUCCESS:
            if(f == SQL_NULL_DATA) {
                if(is_null) *is_null= true;
            }
            else {
                next_len = (f >= 0)? ((size_t)f) : 0;
                next_data.append((char*) buffer, next_len);
            }
            break;
        case SQL_NO_DATA:
            if(f == SQL_NULL_DATA) {
                if(is_null) *is_null= true;
            }
            break;
        case SQL_ERROR:
            ReportErrors();
            return 0;
        default:
            {
                string err_message = "SQLGetData failed." + GetDbgInfo();
                DATABASE_DRIVER_ERROR( err_message, 430026 );
            }
        }

#ifdef HAVE_WSTRING
        if (data_type == SQL_WCHAR  ||  data_type == SQL_WVARCHAR  ||  data_type == SQL_WLONGVARCHAR) {
            string conv_data
                = (CODBCString((wchar_t*) next_data.data(),
                               next_data.size() / sizeof(wchar_t))
                   .ConvertTo(GetClientEncoding()));
            m_LastReadData += conv_data;
        }
        else
#endif
        {
            m_LastReadData += next_data;
        }
    }

    size_t return_len = m_LastReadData.size();
    if (return_len > buffer_size) {
        return_len = buffer_size;
    }
    memcpy(buffer, m_LastReadData.data(), return_len);
    m_LastReadData = m_LastReadData.substr(return_len);
    if (!m_HasMoreData  &&  return_len <= buffer_size) {
        ++m_CurrItem;
        m_HasMoreData = true;
    }

    return return_len;
}
Exemplo n.º 15
0
I_ITDescriptor* CDBL_RowResult::GetImageOrTextDescriptor()
{
    if ((unsigned int) m_CurrItem >= GetDefineParams().GetNum())
        return 0;
    return new CDBL_ITDescriptor(GetConnection(), GetCmd(), m_CurrItem+1);
}
Exemplo n.º 16
0
int CTL_RowResult::GetColumnNum(void) const
{
    return static_cast<int>(GetDefineParams().GetNum());
}
Exemplo n.º 17
0
int CDBL_ResultBase::GetColumnNum(void) const
{
    return static_cast<int>(GetDefineParams().GetNum());
}