Skip to content

Commit 45b6fa9

Browse files
mightymopguusdk
authored andcommitted
fix #232 add if clause for sql server
1 parent 44b488d commit 45b6fa9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/java/org/jivesoftware/openfire/archive/ArchiveSearcher.java

+5
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ private Collection<Conversation> databaseSearch(ArchiveSearch search) {
351351
// rows we need returned. The syntax is LIMIT [rows] OFFSET [offset]
352352
else if (DbConnectionManager.getDatabaseType() == DbConnectionManager.DatabaseType.postgresql) {
353353
query.append(" LIMIT ").append(numResults).append(" OFFSET ").append(startIndex);
354+
}
355+
// SQL Server optimization: use the OFFSET command to tell the database how many
356+
// rows we need returned. The syntax is OFFSET [offset] FETCH NEXT [rows] ROWS ONLY
357+
else if (DbConnectionManager.getDatabaseType() == DbConnectionManager.DatabaseType.sqlserver) {
358+
query.append(" OFFSET ").append(startIndex).append(" ROWS FETCH NEXT ").append(numResults).append(" ROWS ONLY ");
354359
}
355360
}
356361

0 commit comments

Comments
 (0)