BUG #8135: current_setting('DateStyle'); does not reflect User setting

From: frank(at)heuveltop(dot)nl
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8135: current_setting('DateStyle'); does not reflect User setting
Date: 2013-05-05 18:18:02
Message-ID: E1UZ3Va-0003QK-KE@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8135
Logged by: Frank van den Heuvel
Email address: frank(at)heuveltop(dot)nl
PostgreSQL version: 9.1.8
Operating system: Ubuntu 12.04
Description:

Dear developers,

I think I have found a bug. I am building an application that relies on user
setting of TimeZone and DateStyle.

After
ALTER ROLE frank SET TimeZone = 'Europe/Amsterdam';

Where the TimeZone differs from the default timezone.

SELECT current_setting('TimeZone');

Gives the correct answer.

But this same doesn't work for DateStyle

ALTER ROLE frank SET DateStyle = 'SQL, DMY';

Where the DateStyle differs from the default DateStyle

SELECT current_setting('DateStyle');

Gives the system/database setting but not the user setting; while the
setting does have its effect on the output of date's and timestamps. This
might also effect other user settings, but I haven't found any yet.

My application needs to know what the user setting is, so this is a
workaround that I use:

WITH user_config AS (
SELECT rolname, split_part(unnest(rolconfig), '=', 1) AS key,
split_part(unnest(rolconfig), '=', 2) AS value
FROM pg_roles )

SELECT *
FROM user_config
WHERE rolname = USER
AND key ILIKE 'DateStyle';

Thank you for reading,

Frank

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marti Raudsepp 2013-05-05 20:01:50 Re: stable vs. immutable unaccent function
Previous Message Thangalin 2013-05-05 02:05:04 stable vs. immutable unaccent function