Re: Creating redwood datestyle in Postgres 12

From: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Tim <timfosho(at)gmail(dot)com>, Paul Smith <paul(at)pscs(dot)co(dot)uk>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Creating redwood datestyle in Postgres 12
Date: 2021-03-26 15:27:22
Message-ID: CADUqk8VNBpJ8RF5U5KfqErd7QwpaJjKS4KJPQU9vF53gCUz8QA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, Mar 26, 2021 at 9:42 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > On Fri, Mar 26, 2021 at 08:24:37AM -0400, Tim wrote:
> >> I suppose that would be possible, but maintaining date triggers + views
> across
> >> a large database would be a lot of work. I'm just one humble DBA and
> there is
> >> 15-20 devs
>
> > You probably need a custom data type with a custom C output function do
> > to this efficiently.
>
> If you're willing to write C code it likely wouldn't be that hard
> to modify datetime output to honor a new datestyle value. (Input
> is messier, but since we already read this format okay, I don't
> think anything is needed on that end.)
>
> It would seem reasonable to me to have a datestyle that emits
> the month as a 3-letter abbreviation, so that you could get
> '2021-Mar-26' or '26-Mar-2021' etc depending on the YMD/DMY/MDY
> setting. I'd draw the line at emitting 2-digit years though.
> (If you need to be that bug-compatible with Oracle, you should
> stick with EDB --- that's what their AS product is for.)
>

IIRC, in 2005-2008, the Oracle-style date/time format code was < 50 LoC
total as PG already supports almost everything needed. After a cursory look
through those parts of the PG code, I'd guess this is still < 100 LoC
fully-functional. But, for the reasons Tom said, this is something that
wouldn't make it into community PG. Of all the EDB features, this is the
easiest to implement if you were OK running a patched version. I'm sure
several consultants on here would write you a patch fairly quickly for a
fee.

--
Jonah H. Harris

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message legrand legrand 2021-03-26 16:55:12 Re: Creating redwood datestyle in Postgres 12
Previous Message Tom Lane 2021-03-26 13:42:28 Re: Creating redwood datestyle in Postgres 12