Proposal: per expression intervalstyle

From: Michał Wadas <michalwadas(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Proposal: per expression intervalstyle
Date: 2021-05-05 15:06:44
Message-ID: CAMEnU0AxdkgxOsP_b8uFy5ArxHWPHi72TuNCgv945i4qbgUv7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Problem: I have to set IntervalStyle in separate statement to convert
interval type to ISO8601 string.

This isn't well supported by ORMs or similar tools, requiring us to
set it globally (per role or per database).

Problem #2 (exotic): you can't mix two output styles in a single query.

Proposed solution: special case to_char function to accept values accepted
by
SET intervalstyle to 'XYZ'

So:

SELECT to_char(INTERVAL '8 minutes', 'iso_8601')

will act similar to

SET intervalstyle TO 'iso_8601';
SELECT (INTERVAL '8 minutes')::text
RESET interval_style;

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2021-05-05 15:15:53 Re: Is txid_status() actually safe? / What is 011_crash_recovery.pl testing?
Previous Message Robert Haas 2021-05-05 15:04:11 pg_receivewal makes a bad daemon