Re: MERGE ... WHEN NOT MATCHED BY SOURCE

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: MERGE ... WHEN NOT MATCHED BY SOURCE
Дата
Msg-id CAEZATCUR39xOOj5kj6nq4+Jj4N=q0bydHKaj_=aN0ACKpaiatA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: MERGE ... WHEN NOT MATCHED BY SOURCE  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Ответы Re: MERGE ... WHEN NOT MATCHED BY SOURCE  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
On Tue, 21 Mar 2023 at 10:28, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>
> > +                     /* Combine it with the action's WHEN condition */
> > +                     if (action->qual == NULL)
> > +                             action->qual = (Node *) ntest;
> > +                     else
> > +                             action->qual =
> > +                                     (Node *) makeBoolExpr(AND_EXPR,
> > +                                                                               list_make2(ntest, action->qual),
> > +                                                                               -1);
>
> Hmm, I think ->qual is already in implicit-and form, so do you really
> need to makeBoolExpr, or would it be sufficient to append this new
> condition to the list?
>

No, this has come directly from transformWhereClause() in the parser,
so it's an expression tree, not a list. Transforming to implicit-and
form doesn't happen until later.

Looking at it with fresh eyes though, I realise that I could have just written

    action->qual = make_and_qual((Node *) ntest, action->qual);

which is equivalent, but more concise.

Regards,
Dean



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

Предыдущее
От: Önder Kalacı
Дата:
Сообщение: Re: Dropped and generated columns might cause wrong data on subs when REPLICA IDENTITY FULL
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: MERGE ... WHEN NOT MATCHED BY SOURCE