Re: A patch for get origin from commit_ts.

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "movead(dot)li(at)highgo(dot)ca" <movead(dot)li(at)highgo(dot)ca>
Cc: petr <petr(at)2ndquadrant(dot)com>, simon <simon(at)2ndquadrant(dot)com>, madankumar1993 <madankumar1993(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, craig <craig(at)2ndquadrant(dot)com>, alvherre <alvherre(at)2ndquadrant(dot)com>, andres <andres(at)anarazel(dot)de>, soumyadeep2007 <soumyadeep2007(at)gmail(dot)com>
Subject: Re: A patch for get origin from commit_ts.
Date: 2020-07-06 00:36:35
Message-ID: 20200706003635.GC2143@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 04, 2020 at 06:01:28PM +0800, movead(dot)li(at)highgo(dot)ca wrote:
> I make a patch as Michael Paquier described that use a new function to
> return transactionid and origin, and I add a origin version to
> pg_last_committed_xact() too, now it looks like below:

+SELECT pg_replication_origin_create('test_commit_ts: get_origin_1');
+SELECT pg_replication_origin_create('test_commit_ts: get_origin_2');
+SELECT pg_replication_origin_create('test_commit_ts: get_origin_3');

Why do you need three replication origins to test three times the same
pattern? Wouldn't one be enough and why don't you check after the
timestamp? I would also two extra tests: one with a NULL input and an
extra one where the data could not be found.

+ found = TransactionIdGetCommitTsData(xid, &ts, &nodeid);
+
+ if (!found)
+ PG_RETURN_NULL();

This part also looks incorrect to me, I think that you should still
return two tuples, both marked as NULL. You can do that just by
switching the nulls flags to true for the two values if nothing can be
found.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Isaac Morland 2020-07-06 00:47:08 Re: Can I use extern "C" in an extension so I can use C++?
Previous Message Michael Paquier 2020-07-06 00:20:12 Re: Postgres Windows build system doesn't work with python installed in Program Files