You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2015/06/03 12:49:26 UTC
svn commit: r1683278 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Author: reschke
Date: Wed Jun 3 10:49:25 2015
New Revision: 1683278
URL: http://svn.apache.org/r1683278
Log:
OAK-2950 - RDBDocumentStore: conditional fetch logic is reversed
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1683278&r1=1683277&r2=1683278&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Wed Jun 3 10:49:25 2015
@@ -1501,29 +1501,29 @@ public class RDBDocumentStore implements
@CheckForNull
private RDBRow dbRead(Connection connection, String tableName, String id, long lastmodcount) throws SQLException {
PreparedStatement stmt;
+
boolean useCaseStatement = lastmodcount != -1 && this.db.allowsCaseInSelect();
if (useCaseStatement) {
- // either we don't have a previous version of the document
- // or the database does not support CASE in SELECT
- stmt = connection.prepareStatement("select MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, DATA, BDATA from "
- + tableName + " where ID = ?");
- } else {
// the case statement causes the actual row data not to be
// sent in case we already have it
stmt = connection
.prepareStatement("select MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, case MODCOUNT when ? then null else DATA end as DATA, "
+ "case MODCOUNT when ? then null else BDATA end as BDATA from " + tableName + " where ID = ?");
+ } else {
+ // either we don't have a previous version of the document
+ // or the database does not support CASE in SELECT
+ stmt = connection.prepareStatement("select MODIFIED, MODCOUNT, CMODCOUNT, HASBINARY, DELETEDONCE, DATA, BDATA from "
+ + tableName + " where ID = ?");
}
try {
+ int si = 1;
if (useCaseStatement) {
- setIdInStatement(stmt, 1, id);
- }
- else {
- stmt.setLong(1, lastmodcount);
- stmt.setLong(2, lastmodcount);
- setIdInStatement(stmt, 3, id);
+ stmt.setLong(si++, lastmodcount);
+ stmt.setLong(si++, lastmodcount);
}
+ setIdInStatement(stmt, si, id);
+
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
long modified = rs.getLong(1);