Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seFEG-005JPb-QB for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 14:44:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1seFEF-00Avur-Bl for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 14:43:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seFEE-00Avuj-J8 for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 14:43:59 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1seFEB-004iRa-1o for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 14:43:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fetter.org; s=default; t=1723646632; bh=LFdsEeisoPOoRRV+F1HaGi+Maqa7EcisS4V9dVCc1r4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=y2k0YZE8E8wqos7dB/LfraQ61Q10tUijsvUJEQ5FWcY9D7EsmbSzr2UKmi9SGPLXD OTb29VXsmPoN1UjOBazHlMPJmXtvSpB604byGYcSQmXOWG+Tki7xs+4eqDb/ZtnAqQ gtbGDGw29WBnb5AtuwQALDjQt0Rqipjpmpszs2eLJyK5L29VpxdgkNL7vyVUonGnj1 8TfO/nFdTEWBGEqtJcHZjg3upm58yXGLGMCH29J/NOgH51NoW6T/zCdy1p87aNmY8j Y0HqLPtSTtDuTPPZoSngAQFznOAL3/8QU7oCn9Jw1STRm8W4Rtdrrt+EDrwm6pRAZS LvLaLXRlOYeNQ== Received: by fetter.org (Postfix, from userid 1001) id 2933E40473; Wed, 14 Aug 2024 16:43:52 +0200 (CEST) Date: Wed, 14 Aug 2024 16:43:51 +0200 From: David Fetter To: Joel Jacobson Cc: Aleksander Alekseev , pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Add get_bytes() and set_bytes() functions Message-ID: References: <7882ebcf-4f1f-4f57-afeb-e1301dd6c9d3@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Aug 14, 2024 at 02:34:06PM +0200, Joel Jacobson wrote: > On Wed, Aug 14, 2024, at 13:31, Aleksander Alekseev wrote: > >> I wonder if get_bytes() and set_bytes() will behave differently > >> on little-endian vs big-endian systems? > > No, the returned value will not depend on the CPU endiness. Current > > implementation uses big-endian / network order which in my humble > > opinion is what most users would expect. > > Nice. Indeed! > I've reviewed and tested the patch. > It looks straight-forward to me. > I don't see any potential problems. > I've marked it Ready for Committer. > > > I believe we also need reverse(bytea) and repeat(bytea, integer) > > functions e.g. for those who want little-endian. However I want to > > propose them separately when we are done with this patch. > > I agree those functions would be nice too. > > I also think it would be nice to provide these convenience functions: > to_bytes(bigint) -> bytea > from_bytes(bytea) -> bigint Along with these, would it make sense to have other forms of these that won't choke at 63 bits, e.g. NUMERIC or TEXT? Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778