Details
-
New Feature
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
Description
CREATE TABLE tree ( |
`Node` VARCHAR(3), |
`ParentNode` VARCHAR(3), |
`EmployeeID` INTEGER, |
`Depth` INTEGER, |
`Lineage` VARCHAR(16) |
);
|
|
INSERT INTO tree |
(`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`)
|
VALUES |
('100', NULL, '1001', 0, '/'), |
('101', '100', '1002', NULL, NULL), |
('102', '101', '1003', NULL, NULL), |
('103', '102', '1004', NULL, NULL), |
('104', '102', '1005', NULL, NULL), |
('105', '102', '1006', NULL, NULL); |
|
WITH RECURSIVE prev AS ( |
SELECT * FROM tree WHERE ParentNode IS NULL |
UNION |
SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') |
FROM tree t JOIN prev p ON t.ParentNode = p.Node |
)
|
SELECT * FROM prev; |
WITH RECURSIVE prev AS ( |
SELECT * FROM tree WHERE ParentNode IS NULL |
UNION |
SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') |
FROM prev p JOIN tree t ON t.ParentNode = p.Node |
)
|
UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; |
|
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 |
Attachments
Issue Links
- is blocked by
-
MDEV-23552 Merge mergeable derived tables used at the top level of UPDATE/DELETE statements
-
- Stalled
-
- is duplicated by
-
MDEV-22405 Unable to delete data using CTE
-
- Closed
-
- relates to
-
MDEV-36293 Lift limitations of UPDATE/DELETE using view and derived tables
-
- Open
-
Activity
Field | Original Value | New Value |
---|---|---|
Labels | upstream-fixed | gsoc19 upstream-fixed |
Assignee | Igor Babaev [ igor ] |
Component/s | Optimizer [ 10200 ] |
Labels | gsoc19 upstream-fixed | gsoc19 gsoc20 upstream-fixed |
Link |
This issue is duplicated by |
Fix Version/s | 10.6 [ 24028 ] |
Description |
{code:sql} CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]* [supported in MySQL-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
{code:sql}
CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]* [supported in MySQL-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
Summary | Recursive CTE support for UPDATE (and DELETE) statements | CTE support for UPDATE (and DELETE) statements |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Summary | CTE support for UPDATE (and DELETE) statements | CTE support for UPDATE and DELETE statements |
Link | This issue is blocked by MDEV-23552 [ MDEV-23552 ] |
Link |
This issue includes |
Link |
This issue includes |
Rank | Ranked higher |
Status | Confirmed [ 10101 ] | In Progress [ 3 ] |
Fix Version/s | 10.7 [ 24805 ] | |
Fix Version/s | 10.6 [ 24028 ] |
Link |
This issue relates to |
Link |
This issue relates to |
Fix Version/s | 10.8 [ 26121 ] | |
Fix Version/s | 10.7 [ 24805 ] |
Link |
This issue relates to |
Link |
This issue relates to |
Workflow | MariaDB v3 [ 92362 ] | MariaDB v4 [ 131832 ] |
Fix Version/s | 10.9 [ 26905 ] | |
Fix Version/s | 10.8 [ 26121 ] |
Fix Version/s | 10.10 [ 27530 ] | |
Fix Version/s | 10.9 [ 26905 ] |
Description |
{code:sql}
CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]* [supported in MySQL-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
{code:sql} CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]\* [supported in MySQL\-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
Description |
{code:sql} CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]\* [supported in MySQL\-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
{code:sql}
CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]* [supported in MySQL-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
Fix Version/s | 10.11 [ 27614 ] | |
Fix Version/s | 10.10 [ 27530 ] |
Description |
{code:sql}
CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]* [supported in MySQL-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
{code:sql} CREATE TABLE tree ( `Node` VARCHAR(3), `ParentNode` VARCHAR(3), `EmployeeID` INTEGER, `Depth` INTEGER, `Lineage` VARCHAR(16) ); INSERT INTO tree (`Node`, `ParentNode`, `EmployeeID`, `Depth`, `Lineage`) VALUES ('100', NULL, '1001', 0, '/'), ('101', '100', '1002', NULL, NULL), ('102', '101', '1003', NULL, NULL), ('103', '102', '1004', NULL, NULL), ('104', '102', '1005', NULL, NULL), ('105', '102', '1006', NULL, NULL); WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM tree t JOIN prev p ON t.ParentNode = p.Node ) SELECT * FROM prev; WITH RECURSIVE prev AS ( SELECT * FROM tree WHERE ParentNode IS NULL UNION SELECT t.Node,t.ParentNode,t.EmployeeID,p.Depth + 1 as Depth, CONCAT(p.Lineage, t.ParentNode, '/') FROM prev p JOIN tree t ON t.ParentNode = p.Node ) UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.Node; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE tree t, prev p SET t.Depth=p.Depth, t.Lineage=p.Lineage WHERE t.Node=p.No' at line 7 {code} [db<>fiddle here|https://dbfiddle.uk/?rdbms=mariadb_10.3&fiddle=a28ed3cabd68bac75941eba5973fd50a]\* [supported in MySQL\-8.0|https://dev.mysql.com/doc/refman/8.0/en/with.html] and [MSSQL|(https://stackoverflow.com/questions/54583713/mysql-while-exists-from-a-snippet-throws-error/54584556#54584556] |
Fix Version/s | 10.11 [ 27614 ] |
Assignee | Igor Babaev [ igor ] | Ralf Gebhardt [ ralf.gebhardt@mariadb.com ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
Assignee | Ralf Gebhardt [ ralf.gebhardt@mariadb.com ] | Igor Babaev [ igor ] |
Fix Version/s | 11.2 [ 28603 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Fix Version/s | 11.3 [ 28565 ] | |
Fix Version/s | 11.2 [ 28603 ] |
Link |
This issue blocks |
Link |
This issue includes |
Fix Version/s | 11.4 [ 29301 ] | |
Fix Version/s | 11.3 [ 28565 ] |
Fix Version/s | 11.5 [ 29506 ] | |
Fix Version/s | 11.4 [ 29301 ] |
Issue Type | Task [ 3 ] | New Feature [ 2 ] |
Priority | Critical [ 2 ] | Major [ 3 ] |
Fix Version/s | 11.6 [ 29515 ] | |
Fix Version/s | 11.5 [ 29506 ] |
Fix Version/s | 11.7 [ 29815 ] | |
Fix Version/s | 11.6 [ 29515 ] |
Zendesk Related Tickets | 201775 202044 | |
Zendesk active tickets | 201775 |
Link |
This issue blocks |
Fix Version/s | 11.8 [ 29921 ] | |
Fix Version/s | 11.7 [ 29815 ] |
Fix Version/s | 11.9 [ 29945 ] | |
Fix Version/s | 11.8 [ 29921 ] |
Fix Version/s | 11.9 [ 29945 ] |
Status | Stalled [ 10000 ] | Open [ 1 ] |
Link |
This issue includes |
Fix Version/s | 12.1 [ 29992 ] | |
Labels | gsoc19 gsoc20 upstream-fixed |
Status | Open [ 1 ] | In Progress [ 3 ] |
Link | This issue relates to MDEV-36293 [ MDEV-36293 ] |
Labels | gsoc19 gsoc20 upstream-fixed |
Assignee | Igor Babaev [ igor ] | Sergei Petrunia [ psergey ] |
Sprint | Server 12.1 dev sprint [ 793 ] |
Fix Version/s | 12.2 [ 30146 ] | |
Fix Version/s | 12.1 [ 29992 ] |
Sprint | Server 12.1 dev sprint [ 793 ] |
Status | In Progress [ 3 ] | Stalled [ 10000 ] |
This needs to be called out in the documentation for UPDATE & DELETE. Coming from a MySQL project to MariaDB I expected this to work and banged my head on it for an hour, before a lucky Stack Overflow find led me to this bug. Fortunately I have permission to create & drop temporary tables, but not everyone will.