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 1seDD4-004z1U-Vb for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 12:34:39 +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 1seDD3-00A3Us-7Q for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 12:34:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seDD1-00A3Uk-OK for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 12:34:36 +0000 Received: from fhigh6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seDCu-004obc-S3 for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 12:34:35 +0000 Received: from phl-compute-07.internal (phl-compute-07.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id E09721151AC8; Wed, 14 Aug 2024 08:34:26 -0400 (EDT) Received: from wimap21 ([10.202.2.81]) by phl-compute-07.internal (MEProxy); Wed, 14 Aug 2024 08:34:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compiler.org; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1723638866; x=1723725266; bh=o5iK8Q/GDMCISX78xYHtIOGb5oCcPjpWhy4ooSpjcA4=; b= fsr1MfaEJh/BSn+OeCYqdBFv8gNLTrcbLnjqVEgoh9ZqKCBlWn2L2mGFNvJHb2AD Pv6zHtE1K8LABdmLs/Z2V/k69IB/VzZq5lJT43Z53kuyL4CO+8wYPHiBmDFKb34v U0xuvwWsXf26yjDNvz4qcZrkef73g91rWqKhqzcZ7+3VhKgXxFSd30leAv4jwfLh 2Csds5NDUqDg2J7AMBWDYqzqjKpgWbshqALCMkcGEhsTO1XDP/sttbxpICKAACgW eODvgQLHfje/eAg6jvY+vHbcme6REXLw69AnbL4fTpT5eJYEjZY8rRR4dzfvsx7A 7dcugsz/kxTihgCkZj22AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723638866; x= 1723725266; bh=o5iK8Q/GDMCISX78xYHtIOGb5oCcPjpWhy4ooSpjcA4=; b=S 2QSUXR+GbVmcarIeubd16jI7WpRrXNdAqrwHoe2160Bq1JXMCHsrBW6yfdKUv/9Q fnXvHd4Eyx5lHEaINRo5JAUZ6ziYFIWboAu+SbXCo9HFnixzKYNhMsc9Ml2NNtfA YTKWs1BYQrmD8waHF8wl9J+5UhvfVmuBSI2zW3+TPJ6luz8mUc40y7Rbz9cnYoY7 BRl6aSRE2jSLPLVzcMGIeISW7/Owm+574uacnx5VWctRJKhvPvfL0sqkkVpSX4qh nu+GIs/8xhsy/o9l9yTnXOr0PDipRHW97K7hYsTa0jlnze20xYVruuBAPUBgJ3jz 5YAIVpkhndcEQaoE/TRjw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtgedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthejredtredttden ucfhrhhomhepfdflohgvlhculfgrtghosghsohhnfdcuoehjohgvlhestghomhhpihhlvg hrrdhorhhgqeenucggtffrrghtthgvrhhnpeevlefftdeiudfgvdfgffdtvdeiveelteei tefgtedtffejtdejfefflefhleffieenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehjohgvlhestghomhhpihhlvghrrdhorhhgpdhnsggprhgt phhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqdhhrg gtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopegr lhgvkhhsrghnuggvrhesthhimhgvshgtrghlvgdrtghomh X-ME-Proxy: Feedback-ID: ic6394509:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A941337A0085; Wed, 14 Aug 2024 08:34:26 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Wed, 14 Aug 2024 14:34:06 +0200 From: "Joel Jacobson" To: "Aleksander Alekseev" , pgsql-hackers@lists.postgresql.org Message-Id: In-Reply-To: References: <7882ebcf-4f1f-4f57-afeb-e1301dd6c9d3@app.fastmail.com> Subject: Re: [PATCH] Add get_bytes() and set_bytes() functions Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. 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 Since if not having a current bytea value, and just wanting to convert a bigint to bytea, then one would need to construct an zeroed bytea of the proper size first, to then use set_bytes(). And if just wanting to convert the entire bytea to a bigint, then one would need to pass 0 as offset and the length of the bytea as size. Regards, Joel