Proposal: per expression intervalstyle - Mailing list pgsql-hackers

From Michał Wadas
Subject Proposal: per expression intervalstyle
Date
Msg-id CAMEnU0AxdkgxOsP_b8uFy5ArxHWPHi72TuNCgv945i4qbgUv7g@mail.gmail.com
Whole thread Raw
List 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;



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: pg_receivewal makes a bad daemon
Next
From: Craig Ringer
Date:
Subject: Re: Is txid_status() actually safe? / What is 011_crash_recovery.pl testing?