Re: Fix assert failure in composite type dependency check for index expr

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, hlinnaka(at)iki(dot)fi
Subject: Re: Fix assert failure in composite type dependency check for index expr
Date: 2026-11-26 15:22:21
Message-ID: 606cbb79-3a90-4ae4-93ef-d8acb58b394b@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Nov26, 2026 at 11:06 AM Chao Li wrote:
> 1
> ```
> + if (expr == NULL)
> + return false;
> ```
>
> Is this NULL check really needed? As far as I can see, no current caller
> passes NULL. Also, semantically, this function is intended to check type
> dependencies in an expression, so it doesn't seem reasonable to pass NULL as
> the expression. Maybe we can just use Assert(expr != NULL) instead.

Thanks for the comments.

I perfer to keep "if (expr == NULL) return false;" to be consistent with
the sibling functions in dependency.c like recordDependencyOnSingleRelExpr()
and CheckUsageOnTypesInSingleRelExpr().

> 2
> In the preceding if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
> branch, since this patch adds the exprType() check to
> CheckTypeDependencyInSingleRelExpr(), the first check becomes redundant.
> Maybe we can remove it and merge the two comments.

Agreed. Since CheckTypeDependencyInSingleRelExpr() also accepts a
List directly, we can drop the foreach loop over partexprs as well and
pass the expression list in one call, matching indexprs below it. Done
in the attached v2.
--
Best Regards,
Zhijie Hou

Attachment Content-Type Size
v2-0001-Fix-composite-type-dependency-check-for-index-exp.patch text/plain 10.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-11-26 15:29:44 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Shuntian Jiao 2026-11-26 15:15:25 Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773