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 1tlMI3-00BK93-Ij for pgsql-admin@arkaria.postgresql.org; Fri, 21 Feb 2025 06:13:36 +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 1tlMI2-002uPK-48 for pgsql-admin@arkaria.postgresql.org; Fri, 21 Feb 2025 06:13:34 +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 1tlMI1-002uPC-PD for pgsql-admin@lists.postgresql.org; Fri, 21 Feb 2025 06:13:33 +0000 Received: from forward100a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d100]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tlMHy-0022ML-2m for pgsql-admin@lists.postgresql.org; Fri, 21 Feb 2025 06:13:32 +0000 Received: from mail-nwsmtp-smtp-production-main-67.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-67.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:491b:0:640:fe40:0]) by forward100a.mail.yandex.net (Yandex) with ESMTPS id E88D7473A3; Fri, 21 Feb 2025 09:13:26 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-67.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id PDRaPN8LkSw0-EQ4DTaLw; Fri, 21 Feb 2025 09:13:26 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1740118406; bh=pdITCQWPMS5n+dfNUvWEH0E8whhlwmbf1XiYFft2hCw=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=L/+Mq8bpndl3/o4pnyx0WT5CdLKMGXs4qjV6yTL/3XMkG5zidFobv40pZzjIlPeLO PxjbIJ/hCn8Ruel1XIInzJi1KYxMY1CyUCb8D+DqIUYMH6kNpAz3ejrcQD7FNOsSiV wVGBr9ruOAagYGUXHtKkQbNPIsRucjyMHs6Ud/bs= Authentication-Results: mail-nwsmtp-smtp-production-main-67.vla.yp-c.yandex.net; dkim=pass header.i=@ya.ru Message-ID: Date: Fri, 21 Feb 2025 09:13:26 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A trigger in an extension To: Tom Lane Cc: pgsql-admin@lists.postgresql.org References: <40129c90-138c-4331-a3d6-c04158cb91e0@ya.ru> <2790099.1740079810@sss.pgh.pa.us> Content-Language: ru, en-US From: Olleg Samoylov In-Reply-To: <2790099.1740079810@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 20.02.2025 22:30, Tom Lane wrote: > Olleg Samoylov writes: >> I have the extension pgpro_scheduler. In the exception there are two >> tables and the trigger on one of them that write to the other. I was >> surprised but when I load dump created by pg_dump this trigger is >> created in the pre-data stage (automatically by create extension) early >> and thus has wrong behavior when uploaded data in the data stage (lead >> to duplication of primary key). > > pg_dump does not like to editorialize on the contents of extensions. > It just does CREATE EXTENSION and doesn't inquire into what's in > them. I'd argue that if you need triggers like this, maybe you > should rethink your data model. > > regards, tom lane Okey, as I see https://www.postgresql.org/docs/17/extend-extensions.html#EXTEND-EXTENSIONS-CONFIG-TABLES Cite: More complicated situations, such as initially-provided rows that might be modified by users, can be handled by creating triggers on the configuration table to ensure that modified rows are marked correctly. So a trigger is permitted inside an extension. But usually trigger must not be fired when pg_dump load data. May be it is hard for pg_dump to reorder statements inside an extension. May be better just set session_replication_role=replica by pg_dump and pg_restore? (To disable triggers). -- Olleg