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 1m3yuz-0005BE-3R for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Jul 2021 10:48:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3yuw-0005te-TC for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Jul 2021 10:48:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3yuw-0005tW-J7 for pgsql-bugs@lists.postgresql.org; Thu, 15 Jul 2021 10:48:34 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m3yut-0006wE-UE for pgsql-bugs@lists.postgresql.org; Thu, 15 Jul 2021 10:48:33 +0000 Received: by mail-wr1-x434.google.com with SMTP id l7so7146767wrv.7 for ; Thu, 15 Jul 2021 03:48:31 -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=Qk4Cs9NkCIz76s+W0eOAr9daYijcnugsrFrnkk+P2OY=; b=kK185Au5AVNTl20MmvDHrmnacshv77coYXpMgBlE6Z4Tg6lUBLT/7bZub8XlxaRWpt JOn7h3G3HycUPrHYDBv9WRiEOfLMExiNAbQTUJW673JWBykDRUQ5INwoDUvoWEuv8tDi dbY0ACwSZ7UDx388aw78QACLAlhjTgRiJJPSnAyfYtfu0DvMdKOKmeUZFFi+ttAiDA9F mAPRPU4frkEZ6QvMXltf4J38pVXRmqPQhwKc1df9vnNevSZLfCXNVKMFWPO3EnI2WHHB L1PD0sYDXc+P2PgEgAczlnTYQ4MW/lfd3SvAn5zH/FLQyaxqnjtF+RLm1XW8NdBhovuA I+mg== 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=Qk4Cs9NkCIz76s+W0eOAr9daYijcnugsrFrnkk+P2OY=; b=OHbn2L47ayUS5XDRL6JmLP4mMZfx3qpf+D3EYLkjwG7Q/XhgRsPQy+pgODPZRSziCr ckuET3aMzo2FodzTkrppQ52Mg+JQZsHS5l+E9RaGZ2YoYd9z4iB/7VMKmMkMTb96bMYL XY81q5YW0qLIsWvfrDw8M1G7fHjQDN9/O54QT0nO8963k8F3olP3FNNnTy5UybngKGe1 LKRRMV5fJIwtzz8hqEuJ+Wt7hS4nImDdWgwlmzKCRUWrZjP3zGatcNhiufD5pD9L0AyW H1KSGPkFy5t8yA71bFMECA05Od/VdAzwGCfvYGZ3gFvMvTvuAH1gOe4G+QlN1GvkzFeT z5CA== X-Gm-Message-State: AOAM531PvamBbPGuQNKUzIHXSs29Zzvhq36AagbUduKnfKoC33QqOh9A zdDcJPvaFL29/fk4EXILfJa3chxhqR/Azg== X-Google-Smtp-Source: ABdhPJyD6981c+fcld/sHe0h1NqxlqhUVo10DnzKd21mNSDTF1JkiRqobgq7MYL6a4nkXsiuvqilpg== X-Received: by 2002:a5d:4e4d:: with SMTP id r13mr4681864wrt.224.1626346110614; Thu, 15 Jul 2021 03:48:30 -0700 (PDT) Received: from [192.168.1.144] ([90.163.238.61]) by smtp.gmail.com with ESMTPSA id i12sm5973337wrp.57.2021.07.15.03.48.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jul 2021 03:48:30 -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: Date: Thu, 15 Jul 2021 12:48:28 +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 Looking again at https://extendsclass.com/postgresql-online.html and liasing/naming the columns it produces the expected result, so it's a problem on their website. Sorry by the noise, this issue can be closed. ==== select /*NOT*/ 1 BETWEEN -2 and 2 as col1, NOT (1 BETWEEN -2 and 2) as col2, (/*NOT*/ 1) BETWEEN -2 and 2 as col3 ==== Output: ==== col1    col2    col3 true    false    true ==== 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 > ==== >