IN List operator , where list of values are over a number of lines

Started by White, Ian Keith7 months ago3 messagesbugs
Jump to latest
#1White, Ian Keith
Ian.White@ncratleos.com

Hi

We have noticed a quirk in the IN list operator where the list of values are over several lines , but some have missing comma separators.
The command should fail, however it executes only returning certain values.

Create table, insert vales, show values , select using IN List
[cid:image001.png@01DC32EB.03FF0420]

First query errors as expected , Second executes with out error! Returning A & F .
[cid:image002.png@01DC32EC.6DCD8B50]

Details of server .
[cid:image004.png@01DC32EC.D2ED7400]

Attached is the sql that I ran

Please investigate

Many Thanks Ian White
Member British Computer Society

[ncr corporation]
Oracle & Postgres Database Administrator & Perfomance Expert.
Based London
Ian.White@ncratleos.com

Attachments:

image001.pngimage/png; name=image001.pngDownload
image002.pngimage/png; name=image002.pngDownload
image004.pngimage/png; name=image004.pngDownload
IN List operator , where list of values are over a number of lines.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document; name="IN List operator , where list of values are over a number of lines.docx"Download
#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: White, Ian Keith (#1)
Re: IN List operator , where list of values are over a number of lines

Hi

st 1. 10. 2025 v 19:50 odesílatel White, Ian Keith <Ian.White@ncratleos.com>
napsal:

Hi

We have noticed a quirk in the IN list operator where the list of values
are over several lines , but some have missing comma separators.

The command should fail, however it executes only returning certain values.

Create table, insert vales, show values , select using IN List

First query errors as expected , Second executes with out error!
Returning A & F .

Details of server .

Attached is the sql that I ran

Please investigate

Many Thanks Ian White

Member British Computer Society

[image: ncr corporation]

Oracle & Postgres Database Administrator & Perfomance Expert.

Based London

Ian.White@ncratleos.com

It is effect of multiline SQL strings

(2025-10-01 20:07:45) postgres=# select 'a' 'hoj';
ERROR: syntax error at or near "'hoj'"
LINE 1: select 'a' 'hoj';
^

but

(2025-10-01 20:08:38) postgres=# select 'a'
postgres-# 'hoj';
┌──────────┐
│ ?column? │
╞══════════╡
│ ahoj │
└──────────┘
(1 row)

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS

Regards

Pavel

Attachments:

image001.pngimage/png; name=image001.pngDownload
image002.pngimage/png; name=image002.pngDownload
image004.pngimage/png; name=image004.pngDownload
#3White, Ian Keith
Ian.White@ncratleos.com
In reply to: Pavel Stehule (#2)
RE: IN List operator , where list of values are over a number of lines

Hi

Thank you for your prompt response most apricated.

I agree it is a bizarre behaviour .
Programmatically I wouldn’t rely on that to do concatenation I would expect a specific concatenation operator to required, so it is obvious to all what is going on !

You live and learn

All my colleagues were baffled by this – so I have updated them.

Many Thanks Ian

From: Pavel Stehule <pavel.stehule@gmail.com>
Sent: 01 October 2025 19:16
To: White, Ian Keith <Ian.White@ncratleos.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: IN List operator , where list of values are over a number of lines

Hi st 1. 10. 2025 v 19: 50 odesílatel White, Ian Keith <Ian. White@ ncratleos. com> napsal: Hi We have noticed a quirk in the IN list operator where the list of values are over several lines , but some have missing comma separators. The command
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi

st 1. 10. 2025 v 19:50 odesílatel White, Ian Keith <Ian.White@ncratleos.com<mailto:Ian.White@ncratleos.com>> napsal:
Hi

We have noticed a quirk in the IN list operator where the list of values are over several lines , but some have missing comma separators.
The command should fail, however it executes only returning certain values.

Create table, insert vales, show values , select using IN List
[cid:image001.png@01DC337F.676EA580]

First query errors as expected , Second executes with out error! Returning A & F .
[cid:image002.png@01DC337F.676EA580]

Details of server .
[cid:image003.png@01DC337F.676EA580]

Attached is the sql that I ran

Please investigate

Many Thanks Ian White
Member British Computer Society

[ncr corporation]
Oracle & Postgres Database Administrator & Perfomance Expert.
Based London
Ian.White@ncratleos.com<mailto:Ian.White@ncratleos.com>

It is effect of multiline SQL strings

(2025-10-01 20:07:45) postgres=# select 'a' 'hoj';
ERROR: syntax error at or near "'hoj'"
LINE 1: select 'a' 'hoj';
^
but

(2025-10-01 20:08:38) postgres=# select 'a'
postgres-# 'hoj';
┌──────────┐
│ ?column? │
╞══════════╡
│ ahoj │
└──────────┘
(1 row)
https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS&lt;https://urldefense.com/v3/__https:/www.postgresql.org/docs/current/sql-syntax-lexical.html*SQL-SYNTAX-STRINGS__;Iw!!D5WlZnHMtQ!U6la6p9C9Hg-Jy5JVv-NIvOb9uWV-usnsRV-OEREVbrows8rbhOkvqtMpnCj_yCiqS96V6267N5LnLRwW-SLuNZm$&gt;

Regards

Pavel

Attachments:

image001.pngimage/png; name=image001.pngDownload
image002.pngimage/png; name=image002.pngDownload
image003.pngimage/png; name=image003.pngDownload