SQLite

View Ticket
Login
Ticket Hash: 132994c8b1063bfbe4fc0d7cffba974d0970b9ef
Title: RETURNING old.* seg-faults
Status: Fixed Type: Code_Defect
Severity: Severe Priority: High
Subsystem: Code_Generator Resolution: Fixed
Last Modified: 2021-03-30 19:17:30
Version Found In: 3.35.3
User Comments:
larrybr added on 2021-03-29 22:57:42:

This SQL, applied to :memory: DB, CREATE TABLE a (id INTEGER NOT NULL PRIMARY KEY); UPDATE a SET id = a.id + 1 FROM (SELECT * FROM a) AS old RETURNING old.*; produces a seg-fault at line 99948 of sqlite3.c .

Reported in forum post: https://sqlite.org/forum/forumpost/cdc28fec1a


larrybr added on 2021-03-29 23:40:47:

Slightly simpler test case (from Keith at the forum): create table x(a,b); create table y(c,d); update x set a=c from y where b=d returning *;


larrybr added on 2021-03-29 23:55:58:

Strike that final repro update. Both of these seg-fault: update x set a=c from y where b=d returning x.*; update x set a=c from y where b=d returning y.*; . And, interestingly, this does not: update x set a=c from y where b=d returning x.a, y.d; , instead producing: "Error: no such column: y.d". (All lifted from Keith's post.)


drh added on 2021-03-30 00:47:59:

The FROM clause is not required. Any RETURNING that contains the form "table.*" seems to cause the problem. Example:

CREATE TABLE t1(x);
INSERT INTO t1 VALUE(1) RETURNING t1.*;