Re: [HACKERS] storing TZ along timestamps

2011-07-26 Thread Jim Nasby
On Jul 26, 2011, at 5:56 PM, Christopher Browne wrote: >> I'm assuming that the issue here is that multiple backends could be >> connected to the same database, and we don't want all of them to try to >> actually do the updates, only the first one that discovers the change. If >> that's the prob

Re: [HACKERS] storing TZ along timestamps

2011-07-26 Thread Christopher Browne
On Tue, Jul 26, 2011 at 6:45 PM, Jim Nasby wrote: > On Jul 25, 2011, at 6:22 PM, Robert Haas wrote: >> On Mon, Jul 25, 2011 at 6:26 PM, Jim Nasby wrote: >>> Hrm, don't we only pull in ZIC info on a reload? Or do we actually refer to >>> it dynamically all the time? Perhaps we can enforce that we

Re: [HACKERS] storing TZ along timestamps

2011-07-26 Thread Jim Nasby
On Jul 25, 2011, at 6:22 PM, Robert Haas wrote: > On Mon, Jul 25, 2011 at 6:26 PM, Jim Nasby wrote: >> Hrm, don't we only pull in ZIC info on a reload? Or do we actually refer to >> it dynamically all the time? Perhaps we can enforce that we'll only >> recognize new TZ info as part of a config r

Re: [HACKERS] storing TZ along timestamps

2011-07-25 Thread Robert Haas
On Mon, Jul 25, 2011 at 6:26 PM, Jim Nasby wrote: > Hrm, don't we only pull in ZIC info on a reload? Or do we actually refer to > it dynamically all the time? Perhaps we can enforce that we'll only recognize > new TZ info as part of a config reload? Hmm. That might work in theory, but I don't

Re: [HACKERS] storing TZ along timestamps

2011-07-25 Thread Jim Nasby
On Jul 22, 2011, at 10:33 AM, Robert Haas wrote: > On Thu, Jul 21, 2011 at 7:05 PM, Jim Nasby wrote: >> On Jul 21, 2011, at 5:30 PM, Christopher Browne wrote: >>> - I'd commend capturing NOW() in a timestamptz field. That gives you: >>> 1. What time the DB server thought it was, in terms of UT1

Re: [HACKERS] storing TZ along timestamps

2011-07-22 Thread Josh Berkus
Jim, > Arguably, we could just create an add-on data type for storing that timezone > information, but that seems pretty daft to me: you're stuck either storing > raw text which takes what should be a 12 byte datatype up to a 20-30 byte > type (8 byte timestamp + varlena + text of timezone name

Re: [HACKERS] storing TZ along timestamps

2011-07-22 Thread Alvaro Herrera
Excerpts from Robert Haas's message of vie jul 22 11:33:09 -0400 2011: > This problem reminds me a great deal of the problems associated with > managing security labels for SE-Linux. There aren't that many > distinct values, so ideally it would be nice to store an OID -> string > mapping somewher

Re: [HACKERS] storing TZ along timestamps

