Re: Assignment before assert

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Assignment before assert
Date: 2025-02-14 05:44:40
Message-ID: Z67YSMqd2dsJz5Sd@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 14, 2025 at 12:15:40AM +0100, Daniel Gustafsson wrote:
> > On 13 Feb 2025, at 18:08, Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru> wrote:
> >
> > Hi!
> > Function EvalPlanQualFetchRowMark contains an assignment
> >
> > ExecRowMark *erm = earm->rowmark;
> >
> > before assert
> >
> > Assert(earm != NULL);
> >
> > Maybe these lines need to be swapped?
>
> That does admittedly look a bit odd, that assertion can't be reached if earm is
> null since we've already dereferenced it by then. I'll have another look after
> coffee but something along the lines of your patch looks right (or just remove
> the Assertion perhaps).

Accessing earm->rowmark is one thing, assuming that earm should never
be NULL is a different one. Looking at 27cc7cd2bc8a that has
introduced this assertion, the proposed patch makes sense to me.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2025-02-14 05:53:01 Re: Is pgAdmin the only front-end to PostgreSQL debugger ? And is "a working pl/pgsql debugger" something core should care to maintain ?
Previous Message Shubham Khanna 2025-02-14 05:20:41 Re: Adding a '--clean-publisher-objects' option to 'pg_createsubscriber' utility.