From: Tomas Vondra Date: Wed, 30 Aug 2017 23:23:27 +0000 (+0200) Subject: Stabilize ordering in tablefunc contrib module X-Git-Tag: XL_10_R1BETA1~132 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=6d9538d2c37ee7fad3539ca7421e8ae1cde81053;p=postgres-xl.git Stabilize ordering in tablefunc contrib module Add explicit ORDER BY clause to stabilize ordering of test results. --- diff --git a/contrib/tablefunc/expected/tablefunc.out b/contrib/tablefunc/expected/tablefunc.out index fffadc6e1b..3e376cab99 100644 --- a/contrib/tablefunc/expected/tablefunc.out +++ b/contrib/tablefunc/expected/tablefunc.out @@ -332,26 +332,26 @@ SELECT * FROM connectby('connectby_text', 'keyid', 'parent_keyid', 'pos', 'row2' CREATE TABLE connectby_int(keyid int, parent_keyid int); \copy connectby_int from 'data/connectby_int.data' -- with branch -SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level int, branch text); +SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level int, branch text) ORDER BY keyid; keyid | parent_keyid | level | branch -------+--------------+-------+--------- 2 | | 0 | 2 4 | 2 | 1 | 2~4 + 5 | 2 | 1 | 2~5 6 | 4 | 2 | 2~4~6 8 | 6 | 3 | 2~4~6~8 - 5 | 2 | 1 | 2~5 9 | 5 | 2 | 2~5~9 (6 rows) -- without branch -SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0) AS t(keyid int, parent_keyid int, level int); +SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0) AS t(keyid int, parent_keyid int, level int) ORDER BY keyid; keyid | parent_keyid | level -------+--------------+------- 2 | | 0 4 | 2 | 1 + 5 | 2 | 1 6 | 4 | 2 8 | 6 | 3 - 5 | 2 | 1 9 | 5 | 2 (6 rows) @@ -363,14 +363,14 @@ INSERT INTO connectby_int VALUES(9,11); SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level int, branch text); ERROR: infinite recursion detected -- infinite recursion failure avoided by depth limit -SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 4, '~') AS t(keyid int, parent_keyid int, level int, branch text); +SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 4, '~') AS t(keyid int, parent_keyid int, level int, branch text) ORDER BY keyid; keyid | parent_keyid | level | branch -------+--------------+-------+------------- 2 | | 0 | 2 4 | 2 | 1 | 2~4 + 5 | 2 | 1 | 2~5 6 | 4 | 2 | 2~4~6 8 | 6 | 3 | 2~4~6~8 - 5 | 2 | 1 | 2~5 9 | 5 | 2 | 2~5~9 10 | 9 | 3 | 2~5~9~10 11 | 10 | 4 | 2~5~9~10~11 diff --git a/contrib/tablefunc/sql/tablefunc.sql b/contrib/tablefunc/sql/tablefunc.sql index ec375b05c6..8c8f32798a 100644 --- a/contrib/tablefunc/sql/tablefunc.sql +++ b/contrib/tablefunc/sql/tablefunc.sql @@ -163,10 +163,10 @@ CREATE TABLE connectby_int(keyid int, parent_keyid int); \copy connectby_int from 'data/connectby_int.data' -- with branch -SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level int, branch text); +SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level int, branch text) ORDER BY keyid; -- without branch -SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0) AS t(keyid int, parent_keyid int, level int); +SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0) AS t(keyid int, parent_keyid int, level int) ORDER BY keyid; -- recursion detection INSERT INTO connectby_int VALUES(10,9); @@ -177,7 +177,7 @@ INSERT INTO connectby_int VALUES(9,11); SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level int, branch text); -- infinite recursion failure avoided by depth limit -SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 4, '~') AS t(keyid int, parent_keyid int, level int, branch text); +SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 4, '~') AS t(keyid int, parent_keyid int, level int, branch text) ORDER BY keyid; -- should fail as first two columns must have the same type SELECT * FROM connectby('connectby_int', 'keyid', 'parent_keyid', '2', 0, '~') AS t(keyid text, parent_keyid int, level int, branch text);