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 1soq13-00EBVq-Pi for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2024 20:02:10 +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 1soq13-00GIfx-8C for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2024 20:02:09 +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 1soq12-00GIfY-TO for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2024 20:02:08 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1soq0z-000rum-9E for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2024 20:02:08 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5c3c30e6649so1521355a12.2 for ; Thu, 12 Sep 2024 13:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1726171325; x=1726776125; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=BtcgPUsJNoYAmaq+3lul1tbrohXZxJI0oi1m19P9HSg=; b=skdrCNtmNpvKd3XCOAvpt6khp6qAx/FBy5zHXyvmTxD0EhQ1r/Dt7GkMfBJvfdWFMF tfIGlgbPRnVEIx9LcH2QcsKUF9gOzp+JigCieeJ/xU8EZmb4uO7Eo1SufGjmD3Bcoolh WkawXOnUzbClTPVHf/hx7033mDXhTtOmjWxqGbSzEEgZrG2rmnIY3xFWrJqwy8QTPYkX fS6g9FIULS5vJ73o5lJ5eb63RcrPjJ5zpTseHIOJa4xIDlLq/PBYdGXJqhRz2sDSrbrZ NohFZiwEpdtyRHmg7Ib/22eUaoTG4TEpZltBfd2Th7T6mjPsDwPssD+0fUXb1Wk27kSf EwMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726171325; x=1726776125; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BtcgPUsJNoYAmaq+3lul1tbrohXZxJI0oi1m19P9HSg=; b=P5FFQTTid/tG9sysqhhGX7hVY2aTftwmHiewM2oCqX4KfX9SCZpqdfmk9YPUeINTgQ bj7TNE6J4ygiv/G1OJfF2KQhmR/4arstiHzQw60AUOU42sCbdIRKRs2Kzdz3Nht7iDq/ o6DS62Ne3hIuv1Ircjb0Gp/mmYgOJnGgjZUZmtDEM+PdGTC27H+kVLgsHTGoJZhd1+7W pD25w8Szqm67ESTHiih5IyAivssM5dtFzbxMMJFWP2L87V58VYdxEo6ZHYQZZubDG0c1 SdoMVm/jXmi0n0FE0/U3yrB6cAsAjOyNl9cqVofDRVBue035PeCMvMsfuT8Tjl5HsTsg 5Law== X-Forwarded-Encrypted: i=1; AJvYcCWCSdAR8ZUVhFV+QC351fETX48ggxLRanpiqwgZ/VKB3LZWqOo6Ky2tDL/HKqxrXR+Q/ozaW0gASsEN@lists.postgresql.org X-Gm-Message-State: AOJu0YybGESvNN4lR0VWolMR6OLiAD39oDUk/e3E5ztMpKMGKE7QY4gP BO4YEXHxcAYdv69zXOygSqMOSmJ5m9V5DSjhzCuMIHp9+a1u0NzMbyb6An1+J3o= X-Google-Smtp-Source: AGHT+IFpHMvU+5fY534I7gNUt39ZM3FXhFZzWxrtx1jz/ifVmrk/4qsr0HNIkBcRomzD47WfmoycfQ== X-Received: by 2002:a17:907:e668:b0:a8d:4e26:c9b9 with SMTP id a640c23a62f3a-a902943335emr373139566b.17.1726171324768; Thu, 12 Sep 2024 13:02:04 -0700 (PDT) Received: from [10.93.0.121] (p50992f7c.dip0.t-ipconnect.de. [80.153.47.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c72815sm790623166b.140.2024.09.12.13.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 13:02:04 -0700 (PDT) Message-ID: <78a13f951a03bf325027f8dcfb32b1b5089cdb14.camel@cybertec.at> Subject: Re: pg_restore with --disable-triggers discards ENABLE ALWAYS From: Laurenz Albe To: Duncan Sands , pgsql-bugs@lists.postgresql.org Date: Thu, 12 Sep 2024 22:02:01 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.4 (3.52.4-1.fc40) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2024-09-12 at 10:27 +0200, Duncan Sands wrote: > CREATE TABLE test_table(x int); > CREATE FUNCTION test_function() RETURNS trigger AS $$ BEGIN RETURN NULL; = END; $$=20 > LANGUAGE plpgsql; > CREATE TRIGGER test_trigger AFTER UPDATE ON test_table FOR EACH ROW EXECU= TE=20 > FUNCTION test_function(); > ALTER TABLE test_table ENABLE ALWAYS TRIGGER test_trigger; >=20 > Checking the table: >=20 > duncan=3D> \d test_table > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 Table "public.test_table" > =C2=A0 Column |=C2=A0 Type=C2=A0=C2=A0 | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > =C2=A0 x=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | integer |=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 | > Triggers firing always: > =C2=A0=C2=A0=C2=A0=C2=A0 test_trigger AFTER UPDATE ON test_table FOR EACH= ROW EXECUTE FUNCTION=20 > test_function() >=20 > ^ Observe "Triggers firing always". >=20 >=20 > Now for the dump + restore: >=20 > pg_dump -f dump.custom -Fc --table test_table > pg_restore --data-only --disable-triggers --dbname duncan dump.custom >=20 > Checking the table: >=20 > duncan=3D> \d test_table > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 Table "public.test_table" > =C2=A0 Column |=C2=A0 Type=C2=A0=C2=A0 | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > =C2=A0 x=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | integer |=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 | > Triggers: > =C2=A0=C2=A0=C2=A0=C2=A0 test_trigger AFTER UPDATE ON test_table FOR EACH= ROW EXECUTE FUNCTION=20 > test_function() >=20 > ^ Observe that "Triggers firing always" has disappeared. This looks like a user error to me. If you restore with --data-only, the table and constraint definitions are not restored at all. So the table "test_table" in database "duncan" must already have existed before the restore, and the trigger was already defined like that. Yours, Laurenz Albe