diff options
| author | Thomas Markwalder <tmark@isc.org> | 2022-02-17 16:05:25 -0500 |
|---|---|---|
| committer | Thomas Markwalder <tmark@isc.org> | 2022-02-17 16:05:25 -0500 |
| commit | c164541e3ac7deba104b3c1926c22a0bb0857268 (patch) | |
| tree | 95171f4989c3eb6c5b96392444fe54077f53561d /src/share/database/scripts/pgsql/dhcpdb_create.pgsql | |
| parent | 6c20973385e1d13b887da7c77270e82b10a1624f (diff) | |
[#95] Fix time handling and make installable
src/hooks/dhcp/pgsql_cb/pgsql_query_macros_dhcp.h
Use gmt_epoch() to fetch timestamps
src/lib/pgsql/pgsql_exchange.*
PsqlBindArray::addTimestamp()
PsqlBindArray::addTimestamp()
- use convertLocaltoDatabaseTime()
PgSqlExchange::convertLocalToDatabaseTime()
- new function for converting local times
src/lib/pgsql/tests/pgsql_basics.*
Add LOCALTIME_COL column
src/lib/pgsql/tests/pgsql_exchange_unittest.cc
Update unit tests
src/share/database/scripts/pgsql/dhcpdb_create.pgsql
src/share/database/scripts/pgsql/upgrade_008_to_009.sh.in
src/share/database/scripts/pgsql/dhcpdb_drop.pgsql
Add gmt_epoch() function
src/share/database/scripts/pgsql/wipe_data.sh.in
Fix order of tables
Diffstat (limited to 'src/share/database/scripts/pgsql/dhcpdb_create.pgsql')
| -rw-r--r-- | src/share/database/scripts/pgsql/dhcpdb_create.pgsql | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql index c8d18f680c..ecf417d587 100644 --- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql +++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql @@ -4492,6 +4492,24 @@ BEGIN RETURN; END;$$; +-- Returns the epoch GMT time in second from a timestamp with time zone +-- +-- param input_ts timestamp value to convert +-- return a BIGINT containing the number of seconds since the epoch in GMT. +CREATE OR REPLACE FUNCTION gmt_epoch(input_ts TIMESTAMP WITH TIME ZONE) +RETURNS BIGINT +AS $$ +DECLARE + gmt_epoch BIGINT; +BEGIN + select extract(epoch from input_ts) + extract(timezone from input_ts) into gmt_epoch; + RETURN gmt_epoch; + EXCEPTION + WHEN OTHERS THEN + RAISE EXCEPTION 'gmt_epoch(%) : failed, sqlstate: %', input_ts, sqlstate; +END;$$ +LANGUAGE plpgsql; + -- Update the schema version number. UPDATE schema_version SET version = '9', minor = '0'; |
