Re: BUG #19412: Wrong query result with not null constraint

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: BUG #19412: Wrong query result with not null constraint
Дата
Msg-id CAMbWs49NVUNpQPwGb56SCSQL-bkjtxnkCb6Ot7dBxGndJoA3Pw@mail.gmail.com
обсуждение
Ответ на Re: BUG #19412: Wrong query result with not null constraint  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: BUG #19412: Wrong query result with not null constraint
Re: BUG #19412: Wrong query result with not null constraint
Список pgsql-bugs
On Wed, Feb 18, 2026 at 10:51 AM Richard Guo <guofenglinux@gmail.com> wrote:
> Exactly.  I think this is because when adjust_appendrel_attrs_mutator
> propagates the nullingrel bits from the parent rel's Var into the
> translated Var, it loses the translated Var's original bits.  Instead
> of overwriting the translated Var's nullingrels, I think we should
> merge them.
>
> --- a/src/backend/optimizer/util/appendinfo.c
> +++ b/src/backend/optimizer/util/appendinfo.c
> @@ -291,8 +291,11 @@ adjust_appendrel_attrs_mutator(Node *node,
>                  var->varattno, get_rel_name(appinfo->parent_reloid));
>         if (IsA(newnode, Var))
>         {
> -           ((Var *) newnode)->varreturningtype = var->varreturningtype;
> -           ((Var *) newnode)->varnullingrels = var->varnullingrels;
> +           Var    *newvar = (Var *) newnode;
> +
> +           newvar->varreturningtype = var->varreturningtype;
> +           newvar->varnullingrels = bms_add_members(newvar->varnullingrels,
> +                                                    var->varnullingrels);
>         }

Here is a more readable version of the patch.

- Richard

Вложения

В списке pgsql-bugs по дате отправления: