From: | Gurjeet Singh <gurjeet(at)singh(dot)im> |
---|---|
To: | Miroslav Šimulčík <simulcik(dot)miro(at)gmail(dot)com> |
Cc: | Craig Ringer <craig(at)2ndquadrant(dot)com>, PGSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] function for setting/getting same timestamp during whole transaction |
Date: | 2013-02-07 03:00:28 |
Message-ID: | CABwTF4WGoByfMjedDk1GJe1D_GSBrCOmyFqj22tkuGqku0n-Zg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Removing -hackers and adding -general
On Wed, Feb 6, 2013 at 7:26 AM, Miroslav Šimulčík
<simulcik(dot)miro(at)gmail(dot)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 - clearing variable at transaction
> start. Without clearing it's not sufficient solution (see my response to
> Pavel's mail). I don't want to do clearing from application and as far as i
> know there is not "transaction start" trigger.
>
I think you can do it by using 2 GUCs.
Put this at the beginning of your trigger:
if current_setting(my_var.now) != now() then
-- We're executing this code for the first time in this transaction
set_config(my_var.now, now())
set_config(my_var.my_ts, clock_timestamp)
end;
-- Go on happily use my_var.my_ts to stamp your data.
HTH,
--
Gurjeet Singh
From | Date | Subject | |
---|---|---|---|
Next Message | Gurjeet Singh | 2013-02-07 03:12:43 | Re: [NOVICE] Problems with ñ and tildes / CSV import problems in PostgreSQL 9.1 |
Previous Message | Igor Neyman | 2013-02-07 02:47:46 | Re: configuring timezone |
From | Date | Subject | |
---|---|---|---|
Next Message | Seamus Abshere | 2013-02-07 03:33:01 | Re: Alias hstore's ? to ~ so that it works with JDBC |
Previous Message | Tomas Vondra | 2013-02-07 00:28:28 | Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system |