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 1m3yBX-00043n-G8 for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Jul 2021 10:01:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3yBV-0007jU-RS for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Jul 2021 10:01:37 +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 1m3yBV-0007jM-Iq for pgsql-bugs@lists.postgresql.org; Thu, 15 Jul 2021 10:01:37 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3yBT-0003mq-54 for pgsql-bugs@lists.postgresql.org; Thu, 15 Jul 2021 10:01:37 +0000 Received: by mail-wm1-x333.google.com with SMTP id m11-20020a05600c3b0bb0290228f19cb433so5685797wms.0 for ; Thu, 15 Jul 2021 03:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=nWP5EEN210daG2DFEkwAX32GTI5yXSgO6XVt/EEttDM=; b=iuww6hU5bnzWOgFbZk4E8QqQuyOXeM/syIJrWEHtgJEaz1lJFm5W9/m+cMpd5OFfYO TnxYCD4X+FeYhr6RBM1sdkhehQ5tNR1Bj42CCHXuGFzPrNUMMFCOZw2OStLXLvLwlOgr RYjSnvVZSWyx2Hdwj/ehOBbSNpubuj7TzgGNRZ89xlDOWIsBO4tLiYoMJ3nnv38qQ/gt ML4qZw0cB9JyoMMlZ+LN5FjhvMINLOt3vqRkLwrl2j6woezSxS7cZSX9/NYISz0xoaPw cEXfpUWilHlsthiFp2dDb8E8ccYnlczfPuq2VmTQw+8kastaXMkE+jAYeXko8/DeHjMw 7Qow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=nWP5EEN210daG2DFEkwAX32GTI5yXSgO6XVt/EEttDM=; b=PAG+kT8vfNEXsA3Dy9KfoAXHJkL5D+/LPzZkBKgOt2NUnZ9SkG92tBHbWZyCKwJisg da+6sHtXcEml8UiBJoQaAjFWVnONJ57lfG9Dv7QHX938dCaLv3zUi9t3YSqD+kr4qwXo aqxK/AKMpEw7GwQXU+Lzac37doU8RTrbzOUUvMiryzK+EAhgGgvO+LF2kgwFiciMaBOI mWUv40qRLihc6AHsNqDUU3PSBAGN5gVLLW7iAx4joPil+Gj7sEzVX50tFC9Ojnju//du GRcsvzqKYlVZ53LFJXQZgaouVpIgsIbfO4UKh54HxXhGIzyn17dZbQrziqZ3L2vP304e fFPA== X-Gm-Message-State: AOAM531B9DqcYEfmfpV59EIxsWxwD7f9wPlLEaos8IEM3akHc9Y5Q4HL /i0DUVe1WUHjObRmAWJBMPJ4DDroiEQDHw== X-Google-Smtp-Source: ABdhPJxsjT4j9CnhqB/UyU7K4rMSTQxAfnILx3F9zkKah83PuH1Nfz8MAf/ddBkbsTMoIQf3Y7lDGg== X-Received: by 2002:a1c:1dd4:: with SMTP id d203mr9545104wmd.28.1626343293802; Thu, 15 Jul 2021 03:01:33 -0700 (PDT) Received: from [192.168.1.144] ([90.163.238.61]) by smtp.gmail.com with ESMTPSA id v15sm4749599wmj.11.2021.07.15.03.01.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jul 2021 03:01:33 -0700 (PDT) Subject: Re: BUG #17109: Fail to evaluate boolean expression properly To: pgsql-bugs@lists.postgresql.org References: <17109-bc19e4c9849e382d@postgresql.org> From: Domingo Alvarez Duarte Message-ID: <88595360-64b9-1a34-743e-d505dffee030@gmail.com> Date: Thu, 15 Jul 2021 12:01:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <17109-bc19e4c9849e382d@postgresql.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk It seems that I fired the trigger to early, although the output of that website (https://extendsclass.com/postgresql-online.html) does shows wrong result when executing the query on other places with different PostgreSQL version the output is the expected one: psql  template1 psql (13.3) Type "help" for help. template1=# select /*NOT*/ 1 BETWEEN -2 and 2, NOT (1 BETWEEN -2 and 2), (/*NOT*/ 1) BETWEEN -2 and 2 template1-# ;  ?column? | ?column? | ?column? ----------+----------+----------  t        | f        | t (1 row) On 15/7/21 11:38, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 17109 > Logged by: Domingo Alvarez Duarte > Email address: mingodad@gmail.com > PostgreSQL version: 11.10 > Operating system: Online at https://extendsclass.com/postgresql-onli > Description: > > When proposing a change to > https://github.com/facebookincubator/CG-SQL/pull/62 people there found > several problems on their project and one of the related to how > parse/evaluate expressions around "BETWEEN" keyword and they created a > simple test case to check it (adapted by me): > > ==== > select /*NOT*/ 1 BETWEEN -2 and 2, NOT (1 BETWEEN -2 and 2), (/*NOT*/ 1) > BETWEEN -2 and 2 > ==== > > Here is the output of PostgreSQL where the second column is not negated (if > column 1 expression is true then "NOT" that expression should return false > ): > ==== > ?column? | ?column? | ?column? > -- | -- | -- > true | true | true > ==== > > Here is the output of sqlite3: > ==== > sqlite3 < "test-between.sql" > 1|0|1 > ==== >