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 1oqbTK-0006KW-QZ for pgsql-general@arkaria.postgresql.org; Thu, 03 Nov 2022 14:45:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oqbTJ-0001N5-P5 for pgsql-general@arkaria.postgresql.org; Thu, 03 Nov 2022 14:45:33 +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 1oqbTJ-0001Mv-ER for pgsql-general@lists.postgresql.org; Thu, 03 Nov 2022 14:45:33 +0000 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oqbTE-0007Id-UE for pgsql-general@lists.postgresql.org; Thu, 03 Nov 2022 14:45:32 +0000 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-13bd19c3b68so2378915fac.7 for ; Thu, 03 Nov 2022 07:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=7HiGAMstCqyKkpFQemI9akNyazgK0Ks4Cdjk5KP+JMQ=; b=jRKmaTeaIsZknuBlYykDNsYlP35ITVVgw5sBA4tMah14nm7Dtwv1tpPgL7bPodstQc RABVvHWRK/xLMz0tVCpcxt1hd/xSbAuN67Ol7dVWhccEHUleAYvqOdHqCfgoH9Ovy+DA 8JFI2E4TZh4amZ+Oy3UGgHyjBh1PA2WLjUc/0NfqnQt+nWINKoi+qF92vnkr6Mim/2Tw DxuxBcuXgbrUQfn9idrju14+GbTkwYG6S+Qna9fBCVkDnZjS38G1Bb4ePnFLFojA99/Y xJSByqaubS/pJ5F377z2i1oz65GLa6/dmD4gIxqMacTAsswdcR3NNcwFSOQJQZ+c9iSu 8G/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=7HiGAMstCqyKkpFQemI9akNyazgK0Ks4Cdjk5KP+JMQ=; b=OJLyrut8qEi9ScT3Igs56TZ1jHgJiQbNKfN5m8bOvPphEZqKRYCQQuVY4Osx5+1zJb n5LX8T5sNc6Pjr7bkOlaSCnnMDfO+QQkrM69Ok1HESNW/gm3WVATCZVhiYTdqYfkwg5K 1HbgSeom3Y8tZwK4UjeMDezIiA1bDyxv69+KvsdT6IkW2nmaOEQ0mgVRDSaLAzNzB+Vj Lb53nsRAEoF/ctnm2uXONvlHBNZHgHLDcGxjmFrgNd+wdVwCd4fzvGK9336rSPNVh62X noG5lJtu5ks4ZzfKJV3rmr9Oyqjlxg2Yuv789b5P4KDCtIbwBJroZxU4zuJxymtOLKaY HBYA== X-Gm-Message-State: ACrzQf3QPAx5/gxZez9TCkwh/mCLnID2ylMdgTg0igseGCVTXy6NxalQ YjK0B/llZce8tBsAwP7rS94BnwBCS+Y= X-Google-Smtp-Source: AMsMyM4GU0hTrG3LCDrTiY2LNCI7FVKCWKLPF5jN1dOkYcHc77fnVqhdA/9wVzYirP0FunZL/K50Hg== X-Received: by 2002:a05:6870:70a8:b0:131:9591:3eec with SMTP id v40-20020a05687070a800b0013195913eecmr28275664oae.100.1667486727901; Thu, 03 Nov 2022 07:45:27 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id e1-20020a056870c0c100b0013191fdeb9bsm451628oad.38.2022.11.03.07.45.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 07:45:27 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------GGpZ00iBbuiimOEtj51rcEbf" Message-ID: <6a033389-4f9e-6427-b9e5-e5284a8cfabf@gmail.com> Date: Thu, 3 Nov 2022 09:45:26 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: pg_restore error on function Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <32b7cafd-e649-5478-017d-766036a2afbd@taljaren.se> From: Ron In-Reply-To: <32b7cafd-e649-5478-017d-766036a2afbd@taljaren.se> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------GGpZ00iBbuiimOEtj51rcEbf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/3/22 09: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)? What was the *complete* pg_dump command? -- Angular momentum makes the world go 'round. --------------GGpZ00iBbuiimOEtj51rcEbf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/3/22 09: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)?

What was the complete pg_dump command?

--
Angular momentum makes the world go 'round.
--------------GGpZ00iBbuiimOEtj51rcEbf--