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 1qYSKm-001l6B-9r for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Aug 2023 14:26:16 +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 1qYSKl-0022or-4j for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Aug 2023 14:26:14 +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 1qYSKk-0022nF-Qh for pgsql-hackers@lists.postgresql.org; Tue, 22 Aug 2023 14:26:14 +0000 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qYSKh-000Lsd-Cz for pgsql-hackers@postgresql.org; Tue, 22 Aug 2023 14:26:13 +0000 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-1c11d53221cso2934663fac.2 for ; Tue, 22 Aug 2023 07:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692714371; x=1693319171; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dTCAA2/JpGJgv95EjbjXZWtyZBRu4MVylhKUhXuuiVc=; b=gSelxDBP2B6Li5/ERFhy9EJRqZ6Y3HURhAooKG18lcXPuHCKUxCXS5ueuCPKUG9hIG M4LqSlbCx5W9uArzCFxD8/keQtApPI1A1wGMrLF9PBMaIV+zhumjsyV+yUNVercULznM 2Bibtqy16OosPwZRsFPXR9rI0QIEV0cUeBJTAFYliOgsxmGbwUidgVBZPw32cdh88rQa oWrC/1lTTLyWFmNaIyBB0KbL63pXOoqyXlsJPyQQ0t0HgVn22y+RgiK7lYQyDoFbk5y8 k9GACdI4/cK/0jSCVpRK/mM/T/alT9RHxmZH8mT/muzscASttJXlVm8Ob8rp5pPxoGwx DfQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692714371; x=1693319171; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dTCAA2/JpGJgv95EjbjXZWtyZBRu4MVylhKUhXuuiVc=; b=AB+EF80l0TBDjDdkv6RxnINHuCzSlIxz3J6M1Gc8m6ZxWA2eN2bKhTZzDW6eV8BwZV w+P0OtNliCmYktMfBGfmAsdzo1T/9R6yPOxgRzPykjI7YHzUjMk/jpTBJn1h+S4e2+nL +USgIhG3LFKLKZazAceZqvhAxLK4va/eJN9tJZX2I9ZF9wi8m6QzEOfZjlFzKa4FpBpd Mv8SJnlAdEefBmCjb4OO8sbFZUs1kcyd34TYb86FkIeQqUA4UGJcMLlbriIzfZdM4hTx d1Vof9E6YSRE6uJYFWE0VDlCl1Fd7KkbopnohRb1DgCWYYi/XVYvQLtcZkMdYJnUomg5 j82w== X-Gm-Message-State: AOJu0YyAJqM/y1MLCfPKbwrRBG+7lkU9pFVdSfH8cT/zoPOXCRxp4ctK /sBe/gcvyXht+qhtFK7PhszmnbpZnIY= X-Google-Smtp-Source: AGHT+IFawxn++ZjrhJYU+cduz/E+89FlrM2XQXD4L6OzGQxpSZTpD7OKQjZFT/AlZfBTvgwSNSjutQ== X-Received: by 2002:a05:6870:42cc:b0:1c0:3110:12cc with SMTP id z12-20020a05687042cc00b001c0311012ccmr12754977oah.55.1692714370737; Tue, 22 Aug 2023 07:26:10 -0700 (PDT) Received: from nathanxps13 ([2600:1700:48f8:340f:8d61:81c7:8811:f804]) by smtp.gmail.com with ESMTPSA id u2-20020a05687004c200b001c0f4484d20sm5630594oam.25.2023.08.22.07.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Aug 2023 07:26:10 -0700 (PDT) Date: Tue, 22 Aug 2023 07:26:08 -0700 From: Nathan Bossart To: Peter Eisentraut Cc: Dean Rasheed , John Naylor , Kirk Wolak , Eric Radman , pgsql-hackers@postgresql.org Subject: Re: [PATCH] Add function to_oct Message-ID: <20230822142608.GA651404@nathanxps13> References: <20230815041129.GB2294364@nathanxps13> <20230815171715.GA2312399@nathanxps13> <20230816142410.GA2651383@nathanxps13> <20230817152628.GA3148583@nathanxps13> <20230820152551.GB290672@nathanxps13> <0161f4fa-5cd4-ea9b-01a6-8b6b535bd812@eisentraut.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0161f4fa-5cd4-ea9b-01a6-8b6b535bd812@eisentraut.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Aug 22, 2023 at 04:20:02PM +0200, Peter Eisentraut wrote: > On 20.08.23 17:25, Nathan Bossart wrote: >> > Doing a quick test, shows that this changes the current behaviour, >> > because all inputs are now treated as 64-bit: >> > >> > HEAD: >> > >> > select to_hex((-1234)::int); >> > to_hex >> > ---------- >> > fffffb2e >> > >> > With patch: >> > >> > select to_hex((-1234)::int); >> > to_hex >> > ------------------ >> > fffffffffffffb2e >> Good catch. In v8, I fixed this by first casting the input to uint32 for >> the 32-bit versions of the functions. This prevents the conversion to >> uint64 from setting the rest of the bits. AFAICT this behavior is pretty >> well defined in the standard. > > What standard? C99 > I don't understand the reason for this handling of negative values. I would > expect that, say, to_hex(-1234) would return '-' || to_hex(1234). For this patch set, I was trying to retain the current behavior, which is to return the two's complement representation. I'm open to changing this if there's agreement on what the output should be. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com