Eval expression R/O once time (src/backend/executor/execExpr.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Eval expression R/O once time (src/backend/executor/execExpr.c)
Date: 2021-09-21 18:09:11
Message-ID: CAEudQAqXuhbkaAp-sGH6dR6Nsq7v28_0TPexHOm6FiDYqwQD-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Currently when determining where CoerceToDomainValue can be read,
it evaluates every step in a loop.
But, I think that the expression is immutable and should be solved only
once.

Otherwise the logic is wrong since by the rules of C, even though the
variable is
being initialized in the declaration, it still receives initialization at
each repetition.
What causes palloc running multiple times.

In other words:
Datum *domainval = NULL;

is the same:
Datum *domainval;
domainval = NULL;

Once there, reduce the scope for save_innermost_domainval and
save_innermost_domainnull.

Thoughts?

regards,
Ranier Vilela

Attachment Content-Type Size
fix_eval_expr_once.patch application/octet-stream 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-09-21 19:30:35 windows build slow due to windows.h includes
Previous Message vignesh C 2021-09-21 18:08:52 Re: Added schema level support for publication.