Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsSa9-0001gu-8o for pgsql-novice@arkaria.postgresql.org; Mon, 06 Jul 2020 14:58:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jsSa8-0001HD-3p for pgsql-novice@arkaria.postgresql.org; Mon, 06 Jul 2020 14:58:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jsSa7-0001H5-GP for pgsql-novice@lists.postgresql.org; Mon, 06 Jul 2020 14:58:55 +0000 Received: from sonic305-2.consmr.mail.bf2.yahoo.com ([74.6.133.41]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jsSa4-0007Eb-3D for pgsql-novice@lists.postgresql.org; Mon, 06 Jul 2020 14:58:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048; t=1594047529; bh=xUVVDPGSjk56+uWCdwW44gG6hJySlnm8MgQHBYE+IJA=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=rKyXo+4cnWnQYCjmTpkQM3BfqOgqNYi0WTTt4SnpMkNdy8Efr2I7+Lw/6JlxVSZ+3yVZ6uzOmohVcz4hTzlLQXaESv/4SbllA9CSuXy7cT1sJxCNplAYNbmm22Hop1Qv7EZNmfGagv/dtvFAjM4E7zpEbjevrHyEoJFDl0ArFWicrkNIFUiyXjH2abfp+DOalgA4FpNJC00W6Q8mRAoLP4Ls4DdPLn/emcqKsa2PKeJn+HFZyGctEIn6v50DDVxgusPncEbAcL9ATxZl9S47BzerjDxt8lfqRZdsNI0Mg+llXmTq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u89PbwoBCPOrn6jNeBNaSU3bd0rbkaZlTsJBuxw.Qsw XBn1FoqnZlZsn1kLi0I_rzdItCCwaSk.2JWGxrvOeU4r2vl8R0i2Z3z60T379Jof5J0bPvwRWNxP xja5WPI_eAIyfSTMpg2055Vo8XFjKnkHJ3KKKX2rsJOiMHVIqm0Jn5CKrrEXQZCXf34pkqdgpXOI 3q1aZIxQCeerMBfkElJu2Ky6S8CLJe7vgJRkQdsKdpSLFCFSUQYHYAfCYEULq8sV8zC7eD5vucLW Drkk7vPibcDUm4mHf1DK1Q24qxt088wXo.sFDAU4aWY_PLJ5uQF_CDBn.OwaIYemt8mnqCiZnC4d 0bYJG8qqBuFUGahBAHDjN0ZsOOI4Opw6s6SQLRAu.MdHNM0X3ZktNAR.leBTt6oHFR5qaRw.tSx9 5U_SwTqIofnqCiIHTqwtSitxyEqLgDIZMcx1.VUHbNcWxlUpA1MDsoqGD2n7KlXYWvfhaUVKziA- - Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.bf2.yahoo.com with HTTP; Mon, 6 Jul 2020 14:58:49 +0000 Received: by smtp421.mail.ne1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 6530d0256511d9c5d2161f1b806925b7; Mon, 06 Jul 2020 14:58:48 +0000 (UTC) Subject: Re: What's the best practice to compare the transaction with the checkpoint? To: Jialun Zhang , Laurenz Albe Cc: pgsql-novice@lists.postgresql.org References: <0bf46f63bd9f7e57a83710644a0ed4cf5f6c52f0.camel@cybertec.at> From: Gerald Cheves Message-ID: <0e86755d-57aa-9c31-31d2-f90b61456c96@verizon.net> Date: Mon, 6 Jul 2020 10:58:40 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------F37A0192AE7574941EC1FD63" Content-Language: en-US X-Mailer: WebService/1.1.16197 hermes_yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) Content-Length: 4022 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F37A0192AE7574941EC1FD63 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 7/6/2020 10:09 AM, Jialun Zhang wrote: > Thanks! But what I actually mean is how to do this in the backend > source code. I think I could find a way to do this SELECT in backend. What would be the advantage in that method? > > Thank you, > Jialun Zhang > > Laurenz Albe > 于2020年7月6日周一 上午4:09写道: > > On Sat, 2020-07-04 at 12:19 -0400, Jialun Zhang wrote: > > I am trying to add code to determine whether the transaction is > checkpointed or not. > > So I think I need to compare the transaction ID with the > checkpoint's and determine > > whether it is older or not. Could anyone tell me what's the best > practice of doing > > this in Postgres? Is it done somewhere in the existing code? > > You could use > >    SELECT next_xid FROM pg_control_checkpoint(); > > to get information about the last checkpoint. > > I refrain from asking what the point of the exercise is... > > Yours, > Laurenz Albe > -- > Cybertec | https://www.cybertec-postgresql.com > -- siamo arrivati sani e salvi --------------F37A0192AE7574941EC1FD63 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 7/6/2020 10:09 AM, Jialun Zhang wrote:
Thanks! But what I actually mean is how to do this in the backend source code. I think I could find a way to do this SELECT in backend.

What would be the advantage in that method?


Thank you,
Jialun Zhang

Laurenz Albe <laurenz.albe@cybertec.at> 于2020年7月6日周一 上午4:09写道:
On Sat, 2020-07-04 at 12:19 -0400, Jialun Zhang wrote:
> I am trying to add code to determine whether the transaction is checkpointed or not.
> So I think I need to compare the transaction ID with the checkpoint's and determine
> whether it is older or not. Could anyone tell me what's the best practice of doing
> this in Postgres? Is it done somewhere in the existing code?

You could use

   SELECT next_xid FROM pg_control_checkpoint();

to get information about the last checkpoint.

I refrain from asking what the point of the exercise is...

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com


-- 
siamo arrivati sani e salvi
--------------F37A0192AE7574941EC1FD63--