postgresql 恢复postgres架构会导致许多语法错误

hwamh0ep  于 2023-11-18  发布在  PostgreSQL
关注(0)|答案(1)|浏览(130)

Repo dump有以下输出

--
-- Name: add_em(integer, integer); Type: FUNCTION; Schema: public; Owner: developer
--
CREATE FUNCTION public.add_em(x integer, y integer) RETURNS integer LANGUAGE sql AS $ $
SELECT
    x + y;

$ $;

ALTER FUNCTION public.add_em(x integer, y integer) OWNER TO developer;

字符串
但是当我运行psql -f试图恢复数据库时,我得到了这个错误

psql:lib/scripts/repo/structure:87: ERROR:  syntax error at or near "$"
LINE 1: ...em(x integer, y integer) RETURNS integer LANGUAGE sql AS $ $

6vl6ewon

6vl6ewon1#

用于美元报价的标记必须遵守未加引号的标识符的规则(除了区分大小写和不允许$之外),因此空格是无效的。

select $a$ test $a$;
 ?column?
----------
  test
(1 row)

select $ $ test $ $;
ERROR:  syntax error at or near "$"
LINE 1: select $ $ test $ $;

字符串

相关问题