php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81134 SQLite3 ext INSERT with RETURNING causes duplicate rows
Submitted: 2021-06-13 15:26 UTC Modified: 2021-06-14 08:33 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: achernow at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: SQLite related
PHP Version: 7.4.20 OS: MacOS Catalina 10.15.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
43 + 14 = ?
Subscribe to this entry?

 
 [2021-06-13 15:26 UTC] achernow at gmail dot com
Description:
------------
SQLite Shell - 3.35.5 2021-04-19 18:32:05

sqlite> CREATE TABLE profile
(
    profile_id INTEGER     PRIMARY KEY autoincrement,
    name       VARCHAR(64),
    email      VARCHAR(255),
    age        INT         NOT NULL DEFAULT 0,
    created    VARCHAR(20) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
sqlite> -- run php example
sqlite> select * from profile;
profile_id  name      email        age  created            
----------  --------  -----------  ---  -------------------
1           Adam Fry  a@gmail.com  47   2021-06-13 14:54:08
2           Adam Fry  a@gmail.com  47   2021-06-13 14:54:08

Notice it creates two identical rows. This is the issue. If I remove the returning clause, it only creates one row.



Test script:
---------------
// SQLite3 extension version 3.35.5

$db = new SQLite3('tests/file.db');

$result = $db->query("INSERT INTO profile (age, email, name) VALUES (47, 'a@gmail.com', 'Adam Fry') RETURNING profile_id, email");

print_r($result->fetchArray(SQLITE3_ASSOC));

$db->close();

Expected result:
----------------
When I do an insert of a single record, I would expect it to store a single row.

I would expect to see this:

sqlite> -- run php example
sqlite> select * from profile;
profile_id  name      email        age  created            
----------  --------  -----------  ---  -------------------
1           Adam Fry  a@gmail.com  47   2021-06-13 14:54:08


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-14 08:31 UTC] cmb@php.net
-Package: SQLite +Package: SQLite related
 [2021-06-14 08:33 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-06-14 08:33 UTC] cmb@php.net
Duplicate of bug #64531.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC