|
1 | 1 | /* |
2 | | - * Copyright © 2016 IBM Corp. All rights reserved. |
| 2 | + * Copyright © 2016, 2018 IBM Corp. All rights reserved. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
5 | 5 | * except in compliance with the License. You may obtain a copy of the License at |
@@ -39,13 +39,13 @@ public class PickWinningRevisionCallable implements SQLCallable<Void> { |
39 | 39 | // gets all revs whose sequence is not a parent of another rev and the rev isn't deleted |
40 | 40 | public static final String GET_NON_DELETED_LEAFS = "SELECT revs.revid, revs.sequence FROM " + |
41 | 41 | "revs WHERE revs.doc_id = ? AND revs.deleted = 0 AND revs.sequence NOT IN " + |
42 | | - "(SELECT DISTINCT parent FROM revs WHERE parent NOT NULL) "; |
| 42 | + "(SELECT DISTINCT parent FROM revs revs_inner WHERE parent NOT NULL AND revs_inner.doc_id = revs.doc_id) "; |
43 | 43 |
|
44 | 44 | // get all leaf rev IDs for a given doc ID |
45 | 45 | // gets all revs whose sequence is not a parent of another rev |
46 | 46 | public static final String GET_ALL_LEAFS = "SELECT revs.revid, revs.sequence FROM revs " + |
47 | 47 | "WHERE revs.doc_id = ? AND revs.sequence NOT IN " + |
48 | | - "(SELECT DISTINCT parent FROM revs WHERE parent NOT NULL) "; |
| 48 | + "(SELECT DISTINCT parent FROM revs revs_inner WHERE parent NOT NULL AND revs_inner.doc_id = revs.doc_id) "; |
49 | 49 |
|
50 | 50 | private final long docNumericId; |
51 | 51 |
|
@@ -127,7 +127,7 @@ public Void call(SQLDatabase db) throws DocumentStoreException { |
127 | 127 | currentFalse.put("current", 0); |
128 | 128 | db.update("revs", currentFalse, |
129 | 129 | "sequence!=? AND doc_id=? AND sequence NOT IN " + |
130 | | - "(SELECT DISTINCT parent FROM revs WHERE parent NOT NULL)", |
| 130 | + "(SELECT DISTINCT parent FROM revs revs_inner WHERE parent NOT NULL AND revs_inner.doc_id=revs.doc_id)", |
131 | 131 | new String[]{Long.toString(newWinnerSeq), Long.toString(docNumericId)}); |
132 | 132 | return null; |
133 | 133 | } |
|
0 commit comments