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 1p5XyJ-0002QW-6j for pgsql-sql@arkaria.postgresql.org; Wed, 14 Dec 2022 20:03:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p5XyI-0001QZ-74 for pgsql-sql@arkaria.postgresql.org; Wed, 14 Dec 2022 20:03:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5XvI-0006Uu-Nh for pgsql-sql@lists.postgresql.org; Wed, 14 Dec 2022 20:00:12 +0000 Received: from premium22-2.web-hosting.com ([68.65.122.104]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5XvE-0004rO-1l for pgsql-sql@lists.postgresql.org; Wed, 14 Dec 2022 20:00:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=misuse.org; s=default; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ZWRyMHnk2y+a1K2Vu4TcX86H0oR05n8bNC4RFc30Z/Q=; b=Qu2uzJcTS9nXV/4sjMatmR0ctE JG5bOodOeThdYUFsxd0ZxwrjHf15kByBh2YDtWXccOa+QhfOu4Kn8XcwJPXVD7XoiBDpsm+Nihw+a 0Mx3MP0wAOCXBBRnkMjZouCa0LIQVsJyvFbMfg+Wk1CuOxLNGyuI0f7ktQ6aBaWOFhluRE2Th4C2C Z5lOdI0rmUfedBQrXRajGmJq2a8fpOYbRrOKCTnMFnh/9nl4qEU7udS5n7Tgny6rseQnpmkIm5yZ8 cZpCyAbpDCrd5RR8AJFUaTUvPy5+r8feVOvrhmvB78Y7mBNx4DFZbZJG9JE9TC5+BxPPoKkzEKCQi O+jKzZ/w==; Received: from mail-yw1-f178.google.com ([209.85.128.178]:39603) by premium22.web-hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.95) (envelope-from ) id 1p5Xv4-00E6f5-1j for pgsql-sql@lists.postgresql.org; Wed, 14 Dec 2022 15:00:03 -0500 Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-3e45d25de97so12563567b3.6 for ; Wed, 14 Dec 2022 11:59:57 -0800 (PST) X-Gm-Message-State: ANoB5pl0XPcE+90FlqF2fchkjpr88gjq9hkUJQxux4JeiUwf/Errr/RR qtF4J5VENXJx9YxzMWzj8NDbxrptjBYwYE6uPME= X-Google-Smtp-Source: AA0mqf5lA7my/m2hQOyKVQZo+jkhbF/5VX0e2gDVNPXJ+qjXlO5INtLPNgtZOwMB8gS+wIu5dwTOdOVnn6eRq0HeNHM= X-Received: by 2002:a81:3d0:0:b0:3db:a69e:24e0 with SMTP id 199-20020a8103d0000000b003dba69e24e0mr32776500ywd.51.1671047996701; Wed, 14 Dec 2022 11:59:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Steve Midgley Date: Wed, 14 Dec 2022 11:59:44 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Postgresql long transaction support To: Kirmo Uusitalo Cc: Samed YILDIRIM , pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000003f046205efcf2e4b" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - premium22.web-hosting.com X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - misuse.org X-Get-Message-Sender-Via: premium22.web-hosting.com: authenticated_id: science@misuse.org X-Authenticated-Sender: premium22.web-hosting.com: science@misuse.org X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003f046205efcf2e4b Content-Type: text/plain; charset="UTF-8" On Wed, Dec 14, 2022 at 4:46 AM Kirmo Uusitalo wrote: > Hi Samed, > > thanks. The bitemporal tables are somewhat similar except that there is > not a date range to distinguish between versions of objects. One could use > this long transaction feature for comparing the results of different plans > of implementing something - and these could be affecting many objects from > the parent version (or it's parent and so forth). > > Similarly as with bitemporal tables the FK constraints are problematic. If > an object is to be deleted in parent version, any created child object of > this in child version cannot be posted to parent version later. That's why > I believe it is best first merge the changes done in parent version to > current version before you are allowed to post. > > To solve this in application layer for an existing application is quite > complex and this is why I am looking for a more generic solution within the > database. > >> >>> This seems pretty complex to address at any layer! But it would be a useful feature for some situations, for sure. It seems like the approach taken by Ruby/Rails and similar frameworks for "db migrations" might have some useful design patterns for you. Each transaction has a link to its future and past transaction. If the system wants to traverse from "migration 6 to migration 3" and the DB is currently at migration 6 (stored a version number in the db itself), it runs the exit function to downgrade to migration 5, then runs the logic for migration 5, then runs the downgrade to 4, etc. It can be slow, as implemented, but it allows you to attach logic to every step forward and backward in time that ensures you can handle even structure changes in the tables, etc (as well as changing lookup values in tables, etc). Might be worth considering as a design model? Steve --0000000000003f046205efcf2e4b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Dec 14, 2022 at 4:46 AM Kirmo= Uusitalo <kirmo.uusitalo@gm= ail.com> wrote:
Hi Samed,

thanks. The= bitemporal tables are somewhat similar except that there is not a date ran= ge to distinguish between versions of objects. One could use this long tran= saction feature for comparing the results of different plans of implementin= g something - and these could be affecting many objects from the parent ver= sion (or it's parent and so forth).

Similarly = as with bitemporal tables the FK constraints are problematic. If an object = is to be deleted in parent version, any created child object of this in chi= ld version cannot be posted to parent version later. That's why I belie= ve it is best first merge the changes done in parent version to current ver= sion before you are allowed to post.

To solve= this in application layer for an existing application is quite complex and= this is why I am looking for a more generic solution within the database. =


This seems pretty com= plex to address at any layer! But it would be a useful feature for some sit= uations, for sure. It seems like the approach taken by Ruby/Rails and simil= ar frameworks for "db migrations" might have some useful design p= atterns for you. Each transaction has a link to its future and past transac= tion. If the system wants to traverse from "migration 6 to migration 3= " and the DB is currently at migration 6 (stored a version number in t= he db itself), it runs the exit function to downgrade to migration 5, then = runs the logic for migration 5, then runs the downgrade to 4, etc.

It can be slow, as implemented, but it allows you to attac= h logic to every step forward and backward in time that ensures you can han= dle even structure changes in the tables, etc (as well as changing lookup v= alues in tables, etc).

Might be worth considering = as a design model?
Steve
--0000000000003f046205efcf2e4b--