Re: function for setting/getting same timestamp during whole transaction - Mailing list pgsql-hackers

From Miroslav Šimulčík
Subject Re: function for setting/getting same timestamp during whole transaction
Date
Msg-id CAHRNM69nMnxxyoQ6C99hh6vJuepAtqXwARomN=nVb6Pmvdyc=g@mail.gmail.com
Whole thread Raw
In response to Re: function for setting/getting same timestamp during whole transaction  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
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 transaction):
begin;
set local test.value to 123;
show test.value;
 test.value
------------
 123
commit;
show test.value; --cleared => transaction ended
 test.haha
-----------


but this is bad:
begin;
set local test.value to 123;
show test.value;
 test.value
------------
 123
set test.value to 456;
commit;
show test.value; --not cleared
 test.haha
-----------
 456
 
test to system tables is slower then trapping error - just try to read
from tmp and when a read fails, then create table

Ok I will try reading from temp table directly with error trapping and compare times.
 
probably C trigger can be very effective, possible to use this
technique - http://postgres.cz/wiki/Funkce_rownum%28%29 (sorry, it is
in Czech language)

 I'm from Slovakia so I don't have problem with czech language, but I'm not sure how to do it in C function without using temp table, because I need to clear variable at the end/start of transaction. Any hints?

Miro

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: sql_drop Event Trigger
Next
From: Craig Ringer
Date:
Subject: Re: function for setting/getting same timestamp during whole transaction