RE: Skipping NULL keys when uniqueifying a semijoin's RHS

From: William Bernbaum <wbernbaum(at)dwdev(dot)com>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: "guofenglinux(at)gmail(dot)com" <guofenglinux(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: Skipping NULL keys when uniqueifying a semijoin's RHS
Date: 2026-08-31 09:45:46
Message-ID: PH0PR18MB4443D4EB1C4166BDB91D1366A6A92@PH0PR18MB4443.namprd18.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Ilmari,

Thanks for the review - v2 attached.

> [use foreach_node for the loop over join_info_list]

Done.

> [and for the loop over semi_rhs_exprs]

This one I couldn't take as written, so I used foreach_ptr
instead.

Two further changes:

First, I dropped this guard:

/* Nothing reads the whole RHS unless it can be unique-ified */
if (!sjinfo->semi_can_btree && !sjinfo->semi_can_hash)
continue;

The check was unreachable. compute_semijoin_info() assigns
sjinfo->semi_rhs_exprs only after it has already returned early on
!(all_btree || all_hash), so semi_rhs_exprs is NIL whenever both flags
are false.

Second, I added a strictness check:

/* A non-strict operator can match a NULL key */
if (!op_strict(opno))
continue;

compute_semijoin_info() requires each operator to be hashjoinable or
mergejoinable, but nothing requires it to be strict.

Thanks,
Will

Attachment Content-Type Size
v2-0001-Skipping-NULL-keys-when-uniqueifying-a-semijoin-s.patch application/octet-stream 18.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ewan Young 2026-08-31 09:46:22 Re: Use pg_neg_s*_overflow() for open-coded negation overflow checks
Previous Message shveta malik 2026-08-31 09:40:28 Re: [PATCH] Release replication slot on error in SQL-callable slot functions