You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Matthew Cordes <mc...@maine.edu> on 2001/01/16 21:21:23 UTC
Bug in cvs esql: esql:max-rows
Hey Donald (and everyone),
There appears to be another bug in esql in
<xsl:template match="esql:results//esql:row-results">
on or near line 439.
The problem is this block:
<xsl:template match="esql:results//esql:row-results">
<xsp:logic>
while (_esql_query.resultset.next()) {
<xsl:apply-templates/>
if (_esql_query.max_rows != -1 && _esql_query.position - _esql_query.skip_rows == _esql_query.max_rows-1) {
break;
}
_esql_query.position++;
}
</xsp:logic>
</xsl:template>
Now imagine these circumstances:
1. max_rows = 1
2. position = 0 // first record
3. skip_rows = 0 // we skip no rows
In this instance on the first evaulation of the above line it becomes:
if ( 0 != -1 && 0 - 0 == 1 - 1 )
as you can see we just want 1 row back and we get it thanks to
<xsl:apply-templates>, but because of this if, we break before
_esql_query.position is updated. This has the effect of later
causing the test in the template that matches esql:no-results
if (_esql_query.position == _esql_query.skip_rows) {
<xsl:apply-templates/>
}
to be called as well when it should not be. We don't want to
call no-results as we infact did have results and have already
generated the output for it. In this case both row-results kids
and no-results kids are both evaluated; sonething that probably
should not happen.
I fixed mine by replacing the template that matches esql:row-results
with this:
_esql_query.position++;
if (_esql_query.max_rows != -1 &&
_esql_query.position - _esql_query.skip_rows == _esql_query.max_rows )
{
break;
}
As always I could be wrong. If the current version does work please
explain.. And thanks for the great product.
-matt