OF-3277: Introduce helper method to determine database 'limit' keyword#3330
OF-3277: Introduce helper method to determine database 'limit' keyword#3330guusdk wants to merge 1 commit into
Conversation
The SQL LIMIT clause is not portable across the databases Openfire supports. SQL Server, for example, uses `SELECT TOP`. Up until now, code had to interrogate the type of database to find out what variant to be used. In this commit, this information is exposed as metadata. Small changes have been applid to the pubsub persistence implementation. It is expected that the Monitoring plugin (and others) benefit from this, too.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a public API to 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Pull request overview
This PR (OF-3277) centralizes database-specific SQL row-limiting behavior by exposing metadata from DbConnectionManager, reducing the need for scattered database-type checks (eg. LIMIT vs SQL Server TOP).
Changes:
- Added
ResultSetLimitKeywordmetadata (keyword + prefix/suffix positioning) toDbConnectionManager/DatabaseType. - Updated PubSub persistence logic to select the appropriate query variant based on the new metadata.
- Added unit tests that validate the mapping for SQL Server, Oracle, DB2, and ANSI-style databases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| xmppserver/src/main/java/org/jivesoftware/database/DbConnectionManager.java | Introduces ResultSetLimitKeyword and helper methods to expose per-database row-limiting keyword metadata. |
| xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/DefaultPubSubPersistenceProvider.java | Replaces database-type branching with the new row-limiting keyword metadata when loading last published items. |
| xmppserver/src/test/java/org/jivesoftware/database/DbConnectionManagerTest.java | Adds test coverage for the new keyword/prefix metadata across key database types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Looks like start of re-inventing Hibernate Dialect. |
The SQL LIMIT clause is not portable across the databases Openfire supports. SQL Server, for example, uses
SELECT TOP.Up until now, code had to interrogate the type of database to find out what variant to be used. In this commit, this information is exposed as metadata.
Small changes have been applid to the pubsub persistence implementation. It is expected that the Monitoring plugin (and others) benefit from this, too.