Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> On 2019-Apr-24, Jan Skydánek wrote:
>> Works (definitely NOT expected):
>> SELECT
>> 'aaa'
>> 'bbb'
>> 'ccc'
>> ; -- result is: 'aaabbbccc'
>>
>> I really hope this behavior is not intentional.
> Actually it's the SQL standard that defines that it must work in exactly
> that way.
Yeah. Quoting from SQL99:
<separator> ::= { <comment> | <white space> }...
<character string literal> ::=
[ <introducer><character set specification> ]
<quote> [ <character representation>... ] <quote>
[ { <separator> <quote> [ <character representation>... ] <quote> }... ]
Syntax Rules
1) In a <character string literal> or <national character string
literal>, the sequence:
<quote> <character representation>... <quote>
<separator> <quote> <character representation>... <quote>
is equivalent to the sequence
<quote> <character representation>... <character
representation>... <quote>
NOTE 47 - The <character representation>s in the equivalent
sequence are in the same sequence and relative sequence as in
the original <character string literal>.
5) In a <character string literal>, <national character string
literal>, <bit string literal>, <binary string literal>, or <hex
string literal>, a <separator> shall contain a <newline>.
Don't ask us, we just implement it.
regards, tom lane