[Libreoffice-bugs] [Bug 116890] Firebird: empty columns gone with prepared statement

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Tue Apr 10 19:04:52 UTC 2018


https://bugs.documentfoundation.org/show_bug.cgi?id=116890

--- Comment #22 from Lionel Elie Mamane <lionel at mamane.lu> ---
(In reply to Julien Nabet from comment #21)
> (In reply to Lionel Elie Mamane from comment #17)

>> If in one case, several columns have the same name "CONSTANT" and in the
>> other case all columns have unique names like "CONSTANT", "CONSTANT1",
>> "CONSTANT2", etc, then  we have definitely found the problem, it is in
>> Firebird.

> I got "CONSTANT" several times for both cases.

This means the difference is in LibreOffice, and it is LibreOffice that adds
the "1", "2", "3", etc to duplicate names. The case "ccols =
oPrepStatement.Columns" is done in
dbaccess/source/core/api/preparedstatement.cxx function
OPreparedStatement::getColumns, there one sees:

for (sal_Int32 i = 0, nCount = xMetaData->getColumnCount(); i < nCount; ++i)
{
    // retrieve the name of the column
    OUString aName = xMetaData->getColumnName(i + 1);
    OResultColumn* pColumn = new OResultColumn(xMetaData, i + 1, xDBMeta);
    m_pColumns->append(aName, pColumn);
}

That's the problematic bit of code. It needs to be changed to add "1", "2", etc
to duplicate names.

The "ccols = oResult.Columns" case is probably handled in file resultset.cxx in
the same directory, function OResultSet::getColumns(); there we see:


for ( sal_Int32 i = 0; i < nColCount; ++i)
{
    // retrieve the name of the column
    OUString sName = xMetaData->getColumnName(i + 1);
    ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow,
m_xDelegatorRowUpdate, i + 1, xDBMetaData);

    // don't silently assume that the name is unique - result set
implementations
    // are allowed to return duplicate names, but we are required to have
    // unique column names
    if ( m_pColumns->hasByName( sName ) )
        sName = ::dbtools::createUniqueName( m_pColumns.get(), sName );

    m_pColumns->append( sName, pColumn );
}

The two lines
    if ( m_pColumns->hasByName( sName ) )
        sName = ::dbtools::createUniqueName( m_pColumns.get(), sName );
seem to be exactly what needs to be added to OPreparedStatement::getColumns

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20180410/5be90f20/attachment.html>


More information about the Libreoffice-bugs mailing list