Re: Is there a way to change current time?

Поиск
Список
Период
Сортировка
От Justin Pryzby
Тема Re: Is there a way to change current time?
Дата
Msg-id 20210415140155.GJ6091@telsasoft.com
обсуждение исходный текст
Ответ на Re: Is there a way to change current time?  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-performance
On Thu, Apr 15, 2021 at 09:58:23AM -0400, Bruce Momjian wrote:
> On Thu, Apr 15, 2021 at 04:45:44PM +0300, Warstone@list.ru wrote:
> > Hi,
> >  
> > Is there any way to set time that CURRENT_TIMESTAMP and/or now() will give next
> > time? (We need it only for testing purposes so if there is any hack, cheat,
> > etc. It will be fine)
> 
> No, it gets the time from the operating system.

You could overload now():

postgres=# CREATE DATABASE pryzbyj;
postgres=# \c pryzbyj
pryzbyj=# CREATE SCHEMA pryzbyj;
pryzbyj=# CREATE FUNCTION pryzbyj.now() RETURNS timestamp LANGUAGE SQL AS $$ SELECT 'today'::timestamp $$;
pryzbyj=# ALTER ROLE pryzbyj SET search_path=pryzbyj,public,pg_catalog;
pryzbyj=# SELECT now();
now | 2021-04-15 00:00:00

-- 
Justin



В списке pgsql-performance по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Is there a way to change current time?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Is there a way to change current time?