#6417·paradedb

`pdb.score()` fails with `Unsupported query shape` when Postgres removes a redundant search predicate

Author: mdashtiCreated Sep 19, 2026Updated Sep 29, 2026
Labelsbugpriority-lowuser-request

What happens?

When the only search predicate is redundant inside an OR, pdb.score() and pdb.snippet() fail with Unsupported query shape, even though the query has === or @@@.

Postgres reduces A OR (A AND B) to A, because both return the same rows (process_duplicate_ors() in prepqual.c). This happens before the base scan plans the query. If B is the only search predicate, no ParadeDB scan is planned, and pdb.score() runs outside one. Without pdb.score(), the same query returns the correct rows.

This is close to #4767, where the query has no search predicate at all. But here the user did write one, so a "no search predicate" message would confuse them. We could keep the removed predicate for scoring, or say in the error that Postgres removed it as redundant.

Found while looking at #6415.

To Reproduce

sql
CREATE EXTENSION IF NOT EXISTS pg_search CASCADE;
CREATE TABLE t (id SERIAL8 PRIMARY KEY, uuid UUID, name TEXT);
INSERT INTO t (uuid, name)
SELECT '550e8400-e29b-41d4-a716-446655440000', (ARRAY['alice', 'bob', 'cloe'])[1 + i % 3]
FROM generate_series(1, 100) i;
CREATE INDEX t_idx ON t USING paradedb (id, uuid, (name::pdb.literal));

-- Works.
SELECT id, pdb.score(id) FROM t
WHERE uuid = '550e8400-e29b-41d4-a716-446655440000' AND name === 'bob'
ORDER BY id LIMIT 3;

-- ERROR:  Unsupported query shape. Please report at https://github.com/paradedb/paradedb/issues/new/choose
SELECT id, pdb.score(id) FROM t
WHERE uuid = '550e8400-e29b-41d4-a716-446655440000'
   OR (uuid = '550e8400-e29b-41d4-a716-446655440000' AND name === 'bob')
ORDER BY id LIMIT 3;

The plan of the second query has no ParadeDB scan, and only the uuid clause is left:

 Limit
   ->  Sort
         Sort Key: id
         ->  Seq Scan on t
               Filter: (uuid = '550e8400-e29b-41d4-a716-446655440000'::uuid)

@@@ instead of ===, and pdb.snippet(name) instead of pdb.score(id), fail the same way. Seen on PG 15 and PG 18 debug builds.