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 1iNJ4E-0008MD-U5 for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2019 16:00:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJ4D-0001LC-LR for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2019 16:00:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNJ4D-0001L3-5E for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2019 16:00:57 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iNJ4A-0003Uo-8M for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2019 16:00:55 +0000 Received: by mail-wm1-x343.google.com with SMTP id v6so3200880wmj.0 for ; Wed, 23 Oct 2019 09:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ocado.com; s=google; h=reply-to:subject:to:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Osx6Rp/bx3PD6CMZ/jwdOu1TiFKh5vp2GVU7KoE+zcY=; b=Wmi7ojlLwegRuWQ6sxx6utGHDW8WTV4g5FB13QQgAau9cpM8iEGTObNKlrP2LoFgjX S1L8ZPgfXX2PjRx0rdPjzFvSjtfGZ2+GsK6V8Ojm0r1dBAYR3PJSRKl3tRIDhApQnu5c BKwjv10tfPIKf1HoEdYtrKSbIGGuaW9A5535C0iCZs3FvyGecobBp9QqpLhjtEXLhEPh HoQBRHd4UhROY1g4GSf/m0fsm2649kibbKTdvvDNeKiZgpziKmJWuDHjlUg5BgeX/Ujq P5qs53tlgVFdWwEU6dD+ww86JW3Kz/oLyNah+6pJZItCdB0PWyNlAYymAEcdPZ505e1B RFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Osx6Rp/bx3PD6CMZ/jwdOu1TiFKh5vp2GVU7KoE+zcY=; b=HN/CGG17+w/YCX8UMw7cAfyLAxbo/nlrYsutCt0mPu1h02mc8h1UnR9h6urPTsNqJa K3/RWRulM0VSO2rW+vxDqMJxbfm2V5E0EfcB/qOXZpXgb+UczAJNEck8FwNuz4hjNWPb ro6ZAnOAoSgV6iJtIRHG7HSqzP74RIu5IX+uPdWZvms9E0nV4SkFj93l46WcwX5xF+T2 qadWVNw22qpF2piL61zqyTSDpnM1/BtV20aP+OrdekKT7cgl0aX1qyhvCKNARcGBaySM nl9H+dcFFiZsdnEndRwsN9ipc+h0e3LOxAjW7Ws4mTsHnEfUERFqBrSQrIEks81R4tvo euEw== X-Gm-Message-State: APjAAAU7JQAHEw3vm006DzAxNjNkjBDSV2ilWC1z0Fuag1PZtj9MS+fH STkAO+GOXPhz1T7ZRzzP/njG2uZSY5d2eyy49p7OHAC9w27Wd/7xxDDiMRN03SjYNH88dyHBMPu ferPLM3yh82SnHC3X500kWp+kZHgaYg== X-Google-Smtp-Source: APXvYqyOH5Q3aWUCAL0ybj8UPQ2Kef57ffOpdI7uEj3Wz/4f9a3W1T+XpfS6Ok+QnV1+3ICUjvefew== X-Received: by 2002:a1c:1d41:: with SMTP id d62mr607913wmd.32.1571846451679; Wed, 23 Oct 2019 09:00:51 -0700 (PDT) Received: from [10.62.14.68] ([91.206.1.124]) by smtp.gmail.com with ESMTPSA id 74sm32968397wrm.92.2019.10.23.09.00.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Oct 2019 09:00:51 -0700 (PDT) Reply-To: f.venchiarutti@ocado.com Subject: Re: Is this a bug ? To: pgsql-general@lists.postgresql.org References: <6048315C-CE0E-482F-9F48-B300E4D7AC52@aol.com> <9df3ba0d-974d-f13d-ec91-bc22c3ab362b@gmail.com> From: Fabio Ugo Venchiarutti Organization: Ocado Technology Message-ID: <9895e42e-df0d-d436-1191-dacce9c180c0@ocado.com> Date: Wed, 23 Oct 2019 17:00:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <9df3ba0d-974d-f13d-ec91-bc22c3ab362b@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 23/10/2019 16:55, Ron wrote: > On 10/23/19 10:51 AM, Geoff Winkless wrote: >> On Wed, 23 Oct 2019 at 16:42, Ravi Krishna wrote: >> >>> select count(*) from bugtest where fld1 in ('a','b','c' >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '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=20 >>> near 'd'. >>> >>> Can't believe this bug was never found before.=C2=A0 We ended up wastin= g=20 >>> lot of time to figure this out. >> Simplify: >> >> select 'a' >> db-# 'b'; >> =C2=A0 ?column? >> ---------- >> =C2=A0 ab >> (1 row) >> >> This is not a bug. >> >> https://www.postgresql.org/docs/9.2/sql-syntax-lexical.html >> >> Two string constants that are only separated by whitespace with at >> least one newline are concatenated and effectively treated as if the >> string had been written as one constant. >=20 > Then -- since the 'e' is separated from 'd' by a comma, the result=20 > should be "4", not "3". >=20 > No doubt: it's a bug, no matter what the Pg devs say. >=20 Does any record in your test table contain the concatenated 'cd' in=20 "fld1"? If not, it's working as per specification & documentation. I can agree that this sounds like one of those idiosyncratic parts of=20 the ANSI specification that exist only for compatibility with some=20 ancient practice, but this behaviour is documented. BTW, can parser behavior be affected by settings this early? A GUC setting disabling this madness would make sense IMHO... --=20 Regards Fabio Ugo Venchiarutti OSPCFC Network Engineering Dpt. Ocado Technology --=20 Notice:=20 This email is confidential and may contain copyright material of=20 members of the Ocado Group. Opinions and views expressed in this message=20 may not necessarily reflect the opinions and views of the members of the=20 Ocado Group. If you are not the intended recipient, please notify us=20 immediately and delete all copies of this message. Please note that it is= =20 your responsibility to scan this message for viruses. References to the=20 "Ocado Group" are to Ocado Group plc (registered in England and Wales with= =20 number 7098618) and its subsidiary undertakings (as that expression is=20 defined in the Companies Act 2006) from time to time. The registered office= =20 of Ocado Group plc is Buildings One & Two, Trident Place, Mosquito Way,=20 Hatfield, Hertfordshire, AL10 9UL.