Re: Fix a wrong comment in setrefs.c

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: Fix a wrong comment in setrefs.c
Дата
Msg-id CAMbWs498LZVXh1UkAET3Cd+w58QRv8TEqSer6YwqxUcWbnJznA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Fix a wrong comment in setrefs.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Fix a wrong comment in setrefs.c  (shihao zhong <zhong950419@gmail.com>)
Re: Fix a wrong comment in setrefs.c  (Richard Guo <guofenglinux@gmail.com>)
Список pgsql-hackers

On Tue, Sep 26, 2023 at 5:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Hmm.  This kind of makes me itch, because in principle a ressortgroupref
identifier should uniquely identify a sorting/grouping column.  If it
fails to do so here, maybe there are outright bugs lurking elsewhere?

I poked into it a little and determined that the problematic
ressortgroupref values are being assigned during prepunion.c,
which says

         * By convention, all non-resjunk columns in a setop tree have
         * ressortgroupref equal to their resno.  In some cases the ref isn't
         * needed, but this is a cleaner way than modifying the tlist later.

So at the end of that, we can have Vars in the upper relations'
targetlists that are associated by ressortgroupref with values
in the setop input relations' tlists, but don't match.
(You are right that added-on implicit coercions are one reason for
the expressions to be different, but it's not the only one.)

Ah.  Thanks for the investigation.
 
I'm inclined to write the comment more like "Usually the equal()
check is redundant, but in setop plans it may not be, since
prepunion.c assigns ressortgroupref equal to the column resno
without regard to whether that matches the topmost level's
sortgrouprefs and without regard to whether any implicit coercions
are added in the setop tree.  We might have to clean that up someday;
but for now, just ignore any false matches."

+1.  It explains the situation much more clearly and accurately.

Thanks
Richard

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

Предыдущее
От: Japin Li
Дата:
Сообщение: Re: How to update unicode mapping table?
Следующее
От: Japin Li
Дата:
Сообщение: Could not run generate_unaccent_rules.py script when update unicode