@@ -951,7 +951,7 @@ with recursive search_graph(f, t, label) as (
951951 select g.*
952952 from graph g, search_graph sg
953953 where g.f = sg.t
954- ) cycle f, t set is_cycle to true default false using path
954+ ) cycle f, t set is_cycle using path
955955select * from search_graph;
956956 f | t | label | is_cycle | path
957957---+---+------------+----------+-------------------------------------------
@@ -1071,7 +1071,7 @@ with recursive a as (
10711071 select 1 as b
10721072 union all
10731073 select * from a
1074- ) cycle b set c to true default false using p
1074+ ) cycle b set c using p
10751075select * from a;
10761076 b | c | p
10771077---+---+-----------
@@ -1087,7 +1087,7 @@ with recursive search_graph(f, t, label) as (
10871087 from graph g, search_graph sg
10881088 where g.f = sg.t
10891089) search depth first by f, t set seq
1090- cycle f, t set is_cycle to true default false using path
1090+ cycle f, t set is_cycle using path
10911091select * from search_graph;
10921092 f | t | label | seq | is_cycle | path
10931093---+---+------------+-------------------------------------------+----------+-------------------------------------------
@@ -1125,7 +1125,7 @@ with recursive search_graph(f, t, label) as (
11251125 from graph g, search_graph sg
11261126 where g.f = sg.t
11271127) search breadth first by f, t set seq
1128- cycle f, t set is_cycle to true default false using path
1128+ cycle f, t set is_cycle using path
11291129select * from search_graph;
11301130 f | t | label | seq | is_cycle | path
11311131---+---+------------+---------+----------+-------------------------------------------
@@ -1163,10 +1163,10 @@ with recursive search_graph(f, t, label) as (
11631163 select g.*
11641164 from graph g, search_graph sg
11651165 where g.f = sg.t
1166- ) cycle foo, tar set is_cycle to true default false using path
1166+ ) cycle foo, tar set is_cycle using path
11671167select * from search_graph;
11681168ERROR: cycle column "foo" not in WITH query column list
1169- LINE 7: ) cycle foo, tar set is_cycle to true default false using pa...
1169+ LINE 7: ) cycle foo, tar set is_cycle using path
11701170 ^
11711171with recursive search_graph(f, t, label) as (
11721172 select * from graph g
@@ -1257,38 +1257,99 @@ ERROR: search_sequence column name and cycle path column name are the same
12571257LINE 7: ) search depth first by f, t set foo
12581258 ^
12591259-- test ruleutils and view expansion
1260- create temp view v_cycle as
1260+ create temp view v_cycle1 as
12611261with recursive search_graph(f, t, label) as (
12621262 select * from graph g
12631263 union all
12641264 select g.*
12651265 from graph g, search_graph sg
12661266 where g.f = sg.t
1267- ) cycle f, t set is_cycle to true default false using path
1267+ ) cycle f, t set is_cycle using path
12681268select f, t, label from search_graph;
1269- select pg_get_viewdef('v_cycle');
1270- pg_get_viewdef
1271- --------------------------------------------------------------------
1272- WITH RECURSIVE search_graph(f, t, label) AS ( +
1273- SELECT g.f, +
1274- g.t, +
1275- g.label +
1276- FROM graph g +
1277- UNION ALL +
1278- SELECT g.f, +
1279- g.t, +
1280- g.label +
1281- FROM graph g, +
1282- search_graph sg +
1283- WHERE (g.f = sg.t) +
1284- ) CYCLE f, t SET is_cycle TO true DEFAULT false USING path+
1285- SELECT search_graph.f, +
1286- search_graph.t, +
1287- search_graph.label +
1269+ create temp view v_cycle2 as
1270+ with recursive search_graph(f, t, label) as (
1271+ select * from graph g
1272+ union all
1273+ select g.*
1274+ from graph g, search_graph sg
1275+ where g.f = sg.t
1276+ ) cycle f, t set is_cycle to 'Y' default 'N' using path
1277+ select f, t, label from search_graph;
1278+ select pg_get_viewdef('v_cycle1');
1279+ pg_get_viewdef
1280+ ------------------------------------------------
1281+ WITH RECURSIVE search_graph(f, t, label) AS (+
1282+ SELECT g.f, +
1283+ g.t, +
1284+ g.label +
1285+ FROM graph g +
1286+ UNION ALL +
1287+ SELECT g.f, +
1288+ g.t, +
1289+ g.label +
1290+ FROM graph g, +
1291+ search_graph sg +
1292+ WHERE (g.f = sg.t) +
1293+ ) CYCLE f, t SET is_cycle USING path +
1294+ SELECT search_graph.f, +
1295+ search_graph.t, +
1296+ search_graph.label +
12881297 FROM search_graph;
12891298(1 row)
12901299
1291- select * from v_cycle;
1300+ select pg_get_viewdef('v_cycle2');
1301+ pg_get_viewdef
1302+ -----------------------------------------------------------------------------
1303+ WITH RECURSIVE search_graph(f, t, label) AS ( +
1304+ SELECT g.f, +
1305+ g.t, +
1306+ g.label +
1307+ FROM graph g +
1308+ UNION ALL +
1309+ SELECT g.f, +
1310+ g.t, +
1311+ g.label +
1312+ FROM graph g, +
1313+ search_graph sg +
1314+ WHERE (g.f = sg.t) +
1315+ ) CYCLE f, t SET is_cycle TO 'Y'::text DEFAULT 'N'::text USING path+
1316+ SELECT search_graph.f, +
1317+ search_graph.t, +
1318+ search_graph.label +
1319+ FROM search_graph;
1320+ (1 row)
1321+
1322+ select * from v_cycle1;
1323+ f | t | label
1324+ ---+---+------------
1325+ 1 | 2 | arc 1 -> 2
1326+ 1 | 3 | arc 1 -> 3
1327+ 2 | 3 | arc 2 -> 3
1328+ 1 | 4 | arc 1 -> 4
1329+ 4 | 5 | arc 4 -> 5
1330+ 5 | 1 | arc 5 -> 1
1331+ 1 | 2 | arc 1 -> 2
1332+ 1 | 3 | arc 1 -> 3
1333+ 1 | 4 | arc 1 -> 4
1334+ 2 | 3 | arc 2 -> 3
1335+ 4 | 5 | arc 4 -> 5
1336+ 5 | 1 | arc 5 -> 1
1337+ 1 | 2 | arc 1 -> 2
1338+ 1 | 3 | arc 1 -> 3
1339+ 1 | 4 | arc 1 -> 4
1340+ 2 | 3 | arc 2 -> 3
1341+ 4 | 5 | arc 4 -> 5
1342+ 5 | 1 | arc 5 -> 1
1343+ 1 | 2 | arc 1 -> 2
1344+ 1 | 3 | arc 1 -> 3
1345+ 1 | 4 | arc 1 -> 4
1346+ 2 | 3 | arc 2 -> 3
1347+ 4 | 5 | arc 4 -> 5
1348+ 5 | 1 | arc 5 -> 1
1349+ 2 | 3 | arc 2 -> 3
1350+ (25 rows)
1351+
1352+ select * from v_cycle2;
12921353 f | t | label
12931354---+---+------------
12941355 1 | 2 | arc 1 -> 2
0 commit comments