[dev.icinga.com #2106] change timestamp to use time zone by default in postgresql #792
Comments
Updated by mfriedrich on 2011-11-22 13:57:24 +00:00
is this true only for the sla table or do we need to adapt this for all tables? |
Updated by jmosshammer on 2011-11-22 14:03:23 +00:00 Unfortunately it's required for all tables, otherwise #1954 occurs. |
Updated by mfriedrich on 2011-11-22 14:05:27 +00:00 can you please provide me some test queries, then i'll do the change myself while preparing the beta for tomorrow. |
Updated by mfriedrich on 2011-11-22 15:39:32 +00:00 changing this in the initial pgsql.sql is easy. but the upgrade on timestamps with timezones needs a using clause which mocks around on implicite type casts and the provided examples in the docs do not mention that. http://www.postgresql.org/docs/8.4/interactive/sql-altertable.html
ideas? |
Updated by mfriedrich on 2011-11-22 19:23:47 +00:00 got a hint from florian helmberger, the docs example just takes an integer and not a timestamp type. in order to extract the epoch from entry_time, a special routine is needed.
this needs to be applied for all current timestamp columns. |
Updated by mfriedrich on 2011-11-22 20:43:00 +00:00
|
Updated by mfriedrich on 2011-11-23 14:12:12 +00:00
now, all timestamps in postgresql respect the timezone by default and do not require special external treatment, from scratch import as well as in upgrade scripts. |
Updated by mfriedrich on 2014-12-08 14:37:28 +00:00
|
This issue has been migrated from Redmine: https://dev.icinga.com/issues/2106
Created by jmosshammer on 2011-11-22 10:38:42 +00:00
Assignee: mfriedrich
Status: Resolved (closed on 2011-11-23 14:12:12 +00:00)
Target Version: 1.6
Last Update: 2014-12-08 14:37:28 +00:00 (in Redmine)
The pgsql timestamp fields don't respect timezones (without being explicitly asked at querying) if they aren't flagged as 'with time zone'
See:
http://www.postgresql.org/docs/8.0/static/datatype-datetime.html
Fix is simple:
For example
...
CREATE TABLE icinga_acknowledgements (
acknowledgement_id bigserial,
instance_id bigint default 0,
entry_time timestamp default '1970-01-01 00:00:00',
....
should be
CREATE TABLE icinga_acknowledgements (
acknowledgement_id bigserial,
instance_id bigint default 0,
entry_time timestamp with time zone default '1970-01-01 00:00:00',
I tested this on my development machine and it works, timestamps are then returned in the current timezone with the timezone offset appended.
Regards,
Jannis
Also see: #1954
Changesets
2011-11-22 20:47:36 +00:00 by mfriedrich cc0270a
Relations:
The text was updated successfully, but these errors were encountered: