191
191
-- STMT_DELETE_NODE
194
WHERE wc_id = ?1 AND local_relpath = ?2
194
WHERE wc_id = ?1 AND local_relpath = ?2 AND op_depth = ?3
196
196
-- STMT_DELETE_ACTUAL_FOR_BASE_RECURSIVE
197
197
/* The ACTUAL_NODE applies to BASE, unless there is in at least one op_depth
417
417
WHERE work.wc_id = ?1 AND work.local_relpath = ?2 AND work.op_depth > 0
420
-- STMT_SELECT_MOVED_TO_NODE
421
SELECT op_depth, moved_to
423
WHERE wc_id = ?1 AND local_relpath = ?2 AND moved_to IS NOT NULL
424
ORDER BY op_depth DESC
420
426
-- STMT_SELECT_OP_DEPTH_MOVED_TO
421
427
SELECT op_depth, moved_to, repos_path, revision
1503
1509
AND presence=MAP_NORMAL
1504
1510
AND file_external IS NULL
1506
/* ### FIXME: op-depth? What about multiple moves? */
1507
1512
-- STMT_SELECT_MOVED_FROM_RELPATH
1508
1513
SELECT local_relpath, op_depth FROM nodes
1509
1514
WHERE wc_id = ?1 AND moved_to = ?2 AND op_depth > 0
1530
1535
WHERE wc_id = ?1 AND op_depth > 0
1531
1536
AND IS_STRICT_DESCENDANT_OF(moved_to, ?2)
1538
/* If the node is moved here (r.moved_here = 1) we are really interested in
1539
where the node was moved from. To obtain that we need the op_depth, but
1540
this form of select only allows a single return value */
1533
1541
-- STMT_SELECT_MOVED_FOR_DELETE
1534
SELECT local_relpath, moved_to, op_depth FROM nodes
1542
SELECT local_relpath, moved_to, op_depth,
1543
(SELECT CASE WHEN r.moved_here THEN r.op_depth END FROM nodes r
1545
AND r.local_relpath = n.local_relpath
1546
AND r.op_depth < n.op_depth
1547
ORDER BY r.op_depth DESC LIMIT 1) AS moved_here_op_depth
1535
1549
WHERE wc_id = ?1
1536
1550
AND (local_relpath = ?2 OR IS_STRICT_DESCENDANT_OF(local_relpath, ?2))
1537
1551
AND moved_to IS NOT NULL
1538
AND op_depth >= (SELECT MAX(op_depth) FROM nodes o
1540
AND o.local_relpath = ?2)
1554
-- STMT_SELECT_MOVED_FROM_FOR_DELETE
1555
SELECT local_relpath, op_depth,
1556
(SELECT CASE WHEN r.moved_here THEN r.op_depth END FROM nodes r
1558
AND r.local_relpath = n.local_relpath
1559
AND r.op_depth < n.op_depth
1560
ORDER BY r.op_depth DESC LIMIT 1) AS moved_here_op_depth
1562
WHERE wc_id = ?1 AND moved_to = ?2 AND op_depth > 0
1542
1564
-- STMT_UPDATE_MOVED_TO_DESCENDANTS
1543
1565
UPDATE nodes SET moved_to = RELPATH_SKIP_JOIN(?2, ?3, moved_to)