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 1slesp-000R7K-IX for pgsql-general@arkaria.postgresql.org; Wed, 04 Sep 2024 01:32:32 +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 1slesn-002ErX-RV for pgsql-general@arkaria.postgresql.org; Wed, 04 Sep 2024 01:32:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slesm-002EoJ-IV for pgsql-general@lists.postgresql.org; Wed, 04 Sep 2024 01:32:29 +0000 Received: from ook.raf.org ([139.99.156.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1slesi-0002E9-D5 for pgsql-general@postgresql.org; Wed, 04 Sep 2024 01:32:26 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 7680F5DD57 for ; Wed, 4 Sep 2024 11:32:32 +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 KqUzBJGW7hhx for ; Wed, 4 Sep 2024 11:32:31 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raf.org; s=001; t=1725413551; bh=q2Lb+Jqa2NrzUcD1Xdx+fOWwIvfhQ1H3prrA/rOsOB8=; h=Date:From:To:Subject:From; b=nipupTMlDLrFhB378MbEWIZP68DH4cX0AAgK8q4U7++l7acGR35DKHB3AdFMQL6pn XicbtjGfT/krIGLhtRoof8U4JIRCAy2szRJx+Fjf4Rb71WLT3bWsd8Bz0GLSBHhT8+ AnXs9PULldKWYChP3I7JnIRlfUCd1nlsqYt8TYBT0J4hJ3u2zmgQd7efx9ayQJK0uR gEI5xSXEPE+grSvGn3pdEnk4AwbvbfB8JXFFyK95B5u7sG40dU271VJion8XoKBujn PnjDrLGtAEerXUH9rWozYseZ4qb/KdSC8O8tL9tK7JB2a6NqR3t6/tf4AUWDJlEzbx WwCVi1EigoyNA== Received: by ook.raf.org (Postfix, from userid 1001) id 802CE5E019; Wed, 4 Sep 2024 11:32:31 +1000 (AEST) Date: Wed, 4 Sep 2024 11:32:31 +1000 From: raf To: pgsql-general@postgresql.org Subject: Help with "gpg -d ... | pg_restore ..." with unimportant pg_restore errors Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 gpg --decrypt 20240904-011254-payroll_tst.pgdump.gpg.aps24 | pg_restore -1 -h payroll -p 5433 -U postgres -d payroll_tst -Fc (The ".aps24" is a label to indicate which gpg key was used) Below is the output from the gpg | pg_restore pipeline: gpg: encrypted with 2048-bit RSA key, ID 1373FBE2D5B2229A, created 2024-01-15 "Payroll " pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 1925; 1255 937975638 FUNCTION xml_is_well_formed(text) postgres 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... 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. But can anyone explain why gpg is getting SIGPIPE? Does pg_restore behave differently in the face of sql errors when input is stdin rather than from a named file? Is it closing stdin when this error happens (and -e is not supplied)? If so, is there a way to stop it closing stdin when an sql error happens? I could just tell the relevant people (or modify the load script) to decrypt the file to disk and then load the decrypted database backup from disk, and delete the temporary unencrypted database backup, but I'd rather be able to continue to pipe the gpg output into pg_restore. I assume this problem will go away for future backups, but there are many old backups containing these xml functions that might need to be loaded at any time. Any advice? Update: The load was using the 9.6 version of pg_restore. When using the 15.8 version of pg_restore, the output changes to: pg_restore: error: could not execute query: ERROR: schema "public" already exists Command was: CREATE SCHEMA public; gpg: error writing to '-': Broken pipe gpg: error flushing '[stdout]': Broken pipe gpg: handle plaintext failed: Broken pipe And it still doesn't load. cheers, raf