summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2017-08-30 23:23:27 +0000
committerTomas Vondra2017-08-30 23:23:27 +0000
commit6d9538d2c37ee7fad3539ca7421e8ae1cde81053 (patch)
tree589253493a7106f317350a37d232a4bda93cdd96
parent67638229c180cbfcdac7a41d5577ee6db5cc4665 (diff)
Stabilize ordering in tablefunc contrib module
Add explicit ORDER BY clause to stabilize ordering of test results.
-rw-r--r--contrib/tablefunc/expected/tablefunc.out12
-rw-r--r--contrib/tablefunc/sql/tablefunc.sql6
2 files changed, 9 insertions, 9 deletions
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);