Skip to content

Commit 2354c3c

Browse files
committed
Rename
1 parent bc7524b commit 2354c3c

24 files changed

+36
-103
lines changed

Assets/database/Materialized Paths.sqbpro renamed to Repo Assets/database/Materialized Paths.sqbpro

Lines changed: 36 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="G:/Projects/GitHub/SQLite-SQL-Tutorial/Assets/database/Materialized Paths.db" readonly="0" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="1"/><attached/><window><main_tabs open="structure browser pragmas query" current="3"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="5633"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="4,10:maincategories"/><default_encoding codec=""/><browse_table_settings/></tab_browse><tab_sql><sql name="copy">WITH RECURSIVE
1+
<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="G:/Projects/GitHub/SQLite-SQL-Tutorial/Repo Assets/database/Materialized Paths.db" readonly="0" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="1"/><attached/><window><main_tabs open="structure browser pragmas query" current="3"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="5633"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="4,16:mainfiles_categories"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="categories" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk="_rowid_"><sort/><column_widths><column index="1" value="140"/><column index="2" value="69"/><column index="3" value="221"/><column index="4" value="300"/><column index="5" value="300"/></column_widths><filter_values><column index="4" value="BAZ/bld/tcl/tests/safe00/"/></filter_values><conditional_formats/><row_id_formats/><display_formats/><hidden_columns/><plot_y_axes/><global_filter/></table><table schema="main" name="files_categories" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk="_rowid_"><sort/><column_widths><column index="1" value="300"/><column index="2" value="81"/></column_widths><filter_values><column index="1" value="preEEE/"/></filter_values><conditional_formats/><row_id_formats/><display_formats/><hidden_columns/><plot_y_axes/><global_filter/></table></browse_table_settings></tab_browse><tab_sql><sql name="copy">WITH RECURSIVE
22
ops_def(ops_json) AS (VALUES
33
(json(
44
'[' ||
@@ -1269,118 +1269,51 @@ WHERE mvt.path_old = categories.path AND mvt.target_exists = 0;
12691269
-- SELECT * FROM LOOP_COPY_STEP_2;
12701270
-- SELECT * FROM LOOP_COPY_STEP_3;
12711271
SELECT * FROM LOOP_COPY_STEP_STOP;
1272-
</sql><sql name="SQL 14">WITH RECURSIVE
1273-
folders(path_old) AS (
1274-
VALUES
1275-
('doc/thesis/exp'),
1276-
('doc/thesis/theory'),
1277-
('doc/app/job/lor'),
1278-
('code/scripts/py'),
1279-
('code/scripts/bas')
1280-
),
1281-
ops(opid, rootpath_old, rootpath_new) AS (
1272+
</sql><sql name="SQL 22">WITH RECURSIVE
1273+
json_ops(ops) AS (
1274+
VALUES
1275+
(json(
1276+
'[' ||
1277+
'{&quot;op&quot;:&quot;move&quot;, &quot;path_old&quot;:&quot;doc/&quot;, &quot;path_new&quot;:&quot;docABC&quot;},' ||
1278+
'{&quot;op&quot;:&quot;move&quot;, &quot;path_old&quot;:&quot;docABC/thesis/&quot;, &quot;path_new&quot;:&quot;docABC/master&quot;},' ||
1279+
'{&quot;op&quot;:&quot;move&quot;, &quot;path_old&quot;:&quot;docABC/app/job/&quot;, &quot;path_new&quot;:&quot;docABC/app/academic_job&quot;},' ||
1280+
'{&quot;op&quot;:&quot;move&quot;, &quot;path_old&quot;:&quot;code/&quot;, &quot;path_new&quot;:&quot;prog&quot;}' ||
1281+
']'
1282+
))
1283+
),
1284+
base_ops AS (
1285+
SELECT
1286+
&quot;key&quot; + 1 AS opid,
1287+
json_extract(value, '$.op') AS op,
1288+
trim(json_extract(value, '$.path_old'), '/') || '/' AS rootpath_old,
1289+
trim(json_extract(value, '$.path_new'), '/') AS rootpath_new
1290+
FROM json_ops AS jo, json_each(jo.ops) AS terms
1291+
),
1292+
folders(path_old) AS (
12821293
VALUES
1283-
(1, 'doc/', 'docABC' ),
1284-
(2, 'docABC/thesis/', 'docABC/master' ),
1285-
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
1286-
(4, 'code/', 'prog' )
1294+
('doc/thesis/exp'),
1295+
('doc/thesis/theory'),
1296+
('doc/app/job/lor'),
1297+
('code/scripts/py'),
1298+
('code/scripts/bas')
12871299
),
12881300
LOOP_COPY AS (
1301+
-- Initial SELECT --
12891302
SELECT 0 AS opid, path_old AS path_new
12901303
FROM folders
1291-
UNION ALL
1292-
SELECT ops.opid, path_new
1293-
FROM LOOP_COPY AS BUFFER, ops
1294-
WHERE ops.opid = BUFFER.opid + 1
1295-
UNION ALL
1296-
SELECT ops.opid,
1297-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1298-
FROM LOOP_COPY AS BUFFER, ops
1299-
WHERE ops.opid = BUFFER.opid + 1
1300-
AND BUFFER.path_new like rootpath_old || '%'
1301-
ORDER BY opid
1302-
),
1303-
1304-
-------------------------------------------------------------------------------
1305-
-------------------------------------------------------------------------------
1306-
LOOP_COPY_INIT AS (
1307-
SELECT 0 AS opid, path_old AS path_new
1308-
FROM folders
1309-
),
1310-
LOOP_COPY_STEP_1 AS (
1311-
SELECT ops.opid, path_new
1312-
FROM LOOP_COPY_INIT AS BUFFER, ops
1313-
WHERE ops.opid = BUFFER.opid + 1
1314-
UNION ALL
1315-
SELECT ops.opid,
1316-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1317-
FROM LOOP_COPY_INIT AS BUFFER, ops
1318-
WHERE ops.opid = BUFFER.opid + 1
1319-
AND BUFFER.path_new like rootpath_old || '%'
1320-
),
1321-
LOOP_COPY_STEP_2 AS (
1322-
SELECT ops.opid, path_new
1323-
FROM LOOP_COPY_STEP_1 AS BUFFER, ops
1324-
WHERE ops.opid = BUFFER.opid + 1
1325-
UNION ALL
1326-
SELECT ops.opid,
1327-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1328-
FROM LOOP_COPY_STEP_1 AS BUFFER, ops
1329-
WHERE ops.opid = BUFFER.opid + 1
1330-
AND BUFFER.path_new like rootpath_old || '%'
1331-
),
1332-
LOOP_COPY_STEP_3 AS (
1333-
SELECT ops.opid, path_new
1334-
FROM LOOP_COPY_STEP_2 AS BUFFER, ops
1335-
WHERE ops.opid = BUFFER.opid + 1
1336-
UNION ALL
1337-
SELECT ops.opid,
1338-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1339-
FROM LOOP_COPY_STEP_2 AS BUFFER, ops
1340-
WHERE ops.opid = BUFFER.opid + 1
1341-
AND BUFFER.path_new like rootpath_old || '%'
1342-
),
1343-
LOOP_COPY_STEP_4 AS (
1304+
UNION ALL -- LOOP body starts here --
1305+
-- Place input rows in the processing queue for the next loop
13441306
SELECT ops.opid, path_new
1345-
FROM LOOP_COPY_STEP_3 AS BUFFER, ops
1346-
WHERE ops.opid = BUFFER.opid + 1
1347-
UNION ALL
1348-
SELECT ops.opid,
1349-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1350-
FROM LOOP_COPY_STEP_3 AS BUFFER, ops
1351-
WHERE ops.opid = BUFFER.opid + 1
1352-
AND BUFFER.path_new like rootpath_old || '%'
1353-
),
1354-
LOOP_COPY_STEP_5_STOP AS (
1355-
SELECT ops.opid, path_new
1356-
FROM LOOP_COPY_STEP_4 AS BUFFER, ops
1307+
FROM LOOP_COPY AS BUFFER, base_ops AS ops
13571308
WHERE ops.opid = BUFFER.opid + 1
13581309
UNION ALL
1310+
-- Append the processing queue with new paths generated by the current operation
13591311
SELECT ops.opid,
1360-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1361-
FROM LOOP_COPY_STEP_4 AS BUFFER, ops
1312+
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
1313+
FROM LOOP_COPY AS BUFFER, base_ops AS ops
13621314
WHERE ops.opid = BUFFER.opid + 1
13631315
AND BUFFER.path_new like rootpath_old || '%'
1364-
),
1365-
-------------------------------------------------------------------------------
1366-
-------------------------------------------------------------------------------
1367-
1368-
subtrees_new_base AS (
1369-
SELECT ascii_id, path_new
1370-
FROM LOOP_COPY
1371-
WHERE opid = (SELECT max(opid) FROM base_ops)
1372-
AND length(ascii_id) &gt; 8
1373-
GROUP BY ascii_id, path_new
1374-
ORDER BY path_new
13751316
)
1376-
1377-
1378-
-- SELECT * FROM subtrees_new_base;
1379-
-- SELECT * FROM LOOP_COPY_INIT;
1380-
-- SELECT * FROM LOOP_COPY_STEP_1;
1381-
-- SELECT * FROM LOOP_COPY_STEP_2;
1382-
-- SELECT * FROM LOOP_COPY_STEP_3;
1383-
-- SELECT * FROM LOOP_COPY_STEP_4;
1384-
-- SELECT * FROM LOOP_COPY_STEP_5_STOP;
1385-
SELECT * FROM LOOP_COPY;
1317+
SELECT * FROM LOOP_COPY
1318+
WHERE opid = (SELECT max(ops.opid) FROM base_ops AS ops);
13861319
</sql><current_tab id="12"/></tab_sql></sqlb_project>
File renamed without changes.

0 commit comments

Comments
 (0)