Skip site navigation (1) Skip section navigation (2)

Re: overriding current_timestamp

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: (view raw, whole thread or download thread mbox)
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 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



In response to


pgsql-hackers by date

Next:From: David E. WheelerDate: 2012-02-23 18:55:53
Subject: Re: overriding current_timestamp
Previous:From: Kevin GrittnerDate: 2012-02-23 18:44:50
Subject: Re: foreign key locks, 2nd attempt

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group