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 1oqbRI-0006F3-QL for pgsql-general@arkaria.postgresql.org; Thu, 03 Nov 2022 14:43:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oqbRH-0004XP-NF for pgsql-general@arkaria.postgresql.org; Thu, 03 Nov 2022 14:43:27 +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 1oqbRF-0004XG-Rc for pgsql-general@lists.postgresql.org; Thu, 03 Nov 2022 14:43:27 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqbRC-0007GZ-7G for pgsql-general@postgresql.org; Thu, 03 Nov 2022 14:43:24 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 5E3423200940; Thu, 3 Nov 2022 10:43:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 03 Nov 2022 10:43:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1667486598; x= 1667572998; bh=5lZ3jL+d5ftum75uSjPZvAlQBRwVq1dAN3RyYyiy+CM=; b=U 7yEed9sOuzIrGFtIOBRLPYyhs6R25tUhkTmWN2FT4h8UUIXpx9LNsu2ETqg9Yps9 wxvkh3CcMiUAAcXyAZdokY4HAN9BHZzs91+L8JZVDS1R/S23HcpXuVjy9qZDKdOI Wg6WTFQNw+9w5Y2i0+6CXZ43VFSPJf3MsDIyyNY12swXOnaPtKhhXiGsdsAlPX3P dmrL1N6wWW34xnGRI85eOSU2HFhWrLteCR/3XOwItVAZ2UEJ1DGJA0s9T+lzn1sW rTbCJ6cBiy9POpNaxuK8l75og07goKy1A2dkfJMth87XC/5FTaWGEP59m6avKf9T ZyDkepS5Z80+I9AGywpIw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1667486598; x=1667572998; bh=5 lZ3jL+d5ftum75uSjPZvAlQBRwVq1dAN3RyYyiy+CM=; b=mzuYdkuRthD5UrXvP x6NtaZ8LHsSxBX2UcrhwvB5U+9MeApZKDoXfk5g5wsVJqn4EACnqo3kSlAcNTV3v MpcNPjfoKu86H7WfWbyOKCjHayBC0ysnpHN6f2TObCMi1mWu5032KjEYo4KqXywm F1TfWqiEcfqtgjhGp/SXNZhhSNXzIXqv1o/04plB+XAU0Dw7Gi+KmjVQcig+AyE7 iEM7fjsIK2a4YIkdp118mPxZGMkx4xqRb7wRMIIF2XeOmjmuXEcxWnW6fRXdXX2r vyTgP+fevJheKrmgL4Ui0abOPo31uf2Kz6efA6H/6QDYoT9r1/fFik+yETKFxJCh WsTFw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudelgdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepudfgueelgeevfffhgeeljeehhfettdegieelgefgheef ffefveegjedtueetffdtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Nov 2022 10:43:18 -0400 (EDT) Message-ID: <70b322b5-74dc-73db-f0b5-c8eaadd2570a@aklaver.com> Date: Thu, 3 Nov 2022 07:43:17 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: pg_restore error on function To: Post Gresql , pgsql-general References: <32b7cafd-e649-5478-017d-766036a2afbd@taljaren.se> Content-Language: en-US From: Adrian Klaver In-Reply-To: <32b7cafd-e649-5478-017d-766036a2afbd@taljaren.se> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/3/22 07:28, Post Gresql wrote: > 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)? Was there another error before this? Did the -v show the schema my_schema being created? > > The only workaround I can think of is to dump in plain text and then > edit the dump file. > > -- Adrian Klaver adrian.klaver@aklaver.com