SET autocommit and SET foreign_key_checks are accepted but have no effect
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 362
- Fork
- 69
- Merge trung bình
- 4 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của WordPress/sqlite-database-integration
-
MySQL-on-SQLite does not translate DATE arithmetic with INTERVAL HOURCó thể đã có người làm @samuelmbabhazi đã nhận 23 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
WordPress/sqlite-database-integration#454 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 40/100
WordPress/sqlite-database-integration#531 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
WordPress/sqlite-database-integration#528 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 52/100
WordPress/sqlite-database-integration#527 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
WordPress/sqlite-database-integration#526 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của WordPress/sqlite-database-integration
Issue tương tự
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
scanaislop/aislop#482 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug UI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày