From: | "David E(dot) Wheeler" <david(at)justatheory(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: overriding current_timestamp |
Date: | 2012-02-23 18:54:00 |
Message-ID: | C9C9169B-2464-4B6A-82C8-CE36B2C3337E@justatheory.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Feb 23, 2012, at 3:08 AM, Peter Eisentraut wrote:
> For (unit) testing, I have often had the need to override the current
> timestamp in the database system. For example, a column default,
> function, or views would make use of the current timestamp in some way,
> and to test the behavior, it's sometimes useful to tweak the current
> timestamp.
>
> What might be a good way to do that?
>
> Just overwrite xactStartTimestamp? Is that safe? If it weren't static,
> a user-loaded function could do it.
>
> Overwrite pg_catalog.now() in the test database?
>
> Other ideas?
>
> Some semi-official support for this sort of thing would be good.
I create a "mock" schema, add the function to it, and then put it in the search_path ahead of pg_catalog. See the example starting at slide 48 on http://www.slideshare.net/justatheory/pgtap-best-practices.
Best,
David
From | Date | Subject | |
---|---|---|---|
Next Message | David E. Wheeler | 2012-02-23 18:55:53 | Re: overriding current_timestamp |
Previous Message | Kevin Grittner | 2012-02-23 18:44:50 | Re: foreign key locks, 2nd attempt |