2011-07-22 Thread Robert Haas
On Thu, Jul 21, 2011 at 7:05 PM, Jim Nasby wrote: > On Jul 21, 2011, at 5:30 PM, Christopher Browne wrote: >> - I'd commend capturing NOW() in a timestamptz field.  That gives you: >> 1.  What time the DB server thought it was, in terms of UT1 >> 2.  What timezone it thought was tied to that conne

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread Jim Nasby
On Jul 21, 2011, at 5:30 PM, Christopher Browne wrote: > - I'd commend capturing NOW() in a timestamptz field. That gives you: > 1. What time the DB server thought it was, in terms of UT1 > 2. What timezone it thought was tied to that connection. Except that it doesn't, and that's exactly the p

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread Christopher Browne
On Thu, Jul 21, 2011 at 5:48 PM, Jim Nasby wrote: > On Jul 19, 2011, at 4:06 PM, Josh Berkus wrote: >>> I have my doubts about that, and I hope not.  These details haven't been >>> discussed at all; I only started this thread to get community approval >>> on cataloguing the TZs. >> >> I am strongl

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread Tom Lane
Jim Nasby writes: > On Jul 19, 2011, at 11:22 AM, Ian Caulfield wrote: >> There was an earlier point made that if someone puts eg 5pm local time >> two years in the future into the database, and then the DST boundary >> gets moved subsequently, some applications would like the value to >> still sa

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread Jim Nasby
On Jul 19, 2011, at 4:06 PM, Josh Berkus wrote: >> I have my doubts about that, and I hope not. These details haven't been >> discussed at all; I only started this thread to get community approval >> on cataloguing the TZs. > > I am strongly in favor of having a *timezone* data type and some syst

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread David E. Wheeler
On Jul 21, 2011, at 2:39 PM, Jim Nasby wrote: >> CREATE OR REPLACE FUNCTION is_timezone( >> tz CITEXT >> ) RETURNS BOOLEAN LANGUAGE plpgsql STABLE AS $$ > ... >> CREATE DOMAIN timezone AS CITEXT CHECK ( is_timezone( VALUE ) ); > > Storing giant globs of text with every timestamp field is really

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread Jim Nasby
On Jul 19, 2011, at 11:22 AM, Ian Caulfield wrote: > On 19 July 2011 17:11, Kevin Grittner wrote: >> Tom Lane wrote: >>> "Kevin Grittner" writes: Josh Berkus wrote: > The timestamp and the timezone in which that timestamp was > entered are two separate pieces of data and *ought* to

Re: [HACKERS] storing TZ along timestamps

