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 1oqbD7-0005XP-63 for pgsql-general@arkaria.postgresql.org; Thu, 03 Nov 2022 14:28:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oqbD5-00014O-W6 for pgsql-general@arkaria.postgresql.org; Thu, 03 Nov 2022 14:28:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqbD5-00014F-Gf for pgsql-general@lists.postgresql.org; Thu, 03 Nov 2022 14:28:47 +0000 Received: from mailrelay5-3.pub.mailoutpod2-cph3.one.com ([2a02:2350:5:504::1]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqbD3-0005Fm-4Y for pgsql-general@postgresql.org; Thu, 03 Nov 2022 14:28:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=taljaren.se; s=rsa1; h=content-transfer-encoding:content-type:subject:from:to:mime-version:date: message-id:from; bh=gTBvN4C5RMnWEMuKHx3H9yybR09yJ+a9aWrvApJ8VB0=; b=59GkMvPpjKTCwhEfv9xPD819lAyiHQzV5gpHMwe8/45sUiqbB1JMWd7Ha0MZdSoN4k97lm9aPlaYn rr5WRr+DSTQr6oWgUYXbHFg92ZbvOUEsXcnWPxMwjD8SwTdYN0PHdM5AdHT/m/Ur3AIQtzo6rzX2xh D1YLlr+o0l5ctebJZBM+TRRb0NZ3kH/Ah2aaw0qZwWW2kXB47Sahks/GdJngFMnfUCMJfe0NcmU5/7 aSNv8OBGIzbeLC+JekJJcp+71EvNArBD4TUspglXE7GPQaUyS1ipmLjOicHjTDpvAzYw1bJY6yPqzd XVhCr7jMVURx8jsnbVwe2VxJLdF/P9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=taljaren.se; s=ed1; h=content-transfer-encoding:content-type:subject:from:to:mime-version:date: message-id:from; bh=gTBvN4C5RMnWEMuKHx3H9yybR09yJ+a9aWrvApJ8VB0=; b=ZGOW9A5Rf9SRI2fqLzHTkQK7HaEs2alil7CdHiDq2mXEvJLkYMF11Z9HyQ+1gyBFsWo4u6TeuKNaw 2X0huHHBw== X-HalOne-ID: d0d2d155-5b83-11ed-83d0-2b2c31a40212 Received: from [10.100.124.25] (static-212-247-234-236.cust.tele2.se [212.247.234.236]) by mailrelay5 (Halon) with ESMTPSA id d0d2d155-5b83-11ed-83d0-2b2c31a40212; Thu, 03 Nov 2022 14:28:43 +0000 (UTC) Message-ID: <32b7cafd-e649-5478-017d-766036a2afbd@taljaren.se> Date: Thu, 3 Nov 2022 15:28:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: pgsql-general From: Post Gresql Subject: pg_restore error on function Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello I first successfully ran pg_dump -U postgres -b -E UTF8 -f my_dump --format=custom -n my_schema --no-owner -v my_db but then pg_restore --single-transaction -v -U postgres -O -e -d my_other_db my_dump failed with pg_restore: connecting to database for restore pg_restore: creating FUNCTION "my_schema.update_b()" pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 7142; 1255 8618854 FUNCTION update_b() previous_owner pg_restore: [archiver (db)] could not execute query: ERROR: schema my_schema" does not exist Command was: CREATE FUNCTION "my_schema".update_b() RETURNS void LANGUAGE plpgsql AS $$ BEGIN PERFORM pg_advisory_xact_lock(1); INSERT INTO ...; END; $$; This is PG version 10.19 Is there a solution for this (apart from upgrading to a newer PG version)? The only workaround I can think of is to dump in plain text and then edit the dump file.