Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-09 Thread Miroslav Šimulčík
I might be confused here, but I think the point is that if you pass true as the third argument to set_config, the setting lasts only for the duration of the current transaction, like SET LOCAL. Which I think solves your problem. Yes, but at the end of transaction it is reset to the value it

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-08 Thread Robert Haas
On Wed, Feb 6, 2013 at 7:26 AM, Miroslav Šimulčík simulcik.m...@gmail.com wrote: Alternately, you might be able to use a custom GUC from a rather smaller PL/PgSQL function. At transaction start, issue: set_config('myapp.trigger_time', '', 't'); This is problem with using custom GUC -

[HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Miroslav Šimulčík
Hi all, I have deferred constraint update trigger in which I need to set same timestamp to all modified rows. The time needs to be the time of first invocation of this trigger fuction in transaciton. My intention is to set commit time to rows modified in transaction. So I need function that will

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Misa Simic
Hi, I dont have access to pg at this moment... But: BEGIN; SELECT now(); SELECT clock_timestamp(); SELECT now(); SELECT pg_sleep(100); SELECT now(); cCOMMIT; Now() should always return the same, very first, result... On Wednesday, February 6, 2013, Miroslav Šimulčík wrote: Hi

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Miroslav Šimulčík
This is not what I'm looking for. now() returns transaction start time. I need to set my own time anytime in transaction and then use that time later. Miro 2013/2/6 Misa Simic misa.si...@gmail.com Hi, I dont have access to pg at this moment... But: BEGIN; SELECT now(); SELECT

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Pavel Stehule
2013/2/6 Miroslav Šimulčík simulcik.m...@gmail.com: This is not what I'm looking for. now() returns transaction start time. I need to set my own time anytime in transaction and then use that time later. Miro 2013/2/6 Misa Simic misa.si...@gmail.com Hi, I dont have access to pg at this

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Miroslav Šimulčík
probably you can use a little bit cheaper session variables I rejected session variables, because they don't get cleared at the end of transaction if somebody set value on session level. So I can't decide if new transaction started. this is good (variable is cleared at the end of

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Craig Ringer
On 02/06/2013 06:19 PM, Miroslav Šimulčík wrote: Hi all, I have deferred constraint update trigger in which I need to set same timestamp to all modified rows. The time needs to be the time of first invocation of this trigger fuction in transaciton. My intention is to set commit time to rows

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Miroslav Šimulčík
As fast as possible and PL/PgSQL function don't go that well together. PL/PgSQL is well and good for a great many jobs, but I doubt this is one of them. Yes, I know. It was just example to demostrate functionality I need. If you're willing to spend the time to do it, consider writing a

Re: [HACKERS] function for setting/getting same timestamp during whole transaction

2013-02-06 Thread Pavel Stehule
2013/2/6 Miroslav Šimulčík simulcik.m...@gmail.com: As fast as possible and PL/PgSQL function don't go that well together. PL/PgSQL is well and good for a great many jobs, but I doubt this is one of them. Yes, I know. It was just example to demostrate functionality I need. If you're