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 1pIAFa-00076s-Fm for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Jan 2023 15:21:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pIAFZ-000810-2e for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Jan 2023 15:21:17 +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 1pIAFY-0007vb-MR for pgsql-bugs@lists.postgresql.org; Wed, 18 Jan 2023 15:21:16 +0000 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pIAFR-0008O3-Po for pgsql-bugs@lists.postgresql.org; Wed, 18 Jan 2023 15:21:15 +0000 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-4f7b55575f7so9579347b3.11 for ; Wed, 18 Jan 2023 07:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=americanefficient-com.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qVcySdwVjK3GeGSFx8joYv/jSrU3SFiQxw6KC/IRPdE=; b=VPdCMl9dLynBV+SS33AttjS3qnUEs6FULsjdws0BEXMkS0A71GEKn7fzqLwqMVXADQ dp6EoRdguPOXHgxIVbxRevgHNL9/dnFmt6Vxik/VR95WNX1XnkfizPbX4cqa88Ows3f+ tEU+g0remogSMwzOIznk7PWsHWHA6CeCB7+jeG7S051psZcF6UDGd8qID3l+evMDTiWi aXaaRyOf4qU8JSP9aQo/MI0EuuHnp4nWDyW2GsMwQbfcBof3OulBuTLKfTEnHgwYYFAa 13tC88U91cIMLAPv/Xc26FWXLKqOxw50a2IJJ/kOPZMKBaQAyr+/BFZJBRU80xLQAn9u 28BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qVcySdwVjK3GeGSFx8joYv/jSrU3SFiQxw6KC/IRPdE=; b=HKU5n6sIgXCDXiekV+3YujnHZsTwEz6bN+JCh2UPp+D2a3KBovQ9MULdZdOPgkO/gX 3fxDMJoOhsNDwZcf7wr6XS7pBJchZt0D68n6ad1lFknYeuAnqtgT51jV5o4RysEVbPBF WDkzoTWRUtOAf9Z/Tz0+1XjbBLFSZDIXiYAdXWuY0vkKZj+CSsiZl6gp9Bpbx7Jghv4p 5fKJVrJR9qPI2qdP0V1Eez0FSF4RC0VNnKwY9noTfW6cC/koK0C9955MqXayjw4Xs1k8 eLlWZoFnoQiCjCae0O8CVPTrIhynMeU26b8+K5Q4D7WE1n24CNtMDT7r+I2d2PZM6dmN nxWA== X-Gm-Message-State: AFqh2kp0kJFkMlNrztS4F8BWPQjrz8dn4q0o3TPF7bJbZ7R+50l27NOK xjA2iC2coLIPX0eIQKacBs3cjExEOhZmIEZs X-Google-Smtp-Source: AMrXdXt3dp4atloThWOvwlJCF8o1LDWZKXZEcjiMAoDoAVk/ztWb5zxdVpEPKUkdRw6UFwf8Mm8uqw== X-Received: by 2002:a81:cd6:0:b0:4b2:b15e:265a with SMTP id 205-20020a810cd6000000b004b2b15e265amr5901444ywm.30.1674055268869; Wed, 18 Jan 2023 07:21:08 -0800 (PST) Received: from smtpclient.apple ([24.211.149.51]) by smtp.gmail.com with ESMTPSA id t5-20020a05620a450500b006fa8299b4d5sm22610165qkp.100.2023.01.18.07.21.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jan 2023 07:21:08 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Subject: Re: IN clause behaving badly with missing comma and line break From: Philip Semanchuk In-Reply-To: Date: Wed, 18 Jan 2023 10:20:57 -0500 Cc: pgsql-bugs@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <1E97D89B-3195-4A55-918B-2C1152EEE497@americanefficient.com> References: To: Roman Cervenak X-Mailer: Apple Mail (2.3731.300.101.1.3) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jan 18, 2023, at 2:51 AM, Roman Cervenak = wrote: >=20 > Hello, > if you use IN() clause (I've tested in WHERE and CASE) and you forget = comma between values, it is syntax error (correct behaviour). But if = there is newline between those two values, suddenly it is not syntax = error (query will run successfully), and all values are simply ignored.=20= >=20 > Examples: >=20 > WITH sample AS (SELECT 'c' AS t) SELECT CASE WHEN t IN ('a','b') THEN = 1 WHEN t IN ('c'=20 > 'd') THEN 2 END FROM sample; >=20 > WITH sample AS (SELECT 'c' AS t) > SELECT * FROM sample WHERE t IN ('a'=20 > 'c=E2=80=99); As David said, this is expected behavior, although it=E2=80=99s subtle = and easy to overlook. We=E2=80=99ve adopted a formatting standard that = helps us to avoid surprises due to missing commas. We put one string = literal on each line and place the commas all in the same column with a = significant amount of white space to the left of the commas. With this = safeguard in place, it=E2=80=99s very easy to spot a missing comma. WHERE t IN ('a' , 'foo' , 'bar' , ) =20 Cheers Philip=