Skip to content

PGPRO-11987 Support new Optimizer's behaviour in regression tests #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions expected/altorder.out
Original file line number Diff line number Diff line change
@@ -3,8 +3,13 @@
* NOTE: This test behaves differenly
* ------------------------------------
*
* altorder.out - test output for 64-bit systems and
* altorder_1.out - test output for 32-bit systems.
* altorder.out - test output for 64-bit systems
* altorder_1.out - test output for 32-bit systems
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_2.out - test output for 32-bit systems (>=18)
*
*/
CREATE TABLE atsts (id int, t tsvector, d timestamp);
9 changes: 7 additions & 2 deletions expected/altorder_1.out
Original file line number Diff line number Diff line change
@@ -3,8 +3,13 @@
* NOTE: This test behaves differenly
* ------------------------------------
*
* altorder.out - test output for 64-bit systems and
* altorder_1.out - test output for 32-bit systems.
* altorder.out - test output for 64-bit systems
* altorder_1.out - test output for 32-bit systems
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_2.out - test output for 32-bit systems (>=18)
*
*/
CREATE TABLE atsts (id int, t tsvector, d timestamp);
598 changes: 598 additions & 0 deletions expected/altorder_2.out

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions expected/altorder_hash.out
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
* altorder_hash.out - test output for 64-bit systems and
* altorder_hash_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_hash_2.out - test output for 32-bit systems (>=18)
*
*/
CREATE TABLE atstsh (id int, t tsvector, d timestamp);
\copy atstsh from 'data/tsts.data'
5 changes: 5 additions & 0 deletions expected/altorder_hash_1.out
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
* altorder_hash.out - test output for 64-bit systems and
* altorder_hash_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_hash_2.out - test output for 32-bit systems (>=18)
*
*/
CREATE TABLE atstsh (id int, t tsvector, d timestamp);
\copy atstsh from 'data/tsts.data'
363 changes: 363 additions & 0 deletions expected/altorder_hash_2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,363 @@
/*
* ------------------------------------
* NOTE: This test behaves differenly
* ------------------------------------
*
* altorder_hash.out - test output for 64-bit systems and
* altorder_hash_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_hash_2.out - test output for 32-bit systems (>=18)
*
*/
CREATE TABLE atstsh (id int, t tsvector, d timestamp);
\copy atstsh from 'data/tsts.data'
CREATE INDEX atstsh_idx ON atstsh USING rum (t rum_tsvector_hash_addon_ops, d)
WITH (attach = 'd', to = 't', order_by_attach='t');
ERROR: doesn't support order index over pass-by-reference column
INSERT INTO atstsh VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
INSERT INTO atstsh VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
count
-------
158
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ 'wr&qh';
count
-------
17
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ 'eq&yt';
count
-------
6
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ 'eq|yt';
count
-------
98
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ '(eq&yt)|(wr&qh)';
count
-------
23
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
count
-------
39
(1 row)

SET enable_indexscan=OFF;
SET enable_indexonlyscan=OFF;
SET enable_bitmapscan=OFF;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+---------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
(5 rows)

SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+---------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
252 | Thu May 12 07:21:22.326724 2016 | 370802.673276
232 | Wed May 11 11:21:22.326724 2016 | 442802.673276
168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
(5 rows)

SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+---------------
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
428 | Thu May 19 15:21:22.326724 2016 | 262797.326724
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
count
-------
357
(1 row)

SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
count
-------
153
(1 row)

SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
id | d
-----+---------------------------------
16 | Mon May 02 11:21:22.326724 2016
39 | Tue May 03 10:21:22.326724 2016
71 | Wed May 04 18:21:22.326724 2016
135 | Sat May 07 10:21:22.326724 2016
168 | Sun May 08 19:21:22.326724 2016
232 | Wed May 11 11:21:22.326724 2016
252 | Thu May 12 07:21:22.326724 2016
354 | Mon May 16 13:21:22.326724 2016
355 | Mon May 16 14:21:22.326724 2016
(9 rows)

SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
id | d
-----+---------------------------------
371 | Tue May 17 06:21:22.326724 2016
406 | Wed May 18 17:21:22.326724 2016
415 | Thu May 19 02:21:22.326724 2016
428 | Thu May 19 15:21:22.326724 2016
457 | Fri May 20 20:21:22.326724 2016
458 | Fri May 20 21:21:22.326724 2016
484 | Sat May 21 23:21:22.326724 2016
496 | Sun May 22 11:21:22.326724 2016
(8 rows)

