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 <pgsql-general@lists.postgresql.org>
Betreff: Is there a bug in psql? (SELECT ''';)
when I learn the postgres, I try to store the ' into the database,
but something unexpected happend.
postgres=# CREATE TABLE test (str varchar);
CREATE TABLE
postgres=# 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$
postgres=# SELECT ''';
postgres'# exit
Use control-D to quit.
postgres'# \q
Use control-D to quit.
postgres'#
\q
bash-5.1$