tcurdt 2002/12/27 07:19:02 Modified: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp AbstractEsqlQuery.java MysqlEsqlQuery.java OracleEsqlQuery.java PostgresEsqlQuery.java PostgresOldEsqlQuery.java SybaseEsqlQuery.java Log: fixed the esql:more-results bug as reported by Antonio Gallardo Revision Changes Path 1.5 +21 -0 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlQuery.java Index: AbstractEsqlQuery.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlQuery.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractEsqlQuery.java 10 Dec 2002 00:51:45 -0000 1.4 +++ AbstractEsqlQuery.java 27 Dec 2002 15:19:02 -0000 1.5 @@ -122,6 +122,27 @@ * Return the query string ("select * from bla") * * NOTE: Might want to be overridden by indiviual EsqlQuery implementations + * e.g. for database specific LIMIT features. Be aware that there a two different + * limit approaches: + * <pre> + * retrieve query + * time time + * +---------+ ........... + * |JDBC | : : + * |ResultSet| : : + * |.........|-+ :_________:_ + * | | | skip/max+1 |JDBC | | skip/max+1 + * | | | window |ResultSet| | window + * |.........| | |_________| | + * | |-+ : :_| + * | | : : + * +---------+ :.........: + * </pre> + * With the "retrieve time" limit the JDBC ResultSet includes ALL of the rows of the + * query. + * With the "query time" limit only a small window of rows are in the actuall JDBC + * ResultSet. In order to know whether there are more rows available (without an additional + * query) we need to have at least one more row in the JDBC ResultSet. So we ask for getMaxRows()+1 * * @return * @throws SQLException 1.5 +2 -2 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/MysqlEsqlQuery.java Index: MysqlEsqlQuery.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/MysqlEsqlQuery.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MysqlEsqlQuery.java 10 Dec 2002 00:51:45 -0000 1.4 +++ MysqlEsqlQuery.java 27 Dec 2002 15:19:02 -0000 1.5 @@ -88,7 +88,7 @@ if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) .append(" LIMIT ").append(getSkipRows()) - .append(",").append(getMaxRows()) + .append(",").append(getMaxRows()+1) .toString()); } else { @@ -98,7 +98,7 @@ else { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) - .append(" LIMIT ").append(getMaxRows()) + .append(" LIMIT ").append(getMaxRows()+1) .toString()); } else { 1.4 +1 -1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/OracleEsqlQuery.java Index: OracleEsqlQuery.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/OracleEsqlQuery.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- OracleEsqlQuery.java 10 Dec 2002 00:51:45 -0000 1.3 +++ OracleEsqlQuery.java 27 Dec 2002 15:19:02 -0000 1.4 @@ -87,7 +87,7 @@ return (new StringBuffer("select * from (select a.*, rownum rnum from (") .append(super.getQueryString()) .append(") a where rownum <= ") - .append(getSkipRows() + getMaxRows()) + .append(getSkipRows() + getMaxRows() + 1) .append(") where rnum >= ") .append(getSkipRows()) .append(")") 1.6 +2 -2 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java Index: PostgresEsqlQuery.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresEsqlQuery.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- PostgresEsqlQuery.java 19 Dec 2002 11:09:42 -0000 1.5 +++ PostgresEsqlQuery.java 27 Dec 2002 15:19:02 -0000 1.6 @@ -84,9 +84,9 @@ public String getQueryString() throws SQLException { StringBuffer sb = new StringBuffer(super.getQueryString()); - if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows()); + if (getMaxRows() > -1) sb.append(" LIMIT ").append(getMaxRows()+1); if (getSkipRows() > 0) sb.append(" OFFSET ").append(getSkipRows()); - return sb.toString(); + return(sb.toString()); } public void getResultRows() throws SQLException { 1.2 +2 -2 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresOldEsqlQuery.java Index: PostgresOldEsqlQuery.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/PostgresOldEsqlQuery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PostgresOldEsqlQuery.java 19 Dec 2002 11:09:42 -0000 1.1 +++ PostgresOldEsqlQuery.java 27 Dec 2002 15:19:02 -0000 1.2 @@ -85,7 +85,7 @@ if (getSkipRows() > 0) { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) - .append(" LIMIT ").append(getMaxRows()) + .append(" LIMIT ").append(getMaxRows()+1) .append(",").append(getSkipRows()) .toString()); } @@ -98,7 +98,7 @@ else { if (getMaxRows() > -1) { return (new StringBuffer(super.getQueryString()) - .append(" LIMIT ").append(getMaxRows()) + .append(" LIMIT ").append(getMaxRows()+1) .toString()); } else { 1.5 +1 -1 xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/SybaseEsqlQuery.java Index: SybaseEsqlQuery.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp/SybaseEsqlQuery.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SybaseEsqlQuery.java 10 Dec 2002 00:51:45 -0000 1.4 +++ SybaseEsqlQuery.java 27 Dec 2002 15:19:02 -0000 1.5 @@ -90,7 +90,7 @@ int command = original.indexOf(' '); return (new StringBuffer() .append(original.substring(0,command)) - .append(" TOP ").append(getMaxRows()+getSkipRows()) + .append(" TOP ").append(getMaxRows()+1 + getSkipRows()) .append(original.substring(command)) .toString()); }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]