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 1seG6U-005Sdh-C2 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 15:40:02 +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 1seG6S-00BBer-S4 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 15:40:00 +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 1seG6R-00BBej-Eq for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 15:40:00 +0000 Received: from fhigh8-smtp.messagingengine.com ([103.168.172.159]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seG6N-004pvy-KM for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 15:39:58 +0000 Received: from phl-compute-07.internal (phl-compute-07.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 8EBC31151A9A; Wed, 14 Aug 2024 11:39:53 -0400 (EDT) Received: from wimap21 ([10.202.2.81]) by phl-compute-07.internal (MEProxy); Wed, 14 Aug 2024 11:39:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compiler.org; h= cc: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=1723649993; x=1723736393; bh=q/V9bk8YYxnFiCwYCDGQ4JZQKQJFoIjQSzNQncSZOJU=; b= AOLFsMb3hblg3KxF8QpC0pu+Hg/Vj4hHIwExNjsmiiMJu6mu51U3Fb4/08kQRNEB S7Lm5SzyTgoDtL5fQz3ygb+WlKdt3J4BjiTFSpod8hMKykb5Xwb+XFBHI2QpHxKZ XMKWszJ8zJMw2ROsmvQW4J/folMr52v5GjguCxnZ97cS/430m41ctCbDIzHxX3Os veDebPDCg9gPk+pFODxGzLMwRcU4k3F10DJKYz39gW9dkSzPsRA2y1Fb+fELuqCw R3cf1Ug0wrgQImwH0YWTMW3U/IKpLS8Tg+5gO/OjkIbnvlakUIqa3gGH34HcF3cG kqFG5VeLRXpwtpMlY5Su+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1723649993; x= 1723736393; bh=q/V9bk8YYxnFiCwYCDGQ4JZQKQJFoIjQSzNQncSZOJU=; b=n 31NgVoEhTG+F3yneMsY2ANzc1gHy7DDJaOxT3zDPaLlzErp2v1MXpIeCAKnVjudS Dmwk0YQvZ7/tjbSyuhALG9O282MOQh/jgoKlowPE3JpyHp/WeSUrsFaMpEwwAO93 VNg8W0ur65E8+ugDZvWluyCcBs9D1nDASiaMad5O40bd2VpxZ0pGl2b+3or4idDC f4w5m+1iltK9M2k2fJNxQDT2/5LTLMDP1YLdRC6Hd9GySBAfoQb3FiXgMr235Vb3 N/G0IRY+eLr3aj3esSQzn+4A0/6H0mxOn0UYIPWaNy9yQkq7d165nkiD4x9JBX8U CABSHmF+wtk1w2OU0J1Lg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddtgedgledvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedflfhovghlucflrggtohgsshhonhdfuceojhhovghlsegtohhmphhilh gvrhdrohhrgheqnecuggftrfgrthhtvghrnhepfeehleffgedvleefveetjedtkeetfeel iefhtdduleekieejtdevgfeuveeikeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepjhhovghlsegtohhmphhilhgvrhdrohhrghdpnhgspghr tghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuggrvhhiugesfh gvthhtvghrrdhorhhgpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishht shdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtoheprghlvghkshgrnhguvghrse htihhmvghstggrlhgvrdgtohhm X-ME-Proxy: Feedback-ID: ic6394509:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5594C37A0085; Wed, 14 Aug 2024 11:39:53 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Wed, 14 Aug 2024 17:39:32 +0200 From: "Joel Jacobson" To: "David Fetter" Cc: "Aleksander Alekseev" , pgsql-hackers@lists.postgresql.org Message-Id: <7b4236b7-079d-4f10-b2aa-efc83955f6df@app.fastmail.com> 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 16:43, David Fetter wrote: >> 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? I wonder what would be good names for such functions though? Since NUMERIC can have decimal digits, and since BYTEA can already be casted to TEXT, which will just be \x followed by the hex digits, maybe such names should include "integer" or some other word, to indicate what is being returned? It's already quite easy to convert to NUMERIC though, for users who are aware of tricks like this: SELECT ('0x'||encode('\xCAFEBABEDEADBEEF'::bytea,'hex'))::numeric; numeric ---------------------- 14627333968688430831 (1 row) But, I think it would be better to provide functions, since many users probably have to google+stackoverflow or gpt to learn such tricks, which are not in the official documentation. Regards, Joel