PL/SQL parser (MDEV-10142)

[MDEV-12874] UPDATE statements with the same source and target Created: 2017-05-23  Updated: 2018-08-31  Resolved: 2017-10-03

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.3
Fix Version/s: 10.3.2

Type: Technical task Priority: Critical
Reporter: Alexander Barkov Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: Compatibility

Issue Links:
Blocks
is blocked by MDEV-13911 Support ORDER BY and LIMIT in multi-t... Closed
Relates
relates to MDEV-12137 DELETE statement with the same source... Closed
Sprint: 10.2.2-3, 10.2.2-1, 10.2.2-2, 10.2.2-4, 10.1.18

 Description   

This script works fine in Oracle (and PostgreSQL):

DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT);
INSERT INTO t1 VALUES (10,10);
INSERT INTO t1 VALUES (20,20);
UPDATE t1 SET c1=c1+1 WHERE c2=(SELECT MAX(c2) FROM t1);
SELECT * FROM t1;

SQL> SELECT * FROM t1; 
 
	C1	   C2
---------- ----------
	10	   10
	21	   20

Notice, the table t1 is used twice in the UPDATE query, as a target and as a source.

Under term of this tasks will allow to use the same table as a source and as a target in UPDATE statements in MariaDB.

Currently its not allowed and returns this error:

ERROR 1093 (HY000): Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data


Generated at Thu Feb 08 08:01:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.