Re: Weird behaviour of ROLLUP/GROUPING

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Weird behaviour of ROLLUP/GROUPING
Date: 2019-01-16 17:05:39
Message-ID: CAECtzeWeLfm3_VOg5RzNVAgh5Zs051qrkoOmMZTk65cS_tZ8PA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le mer. 16 janv. 2019 à 17:40, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
a écrit :

> >>>>> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> >>>>> "Guillaume" == Guillaume Lelarge <guillaume(at)lelarge(dot)info> writes:
>
> Guillaume> CASE grouping(to_char(b, 'MMYYYY'))
>
> Guillaume> ERROR: arguments to GROUPING must be grouping expressions of
> the
> Guillaume> associated query level
> Guillaume> LINE 3: CASE grouping(to_char(b, 'MMYYYY')) WHEN 1 THEN 'some
> date' ...
>
> Guillaume> AFAICT, both queries should behave the same, though their
> Guillaume> actual behaviours are quite opposite. Working fine for the
> Guillaume> first, erroring out on the second.
>
> Guillaume> Does anyone has any idea what's going on here?
>
> Andrew> Not yet. But I will find out, since it seems to be a bug.
>
> It is definitely a bug, to do with assignment of collations. It
> specifically happens when you use GROUPING which contains any
> subexpression of a collatable type, inside a CASE expr WHEN clause,
> since that assigns collations to the expression much earlier in parsing
> than the rest of the query, so the code that validates GROUPING ends up
> trying to compare an expression which has had collations assigned to it
> to one which has not, and so it thinks they differ.
>
> I will see about fixing this, somehow.
>
>
Thanks a lot.

--
Guillaume.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Patterson 2019-01-16 22:08:35 Varlena with recursive data structures?
Previous Message Andrew Gierth 2019-01-16 16:40:49 Re: Weird behaviour of ROLLUP/GROUPING