Thread:

From
Fabrice Chapuis
Date:
I am using postgres v.14 on rhel8
I enabled the track_commit_timestamp parameter. 

postgres [379418]=# show track_commit_timestamp ;
┌────────────────────────┐
│ track_commit_timestamp │
├────────────────────────┤
│ on                     │
└────────────────────────┘
(1 row)

I performed a recover with the_recovery_target_time parameter. In the postgres log the following informations are present:

statement: alter system set recovery_target_time = '2023-05-15 16:10:00'

recovery stopping before commit of transaction 53013547, time 2023-05-15 16:10:00.150823+02

I would like to get the xid related timestamp with the following query:

postgres[379418]=#select pg_xact_commit_timestamp(53013547);
ERROR: function pg_xact_commit_timestamp(integer) does not exist
LINE 1: select pg_xact_commit_timestamp(53013547);
                ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

What is the xid type and how can I cast integer value to make pg_xact_commit_timestamp to work?

Regards

Fabrice Chapuis


xid type? (was :)

From
Christophe Pettus
Date:

> On May 15, 2023, at 08:41, Fabrice Chapuis <fabrice636861@gmail.com> wrote:
> What is the xid type and how can I cast integer value to make pg_xact_commit_timestamp to work?

The xid type is... xid.  You'll need to cast as a string instead of an integer:

xof=# select pg_xact_commit_timestamp('53013547'::xid);
   pg_xact_commit_timestamp
-------------------------------
 2023-03-31 09:12:07.673883-07
(1 row)




Re:

From
Kirk Wolak
Date:
On Mon, May 15, 2023 at 11:42 AM Fabrice Chapuis <fabrice636861@gmail.com> wrote:
I am using postgres v.14 on rhel8
I enabled the track_commit_timestamp parameter. 

postgres [379418]=# show track_commit_timestamp ;
┌────────────────────────┐
│ track_commit_timestamp │
├────────────────────────┤
│ on                     │
└────────────────────────┘
(1 row)

I performed a recover with the_recovery_target_time parameter. In the postgres log the following informations are present:

statement: alter system set recovery_target_time = '2023-05-15 16:10:00'

recovery stopping before commit of transaction 53013547, time 2023-05-15 16:10:00.150823+02

I would like to get the xid related timestamp with the following query:

postgres[379418]=#select pg_xact_commit_timestamp(53013547);
ERROR: function pg_xact_commit_timestamp(integer) does not exist
LINE 1: select pg_xact_commit_timestamp(53013547);
                ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

What is the xid type and how can I cast integer value to make pg_xact_commit_timestamp to work?

Regards

Fabrice Chapuis



This is not obvious, but QUOTE that value:
select pg_xact_commit_timestamp('53013547'); 

And it figures it out!

Re:

From
Fabrice Chapuis
Date:
I works, thank you

postgres [429007]=# select pg_xact_commit_timestamp('53013547');
┌───────────────────────────────┐
│   pg_xact_commit_timestamp    │
├───────────────────────────────┤
│ 2023-05-15 16:10:00.150823+02 │
└───────────────────────────────┘
(1 row)


On Tue, May 16, 2023 at 5:25 AM Kirk Wolak <wolakk@gmail.com> wrote:
On Mon, May 15, 2023 at 11:42 AM Fabrice Chapuis <fabrice636861@gmail.com> wrote:
I am using postgres v.14 on rhel8
I enabled the track_commit_timestamp parameter. 

postgres [379418]=# show track_commit_timestamp ;
┌────────────────────────┐
│ track_commit_timestamp │
├────────────────────────┤
│ on                     │
└────────────────────────┘
(1 row)

I performed a recover with the_recovery_target_time parameter. In the postgres log the following informations are present:

statement: alter system set recovery_target_time = '2023-05-15 16:10:00'

recovery stopping before commit of transaction 53013547, time 2023-05-15 16:10:00.150823+02

I would like to get the xid related timestamp with the following query:

postgres[379418]=#select pg_xact_commit_timestamp(53013547);
ERROR: function pg_xact_commit_timestamp(integer) does not exist
LINE 1: select pg_xact_commit_timestamp(53013547);
                ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

What is the xid type and how can I cast integer value to make pg_xact_commit_timestamp to work?

Regards

Fabrice Chapuis



This is not obvious, but QUOTE that value:
select pg_xact_commit_timestamp('53013547'); 

And it figures it out!