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 1uXIyi-008GbF-Qv for pgsql-bugs@arkaria.postgresql.org; Thu, 03 Jul 2025 12:23:48 +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 1uXIyg-00DGmm-Jb for pgsql-bugs@arkaria.postgresql.org; Thu, 03 Jul 2025 12:23:47 +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 1uXIyg-00DGmc-AI for pgsql-bugs@lists.postgresql.org; Thu, 03 Jul 2025 12:23:46 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uXIye-005V79-39 for pgsql-bugs@lists.postgresql.org; Thu, 03 Jul 2025 12:23:46 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-60c51860bf5so13311106a12.1 for ; Thu, 03 Jul 2025 05:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1751545424; x=1752150224; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=63rlH6bySYZzA/RDOd6qkJFQSzq7jCBtewxn54f/doQ=; b=QcTwyhI3Nfo7wfxjbe+hB6jMORcZ9H5FDZGbhMeg3cWjg01PIjmFpGLsZQocJUnbiQ Gozet+kngVrInUD8CCAwB0QAeAbuDopop4rsf+Geomgn8xq3LaThOaRE8YNU51Y8MrGY UbvGaXb8e7Pl7XpsoGoli22Jpo7qhHT5Kq/1s0c70YfLqtJIT/sfBNjbGOa78Ag9Qet+ aCOhA6d7yg15amLRwVTB+ORr1ILFOEhpwzvhJLB2ApzriTWaxAqaSxuXpWh1Nx237roX LRbDo2ktJLqjgfFM3JUt17WUr9O1Udh9rxUk5nhawReXLt1O3Wzy11HsBPHvArrbLlkK Abvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751545424; x=1752150224; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=63rlH6bySYZzA/RDOd6qkJFQSzq7jCBtewxn54f/doQ=; b=nxGVU80AYb5BjnUUNF2Wxk+1L7JniKfjTLotpsVYSzOeBgEeC9V6l6J3t/RFG/o/2A uCVVmJ4tk1LpSF5lVHYWXIsvj/UxmefPsh65ujew68CGKGc4SUaf8+Fb565Tn6avUman gWaxFepASQvmVkHBNgKh2h73hbqalSlm+ZLACBlDletrMlcUP6ckOrbmE3iQZC1Wbg87 L28DQzmTgwuEcwH5ow4y4WVaNiQUlkEnTyjTVOevMg+kQ0pJx99Gyw095rKGXMjMputt PRdSeYTrnjIov/E98FGkYFoMHAVhBigNIphB/6s+Q29ETr3RUX+UNlKz35rrOEsXWnMN hGlQ== X-Forwarded-Encrypted: i=1; AJvYcCVvDzLZraWzshc9gWB2I7O0XMq3Ox9kveWyKiO5UXzEarOAQ3cw6gb6WYsUlsKidxLQ2V0CQ7IoikYW@lists.postgresql.org X-Gm-Message-State: AOJu0YwWBYDGELhnhirLpp7bsdTbqMDzN+R9qA/b8dDlZSOXgo7sojhz nR4WUjPoLXpM+l7baojv8HG2AqxvqfjGwO7xc4ooBJLb2cinYbh4PN7JMqpraY6MkYU= X-Gm-Gg: ASbGncuEEBp28nG+VTpTfgsrykYtgcyRwvwidRkqwmolJc4L41UpxPL+0Oy+jTCT6WA 8az8skTf0d2bTCvHwzAf7C+fW8EA+hrBohkGL9tOHgdWLxaYAyBiADwvvHrXG0H+JsHicczuzLo m7yKwL/EXFM5zikVN1s/cXvqlylg8yrF03weq6JFau2rm8F4FJs4uj9e/xUdXyoi2tudey/PERp HXgrpwMTGDlgtnQnwrv1UP5Wt263HEpGJ/oEPYoC0+4Cw/HCJHsgIB+ZhquzL4VmyovxjshjSbH LyyRa4POoay2rRrSQqhW5ztEYxYttGksh8y5rbbNcAY92O/YYor6fyIulxgVTrk/kKlSg6q4Ygg 9IqZIib4+k4cSSw== X-Google-Smtp-Source: AGHT+IGocitUe+OEE8HO3EXuHM/qw4t4X5f3IAyhVj/1oF4PV3sxFVUIjzgTw0+jlnpjoa5koq5hew== X-Received: by 2002:a17:907:3e03:b0:ad5:3a97:8438 with SMTP id a640c23a62f3a-ae3d8cf05abmr277233766b.41.1751545423578; Thu, 03 Jul 2025 05:23:43 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:5e:ea56:ea48:53db:df97:245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae353c6bd2dsm1256574666b.113.2025.07.03.05.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jul 2025 05:23:43 -0700 (PDT) Message-ID: Subject: Re: BUG #18976: -0.0 with float8 will be transformed to 0 in prepare statement but not in normal execution From: Laurenz Albe To: 798604270@qq.com, pgsql-bugs@lists.postgresql.org Date: Thu, 03 Jul 2025 14:23:42 +0200 In-Reply-To: <18976-c1bc92542b90e5e6@postgresql.org> References: <18976-c1bc92542b90e5e6@postgresql.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2025-07-03 at 03:03 +0000, PG Bug reporting form wrote: > The following bug has been logged on the website: >=20 > Bug reference: 18976 > Logged by: Chi Zhang > Email address: 798604270@qq.com > PostgreSQL version: 18beta1 > Operating system: Ubuntu 24.04 and docker > Description: =20 >=20 > The value -0.0 with float8 is transformed to 0 in prepared statements but > remains -0 in normal execution. Although 0 and -0 are numerically equal, > this discrepancy can lead to subtle bugs in certain cases=E2=80=94for exa= mple, when > the value is cast to a VARCHAR, as illustrated below. >=20 > PREPARE prepare_query (float8) AS SELECT CAST($1 AS VARCHAR) =3D > CAST(-0.0::float8 AS VARCHAR); > EXECUTE prepare_query(-0.0); -- f That's not a bug, but a pilot error. If you feed a "float8", the result is= t TRUE: EXECUTE prepare_query(-0.0::float8); ?column?=20 =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90 t (1 row) Yours, Laurenz Albe