Re: Programmatic access to interval units - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Programmatic access to interval units
Date
Msg-id CAHyXU0y=bg-+PHVK6nFmGCAzj9D_Aw2Y3Gz9KeHwmeNejfo9vg@mail.gmail.com
Whole thread Raw
In response to Programmatic access to interval units  (Nelson Green <nelsongreen84@gmail.com>)
Responses Re: Programmatic access to interval units
List pgsql-general
On Mon, Dec 1, 2014 at 10:42 AM, Nelson Green <nelsongreen84@gmail.com> wrote:
> Good morning list,
>
> According to the documentation for interval data type inputs, the unit can
> be one of microsecond, millisecond, second, minute, hour, day, week, month,
> year, decade, century, or millennium. Are these units stored in a catalog
> somewhere? I would like to access them programmatically if possible, to
> validate input for a function I am developing.

if you're writing C, you can use libpqtypes to do this. It exposes the
interval as a C structure.

typedef struct
{
        int years;
        int mons;
        int days;
        int hours;
        int mins;
        int secs;
        int usecs;
} PGinterval;


merlin


pgsql-general by date:

Previous
From: Andres Freund
Date:
Subject: Re: recovering from "too many failures" wal error
Next
From: Bryn Jeffries
Date:
Subject: Irreversible SET ROLE