[AST] Support MySQL locking clauses (FOR UPDATE, SKIP LOCKED, etc.)#342
Open
wp-fuse wants to merge 3 commits intoWordPress:trunkfrom
Open
[AST] Support MySQL locking clauses (FOR UPDATE, SKIP LOCKED, etc.)#342wp-fuse wants to merge 3 commits intoWordPress:trunkfrom
wp-fuse wants to merge 3 commits intoWordPress:trunkfrom
Conversation
Goal: Support MySQL queries that utilize locking clauses (e.g., FOR UPDATE, LOCK IN SHARE MODE, SKIP LOCKED, NOWAIT) by ensuring they are safely ignored during translation to SQLite. Why is this necessary? SQLite does not support row-level locking syntax in SELECT statements. In environments like WordPress, plugins such as Action Scheduler frequently use these clauses for concurrency control. Since SQLite manages concurrency through database-level locking during write transactions, these clauses are redundant at the SQL level but would cause syntax errors if not stripped. What was changed: - Added the lockingClause rule to the AST translator (class-wp-pdo-mysql-on-sqlite.php). - The rule now returns null, safely removing the clause from the final SQL string. - Added a detailed comment explaining that while this ensures syntax compatibility, the specific row-level locking semantics of MySQL are not preserved. Verification: - Validated via the driver test suite (WP_SQLite_Driver_Tests.php), which includes complex queries and emulated Action Scheduler scenarios with FOR UPDATE. - Confirmed that queries with joins and subqueries containing FOR UPDATE are correctly translated into valid SQLite 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Goal:
Support MySQL queries that utilize locking clauses (e.g., FOR UPDATE, LOCK IN SHARE MODE, SKIP LOCKED, NOWAIT) by ensuring they are safely ignored during translation to SQLite.
Why is this necessary?
SQLite does not support row-level locking syntax in SELECT statements. In environments like WordPress, plugins such as Action Scheduler frequently use these clauses for concurrency control. Since SQLite manages concurrency through database-level locking during write transactions, these clauses are redundant at the SQL level but would cause syntax errors if not stripped.
What was changed:
Verification: