-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
OF-3131: Move 'subject' from history to room #3035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guusdk
wants to merge
9
commits into
igniterealtime:main
Choose a base branch
from
guusdk:OF-3131_MUC-subject
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
462fa39
OF-3131: Move 'subject' from history to room
guusdk 6f05486
OF-3131: Add unit tests for subject stanza reconstruction
guusdk 0053c4a
OF-3131: Ensure that the database migration scripts run.
guusdk c96439a
OF-3131: Fix Oracle upgrade script: Can't change a column to NULL if …
guusdk 9d6de66
OF-3131: Test data for database update scripts.
guusdk 645e354
Revert "OF-3131: Test data for database update scripts."
guusdk 4e71f29
OF-3131: Improve HSQLDB update script for performance.
guusdk 732f4f4
OF-3131: Test data for database update scripts.
guusdk 3bfb338
Revert "OF-3131: Test data for database update scripts."
guusdk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom ALTER COLUMN subject SET DATA TYPE CLOB; | ||
|
||
UPDATE ofMucRoom r | ||
SET subject = ( | ||
SELECT stanza | ||
FROM ( | ||
SELECT roomID, stanza, | ||
ROW_NUMBER() OVER (PARTITION BY roomID ORDER BY logTime DESC) AS rn | ||
FROM ofMucConversationLog | ||
WHERE subject IS NOT NULL | ||
) l | ||
WHERE l.roomID = r.roomID | ||
AND l.rn = 1 | ||
); | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom ALTER COLUMN subject SET DATA TYPE LONGVARCHAR; | ||
|
||
UPDATE ofMucRoom r | ||
SET r.subject = ( | ||
SELECT l.stanza | ||
FROM ofMucConversationLog l | ||
WHERE l.roomID = r.roomID | ||
AND l.subject IS NOT NULL | ||
AND l.logTime = ( | ||
SELECT MAX(l2.logTime) | ||
FROM ofMucConversationLog l2 | ||
WHERE l2.roomID = r.roomID | ||
AND l2.subject IS NOT NULL | ||
) | ||
); | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom MODIFY subject TEXT NULL; | ||
|
||
UPDATE ofMucRoom r | ||
JOIN ( | ||
SELECT l.roomID, l.stanza | ||
FROM ofMucConversationLog l | ||
JOIN ( | ||
SELECT roomID, MAX(logTime) AS maxTime | ||
FROM ofMucConversationLog | ||
WHERE subject IS NOT NULL | ||
GROUP BY roomID | ||
) latest | ||
ON l.roomID = latest.roomID | ||
AND l.logTime = latest.maxTime | ||
) c | ||
ON r.roomID = c.roomID | ||
SET r.subject = c.stanza | ||
WHERE c.stanza IS NOT NULL; | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom MODIFY subject VARCHAR2(4000); | ||
|
||
MERGE INTO ofMucRoom r | ||
USING ( | ||
SELECT roomID, stanza | ||
FROM ( | ||
SELECT roomID, stanza, | ||
ROW_NUMBER() OVER (PARTITION BY roomID ORDER BY logTime DESC) AS rn | ||
FROM ofMucConversationLog | ||
WHERE subject IS NOT NULL | ||
) t | ||
WHERE rn = 1 | ||
) c | ||
ON (r.roomID = c.roomID) | ||
WHEN MATCHED THEN | ||
UPDATE SET r.subject = c.stanza; | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
22 changes: 22 additions & 0 deletions
22
distribution/src/database/upgrade/38/openfire_postgresql.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom ALTER COLUMN subject TYPE TEXT; | ||
|
||
UPDATE ofMucRoom r | ||
SET subject = c.stanza | ||
FROM ( | ||
SELECT DISTINCT ON (roomID) roomID, stanza | ||
FROM ofMucConversationLog | ||
WHERE subject IS NOT NULL | ||
ORDER BY roomID, logTime DESC | ||
) c | ||
WHERE c.roomID = r.roomID | ||
AND c.stanza IS NOT NULL; | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
25 changes: 25 additions & 0 deletions
25
distribution/src/database/upgrade/38/openfire_sqlserver.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom ALTER COLUMN subject NTEXT NULL; | ||
|
||
WITH LatestLogs AS ( | ||
SELECT roomID, stanza, | ||
ROW_NUMBER() OVER (PARTITION BY roomID ORDER BY logTime DESC) AS rn | ||
FROM ofMucConversationLog | ||
WHERE subject IS NOT NULL | ||
) | ||
UPDATE r | ||
SET r.subject = l.stanza | ||
FROM ofMucRoom r | ||
JOIN LatestLogs l | ||
ON r.roomID = l.roomID | ||
WHERE l.rn = 1 | ||
AND l.stanza IS NOT NULL; | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- This copies the subject-defining stanza as stored in the message archive into the room's table, replacing any text | ||
-- based (non-stanza) subject that was stored there. | ||
-- In rare occasions (see OF-3131) the room can have a subject, while the history does not. In those cases, this script | ||
-- leaves the (non-stanza) subject in the ofMucRoom table intact (this means that the column holds a mixture of plain | ||
-- text and XMPP data). | ||
-- Note that the stanzas in ofMucConversationLog typically do not contain a timestamp (although one is provided in a | ||
-- separate column). If the subject that gets migrated to ofMucRoom is used as-is, the time of subject change is likely | ||
-- lost (until the room's subject gets changed). This is deemed an acceptable loss. | ||
ALTER TABLE ofMucRoom ALTER COLUMN subject TEXT NULL; | ||
|
||
WITH LatestLogs AS ( | ||
SELECT roomID, stanza, | ||
ROW_NUMBER() OVER (PARTITION BY roomID ORDER BY logTime DESC) AS rn | ||
FROM ofMucConversationLog | ||
WHERE subject IS NOT NULL | ||
) | ||
UPDATE r | ||
SET r.subject = l.stanza | ||
FROM ofMucRoom r | ||
JOIN LatestLogs l | ||
ON r.roomID = l.roomID | ||
WHERE l.rn = 1 | ||
AND l.stanza IS NOT NULL; | ||
|
||
UPDATE ofVersion SET version = 38 WHERE name = 'openfire'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLM complained that this might have many full table scans, and suggested using ROW_NUMBER like you did for Oracle. I've no experience here, but docs suggest that it's possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ROW_NUMBER in HSQLDB appears to have quirks. LLM suggests that we can use it only for this particular purpose after upgrading from 2.7.1 to 2.7.4 (which we may want to do anyways).
I do believe that the query can be improved for a roughly comparable performance improvement, but with something that's usable under 2.7.1. I have added a commit that has that improvement.