Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/WP_SQLite_Driver_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -7380,6 +7380,22 @@ public function testUpdateWithJoinComplexQuery(): void {
);
}

public function testLockingClauses() {
$this->engine->query( "INSERT INTO _options (option_name, option_value) VALUES ('test_lock', '1')" );

// Test FOR UPDATE
$res = $this->engine->query( "SELECT option_value FROM _options WHERE option_name = 'test_lock' FOR UPDATE" );
$this->assertEquals( '1', $res[0]->option_value );

// Test LOCK IN SHARE MODE
$res = $this->engine->query( "SELECT option_value FROM _options WHERE option_name = 'test_lock' LOCK IN SHARE MODE" );
$this->assertEquals( '1', $res[0]->option_value );

// Test multiple clauses
$res = $this->engine->query( "SELECT option_value FROM _options WHERE option_name = 'test_lock' FOR UPDATE SKIP LOCKED" );
$this->assertEquals( '1', $res[0]->option_value );
}

public function testBinaryLiterals(): void {
$result = $this->assertQuery( 'SELECT 0b0100000101111010' );
$this->assertEquals( array( (object) array( '0b0100000101111010' => 'Az' ) ), $result );
Expand Down
6 changes: 4 additions & 2 deletions wp-includes/sqlite-ast/class-wp-pdo-mysql-on-sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -3808,8 +3808,10 @@ private function translate( $node ): ?string {
case 'indexHintList':
return null;
case 'lockingClause':
// SQLite doesn't support locking clauses (SELECT ... FOR UPDATE).
// They are not needed in SQLite due to the database file locking.
// MySQL locking clauses (e.g., SELECT ... FOR UPDATE) are not supported in SQLite.
// We omit them for syntax compatibility. While this doesn't preserve row-level
// locking semantics, SQLite's database-level locking is sufficient for
// typical WordPress workloads.
return null;
default:
return $this->translate_sequence( $node->get_children() );
Expand Down
Loading