【发布时间】:2021-07-11 22:25:15
【问题描述】:
为了防止旧版本覆盖新版本,在这个简单的函数中:
create function myupdate(paramts timestamp without time zone, ...)
language plpgsql AS
$$
begin
-- step 1 compare current record timestamp vs. supplied timestamp
if exists (select 1 from record where ts <> paramts and ...) then
raise exception 'A newer version exists, cannot update.';
end if;
...
end
$$;
ts 定义与timestamp without time zone 相同。
paramts 值由函数提供:
create function myfetch(...)
language plpgsql AS
$$
begin
return query select ts, ... from record where ...;
end
$$;
节点 API 和 Angular 客户端 UI 获得的是 2021-04-16T21:37:35.878Z,提交给 myupdate() 的值也是如此。但是,在我们的一台西海岸服务器上,在 myupdate() 内部执行期间,ts 会自动转换为 PST 2021-04-16 14:37:35.878694 并在对。
如何比较 UTC 和相同精度?
【问题讨论】:
标签: postgresql timezone