From 53948ec2d38ad609e868511da9f59d7605242b93 Mon Sep 17 00:00:00 2001 From: Arseny Kositsin Date: Thu, 24 Oct 2024 16:30:08 +0300 Subject: [PATCH 1/2] [PGPRO-11393] Fixed the content of the error message If the "RUM" index was created without the "WITH" operator, when "SELECT...ORDER BY" an error message of the form would appear: "ERROR: cannot order without attribute ... in WHERE clause" Fixed the content of error message, "WHERE" replaced by "ORDER BY". Tags: rum --- src/rumscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rumscan.c b/src/rumscan.c index 42bca53822..c7a523df55 100644 --- a/src/rumscan.c +++ b/src/rumscan.c @@ -214,7 +214,7 @@ rumFillScanKey(RumScanOpaque so, OffsetNumber attnum, } if (scanKey == NULL) - elog(ERROR, "cannot order without attribute %d in WHERE clause", + elog(ERROR, "cannot order without attribute %d in ORDER BY clause", key->attnum); else if (scanKey->nentries > 1) elog(ERROR, "scan key should contain only one value"); From 6fecdf76d1ffc29d127c955c2c99df1731c0c0b7 Mon Sep 17 00:00:00 2001 From: Arseny Kositsin Date: Wed, 6 Nov 2024 17:28:51 +0300 Subject: [PATCH 2/2] [PGPRO-11393] Added test for "ORDER BY" error message If the "rum" index is created without the "WITH" operator, two columns must be specified for "ORDER BY" to work. Added a test that checks for an error message if only one column is specified in the "ORDER BY". Tags: rum --- expected/orderby.out | 5 +++++ sql/orderby.sql | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/expected/orderby.out b/expected/orderby.out index 9bc421970c..0f8a5454ef 100644 --- a/expected/orderby.out +++ b/expected/orderby.out @@ -460,6 +460,11 @@ 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) +-- Test "ORDER BY" error message +DROP INDEX tsts_idx; +CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d); +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: cannot order without attribute 2 in ORDER BY clause -- Test multicolumn index RESET enable_indexscan; RESET enable_indexonlyscan; diff --git a/sql/orderby.sql b/sql/orderby.sql index 28e5b6038b..4c2689d193 100644 --- a/sql/orderby.sql +++ b/sql/orderby.sql @@ -95,6 +95,13 @@ 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; +-- Test "ORDER BY" error message +DROP INDEX tsts_idx; + +CREATE INDEX tsts_idx ON tsts USING rum (t rum_tsvector_addon_ops, d); + +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; + -- Test multicolumn index RESET enable_indexscan;