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 1q4GBY-0006sz-Bu for pgsql-general@arkaria.postgresql.org; Wed, 31 May 2023 07:23:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q4GBX-0002oM-7S for pgsql-general@arkaria.postgresql.org; Wed, 31 May 2023 07:23:55 +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 1q4GBW-0002oD-N7 for pgsql-general@lists.postgresql.org; Wed, 31 May 2023 07:23:54 +0000 Received: from mx01-sz.bfs.de ([194.94.69.67] helo=mx02-sz.bfs.de) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q4GBT-002qsl-DE for pgsql-general@lists.postgresql.org; Wed, 31 May 2023 07:23:53 +0000 Received: from SRVEX01-MUC.bfs.intern (unknown [10.161.90.31]) by mx02-sz.bfs.de (Postfix) with ESMTPS id 2870720303 for ; Wed, 31 May 2023 09:23:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bfs.de; s=dkim201901; t=1685517827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nyqKkMn6InrMnT62CoOhRtsyAzJTiSZFbQYpKtDpufw=; b=C+dWXg7ay9RhdOqAmJBMPZnxi++OY3+BDCVE0uIUI6UXVE0fqJW8UqzLo9PV7ypOWLGDZM 11rpCwqPR8ybqmphV7uzK0NPfZa3j0Y/8es3YUEyq6lBrFW1aQnHbe0Qclc8E9qflGnxrF G8d3mIC9YiFo7kopJSo7+sESQQ+Ygt4pA24JrEOLp63TtMriaCZD9nJga/xC8s9t/iM0m5 R4EjKTnERTXJXVp85cT1ugXWDWdnIWe2RBVVEk/wgUDiRCshh5FN539Qq+PkVLNd8mPsj5 zx4EMLwSeivTJ9P0vlaDZYY7YUPVDPYrr/5W7bPLM1PkVhxsJD/pT7u6dQnNpA== Authentication-Results: mx02-sz.bfs.de; none Received: from SRVEX01-MUC.bfs.intern (10.161.90.31) by SRVEX01-MUC.bfs.intern (10.161.90.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Wed, 31 May 2023 09:23:46 +0200 Received: from SRVEX01-MUC.bfs.intern ([fe80::e8ba:5ab1:557f:4aad]) by SRVEX01-MUC.bfs.intern ([fe80::e8ba:5ab1:557f:4aad%5]) with mapi id 15.01.2507.023; Wed, 31 May 2023 09:23:46 +0200 From: Marco Lechner To: pgsql-general Subject: AW: Is there a bug in psql? (SELECT ''';) Thread-Topic: Is there a bug in psql? (SELECT ''';) Thread-Index: AQHZk4/7cEZaYC/hK0+nzR5eUcU+jK9z+kqQ Date: Wed, 31 May 2023 07:23:46 +0000 Message-ID: <9553ca9840a24e1ba215cf970b98a1f5@bfs.de> References: In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.128.70] Content-Type: multipart/alternative; boundary="_000_9553ca9840a24e1ba215cf970b98a1f5bfsde_" MIME-Version: 1.0 X-Spam-Status: No, score=-18.00 X-Spamd-Result: default: False [-18.00 / 7.00]; WHITELIST_LOCAL_IP(-15.00)[10.161.90.31]; BAYES_HAM(-3.00)[99.99%]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCVD_NO_TLS_LAST(0.10)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FROM_EQ_ENVFROM(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; ARC_NA(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_SIGNED(0.00)[bfs.de:s=dkim201901]; HAS_XOIP(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SUBJECT_HAS_QUESTION(0.00)[] List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_9553ca9840a24e1ba215cf970b98a1f5bfsde_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable You have to mask the single quote: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-= CONSTANTS Von: Wen Yi <896634148@qq.com> Gesendet: Mittwoch, 31. Mai 2023 09:17 An: pgsql-general Betreff: Is there a bug in psql? (SELECT ''';) Hi team, when I learn the postgres, I try to store the ' into the database, but something unexpected happend. postgres=3D# CREATE TABLE test (str varchar); CREATE TABLE postgres=3D# INSERT INTO test values ('''); postgres'# SELECT * FROM test; postgres'# exit Use control-D to quit. postgres'# \q Use control-D to quit. postgres'# \q bash-5.1$ And I do another test postgres=3D# SELECT '''; postgres'# exit Use control-D to quit. postgres'# \q Use control-D to quit. postgres'# \q bash-5.1$ Is there a bug in psql? Yours, Wen Yi --_000_9553ca9840a24e1ba215cf970b98a1f5bfsde_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

You have to mask the single quote:

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-S= YNTAX-CONSTANTS

 

Von: Wen Yi <896634148@qq.com>
Gesendet: Mittwoch, 31. Mai 2023 09:17
An: pgsql-general <pgsql-general@lists.postgresql.org>
Betreff: Is there a bug in psql? (SELECT ''';)

 

Hi team,

when I learn the postgres, I try to store the ' into= the database,

but something unexpected happend.

 

postgres=3D# CREATE TABLE test (str varchar);
CREATE TABLE
postgres=3D# INSERT INTO test values (''');
postgres'# SELECT * FROM test;
postgres'# exit
Use control-D to quit.
postgres'# \q
Use control-D to quit.
postgres'#
\q
bash-5.1$

 

And I do another test

 

postgres=3D# SELECT ''';
postgres'# exit
Use control-D to quit.
postgres'# \q
Use control-D to quit.
postgres'#
\q
bash-5.1$

 

Is there a bug in psql?

 

Yours,

Wen Yi

 

--_000_9553ca9840a24e1ba215cf970b98a1f5bfsde_--