<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Firebird: empty columns gone with prepared statement"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=116890#c22">Comment # 22</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Firebird: empty columns gone with prepared statement"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=116890">bug 116890</a>
from <span class="vcard"><a class="email" href="mailto:lionel@mamane.lu" title="Lionel Elie Mamane <lionel@mamane.lu>"> <span class="fn">Lionel Elie Mamane</span></a>
</span></b>
<pre>(In reply to Julien Nabet from <a href="show_bug.cgi?id=116890#c21">comment #21</a>)
<span class="quote">> (In reply to Lionel Elie Mamane from <a href="show_bug.cgi?id=116890#c17">comment #17</a>)</span >
<span class="quote">>> 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.</span >
<span class="quote">> I got "CONSTANT" several times for both cases.</span >
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>