GSets: Getting collation related error when GSets has text column - Mailing list pgsql-hackers

From Jeevan Chalke
Subject GSets: Getting collation related error when GSets has text column
Date
Msg-id CAM2+6=W=9=hQOipH0HAPbkun3Z3TFWij_EiHue0_6UX=oR=1kw@mail.gmail.com
Whole thread Raw
Responses Re: GSets: Getting collation related error when GSets has text column  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Re: GSets: Getting collation related error when GSets has text column  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

When we have text column in the GROUPING SETS (and with some specific
order of columns), we are getting error saying
"could not determine which collation to use for string comparison"

Here is the example:

postgres=# select sum(ten) from onek group by rollup(four::text), two
order by 1;
ERROR:  could not determine which collation to use for string comparison
HINT:  Use the COLLATE clause to set the collation explicitly.

However if we have sql like;
select sum(ten) from onek group by two, rollup(four::text)
order by 1;

It is not failing.

After spending enough time, If I understood the code correctly, we are
re-ordering the sort columns but we are not remapping the grpColIdx
correctly.

Attached patch which attempts to fix this issue. However I am not sure
whether it is correct. But it does not add any new issues as such.
Added few test in the patch as well.

Please have a look.

Thanks

--
Jeevan B Chalke
Principal Software Engineer, Product Development
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [PATCH] Function to get size of asynchronous notification queue
Next
From: Fabien
Date:
Subject: pgbench stats per script & other stuff