Just found this:
createdb zzz
createlang plpgsql zzz
psql zzz
create function xxx() returns integer as
$$ begin return 1; end; $$
language plpgsql;
\q
pg_dump -Fc zzz > zzz.bck
dropdb zzz
createdb zzz
createlang plpgsql zzz
pg_restore --function="xxx()" -d zzz zzz.bckresults in 'unterminated dollar-quoted string' errors.
Doing:
pg_restore --function="xxx()" zzz.bck > zzz.sqlthen running the sql file, works fine.
The statements that are sent to the backend (using log_statements) by pg_restore include the comment strings. Not sure if this is relevant.
The sql is:
-- -- PostgreSQL database dump --
SET client_encoding = 'LATIN1'; SET check_function_bodies = false;
SET search_path = public, pg_catalog;
-- -- Name: xxx(); Type: FUNCTION; Schema: public; Owner: birds --
CREATE FUNCTION xxx() RETURNS integer
AS $$ begin return 1; end; $$
LANGUAGE plpgsql;
ALTER FUNCTION public.xxx() OWNER TO birds;
-- -- PostgreSQL database dump complete --
The error log is:
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement: --
-- PostgreSQL database dump
--SET client_encoding = 'LATIN1';
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement: SET check_function_bodies = false;
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement: SET search_path = public, pg_catalog
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement:
--
-- Name: xxx(); Type: FUNCTION; Schema: public; Owner: birds
--
CREATE FUNCTION xxx() RETURNS integer
AS $$ begin return 1;
2004-08-12 01:38:48 EST<zzz,birds>: ERROR: unterminated dollar-quoted string at or near "$$ begin return 1;" at character 115
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement: end;
2004-08-12 01:38:48 EST<zzz,birds>: WARNING: there is no transaction in progress
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement: $$
LANGUAGE plpgsql;
2004-08-12 01:38:48 EST<zzz,birds>: ERROR: unterminated dollar-quoted string at or near "$$
LANGUAGE plpgsql;" at character 2
2004-08-12 01:38:48 EST<zzz,birds>: LOG: statement: ALTER FUNCTION public.xxx() OWNER TO birds;
Not sure I see the problem; I can only guess it may relate to the whole comments being passed.
Running the extracted sql in psql gives the following log:
2004-08-12 01:45:02 EST<zzz,birds>: LOG: statement: SET client_encoding = 'LATIN1';
2004-08-12 01:45:02 EST<zzz,birds>: LOG: statement: SET check_function_bodies = false;
2004-08-12 01:45:02 EST<zzz,birds>: LOG: statement: SET search_path = public, pg_catalog;
2004-08-12 01:45:02 EST<zzz,birds>: LOG: statement: CREATE FUNCTION xxx() RETURNS integer
AS $$ begin return 1; end; $$
LANGUAGE plpgsql;
2004-08-12 01:45:02 EST<zzz,birds>: LOG: statement: ALTER FUNCTION public.xxx() OWNER TO birds;
----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 03 5330 3172 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp.mit.edu:11371 |/
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