-- Test bitmap index scan
SET enable_bitmapscan=on;
SET enable_seqscan = off;
EXPLAIN (costs off)
SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
QUERY PLAN
---------------------------------------------------
Aggregate
Disabled Nodes: 1
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: (t @@ '''wr'' | ''qh'''::tsquery)
(5 rows)

SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
count
-------
158
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ 'wr&qh';
count
-------
17
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ 'eq&yt';
count
-------
6
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ 'eq|yt';
count
-------
98
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ '(eq&yt)|(wr&qh)';
count
-------
23
(1 row)

SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
count
-------
39
(1 row)

EXPLAIN (costs off)
SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
QUERY PLAN
-------------------------------------------------------------------------------
Aggregate
Disabled Nodes: 1
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(5 rows)

SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
count
-------
357
(1 row)

EXPLAIN (costs off)
SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
QUERY PLAN
-------------------------------------------------------------------------------
Aggregate
Disabled Nodes: 1
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(5 rows)

SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
count
-------
153
(1 row)

-- Test index scan
SET enable_indexscan=on;
SET enable_indexonlyscan=on;
SET enable_bitmapscan=off;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-------------------------------------------------------------------------------------
Limit
Disabled Nodes: 1
-> Sort
Disabled Nodes: 1
Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: (t @@ '''wr'' & ''qh'''::tsquery)
(8 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+---------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-------------------------------------------------------------------------------------
Limit
Disabled Nodes: 1
-> Sort
Disabled Nodes: 1
Sort Key: ((d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone))
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: (t @@ '''wr'' & ''qh'''::tsquery)
(8 rows)

SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+---------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
252 | Thu May 12 07:21:22.326724 2016 | 370802.673276
232 | Wed May 11 11:21:22.326724 2016 | 442802.673276
168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-------------------------------------------------------------------------------------
Limit
Disabled Nodes: 1
-> Sort
Disabled Nodes: 1
Sort Key: ((d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: (t @@ '''wr'' & ''qh'''::tsquery)
(8 rows)

SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+---------------
371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
428 | Thu May 19 15:21:22.326724 2016 | 262797.326724
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-------------------------------------------------------------------------------------
Limit
Disabled Nodes: 1
-> Sort
Disabled Nodes: 1
Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
-> Seq Scan on atstsh
Disabled Nodes: 1
(7 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

EXPLAIN (costs off)
SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Sort
Disabled Nodes: 1
Sort Key: d
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
(6 rows)

SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
id | d
-----+---------------------------------
16 | Mon May 02 11:21:22.326724 2016
39 | Tue May 03 10:21:22.326724 2016
71 | Wed May 04 18:21:22.326724 2016
135 | Sat May 07 10:21:22.326724 2016
168 | Sun May 08 19:21:22.326724 2016
232 | Wed May 11 11:21:22.326724 2016
252 | Thu May 12 07:21:22.326724 2016
354 | Mon May 16 13:21:22.326724 2016
355 | Mon May 16 14:21:22.326724 2016
(9 rows)

EXPLAIN (costs off)
SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Sort
Disabled Nodes: 1
Sort Key: d
-> Seq Scan on atstsh
Disabled Nodes: 1
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
(6 rows)

SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
id | d
-----+---------------------------------
371 | Tue May 17 06:21:22.326724 2016
406 | Wed May 18 17:21:22.326724 2016
415 | Thu May 19 02:21:22.326724 2016
428 | Thu May 19 15:21:22.326724 2016
457 | Fri May 20 20:21:22.326724 2016
458 | Fri May 20 21:21:22.326724 2016
484 | Sat May 21 23:21:22.326724 2016
496 | Sun May 22 11:21:22.326724 2016
(8 rows)

6 changes: 6 additions & 0 deletions expected/array.out
Original file line number Diff line number Diff line change
@@ -6,6 +6,12 @@
* array.out - test output for 64-bit systems and
* array_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* array_2.out - test output for 64-bit systems (>=18).
* array_3.out - test output for 32-bit systems (>=18).
*
*/
set enable_seqscan=off;
set enable_sort=off;
6 changes: 6 additions & 0 deletions expected/array_1.out
Original file line number Diff line number Diff line change
@@ -6,6 +6,12 @@
* array.out - test output for 64-bit systems and
* array_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* array_2.out - test output for 64-bit systems (>=18).
* array_3.out - test output for 32-bit systems (>=18).
*
*/
set enable_seqscan=off;
set enable_sort=off;
929 changes: 929 additions & 0 deletions expected/array_2.out

Large diffs are not rendered by default.

922 changes: 922 additions & 0 deletions expected/array_3.out

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions expected/int8.out
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
* int8.out - test output for 64-bit systems and
* int8_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* int8_2.out - test output for 32-bit systems (>=18)
*
*/
set enable_seqscan=off;
CREATE TABLE test_int8 (
5 changes: 5 additions & 0 deletions expected/int8_1.out
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
* int8.out - test output for 64-bit systems and
* int8_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* int8_2.out - test output for 32-bit systems (>=18)
*
*/
set enable_seqscan=off;
CREATE TABLE test_int8 (
701 changes: 701 additions & 0 deletions expected/int8_2.out

Large diffs are not rendered by default.

78 changes: 40 additions & 38 deletions expected/orderby.out
Original file line number Diff line number Diff line change
@@ -192,25 +192,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
@@ -262,6 +243,26 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
496 | Sun May 22 11:21:22.326724 2016
(8 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

-- Test index scan
RESET enable_indexscan;
RESET enable_indexonlyscan;
@@ -371,25 +372,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
@@ -469,6 +451,26 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
458 | Fri May 20 21:21:22.326724 2016
(3 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

-- Test "ORDER BY" error message
DROP INDEX tsts_idx;
CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d);
46 changes: 24 additions & 22 deletions expected/orderby_1.out
Original file line number Diff line number Diff line change
@@ -192,17 +192,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
@@ -254,6 +243,18 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
496 | Sun May 22 11:21:22.326724 2016
(8 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
-- Test index scan
RESET enable_indexscan;
RESET enable_indexonlyscan;
@@ -340,17 +341,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------
@@ -429,6 +419,18 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
458 | Fri May 20 21:21:22.326724 2016
(3 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tsts_idx on tsts
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
-- Test "ORDER BY" error message
DROP INDEX tsts_idx;
CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d);
78 changes: 40 additions & 38 deletions expected/orderby_hash.out
Original file line number Diff line number Diff line change
@@ -192,25 +192,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
@@ -262,6 +243,26 @@ SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
496 | Sun May 22 11:21:22.326724 2016
(8 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

-- Test index scan
RESET enable_indexscan;
RESET enable_indexonlyscan;
@@ -371,25 +372,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
@@ -469,6 +451,26 @@ SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
458 | Fri May 20 21:21:22.326724 2016
(3 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
id | d | ?column?
-----+---------------------------------+-------------
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
(5 rows)

-- Test multicolumn index
RESET enable_indexscan;
RESET enable_indexonlyscan;
46 changes: 24 additions & 22 deletions expected/orderby_hash_1.out
Original file line number Diff line number Diff line change
@@ -192,17 +192,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
(5 rows)

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
@@ -254,6 +243,18 @@ SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
496 | Sun May 22 11:21:22.326724 2016
(8 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
-- Test index scan
RESET enable_indexscan;
RESET enable_indexonlyscan;
@@ -340,17 +341,6 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------
@@ -429,6 +419,18 @@ SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
458 | Fri May 20 21:21:22.326724 2016
(3 rows)

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
QUERY PLAN
-----------------------------------------------------------------------------------
Limit
-> Index Scan using tstsh_idx on tstsh
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
(3 rows)

SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
ERROR: doesn't support order by over pass-by-reference column
-- Test multicolumn index
RESET enable_indexscan;
RESET enable_indexonlyscan;
1 change: 1 addition & 0 deletions expected/rum.out
Original file line number Diff line number Diff line change
@@ -163,6 +163,7 @@ SELECT
rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,4),
*
FROM test_rum
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
distance | rum_ts_distance | t | a
----------+-----------------+---------------------------------------------------------------------+---------------------------------------------------------
1 change: 1 addition & 0 deletions expected/rum_hash.out
Original file line number Diff line number Diff line change
@@ -150,6 +150,7 @@ SELECT
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,6),
*
FROM test_rum_hash
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
distance | rum_ts_distance | rum_ts_score | t | a
----------+-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
12 changes: 12 additions & 0 deletions expected/text.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
* ------------------------------------
* NOTE: This test behaves differenly
* ------------------------------------
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* text.out - test output for PostgreSQL (<18)
* text_1.out - for PostgreSQL (>=18)
*
*/
set enable_seqscan=off;
CREATE TABLE test_text (
i text
337 changes: 337 additions & 0 deletions expected/text_1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
/*
* ------------------------------------
* NOTE: This test behaves differenly
* ------------------------------------
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* text.out - test output for PostgreSQL (<18)
* text_1.out - for PostgreSQL (>=18)
*
*/
set enable_seqscan=off;
CREATE TABLE test_text (
i text
);
INSERT INTO test_text VALUES ('a'),('ab'),('abc'),('abb'),('axy'),('xyz');
CREATE INDEX idx_text ON test_text USING rum (i);
SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
i
-----
a
ab
abb
(3 rows)

SELECT * FROM test_text WHERE i<='abc' ORDER BY i;
i
-----
a
ab
abb
abc
(4 rows)

SELECT * FROM test_text WHERE i='abc' ORDER BY i;
i
-----
abc
(1 row)

SELECT * FROM test_text WHERE i>='abc' ORDER BY i;
i
-----
abc
axy
xyz
(3 rows)

SELECT * FROM test_text WHERE i>'abc' ORDER BY i;
i
-----
axy
xyz
(2 rows)

CREATE TABLE test_text_o AS SELECT id::text, t FROM tsts;
SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
id
-----
135
16
168
232
252
354
355
371
39
(9 rows)

SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
id
-----
406
415
428
457
458
484
496
71
(8 rows)

CREATE INDEX test_text_o_idx ON test_text_o USING rum
(t rum_tsvector_addon_ops, id)
WITH (attach = 'id', to = 't');
RESET enable_indexscan;
RESET enable_indexonlyscan;
SET enable_bitmapscan=OFF;
SET enable_seqscan = off;
EXPLAIN (costs off)
SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
QUERY PLAN
---------------------------------------------------------------------------------
Sort
Sort Key: id
-> Index Scan using test_text_o_idx on test_text_o
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
(4 rows)

SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
id
-----
135
16
168
232
252
354
355
371
39
(9 rows)

EXPLAIN (costs off)
SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
QUERY PLAN
---------------------------------------------------------------------------------
Sort
Sort Key: id
-> Index Scan using test_text_o_idx on test_text_o
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
(4 rows)

SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
id
-----
406
415
428
457
458
484
496
71
(8 rows)

CREATE TABLE test_text_a AS SELECT id::text, t FROM tsts;
-- Should fail, temporarly it isn't allowed to order an index over pass-by-reference column
CREATE INDEX test_text_a_idx ON test_text_a USING rum
(t rum_tsvector_addon_ops, id)
WITH (attach = 'id', to = 't', order_by_attach='t');
ERROR: doesn't support order index over pass-by-reference column
EXPLAIN (costs off)
SELECT count(*) FROM test_text_a WHERE id < '400';
QUERY PLAN
------------------------------------
Aggregate
Disabled Nodes: 1
-> Seq Scan on test_text_a
Disabled Nodes: 1
Filter: (id < '400'::text)
(5 rows)

SELECT count(*) FROM test_text_a WHERE id < '400';
count
-------
337
(1 row)

EXPLAIN (costs off)
SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
QUERY PLAN
-----------------------------------------------------------------------------
Sort
Disabled Nodes: 1
Sort Key: id
-> Seq Scan on test_text_a
Disabled Nodes: 1
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
(6 rows)

SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
id
-----
135
16
168
232
252
354
355
371
39
(9 rows)

EXPLAIN (costs off)
SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
QUERY PLAN
-----------------------------------------------------------------------------
Sort
Disabled Nodes: 1
Sort Key: id
-> Seq Scan on test_text_a
Disabled Nodes: 1
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
(6 rows)

SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
id
-----
406
415
428
457
458
484
496
71
(8 rows)

CREATE TABLE test_text_h_o AS SELECT id::text, t FROM tsts;
CREATE INDEX test_text_h_o_idx ON test_text_h_o USING rum
(t rum_tsvector_hash_addon_ops, id)
WITH (attach = 'id', to = 't');
EXPLAIN (costs off)
SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
QUERY PLAN
---------------------------------------------------------------------------------
Sort
Sort Key: id
-> Index Scan using test_text_h_o_idx on test_text_h_o
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
(4 rows)

SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
id
-----
135
16
168
232
252
354
355
371
39
(9 rows)

EXPLAIN (costs off)
SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
QUERY PLAN
---------------------------------------------------------------------------------
Sort
Sort Key: id
-> Index Scan using test_text_h_o_idx on test_text_h_o
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
(4 rows)

SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
id
-----
406
415
428
457
458
484
496
71
(8 rows)

CREATE TABLE test_text_h_a AS SELECT id::text, t FROM tsts;
-- Should fail, temporarly it isn't allowed to order an index over pass-by-reference column
CREATE INDEX test_text_h_a_idx ON test_text_h_a USING rum
(t rum_tsvector_hash_addon_ops, id)
WITH (attach = 'id', to = 't', order_by_attach='t');
ERROR: doesn't support order index over pass-by-reference column
EXPLAIN (costs off)
SELECT count(*) FROM test_text_h_a WHERE id < '400';
QUERY PLAN
------------------------------------
Aggregate
Disabled Nodes: 1
-> Seq Scan on test_text_h_a
Disabled Nodes: 1
Filter: (id < '400'::text)
(5 rows)

SELECT count(*) FROM test_text_h_a WHERE id < '400';
count
-------
337
(1 row)

EXPLAIN (costs off)
SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
QUERY PLAN
-----------------------------------------------------------------------------
Sort
Disabled Nodes: 1
Sort Key: id
-> Seq Scan on test_text_h_a
Disabled Nodes: 1
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
(6 rows)

SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
id
-----
135
16
168
232
252
354
355
371
39
(9 rows)

EXPLAIN (costs off)
SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
QUERY PLAN
-----------------------------------------------------------------------------
Sort
Disabled Nodes: 1
Sort Key: id
-> Seq Scan on test_text_h_a
Disabled Nodes: 1
Filter: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
(6 rows)

SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
id
-----
406
415
428
457
458
484
496
71
(8 rows)

11 changes: 7 additions & 4 deletions sql/altorder.sql
Original file line number Diff line number Diff line change
@@ -3,12 +3,15 @@
* NOTE: This test behaves differenly
* ------------------------------------
*
* altorder.out - test output for 64-bit systems and
* altorder_1.out - test output for 32-bit systems.
* altorder.out - test output for 64-bit systems
* altorder_1.out - test output for 32-bit systems
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_2.out - test output for 32-bit systems (>=18)
*
*/


CREATE TABLE atsts (id int, t tsvector, d timestamp);

\copy atsts from 'data/tsts.data'
5 changes: 5 additions & 0 deletions sql/altorder_hash.sql
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
* altorder_hash.out - test output for 64-bit systems and
* altorder_hash_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* altorder_hash_2.out - test output for 32-bit systems (>=18)
*
*/


6 changes: 6 additions & 0 deletions sql/array.sql
Original file line number Diff line number Diff line change
@@ -6,6 +6,12 @@
* array.out - test output for 64-bit systems and
* array_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* array_2.out - test output for 64-bit systems (>=18).
* array_3.out - test output for 32-bit systems (>=18).
*
*/


5 changes: 5 additions & 0 deletions sql/int8.sql
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@
* int8.out - test output for 64-bit systems and
* int8_1.out - test output for 32-bit systems.
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* int8_2.out - test output for 32-bit systems (>=18)
*
*/


18 changes: 10 additions & 8 deletions sql/orderby.sql
Original file line number Diff line number Diff line change
@@ -54,17 +54,18 @@ EXPLAIN (costs off)
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

-- Test index scan
RESET enable_indexscan;
RESET enable_indexonlyscan;
@@ -89,10 +90,6 @@ EXPLAIN (costs off)
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
@@ -106,6 +103,11 @@ SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d ASC LIMIT 3;
SELECT id, d FROM tsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d DESC LIMIT 3;

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

-- Test "ORDER BY" error message
DROP INDEX tsts_idx;

18 changes: 10 additions & 8 deletions sql/orderby_hash.sql
Original file line number Diff line number Diff line change
@@ -54,17 +54,18 @@ EXPLAIN (costs off)
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

-- Test index scan
RESET enable_indexscan;
RESET enable_indexonlyscan;
@@ -89,10 +90,6 @@ EXPLAIN (costs off)
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d |=> '2016-05-16 14:21:25' FROM tstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

EXPLAIN (costs off)
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
@@ -106,6 +103,11 @@ SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d ASC LIMIT 3;
SELECT id, d FROM tstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d DESC LIMIT 3;

RESET enable_indexscan;
EXPLAIN (costs off)
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM tstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;

-- Test multicolumn index

RESET enable_indexscan;
1 change: 1 addition & 0 deletions sql/rum.sql
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ SELECT
rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,4),
*
FROM test_rum
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;

-- Check ranking normalization
1 change: 1 addition & 0 deletions sql/rum_hash.sql
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ SELECT
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,6),
*
FROM test_rum_hash
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;

-- Check ranking normalization
12 changes: 12 additions & 0 deletions sql/text.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
* ------------------------------------
* NOTE: This test behaves differenly
* ------------------------------------
*
* Since c01743aa486 (>=18) EXPLAIN output was changed,
* now it includes the number of disabled nodes
*
* text.out - test output for PostgreSQL (<18)
* text_1.out - for PostgreSQL (>=18)
*
*/
set enable_seqscan=off;

CREATE TABLE test_text (