Skip to content

[3.x] Use row_number window function on MySQL and MariaDB if supported#308

Closed
richard67 wants to merge 2 commits intojoomla-framework:3.x-devfrom
richard67:3.x-dev-select-row-number-mariadb-2
Closed

[3.x] Use row_number window function on MySQL and MariaDB if supported#308
richard67 wants to merge 2 commits intojoomla-framework:3.x-devfrom
richard67:3.x-dev-select-row-number-mariadb-2

Conversation

@richard67
Copy link
Contributor

@richard67 richard67 commented Aug 3, 2024

Pull Request for Issue #290 .

Alternative to PRs #291 and #300 .

See also joomla/joomla-cms#42333 .

Summary of Changes

Use the ROW_NUMBER() window function in the selectRowNumber method on MySQL >= 8.0.0 and MariaDB >= 10.2.0.

Different to PR #300 , this one here extends the database driver and database interface by the new method hasRowNumberSupport to tell if the database engine supports the ROW_NUMBER() window function, and the MysqlQueryBuilder uses that method. The new method might be used by 3rd party extensions of the CMS, too.

The MySQL drivers set a new property rownum when connecting to the database, and the new hasRowNumberSupport method just returns the value of that property, so the checks for MariaDB and the version are not done with every call to the selectRowNumber query method like it is done in PR #300 , so it should be a bit faster.

Also different to PR #300 , this one here uses the ROW_NUMBER() window function whenever supported, i.e. as said with MySQL >= 8.0.0 and MariaDB >= 10.2.0. The other PR #300 does that only for MariaDB >= 11.0.0 in order to play safe and because issues where only reported for MariaDB 11, but I think that's not really necessary. Using the ROW_NUMBER() is more reliable than the "hack" with the SQL variable (@rownum).

I could not find any unit tests for the selectRowNumber method, so no changes on unit tests with this PR.

Testing Instructions

See joomla/joomla-cms#42333 .

Documentation Changes Required

None.

Add $rownum variable and hasRowNumberSupport method to the database driver to tell if the database engine supports the ROW_NUMBER() window function.
In the selectRowNumber method, use parent method  with ROW_NUMBER() window function if the database engine supports it
@richard67
Copy link
Contributor Author

Closing in favour of PR #300 .

@richard67 richard67 closed this Aug 7, 2024
@richard67 richard67 deleted the 3.x-dev-select-row-number-mariadb-2 branch August 7, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant