Re: BUG #18589: pg_get_viewdef returns wrong query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: tlhquynh(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18589: pg_get_viewdef returns wrong query
Date: 2024-08-27 14:42:33
Message-ID: 3094457.1724769753@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Richard Guo <guofenglinux(at)gmail(dot)com> writes:
> On Tue, Aug 27, 2024 at 1:11 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> The other debatable point in the patch is
>> how to tell get_variable that we're considering an ORDER BY item.

> It seems to me that this might result in different behavior from
> previous when deparsing Vars in a GROUP BY list, due to overriding
> special_exprkind from EXPR_KIND_GROUP_BY to EXPR_KIND_ORDER_BY.

Yeah, I was uncertain whether to bother with that detail. It's true
that there's no bug in GROUP BY because the parser prefers SQL99
semantics in that case, but maybe we shouldn't have this code assuming
that? And it wasn't easy to do with the special_exprkind approach.
But it is pretty easy with the two-bools approach, so I fixed that in
the attached v2.

regards, tom lane

Attachment Content-Type Size
bug-18589-better-fix-2.patch text/x-diff 14.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Weslley Braga 2024-08-27 17:20:03 Re: Postgres v16.4 crashes on segfault when memory >= 16gb
Previous Message Tom Lane 2024-08-27 13:23:08 Re: BUG #18589: pg_get_viewdef returns wrong query