Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slfhQ-000VNY-Ig for pgsql-general@arkaria.postgresql.org; Wed, 04 Sep 2024 02:24:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1slfgQ-002hJt-D6 for pgsql-general@arkaria.postgresql.org; Wed, 04 Sep 2024 02:23:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slfgQ-002hJl-2y for pgsql-general@lists.postgresql.org; Wed, 04 Sep 2024 02:23:46 +0000 Received: from ook.raf.org ([139.99.156.21]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slfgH-0002x0-Vr for pgsql-general@lists.postgresql.org; Wed, 04 Sep 2024 02:23:44 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id BA6B15DD57 for ; Wed, 4 Sep 2024 12:23:46 +1000 (AEST) X-Virus-Scanned: Debian amavis at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavis, port 10024) with ESMTP id nMK_Ocm39Bmk for ; Wed, 4 Sep 2024 12:23:45 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raf.org; s=001; t=1725416625; bh=xyfZ06kFFApt5vncHqrKSA3mYIOQKxcCb4rrNj47l5g=; h=Date:From:To:Subject:References:In-Reply-To:From; b=DACIAYGOJaowfeS4qz14hCs9HoPfDpogclNm3awszs8qBrmkjsF/ipoRlB0YJjCB+ 7Th4L76t/rMlltHdDSc89jKL2+y7HnD1ki+Wz9YjP2M5LjSN/qz5SOXvdXKCJLQ2F6 DXQ8ALe8ct9KByLPAPpfPVI7hKupNPMqEH/ZmXxfP6mt5Is3vGtnZIIZh7/RAM+iz1 PdLf2ehzc9kFcc7Jaxd5oeHjH0DcqDFsngN+Q2oXjH9wpfKTI+BzYoRNnflgDr6OpZ VNMa4t12ooUBF4kptShN/B/UqwiDSj5LOpi0lAbvj1KE/zHqsdxhs/mnDyLs6Kn1MS lmdKbSiZk4stA== Received: by ook.raf.org (Postfix, from userid 1001) id D50A55E019; Wed, 4 Sep 2024 12:23:45 +1000 (AEST) Date: Wed, 4 Sep 2024 12:23:45 +1000 From: raf To: pgsql-general@lists.postgresql.org Subject: Re: Help with "gpg -d ... | pg_restore ..." with unimportant pg_restore errors Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Sep 03, 2024 at 06:43:22PM -0700, "David G. Johnston" wrote: > On Tuesday, September 3, 2024, raf wrote: > > > Hi, > > > > I need help! > > > > I'm upgrading an ancient (but still awesome) postgresql-9.6.24 (via > > EnterpriseDB) > > to (a no doubt even more awesome) postgresql-15.8 (via debian (stable) > > packages) > > but am unable to load database backups that were encrypted via gpg. > > Loading from > > unencrypted backups works fine (and the millions of tests all pass! Yay!). > > > > I have a convenience program for handling loading called "load" > > and the underlying commands that it executes look like this: > > > > dropdb -h payroll -p 5433 -U postgres payroll_tst > > createdb -h payroll -p 5433 -U postgres -T template0 -E utf8 -O admin > > payroll_tst > > Given the following command > > > gpg --decrypt 20240904-011254-payroll_tst.pgdump.gpg.aps24 | pg_restore > > -1 -h payroll -p 5433 -U postgres -d payroll_tst -Fc > > And this error > > > pg_restore: [archiver (db)] could not execute query: ERROR: could not > > find function "xml_is_well_formed" in file "/usr/lib/postgresql/15/lib/ > > pgxml.so" > > Command was: CREATE FUNCTION public.xml_is_well_formed(text) > > RETURNS boolean > > LANGUAGE c IMMUTABLE STRICT > > AS '$libdir/pgxml', 'xml... > > This should be expected. In particular… > > > gpg: error writing to '-': Broken pipe > > gpg: error flushing '[stdout]': Broken pipe > > gpg: handle plaintext failed: Broken pipe > > pgrestore encountered errors > > > > I'm not worried about the xml_is_well_formed error (or the xml_valid > > error that would happen next). I think those functions are ancient > > and irrelevant and not in use, and I'm happy for pg_restore to > > continue, like it does when gpg is not involved. > > You specified “-1” so I don’t get why you believe pg_restore should be > continuing to execute in the face of the SQL error. The reason I believe pg_restore should be continuing to execute in the face of the SQL error is because I didn't supply the -e option which is described thusly in the pg_restore manual entry: -e --exit-on-error Exit if an error is encountered while sending SQL commands to the database. The default is to continue and to display a count of errors at the end of the restoration. So, since I didn't specify the -e option, pg_restore should continue to execute, and not close stdin. As I explained, when restoring from a file on disk, the pg_restore command does continue and work fine. It's only when restoring from stdin that I'm seeing this problem. Ah, I see. The manual entry also says that -1 implies -e. And when reading from a file on disk, my load script doesn't include -1. Instead, it uses the -j option. Now it all makes sense. Many thanks. It's working without the -1. I'll change the load script so that it only uses the -1 option when restoring from new backups taken after the upgrade to 15.8 (where these vestigial xml functions won't be present in the backup). > David J. cheers, raf