Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU2xs-00029L-Cb for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Feb 2023 10:00:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pU2xr-0006cg-0O for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Feb 2023 10:00:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU2xq-0006cX-Lm for pgsql-bugs@lists.postgresql.org; Mon, 20 Feb 2023 10:00:06 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pU2xo-00016T-IO for pgsql-bugs@lists.postgresql.org; Mon, 20 Feb 2023 10:00:06 +0000 Received: by mail-lf1-x134.google.com with SMTP id s20so686625lfb.11 for ; Mon, 20 Feb 2023 02:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=MZOf+PJLVtM/skfUxucb0yIk/ns+mFoO2uVOPJzEMqc=; b=Jw/ojcW88jFmtaifC61UIbyirbQENSkyytlzUjsXfh1pvv29/D4J6vt2T3ynm0SmXi UuOmuYByu5FgUUrxMW05q07WMKAIDhcRKyjKw8PxoXfWblfOLcRGd2lsUocWzVlpqlFr T7185r/tvsR9ykEs2QlLVAsRCQm3wPEUVR/l0ieRAM98Sda03INsqV6VZI2WgAfG7/sy JdnA48HMMKeN+mSlgylLFoZgJxFkNSiGtOT0pSMxOld8mK+tzBLJbVj6Xi5zH90X2yOA bfGlhcCPZFaaFNpDwGKF5tCJpnO5103+isVm+4IKLrv8vwl1Kamqjcb+P/ItvGMq6iMp c4NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MZOf+PJLVtM/skfUxucb0yIk/ns+mFoO2uVOPJzEMqc=; b=5gd0n/ps7UuPFR2xkOjZIW/zA4fHudlsILfzd/LmjkGC0+XFR0OlqjIWThsEmNR1es WG4JTJqOKwewJK6CSULyKoQ9bws7GBVF5xX9jssFtv7QjrLhO4/4X0SsS1+K9Vt9ZSuL JB8g3NC2+yamUx0TXsojocO2xJAGsvpcRWIBNjJuFKA3lzfFBGjBW2CSXha0diY8buj0 r9Q5ELIl4T8RWr6szCOjOfYYCOWDqP1jaaQg7EMigaZgjU0IQrguRtYqMPnJo4e8mmc3 5714dz26uLL/g1bbqnnQgwnZNrzm7Fi8gnf8npNtV0CFdGknmJIgUaG8HfswPUggGIgo Hs+A== X-Gm-Message-State: AO0yUKW82XtPPlNN2ScOucsC7Qq6roNlc/zgjTcKvj3UJKAUSpa5znrl xr9URR3Z9yx53U9Uaj/VBvtlAANuiq4= X-Google-Smtp-Source: AK7set/N+1fNexHot2pS/DAZZT/JeOy5XLZCASHbPyA9Nz6v8UDVp94UijWLu6r7pm0FrD03y81Cxg== X-Received: by 2002:ac2:43a4:0:b0:4d7:ccef:6b52 with SMTP id t4-20020ac243a4000000b004d7ccef6b52mr398712lfl.39.1676887203007; Mon, 20 Feb 2023 02:00:03 -0800 (PST) Received: from [1.0.0.7] ([178.155.5.178]) by smtp.gmail.com with ESMTPSA id x28-20020ac25ddc000000b004d342e1332csm1483796lfq.25.2023.02.20.02.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 02:00:02 -0800 (PST) Message-ID: <18486f0e-cdfa-49b3-c863-bb83bdd8a097@gmail.com> Date: Mon, 20 Feb 2023 13:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: BUG #17795: Erroneous parsing of floating-poing components in DecodeISO8601Interval() To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org References: <17795-748d6db3ed95d313@postgresql.org> <3449142.1676850059@sss.pgh.pa.us> Content-Language: en-US From: Alexander Lakhin In-Reply-To: <3449142.1676850059@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 20.02.2023 02:40, Tom Lane wrote: > PG Bug reporting form writes: >> I've encountered a pair of relatively new anomalies when using ISO-8601 >> intervals. >> >> >> On the whole I think the right fix is to go back to using strtod() >> to parse the whole input string, as we did before e39f99046. This >> results in some inaccuracy if there's more than 15 digits in the >> input, but I don't care enough about that scenario to work harder. This approach seems less fragile to me. All my examples shown before work as expected now. Thanks! >> There are a couple of other places where datetime.c is using strtod() >> to parse what it expects to be a fractional value. I'm inclined to >> just barf if the result is out of range. Maybe we shouldn't back-patch >> that aspect into v15, not sure. I could not find a way to pass the e-notation there. Looking at the callers of the ParseFraction() and DecodeNumberField() I see only DecodeDate(), DecodeDateTime(), DecodeTimeOnly(), and DecodeInterval(). All these functions pass to ParseFraction() and DecodeNumberField() not full "fractional" strings, but fields, that were extracted before. For example, with "SELECT time 'J0.5e1';" there are three fieldsĀ  "j", "0.5", "e1" passed to DecodeTimeOnly(), or with "SELECT interval '1.5e1';" I see fields "1.5" and "e1". (Maybe I miss something.) Also, the comment added makes me wonder, whether ".1e-10" (e.g., in "1.1e-10") can be considered bogus too. I would say so (if we are going to just add a fraction produced by ParseFraction() to some integer part later, we still get the wrong result (for the scientific notation)), and if we want to have a consistent syntax, maybe it's worth to check an input string for 'e'/'E', but if not, then maybe leave it alone. I would prefer the latter for now. Best regards, Alexander