Weird "could not determine which collation to use for string comparison" with LEAST/GREATEST on PG11 procedure

From: "Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com>
To: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Weird "could not determine which collation to use for string comparison" with LEAST/GREATEST on PG11 procedure
Date: 2018-11-21 14:09:55
Message-ID: 1EC8157EB499BF459A516ADCF135ADCE39FFAC54@LON-WGMSX712.ad.moodys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-sql

Hello,

When I run the following script on a PG 11 psql:

select version();
show lc_collate;
create or replace function same_values_func(a text, b text) returns void as $body$
begin
assert a = b;
end;$body$ language plpgsql;
select same_values_func(least('a','b'),'a');
create or replace procedure same_values_proc(a text, b text) as $body$
begin
assert a = b;
end;$body$ language plpgsql;
call same_values_proc(least('a','b'),'a');

I get the following output and error at the end:

SIMPLE=> select version();
version
--------------------------------------------------------------------------------------------------------
PostgreSQL 11.0 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit
(1 row)

SIMPLE=>
SIMPLE=> show lc_collate;
lc_collate
------------
C
(1 row)

SIMPLE=>
SIMPLE=> create or replace function same_values_func(a text, b text) returns void as $body$
SIMPLE$> begin
SIMPLE$> assert a = b;
SIMPLE$> end;$body$ language plpgsql;
CREATE FUNCTION
SIMPLE=>
SIMPLE=> select same_values_func(least('a','b'),'a');
same_values_func
------------------

(1 row)

SIMPLE=>
SIMPLE=> create or replace procedure same_values_proc(a text, b text) as $body$
SIMPLE$> begin
SIMPLE$> assert a = b;
SIMPLE$> end;$body$ language plpgsql;
CREATE PROCEDURE
SIMPLE=>
SIMPLE=> call same_values_proc(least('a','b'),'a');
ERROR: could not determine which collation to use for string comparison
HINT: Use the COLLATE clause to set the collation explicitly.
SIMPLE=>

I tried to convert all void functions we have on a PG10 DB to procedures and I get this strange error.
The same error occurs with GREATEST.
Any idea?
Regards.

-----------------------------------------

Moody's monitors email communications through its networks for regulatory compliance purposes and to protect its customers, employees and business and where allowed to do so by applicable law. The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

This email was sent to you by Moody’s Investors Service EMEA Limited
Registered office address:
One Canada Square
Canary Wharf
London, E14 5FA
Registered in England and Wales No: 8922701

-----------------------------------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-11-21 18:19:20 Re: Weird "could not determine which collation to use for string comparison" with LEAST/GREATEST on PG11 procedure
Previous Message PG Bug reporting form 2018-11-21 13:21:33 BUG #15515: DatabaseMetadata.getProcedures and getFunctions return objects of either type

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2018-11-21 18:19:20 Re: Weird "could not determine which collation to use for string comparison" with LEAST/GREATEST on PG11 procedure
Previous Message Andreas Joseph Krogh 2018-11-19 16:49:22 Sv: Sv: Re: Difficulties with LAG-function when calculating overtime