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 1jUAN9-0000vH-Ip for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Apr 2020 14:41:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jUAN8-0007zJ-Cm for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Apr 2020 14:41:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jUAN8-0007zC-5u for pgsql-hackers@lists.postgresql.org; Thu, 30 Apr 2020 14:41:06 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jUAN5-0000Bp-Ja for pgsql-hackers@postgresql.org; Thu, 30 Apr 2020 14:41:05 +0000 Received: from hnk.local (p2421237-ipbf2725funabasi.chiba.ocn.ne.jp [122.24.33.237]) by oss.nttdata.com (Postfix) with ESMTPSA id AEAE260135; Thu, 30 Apr 2020 23:40:59 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at oss.nttdata.com Subject: Re: +(pg_lsn, int8) and -(pg_lsn, int8) operators To: Michael Paquier Cc: Robert Haas , Kyotaro Horiguchi , Jehan-Guillaume de Rorthais , "pgsql-hackers@postgresql.org" References: <20200424072414.GP33034@paquier.xyz> <20200424121526.399578eb@firost> <20200427.104147.1848676018835134301.horikyota.ntt@gmail.com> <20200428060328.GF279958@paquier.xyz> From: Fujii Masao Message-ID: <8aa9c491-c693-0e8c-66e8-eb22e72ab329@oss.nttdata.com> Date: Thu, 30 Apr 2020 23:40:59 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200428060328.GF279958@paquier.xyz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/04/28 15:03, Michael Paquier wrote: > On Tue, Apr 28, 2020 at 12:56:19PM +0900, Fujii Masao wrote: >> Yes. Attached is the updated version of the patch, which introduces >> +(pg_lsn, numeric) and -(pg_lsn, numeric) operators. >> To implement them, I added also numeric_pg_lsn() function that converts >> numeric to pg_lsn. > > - those write-ahead log locations. > + those write-ahead log locations. Also the number of bytes can be added > + into and substracted from LSN using the + and > + - operators, respectively. > That's short. Should this mention the restriction with numeric (or > just recommend its use) because we don't have a 64b unsigned type > internally, basically Robert's point? Thanks for the review! What about the following description? ----------------- Also the number of bytes can be added into and substracted from LSN using the +(pg_lsn,numeric) and -(pg_lsn,numeric) operators, respectively. Note that the calculated LSN should be in the range of pg_lsn type, i.e., between 0/0 and FFFFFFFF/FFFFFFFF. ----------------- > > + /* XXX would it be better to return NULL? */ > + if (NUMERIC_IS_NAN(num)) > + ereport(ERROR, > + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), > + errmsg("cannot convert NaN to pg_lsn"))); > That would be good to test, and an error sounds fine to me. You mean that we should add the test that goes through this code block, into the regression test? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION