@@ -89,32 +89,32 @@ Even though the RCTE loop body processes one row at a time, when the processing
89
89
90
90
~~~ sql
91
91
WITH RECURSIVE
92
- folders(path_old) AS (
93
- VALUES
94
- (' doc/thesis/exp' ),
95
- (' doc/thesis/theory' ),
96
- (' doc/app/job/lor' ),
97
- (' code/scripts/py' ),
98
- (' code/scripts/bas' )
99
- ),
92
+ folders(path_old) AS (
93
+ VALUES
94
+ (' doc/thesis/exp' ),
95
+ (' doc/thesis/theory' ),
96
+ (' doc/app/job/lor' ),
97
+ (' code/scripts/py' ),
98
+ (' code/scripts/bas' )
99
+ ),
100
100
ops(opid, rootpath_old, rootpath_new) AS (
101
101
VALUES
102
- (1 , ' doc/' , ' docABC' ),
103
- (2 , ' docABC/thesis/' , ' docABC/master' ),
104
- (3 , ' docABC/app/job/' , ' docABC/app/academic_job' ),
105
- (4 , ' code/' , ' prog' )
102
+ (1 , ' doc/' , ' docABC' ),
103
+ (2 , ' docABC/thesis/' , ' docABC/master' ),
104
+ (3 , ' docABC/app/job/' , ' docABC/app/academic_job' ),
105
+ (4 , ' code/' , ' prog' )
106
106
),
107
107
LOOP_COPY_INIT AS (
108
- SELECT 0 AS opid, path_old AS path_new
109
- FROM folders
108
+ SELECT 0 AS opid, path_old AS path_new
109
+ FROM folders
110
110
),
111
111
LOOP_COPY_STEP_1 AS (
112
112
SELECT ops .opid , path_new
113
113
FROM LOOP_COPY_INIT AS BUFFER, ops
114
114
WHERE ops .opid = BUFFER .opid + 1
115
115
UNION ALL
116
116
SELECT ops .opid ,
117
- rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
117
+ rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
118
118
FROM LOOP_COPY_INIT AS BUFFER, ops
119
119
WHERE ops .opid = BUFFER .opid + 1
120
120
AND BUFFER .path_new like rootpath_old || ' %'
@@ -125,7 +125,7 @@ WITH RECURSIVE
125
125
WHERE ops .opid = BUFFER .opid + 1
126
126
UNION ALL
127
127
SELECT ops .opid ,
128
- rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
128
+ rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
129
129
FROM LOOP_COPY_STEP_1 AS BUFFER, ops
130
130
WHERE ops .opid = BUFFER .opid + 1
131
131
AND BUFFER .path_new like rootpath_old || ' %'
@@ -136,7 +136,7 @@ WITH RECURSIVE
136
136
WHERE ops .opid = BUFFER .opid + 1
137
137
UNION ALL
138
138
SELECT ops .opid ,
139
- rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
139
+ rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
140
140
FROM LOOP_COPY_STEP_2 AS BUFFER, ops
141
141
WHERE ops .opid = BUFFER .opid + 1
142
142
AND BUFFER .path_new like rootpath_old || ' %'
@@ -147,7 +147,7 @@ WITH RECURSIVE
147
147
WHERE ops .opid = BUFFER .opid + 1
148
148
UNION ALL
149
149
SELECT ops .opid ,
150
- rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
150
+ rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
151
151
FROM LOOP_COPY_STEP_3 AS BUFFER, ops
152
152
WHERE ops .opid = BUFFER .opid + 1
153
153
AND BUFFER .path_new like rootpath_old || ' %'
@@ -158,7 +158,7 @@ WITH RECURSIVE
158
158
WHERE ops .opid = BUFFER .opid + 1
159
159
UNION ALL
160
160
SELECT ops .opid ,
161
- rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
161
+ rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
162
162
FROM LOOP_COPY_STEP_4 AS BUFFER, ops
163
163
WHERE ops .opid = BUFFER .opid + 1
164
164
AND BUFFER .path_new like rootpath_old || ' %'
0 commit comments