pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Guillaume Lelarge <guillaume@lelarge.info>
Cc: PostgreSQL General <pgsql-general@postgresql.org>
Subject: Re: Weird behaviour of ROLLUP/GROUPING
Date: Wed, 16 Jan 2019 16:40:49 +0000
Message-ID: <87r2dck1dn.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <874la8lhvp.fsf@news-spur.riddles.org.uk>
References: <CAECtzeVSO_US8C2Khgfv54ZMUOBR4sWq+6_bLrETnWExHT=rFg@mail.gmail.com>
	<874la8lhvp.fsf@news-spur.riddles.org.uk>

>>>>> "Andrew" == Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
>>>>> "Guillaume" == Guillaume Lelarge <guillaume@lelarge.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.

-- 
Andrew (irc:RhodiumToad)




view thread (7+ messages)  latest in thread

Message-ID: <87r2dck1dn.fsf@news-spur.riddles.org.uk>
Permalink:  ../87r2dck1dn.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87r2dck1dn.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, guillaume@lelarge.info
  Subject: Re: Weird behaviour of ROLLUP/GROUPING
  In-Reply-To: <87r2dck1dn.fsf@news-spur.riddles.org.uk>
  References: <CAECtzeVSO_US8C2Khgfv54ZMUOBR4sWq+6_bLrETnWExHT=rFg@mail.gmail.com> <874la8lhvp.fsf@news-spur.riddles.org.uk> <87r2dck1dn.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox