Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WwjrZ-0003IV-Nm for pgsql-docs@arkaria.postgresql.org; Tue, 17 Jun 2014 03:15:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WwjrZ-0001EO-7F for pgsql-docs@arkaria.postgresql.org; Tue, 17 Jun 2014 03:15:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WwjrX-0001EH-Ul for pgsql-docs@postgresql.org; Tue, 17 Jun 2014 03:15:08 +0000 Received: from mail-la0-x22c.google.com ([2a00:1450:4010:c03::22c]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1WwjrT-0003vJ-Jw for pgsql-docs@postgresql.org; Tue, 17 Jun 2014 03:15:06 +0000 Received: by mail-la0-f44.google.com with SMTP id ty20so1521062lab.17 for ; Mon, 16 Jun 2014 20:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=/j6ZZnystJvfHCU4G19lczVG/b8fhV7SydmpC8SpFVg=; b=L5TLoNwvQ0omuI8j+rXOxYt+5cNBArIV3lgTV+ZAeGkx0Vhy+WHwcIIKnpRzVcM+kz vVnNB6QElISMmQjzCJTUDKwcshAs6IpcvLttpRxmI2d2WjEt9B9TfH3AjKFwC1XswHFa Kh29irjpObay7g8RNS9P5c7sA1s6pUBrZX+owDEDq1MPQFAdTzbY9FRHrzBMNWDSvWw1 xfuHL3TjTQRLv5ZJBca4jkq5SALKsLToQ4811OerBEcC5qdc2rBWc96OM5v22AkQxYmG lYY4iO00qlZGYWyy+nbgwqUEuisNsZg+tR6eLLfaf4d+A9TFj2Sww+64x5JfJ5frNGm9 qr1Q== X-Received: by 10.112.73.234 with SMTP id o10mr15436182lbv.41.1402974900102; Mon, 16 Jun 2014 20:15:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.9.133 with HTTP; Mon, 16 Jun 2014 20:14:40 -0700 (PDT) From: =?UTF-8?Q?S=C3=A9rgio_Saquetim?= Date: Tue, 17 Jun 2014 00:14:40 -0300 Message-ID: Subject: Lexical Structure - String Constants To: pgsql-docs@postgresql.org Content-Type: multipart/alternative; boundary=14dae94739098cac0104fbff8c49 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --14dae94739098cac0104fbff8c49 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, I'm trying to build in Java a SQL lexer/parser, compliant with PostgreSQL 9.3, from scratch as a hobby project and reading chapter 4, section 4.1 ( http://www.postgresql.org/docs/9.3/interactive/sql-syntax-lexical.html) and I've noticed a few things I thought I should mention: In section 4.1.2.1, the following text introduces us to SQL's bizarre multiline/multisegment split style: "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." The text does not mention if comments are allowed between segments, so I've run a few tests on PSQL (PostgreSQL 9.3.4): version ---------------------------------------------------------------------------= --------------------------- PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-16ubuntu6) 4.8.2, 64-bit (1 row) postgres=3D# SELECT 'a' 'b'; ?column? ---------- ab (1 row) postgres=3D# SELECT 'a' --comment 'b'; ?column? ---------- ab (1 row) So far everything worked, but I've got different results with C style block comments: postgres=3D# SELECT 'a' /*comment*/ 'b'; ERROR: syntax error at or near "'b'" LINE 2: 'b'; So line style comments (--) are accepted between segments but not C style block comments (/* */). Do you think this difference in behavior should me mentioned in the docs? I've also noticed that in section 4.1.2.6, the following statement: "At least one digit must follow the exponent marker (e), if one is present." As I've understood the statement, I think it says that the following instruction should not be valid because the exponent marker is not followed by at least one digit, but the expression is successfully evaluated: postgres=3D# SELECT 10e; e ---- 10 (1 row) That said, I live in Brazil and English is not my first language so I may be mistaken, but I thought I should bring this to this list. Regards, S=C3=A9rgio Saquetim --14dae94739098cac0104fbff8c49 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I'm trying to build in Java a SQL lexer/parser, compl= iant with PostgreSQL 9.3, from scratch as a hobby project and reading chapt= er 4, section 4.1 (http://www.postgresql.org/docs/9.3/interactive/s= ql-syntax-lexical.html) and I've noticed a few things I thought I s= hould mention:

In section 4.1.2.1, the following text introduc= es us to SQL's bizarre multiline/multisegment split style: "Two string cons= tants that are only separated by whitespace=C2=A0with at least one= newline=C2=A0are concatenated and effectively treated as if the string had b= een written as one constant."

The text does not mention if comments are allowed betwee= n segments, so I've run a few tests on PSQL (PostgreSQL 9.3.4):<= /font>

=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=A0version =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
<= div style>----------------= ---------------------------------------------------------------------------= -----------
=C2=A0PostgreSQ= L 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-16ubuntu= 6) 4.8.2, 64-bit
(1 row)

postgres=3D# = SELECT 'a'
'b';
=C2=A0?column?= =C2=A0
----------
=C2=A0ab
(1 row)<= /div>

postgres=3D# SELECT 'a' --= comment
'b';
=C2=A0?column?=C2=A0
----------
=C2=A0ab
(1 row)

So far every= thing worked, but I've got different results with=C2=A0C style block comments:

<= font color=3D"#000000" face=3D"courier new, monospace">postgres=3D# SELECT 'a' /*comment*/
'b';
ERROR: =C2=A0syntax error at or near= "'b'"
LINE 2: 'b';=

So line style comments (--) are acc= epted between segments but not C style block comments (/* */). Do you think= this difference in behavior should me mentioned in the docs?

I've also noticed that in section 4.1.2.6, = the following statement: "At least= one digit must follow the exponent marker (e), if one is present."

As I've understood the statement, I think it says tha= t the following instruction should not be valid because the exponent marker= is not followed by at least one digit, but the expression is successfully = evaluated:=C2=A0

<= font color=3D"#000000" face=3D"courier new, monospace">postgres=3D# SELECT 10e;
=C2=A0e =C2=A0
=
----
=C2=A010
(1 row)

That said, I live in Brazil and English is not my first language = so I may be mistaken, but I thought I should bring this to this list.

Regards,

S=C3=A9rgio Saquetim


--14dae94739098cac0104fbff8c49--