SET autocommit and SET foreign_key_checks are accepted but have no effect
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Read the driver's session-variable handling and wrapper transaction code, then trace how foreign_key_checks maps to PRAGMA foreign_keys and how autocommit interacts with COMMIT and ROLLBACK. Reproduce both SQL examples from the issue. Done means these settings either affect behavior as described or are rejected clearly instead of being stored silently.
索引モデルが issue の本文から書いたものです。
説明
Reproduction
CREATE TABLE p (id INT PRIMARY KEY);
CREATE TABLE c (pid INT, FOREIGN KEY (pid) REFERENCES p (id));
SET foreign_key_checks = 0;
SELECT @@foreign_key_checks;
-- 0
INSERT INTO c VALUES (99);
-- SQLSTATE[23000]: Integrity constraint violation: 19 FOREIGN KEY constraint failed
-- (MySQL: the row is inserted)
CREATE TABLE t (id INT PRIMARY KEY);
SET autocommit = 0;
SELECT @@autocommit;
-- 0
INSERT INTO t VALUES (1);
ROLLBACK;
SELECT id FROM t;
-- 1 (MySQL: no rows; with autocommit off, the INSERT opened a transaction)
Reproduced on trunk (3.1.0) with PHP 8.3 and SQLite 3.45.1.
Both statements are accepted and stored as session variables, so SELECT @@... reports the new value, but neither changes behavior. Before they are set, both variables read as NULL (MySQL: 1).
Impact
foreign_key_checks: SQL dumps disable foreign key checks so that tables can be loaded in any order.mysqldumpoutput setsFOREIGN_KEY_CHECKS=0in its header. Here, importing such a dump fails at the first row of a child table that is loaded before its parent.autocommit: Code that turns autocommit off and relies onROLLBACKto discard its changes has them committed instead. This one silently keeps data the application meant to discard.
Implementation notes
foreign_key_checks maps to PRAGMA foreign_keys, with one limit: SQLite ignores that pragma inside a transaction, so a change made inside a transaction can only take effect when it ends. The driver's wrapper transaction has the same limit, and #528 discusses running DDL outside it, which would also be the place to apply this setting.
autocommit = 0 could be emulated by opening a transaction before the next statement and keeping it open until COMMIT or ROLLBACK, as MySQL does.
Until then, would it be preferable to reject these values with an error rather than accept them silently? I'm happy to contribute a PR in whichever direction you prefer.
Use of AI
This report was prepared with Claude Code.
- 主要言語
- PHP
- スター
- 362
- フォーク
- 69
- 平均マージ
- 3日 11時間
- マージ済み PR(30日)
- 12
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
WordPress/sqlite-database-integration のほかの issue
-
MySQL-on-SQLite does not translate DATE arithmetic with INTERVAL HOUR対応中かも @samuelmbabhazi が 25 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
WordPress/sqlite-database-integration#454 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 40/100
WordPress/sqlite-database-integration#531 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
WordPress/sqlite-database-integration#528 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 52/100
WordPress/sqlite-database-integration#527 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
WordPress/sqlite-database-integration#526 ·
メンテナーはふだん 1 日以内に返信
WordPress/sqlite-database-integration の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Automattic/blocks-engine#2866 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
backend gamification P0
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
semanadeinformatica/website#461 ·
-
HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Baseオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
area: docs eco: php good first issue help wanted lane: free-agent roadmap size: XS type: docs
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
arminazimi/evergreen#453 ·
メンテナーはふだん 1 日以内に返信