Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNIrX-0007iF-Ct for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2019 15:47:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iNIrU-0005wd-OF for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2019 15:47:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNIrU-0005w6-Ce for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2019 15:47:48 +0000 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNIrR-0004r5-Uq for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2019 15:47:48 +0000 Received: by mail-ot1-x343.google.com with SMTP id s22so17821842otr.6 for ; Wed, 23 Oct 2019 08:47:45 -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=fGC0zWNa7anp5+rN6JEiYe7It7Vwm+Kst2hvc4tzh4s=; b=QyWb8wH5lftGv4Vof/QltY99fd/bT9z8SFKVQtFJ23Yld3cxlxCq0W6xfvdLz1KHs3 WfZ5WZivFxtY/k/hxEs5BrSXFqQHzTWjg/jCOwGvlL7NJINRv2fH7vaZGfKJjCuWO3FU LRvg01X6DE0a1PiDNRzu5vxN29ujkQff1OCBVgbWtTZVjaHWahe7wUvmnyq8gpLXGIgM zZrTdWkbrqpzzH7iHx1+3nVzwC2qxnnI2u8jC9OC86Pv/3BDi2VXKjoA1kmsHm8ZCRLd 4TGxLV0fC5vB4J9nLX4FKh4sDBYPnPkcFO+WUT1IvmpMvMysu2SPJ6ZIIcxj0d8CUvNB h5OQ== 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=fGC0zWNa7anp5+rN6JEiYe7It7Vwm+Kst2hvc4tzh4s=; b=h8Ycj6wtHjC46+vxWnPIm+nxyKFd4ODmCDY55QQkHXmDzcAuefDFo2ngXaEI/Juj0z lvvhPO4n+nIDczKIJPYSPbsIOt0oa3wQNwCZ6alh+IskvdUC7K01MlxdFX6FqkrZH/e/ OC+2ierg4hMyYtJqLsSYUUQSEvYUYmEokgaIC6eN2Lrpq7Z+idwduTMhhnFP0+sePs4+ XRaNIOPIN/L17d+TJAax21EfCcf5NmKVXzPAw6lroonm5k9NuIxelVDOyeutZyR/OrpL cWFOZ995tIPU1NCl6DUJn2lb1bYnXizwcNietQf1m8hozhzlqKiCF9uFYA/+iaso9lMS 8iwQ== X-Gm-Message-State: APjAAAUAHrF1viX4EkAhL7MqkXoJ8ZkBh53tIUl6ZZbua9Xm8BMfnRWo o/rV7MSA7fgjWqpHGxrqQScmJuBBLw+R8g== X-Google-Smtp-Source: APXvYqx7Il+XZyXpPsppYKsvnuYds4zQ1wK2RPuHeFCD/7YEf8QbXi8aVw7wrmMV5aQVVf7dE1vZyQ== X-Received: by 2002:a05:6830:1099:: with SMTP id y25mr7573551oto.113.1571845663610; Wed, 23 Oct 2019 08:47:43 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id r26sm5648912oij.46.2019.10.23.08.47.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2019 08:47:42 -0700 (PDT) Subject: Re: Is this a bug ? To: pgsql-general@lists.postgresql.org References: <6048315C-CE0E-482F-9F48-B300E4D7AC52@aol.com> From: Ron Message-ID: <0e1c9266-80fa-c879-ef10-c585e93e0ae5@gmail.com> Date: Wed, 23 Oct 2019 10:47:42 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <6048315C-CE0E-482F-9F48-B300E4D7AC52@aol.com> 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: Precedence: bulk On 10/23/19 10:42 AM, Ravi Krishna wrote: > We noticed this bug in Redshift. It then occurred to me that this may > very well be a PG bug since Redshift is based on PG. > > Reproduced it in Version 11.5 > > create table bugtest (fld1 char(1)) ; > > insert into bugtest values('a'); > insert into bugtest values('b'); > insert into bugtest values('c'); > insert into bugtest values('d'); > insert into bugtest values('e'); > > select count(*) from bugtest where fld1 in ('a','b','c', > 'd','e'); -> produces 5 as output. > So far so good. > > Now check this: > > select count(*) from bugtest where fld1 in ('a','b','c' > 'd','e'); > > Note the missing comma after 'c'. > > PG takes it a syntactically right SQL and gives 3 as output. > > In SQLServer it errors out SQL Error [102] [S0001]: Incorrect syntax near 'd'. > > Can't believe this bug was never found before. We ended up wasting lot of time to figure this out. Confirmed in 9.6. postgres@haggis:~$ psql psql (9.6.15) Type "help" for help. postgres=# create table bugtest (fld1 char(1)) ; CREATE TABLE postgres=# postgres=# insert into bugtest values('a'); INSERT 0 1 postgres=# insert into bugtest values('b'); INSERT 0 1 postgres=# insert into bugtest values('c'); INSERT 0 1 postgres=# insert into bugtest values('d'); INSERT 0 1 postgres=# insert into bugtest values('e'); INSERT 0 1 postgres=# select count(*) from bugtest where fld1 in ('a','b','c', postgres(# 'd','e');  count -------      5 (1 row) postgres=# select count(*) from bugtest where fld1 in ('a','b','c' postgres(# 'd','e');  count -------      3 (1 row) -- Angular momentum makes the world go 'round.