Get commit transaction ID inside iter() func

Hi,
Is it possible, and if so, how, to get the commit transaction ID from inside the subscribed iter() function?
Or before calling the iter() function?

I want to know when is the first time an iter function is called and when is the last time it’s being called in a commit transaction.

Thanks.

Hi,
Does cdb_get_txid() do what you want?

I’ll try using it! Thanks!

But calling it from inside iter() doesn’t make sense - the sequence of events for one notification is: 1) call cdb_read_subscription_socket(), followed by one sequence per subscription point of 2) invoke cdb_diff_iterate() -> one or more invocations of iter() -> cdb_diff_terate() returns. All the iter() invocations originating from one call of cdb_read_subscription_socket() pertain to the same notification, and thus necessarily are from one and the same transaction. Thus calling cdb_get_txid() once in the complete sequence (e.g. before the first invocation of cdb_diff_iterate()) is sufficient. However you still won’t know that one such sequence is the last for a given transaction until you get a notification for another transaction.

You probably want to combine this with using cdb_read_subscription_socket2() instead of cdb_read_subscription_socket(), and checking the CDB_SUB_FLAG_IS_LAST flag. That way you a) only need to call cdb_get_txid() once per transaction, and b) can tell when you have received all the notifications for a given transaction.