public inbox for [email protected]  
help / color / mirror / Atom feed
From: Voillequin, Jean-Marc <[email protected]>
To: [email protected] <[email protected]>
Subject: execution id
Date: Tue, 30 Aug 2022 16:22:45 +0000
Message-ID: <MN2PR20MB27356F937609C465A9FD9B2EBE799@MN2PR20MB2735.namprd20.prod.outlook.com> (raw)

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.


view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: execution id
  In-Reply-To: <MN2PR20MB27356F937609C465A9FD9B2EBE799@MN2PR20MB2735.namprd20.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox