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 1lv0bp-00036t-GQ for pgsql-general@arkaria.postgresql.org; Sun, 20 Jun 2021 16:47:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lv0bo-0005lg-GI for pgsql-general@arkaria.postgresql.org; Sun, 20 Jun 2021 16:47:44 +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 1lv0bo-0005bZ-5z for pgsql-general@lists.postgresql.org; Sun, 20 Jun 2021 16:47:44 +0000 Received: from mout.gmx.net ([212.227.15.18]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lv0bl-0006C6-QU for pgsql-general@lists.postgresql.org; Sun, 20 Jun 2021 16:47:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1624207658; bh=/FI6eDJ+7c5SUj2cx0g4896Qenb051kEz0ApOK8mfls=; h=X-UI-Sender-Class:Date:From:To:Subject; b=ZsobCI1EzhkcS4V6mUqcyduJWa3Gh1f5xKxHC94sUiqu1k0LsvQKGhwpbmvPvJZii Obz2RLH39zCU5amFXks2GgHgDAPlnEDB1pwZEcQCmaZa0e8enOq4z2ZL8j/9LRcwSu ppsq3BU05X5G/AABeCoQjDbDJCvcCyDUiQB/AUy0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from hermes ([78.55.9.221]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N3KPg-1lCUzT4386-010Klg for ; Sun, 20 Jun 2021 18:47:38 +0200 Received: from ncq by hermes with local (Exim 4.94.2) (envelope-from ) id 1lv0bg-0001qr-LA for pgsql-general@lists.postgresql.org; Sun, 20 Jun 2021 18:47:36 +0200 Date: Sun, 20 Jun 2021 18:47:36 +0200 From: Karsten Hilbert To: pgsql-general@lists.postgresql.org Subject: pg_dump/pg_restore vs default_transaction_read_only under PG 13.2 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ma_X_il-Followup-to: d Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net X-Pri_X_ority: 2 (High) Sender: X-Provags-ID: V03:K1:UJ8lQnvCLGfXUI6GkbhF4VHHCbO5eWMF1odHrhSn7UhlHq6ot6m imHZqaxF5EjfXCzEYGMPvktDL+ch+SAhWDO8R801X2rbIvUska1xrwRECfTRqV2lVl/qkCN ETycR/IWyMWy0ldhiiTKsuWTvEGwwLKNY/ElJHQmTQWT/gu/Yk6SmwmqRNyc5tDpv2g+NDI P2py5rNDoYfD7fnUsfgiw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:nK7y1+fZoDE=:87BMjqG+uc4MWnqQMto1Ep MLzhquBvHpsHTb+4LLiCfjUZgPURzE3A3/rJE6knuFsMoDDP+3+hJCkm72RU6BRJmRLtgIojC SLPYyxFhSdDmXrPQ/f/o7TSUl0Hh3MjYWMGwFlA+D1E5/OSn14OcKSCxhvkZSQuT38/ZOJqNb kHQKZIgWpOuBy017uNSHTCCrww/v8Be7HA2pShWgtAOWYVPyK2qie7AuC4w9O7/Kq4KV7W8+s jPQdMNmDeXS6AV4WtuNc/r/6aoOnRFSKDD/tKN1YSyL1ljpPC2sGXe+FEfeUZU701Ays/GIFV JaH6DJ1UPd+hK6MR7B9PMUCmmpXkGT0tiFfJmCH8K4LB7mPa821lraQ4TKBlGynCD/bBmksn1 uKCO3WP/2U2ouwySckwdHsjvP07Yts9M84Z8Tsi624qftmJKerpS9WTmdc9COjNCEJYoEetDp hnsFXsQyV6jXlEjdATG1yxfBEwPFhTb757BYhb8S7hbItFBT+UlvZldt7731DdFUuaz/K1hbI +j5ArIPXX4Az6zyLngtOyIlqBWCel3uxwgj2HZVTxsPFnRteu68xgkgohwFw12JDE0COons9N ujxFiPz2EDprKIqL9hrKaxOFT9IUuo6Gf4ngFUb+8Z+KRx3MOWLJnvaXJUc67qD8Y52cPK889 jM/okSlbCQiJYJTpyRHqmAnTrbbZEBC3V8aLuEfxLcJCHiYN0l0Cb4Gkx5AG/B/KdvTdxcdGm LNphh84/V4KV/wUMSu99Wdgh1u3I80I4sJHsCKk2E25j5/8EGL4eHCFc4MbDgWoDvAZlrdO5C Al07MzcziKi/41sEUVDkLTt2u+H1aPY8pF4K3sOOFcmY6RlWcfvqbnFgttTebSt/mnhjk3tEM 3eKZEvtj96Yc5txuIJWF6s4dVRCuMAIUxD18qEvYuXtxH8hJHU6AV9cfo1vAQHuEGfiYdc+3k tFHpv8NlzhMCRVt+CYO/7V7E3aLSb69wXfj3Ft8at2INAE5HP4LQZXXRfl/OpKs2/ZGBIB+yP dqNJWc+7TrAg2IKiXK2wjKYU0HLEZurLWsx1pnsTtkTq4x4NUfWezbEqmTkvH8ZDA1Ai+M+oT XyrSqDOo2fmvVafBmrp1Ltbjz9vZOAMDmFPu961I/zd8E2LvxDlaVsHhQ== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dear all, I am testing the pg_restore of a database with default_transaction_read_only=3Don. The following issue ensues sudo -u postgres pg_restore --verbose --create --dbname=3Dtemplate1 --exi= t-on-error -p 5432 /tmp/gnumed/gm-restore_2021-06-20_18-31-07/backup-gnume= d_v22-GNUmed_Team-hermes.dir/ pg_restore: verbinde mit der Datenbank zur Wiederherstellung pg_restore: erstelle DATABASE =BBgnumed_v22=AB pg_restore: verbinde mit neuer Datenbank =BBgnumed_v22=AB pg_restore: erstelle DATABASE PROPERTIES =BBgnumed_v22=AB pg_restore: verbinde mit neuer Datenbank =BBgnumed_v22=AB pg_restore: erstelle SCHEMA =BBau=AB pg_restore: in Phase PROCESSING TOC: pg_restore: in Inhaltsverzeichniseintrag 7; 2615 16753 SCHEMA au gm-dbo pg_restore: Fehler: could not execute query: ERROR: cannot execute CREAT= E SCHEMA in a read-only transaction Die Anweisung war: CREATE SCHEMA au; pg_restore exit code: 1 Producing an SQL file instead of restoring shows which sequence of events quite logically leads up to this: -- -- PostgreSQL database dump -- -- Dumped from database version 13.2 (Debian 13.2-1) -- Dumped by pg_dump version 13.2 (Debian 13.2-1) -- Started on 2021-06-20 14:04:46 CEST SET statement_timeout =3D 0; SET lock_timeout =3D 0; SET idle_in_transaction_session_timeout =3D 0; SET client_encoding =3D 'UTF8'; SET standard_conforming_strings =3D on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies =3D false; SET xmloption =3D content; SET client_min_messages =3D warning; SET row_security =3D off; -- -- TOC entry 9963 (class 1262 OID 130036) -- Name: gnumed_v22; Type: DATABASE; Schema: -; Owner: gm-dbo -- CREATE DATABASE gnumed_v22 WITH TEMPLATE =3D template0 ENCODING =3D 'UTF8= ' LOCALE =3D 'de_DE.UTF-8'; ALTER DATABASE gnumed_v22 OWNER TO "gm-dbo"; \connect gnumed_v22 SET statement_timeout =3D 0; SET lock_timeout =3D 0; SET idle_in_transaction_session_timeout =3D 0; SET client_encoding =3D 'UTF8'; SET standard_conforming_strings =3D on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies =3D false; SET xmloption =3D content; SET client_min_messages =3D warning; SET row_security =3D off; -- -- TOC entry 9964 (class 0 OID 0) -- Name: gnumed_v22; Type: DATABASE PROPERTIES; Schema: -; Owner: gm-dbo -- ALTER DATABASE gnumed_v22 SET lc_messages TO 'C'; ALTER DATABASE gnumed_v22 SET default_transaction_read_only TO 'on'; ALTER DATABASE gnumed_v22 SET check_function_bodies TO 'on'; ALTER DATABASE gnumed_v22 SET ignore_checksum_failure TO 'off'; \connect gnumed_v22 SET statement_timeout =3D 0; SET lock_timeout =3D 0; SET idle_in_transaction_session_timeout =3D 0; SET client_encoding =3D 'UTF8'; SET standard_conforming_strings =3D on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies =3D false; SET xmloption =3D content; SET client_min_messages =3D warning; SET row_security =3D off; -- -- TOC entry 7 (class 2615 OID 16753) -- Name: au; Type: SCHEMA; Schema: -; Owner: gm-dbo -- CREATE SCHEMA au; The problem being that pg_restore sets database properties from -- TOC entry 9964 (class 0 OID 0) -- Name: gnumed_v22; Type: DATABASE PROPERTIES; Schema: -; Owner: gm-dbo including ALTER DATABASE gnumed_v22 SET default_transaction_read_only TO 'on'; (which was, indeed, set to "on" in the dumped database) and only then attempts to create schema/restore data. Is this issue handled differently in later versions or should I be doing something differently during restore ? It would seem the restore script lacks a SET default_transaction_read_only TO 'off'; in the setup section after re-connecting to the DB following the ALTER DATABASE section ? Thanks, Karsten =2D- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B