2011-07-21 Thread Jim Nasby
On Jul 19, 2011, at 4:20 PM, David E. Wheeler wrote: > On Jul 19, 2011, at 2:06 PM, Josh Berkus wrote: > >> I am strongly in favor of having a *timezone* data type and some system >> whereby we can uniquely identify timezones in the Zic database. > > CREATE OR REPLACE FUNCTION is_timezone( >t

Re: [HACKERS] storing TZ along timestamps

2011-07-19 Thread David E. Wheeler
On Jul 19, 2011, at 2:06 PM, Josh Berkus wrote: > I am strongly in favor of having a *timezone* data type and some system > whereby we can uniquely identify timezones in the Zic database. CREATE OR REPLACE FUNCTION is_timezone( tz CITEXT ) RETURNS BOOLEAN LANGUAGE plpgsql STABLE AS $$ BEGIN

Re: [HACKERS] storing TZ along timestamps

2011-07-19 Thread Josh Berkus
Alvaro, Kevin, >> In a builtin data type, which of those three would you pick? Only the >> application knows. > > I think this whole discussion is built on the assumption that the client > timezone and the application timezone are one thing and the same; and > the server timezone is not relevant

Re: [HACKERS] storing TZ along timestamps

2011-07-19 Thread Ian Caulfield
On 19 July 2011 17:11, Kevin Grittner wrote: > Tom Lane wrote: >> "Kevin Grittner" writes: >>> Josh Berkus wrote: The timestamp and the timezone in which that timestamp was entered are two separate pieces of data and *ought* to be in two separate fields. >> >>> So, if you're grab

Re: [HACKERS] storing TZ along timestamps

2011-07-19 Thread Kevin Grittner
Tom Lane wrote: > "Kevin Grittner" writes: >> Josh Berkus wrote: >>> The timestamp and the timezone in which that timestamp was >>> entered are two separate pieces of data and *ought* to be in two >>> separate fields. > >> So, if you're grabbing a timestamp and the time zone for it, how >> do

Re: [HACKERS] storing TZ along timestamps

2011-07-19 Thread Tom Lane
"Kevin Grittner" writes: > Josh Berkus wrote: >> The timestamp and the timezone in which that timestamp was entered >> are two separate pieces of data and *ought* to be in two separate >> fields. > So, if you're grabbing a timestamp and the time zone for it, how do > you ensure you've done that

Re: [HACKERS] storing TZ along timestamps

2011-07-19 Thread Kevin Grittner
Josh Berkus wrote: > The timestamp and the timezone in which that timestamp was entered > are two separate pieces of data and *ought* to be in two separate > fields. So, if you're grabbing a timestamp and the time zone for it, how do you ensure you've done that atomically if you're at the boun

Re: [HACKERS] storing TZ along timestamps

2011-07-18 Thread Alvaro Herrera
Excerpts from Josh Berkus's message of lun jul 18 18:37:15 -0400 2011: > The timestamp and the timezone in which that timestamp was entered are > two separate pieces of data and *ought* to be in two separate fields. > For one thing, the question of "what timezone was this entered in" is an > appli

Re: [HACKERS] storing TZ along timestamps

2011-07-18 Thread Josh Berkus
Jim, > Right; you need a timestamp and you need to know what timezone that timestamp > was entered in. That means you can always convert that time to whatever > timezone you'd like (like timestamptz), but you also know what time was > originally entered, and what timezone it was entered in. Tec

Re: [HACKERS] storing TZ along timestamps

2011-07-18 Thread Jim Nasby
On Jul 18, 2011, at 12:29 AM, Robert Haas wrote: > On Fri, Jul 8, 2011 at 11:13 AM, Stuart Bishop > wrote: >> On Mon, Jun 6, 2011 at 7:50 AM, Jim Nasby wrote: >>> On Jun 4, 2011, at 3:56 AM, Greg Stark wrote: On Thu, Jun 2, 2011 at 8:58 PM, Jim Nasby wrote: > > I'm torn between wh

Re: [HACKERS] storing TZ along timestamps

2011-07-17 Thread Robert Haas
On Fri, Jul 8, 2011 at 11:13 AM, Stuart Bishop wrote: > On Mon, Jun 6, 2011 at 7:50 AM, Jim Nasby wrote: >> On Jun 4, 2011, at 3:56 AM, Greg Stark wrote: >>> On Thu, Jun 2, 2011 at 8:58 PM, Jim Nasby wrote: I'm torn between whether the type should store the original time or the o

Re: [HACKERS] storing TZ along timestamps

2011-07-17 Thread Jim Nasby
On Jul 6, 2011, at 9:24 AM, Alexey Klyukin wrote: > So, I'd think there are 2 reasonable approaches to storing the > timezone part: > > 1. Store the timezone abbreviation (i.e. 'EST' along w/ the timestamp > data). > 2. Assign OID to each of the timezones and store it w/ the timestamp. > > The f

Re: [HACKERS] storing TZ along timestamps

2011-07-08 Thread Stuart Bishop
On Mon, Jun 6, 2011 at 7:50 AM, Jim Nasby wrote: > On Jun 4, 2011, at 3:56 AM, Greg Stark wrote: >> On Thu, Jun 2, 2011 at 8:58 PM, Jim Nasby wrote: >>> >>> I'm torn between whether the type should store the original time or the >>> original time converted to GMT. >> >> This is the wrong way to

Re: [HACKERS] storing TZ along timestamps

2011-07-06 Thread Alexey Klyukin
Hi, On May 27, 2011, at 11:43 PM, Alvaro Herrera wrote: > > One of our customers is interested in being able to store original > timezone along with a certain timestamp. > > It is currently possible to store a TZ in a separate column, but this is > a bit wasteful and not very convenient anyway.

Re: [HACKERS] storing TZ along timestamps

2011-06-05 Thread Jim Nasby
On Jun 4, 2011, at 3:56 AM, Greg Stark wrote: > On Thu, Jun 2, 2011 at 8:58 PM, Jim Nasby wrote: >> >> I'm torn between whether the type should store the original time or the >> original time converted to GMT. > > This is the wrong way to think about it. We *never* store time > "converted to GM

Re: [HACKERS] storing TZ along timestamps

2011-06-04 Thread Greg Stark
On Thu, Jun 2, 2011 at 8:58 PM, Jim Nasby wrote: > > I'm torn between whether the type should store the original time or the > original time converted to GMT. This is the wrong way to think about it. We *never* store time "converted to GMT". When we want to represent a point in time we represen

Re: [HACKERS] storing TZ along timestamps

2011-06-03 Thread Peter Eisentraut
On tor, 2011-06-02 at 22:58 -0500, Jim Nasby wrote: > I'm torn between whether the type should store the original time or > the original time converted to GMT. I believe you would have the most > accuracy if you stored the original time... but then indexing becomes > problematic. I don't know if th

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Jim Nasby
On Jun 2, 2011, at 7:48 PM, Jeff Davis wrote: > On Thu, 2011-06-02 at 20:28 -0400, Robert Haas wrote: >> But that doesn't seem like enough, because if someone adds '1 day', >> knowing the offset isn't sufficient to figure out the answer. You >> have to know where the DST boundary is. > > Good poi

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Jeff Davis
On Thu, 2011-06-02 at 20:28 -0400, Robert Haas wrote: > But that doesn't seem like enough, because if someone adds '1 day', > knowing the offset isn't sufficient to figure out the answer. You > have to know where the DST boundary is. Good point, I guess the timezone itself needs to be stored. Tha

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Robert Haas
On Thu, Jun 2, 2011 at 3:02 PM, Jeff Davis wrote: > On Thu, 2011-06-02 at 18:46 +, Christopher Browne wrote: >> > 1. How would the time-zone be defined in this composite? Offset from GMT? >> > Timezone (well, link thereto) with all DST rules intact? Would "extract" >> > need to be modified to

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Merlin Moncure
On Thu, Jun 2, 2011 at 12:55 PM, Alvaro Herrera wrote: >> >> > One of our customers is interested in being able to store original >> >> > timezone along with a certain timestamp. >> >> >> >> I assume that you're talking about a new data type, not augmenting the >> >> current types, correct? >> > >

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Jeff Davis
On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: > One of our customers is interested in being able to store original > timezone along with a certain timestamp. Another thing to consider is that this will eliminate any useful total order. You could define an arbitrary total order, of cour

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Christopher Browne
On Thu, Jun 2, 2011 at 6:06 PM, Steve Crawford wrote: > On 06/01/2011 05:18 PM, Alvaro Herrera wrote: >> >> Excerpts from Jeff Davis's message of mié jun 01 19:57:40 -0400 2011: >>> >>> On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: Hi, One of our customers is interes

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Jeff Davis
On Thu, 2011-06-02 at 18:46 +, Christopher Browne wrote: > > 1. How would the time-zone be defined in this composite? Offset from GMT? > > Timezone (well, link thereto) with all DST rules intact? Would "extract" > > need to be modified to include the ability to grab the timezone? > > That does

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Alvaro Herrera
Excerpts from Merlin Moncure's message of mié jun 01 21:36:32 -0400 2011: > On Wed, Jun 1, 2011 at 8:18 PM, Alvaro Herrera > wrote: > > Excerpts from Jeff Davis's message of mié jun 01 19:57:40 -0400 2011: > >> On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: > >> > Hi, > >> > > >> > One o

Re: [HACKERS] storing TZ along timestamps

2011-06-02 Thread Steve Crawford
On 06/01/2011 05:18 PM, Alvaro Herrera wrote: Excerpts from Jeff Davis's message of mié jun 01 19:57:40 -0400 2011: On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: Hi, One of our customers is interested in being able to store original timezone along with a certain timestamp. I assume

Re: [HACKERS] storing TZ along timestamps

2011-06-01 Thread Merlin Moncure
On Wed, Jun 1, 2011 at 8:18 PM, Alvaro Herrera wrote: > Excerpts from Jeff Davis's message of mié jun 01 19:57:40 -0400 2011: >> On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: >> > Hi, >> > >> > One of our customers is interested in being able to store original >> > timezone along with a

Re: [HACKERS] storing TZ along timestamps

2011-06-01 Thread Jeff Davis
On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: > Hi, > > One of our customers is interested in being able to store original > timezone along with a certain timestamp. I assume that you're talking about a new data type, not augmenting the current types, correct? Regards, Jeff Da

Re: [HACKERS] storing TZ along timestamps

2011-06-01 Thread Alvaro Herrera
Excerpts from Jeff Davis's message of mié jun 01 19:57:40 -0400 2011: > On Fri, 2011-05-27 at 16:43 -0400, Alvaro Herrera wrote: > > Hi, > > > > One of our customers is interested in being able to store original > > timezone along with a certain timestamp. > > I assume that you're talking about a

Re: [HACKERS] storing TZ along timestamps

2011-06-01 Thread Steve Crawford
On 05/28/2011 02:58 PM, Peter Eisentraut wrote: On fre, 2011-05-27 at 16:57 -0700, Steve Crawford wrote: And the second case is already well handled. In fact calendaring is a great example. I enter the time for the teleconference and PG nicely uses my default timezone to store the point-in-time.

Re: [HACKERS] storing TZ along timestamps

2011-05-28 Thread Peter Eisentraut
On fre, 2011-05-27 at 16:57 -0700, Steve Crawford wrote: > And the second case is already well handled. In fact calendaring is a > great example. I enter the time for the teleconference and PG nicely > uses my default timezone to store the point-in-time. When you > retrieve > it, it is shown in

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, May 27, 2011 at 04:43:28PM -0400, Alvaro Herrera wrote: > Hi, > > One of our customers is interested in being able to store original > timezone along with a certain timestamp. I've felt that pain here and there too... > So the first thing is

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Jim Nasby
On May 27, 2011, at 6:29 PM, Greg Stark wrote: > Both of these two cases can be handled differently. The former by > storing the raw text inputs and then storing the interpreted value as > a derived column separetly, and the latter by storing the local time > zone to use for display as an additiona

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Steve Crawford
On 05/27/2011 04:29 PM, Greg Stark wrote: On Fri, May 27, 2011 at 4:13 PM, Steve Crawford wrote: I am very interested in the use-case for this (in part as I'm working on a PG related time talk). My experience thus far is that people who want this do not fully understand the nature of date-time

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Greg Stark
On Fri, May 27, 2011 at 4:13 PM, Steve Crawford wrote: > I am very interested in the use-case for this (in part as I'm working on a > PG related time talk). My experience thus far is that people who want this > do not fully understand the nature of date-time calculations and variables > in PG. Th

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Steve Crawford
On 05/27/2011 01:43 PM, Alvaro Herrera wrote: Hi, One of our customers is interested in being able to store original timezone along with a certain timestamp. I am very interested in the use-case for this (in part as I'm working on a PG related time talk). My experience thus far is that people w

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Greg Stark
On Fri, May 27, 2011 at 2:32 PM, Kevin Grittner wrote: > I think the key thing is that the timestamp portion of it would be > identical to our current TIMESTAMP WITH TIME ZONE -- always store it > in the value UTC zone. Fwiw our timestamp with time zone stores seconds since the epoch. This is a q

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread David E. Wheeler
On May 27, 2011, at 2:35 PM, Tom Lane wrote: > "David E. Wheeler" writes: >> I like it, but what do you do when a TZ has been renamed or has ceased >> to exist. > > As far as that goes, I think "nothing" is a sufficient answer. There's > no requirement that an OID in the mapping table correspon

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Tom Lane
"David E. Wheeler" writes: > I like it, but what do you do when a TZ has been renamed or has ceased > to exist. As far as that goes, I think "nothing" is a sufficient answer. There's no requirement that an OID in the mapping table correspond to a live TZ. It's just a more compact way of storing

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Kevin Grittner
"David E. Wheeler" wrote: > I like it, but what do you do when a TZ has been renamed or has > ceased to exist. Or, worse, existed last week, so last week's > dates might still use it, but next week's must not? I think the key thing is that the timestamp portion of it would be identical to our

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread David E. Wheeler
On May 27, 2011, at 1:43 PM, Alvaro Herrera wrote: > Right now we rely on the tzdata files on disk for things like > pg_timezone_names and other accesses of TZ data; so the files are the > authoritative source of TZ info. So we need to ensure that whenever the > files are updated, the catalogs ar

Re: [HACKERS] storing TZ along timestamps

2011-05-27 Thread Tom Lane
Alvaro Herrera writes: > Right now we rely on the tzdata files on disk for things like > pg_timezone_names and other accesses of TZ data; so the files are the > authoritative source of TZ info. So we need to ensure that whenever the > files are updated, the catalogs are updated as well. > I thi

[HACKERS] storing TZ along timestamps

2011-05-27 Thread Alvaro Herrera
Hi, One of our customers is interested in being able to store original timezone along with a certain timestamp. It is currently possible to store a TZ in a separate column, but this is a bit wasteful and not very convenient anyway. There are all sorts of UI issues that need to be resolved in ord