From 04e0aee0ab7cc6b05afed3fa8479d168225918bb Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 20 Mar 2026 11:36:11 -0400 Subject: [PATCH v1 3/3] Add a test for creating an index on a whole-row expression. Surprisingly, we have no existing test for this. Had this test been present before commit 0000000000000000000000000000000000000000, the Assert added in commit 0000000000000000000000000000000000000000 would have caught the bug. !!! Update this with the final commit hashes. --- src/test/regress/expected/indexing.out | 11 +++++++++++ src/test/regress/sql/indexing.sql | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/test/regress/expected/indexing.out b/src/test/regress/expected/indexing.out index dc629928c8f..f50868ca6a6 100644 --- a/src/test/regress/expected/indexing.out +++ b/src/test/regress/expected/indexing.out @@ -1669,3 +1669,14 @@ reindex index test_pg_index_toast_index; drop index test_pg_index_toast_index; drop function test_pg_index_toast_func; drop table test_pg_index_toast_table; +-- test creation of an index involving a whole-row expression +create table test_pg_wholerow_index (a int, b text, c numeric); +create or replace function row_image(test_pg_wholerow_index) + returns test_pg_wholerow_index as $$select $1$$ language sql immutable; +insert into test_pg_wholerow_index values (1, 'multiplication', 1.0); +create index row_image_index + on test_pg_wholerow_index ((row_image(test_pg_wholerow_index))); +insert into test_pg_wholerow_index values (2, 'addition', 0); +drop index row_image_index; +drop function row_image(test_pg_wholerow_index); +drop table test_pg_wholerow_index; diff --git a/src/test/regress/sql/indexing.sql b/src/test/regress/sql/indexing.sql index b5cb01c2d70..129130d04d4 100644 --- a/src/test/regress/sql/indexing.sql +++ b/src/test/regress/sql/indexing.sql @@ -934,3 +934,15 @@ reindex index test_pg_index_toast_index; drop index test_pg_index_toast_index; drop function test_pg_index_toast_func; drop table test_pg_index_toast_table; + +-- test creation of an index involving a whole-row expression +create table test_pg_wholerow_index (a int, b text, c numeric); +create or replace function row_image(test_pg_wholerow_index) + returns test_pg_wholerow_index as $$select $1$$ language sql immutable; +insert into test_pg_wholerow_index values (1, 'multiplication', 1.0); +create index row_image_index + on test_pg_wholerow_index ((row_image(test_pg_wholerow_index))); +insert into test_pg_wholerow_index values (2, 'addition', 0); +drop index row_image_index; +drop function row_image(test_pg_wholerow_index); +drop table test_pg_wholerow_index; -- 2.51.0