execution id - Mailing list pgsql-sql

From Voillequin, Jean-Marc
Subject execution id
Date
Msg-id MN2PR20MB27356F937609C465A9FD9B2EBE799@MN2PR20MB2735.namprd20.prod.outlook.com
Whole thread Raw
Responses Re: execution id  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: execution id  (hubert depesz lubaczewski <depesz@depesz.com>)
List pgsql-sql

Hello guys,

 

Is there a kind of magical system administration function that returns a unique id each time a select/insert/update/delete statement is launched?

 

Assuming x is a table with several rows:

 

select pg_magical_exec_id() from x;

  • returns 1 for each row

 

insert into x select pg_magical_exec_id() from x;

  • pg_magical_exec_id()=2

 

Select 1 from x where pg_magical_exec_id()>0;

  • pg_magical_exec_id=3

 

Select pg_magical_exec_id() from x;

  • returns 4 for each row

 

And even, in a transaction:

 

Begin;

delete from x where …;

  • pg_magical_exec_id=5

update x set … ;

  • pg_magical_exec_id=6

End;

 

Select pg_magical_exec_id() from x;

  • returns 7 for each row

 

I can understand it is a strange question!

There is a txid_current() function that could fit, but the transaction id does not change within a transaction.

 

 

 


Moody's monitors email communications through its networks for regulatory compliance purposes and to protect its customers, employees and business and where allowed to do so by applicable law. The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.

pgsql-sql by date:

Previous
From: Brice André
Date:
Subject: Most efficient way to select events from users having common subscriptions
Next
From: "David G. Johnston"
Date:
Subject: Re: execution id