From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: dusan.djuric@istratech.hr
Subject: BUG #16977: SET LC_TIME TO local_variable don't work
Date: Thu, 22 Apr 2021 13:12:16 +0000
Message-ID: <16977-913c4d7548c2e568@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16977
Logged by: Dusan Djuric
Email address: dusan.djuric@istratech.hr
PostgreSQL version: 13.2
Operating system: Windows 10
Description:
-- THIS DON'T WORK!
CREATE OR REPLACE FUNCTION lctest(p_parameter varchar)
RETURNS varchar
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
l_lc_time varchar;
l_dateFormat varchar := 'TMDay, TMMonth dd.mm.yyyy';
l_current_date varchar;
BEGIN
l_lc_time := p_parameter;
SET LC_TIME TO l_lc_time;
select to_char(current_date, l_dateFormat)
into l_current_date;
RETURN l_current_date;
END;
$BODY$;
-- THIS WORKS!
CREATE OR REPLACE FUNCTION lctest(p_parameter varchar)
RETURNS varchar
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
l_lc_time varchar;
l_dateFormat varchar := 'TMDay, TMMonth dd.mm.yyyy';
l_current_date varchar;
BEGIN
l_lc_time := p_parameter;
SET LC_TIME TO l_lc_time;
IF l_lc_time = 'hr_HR.UTF8' THEN
SET LC_TIME TO 'hr_HR.UTF8';
END IF;
IF l_lc_time = 'en_EN.UTF8' THEN
SET LC_TIME TO 'en_EN.UTF8';
END IF;
select to_char(current_date, l_dateFormat)
into l_current_date;
RETURN l_current_date;
END;
$BODY$;
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, dusan.djuric@istratech.hr
Subject: Re: BUG #16977: SET LC_TIME TO local_variable don't work
In-Reply-To: <16977-913c4d7548c2e568@postgresql.org>
* 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