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 1npP1t-0006nT-Vs for pgsql-general@arkaria.postgresql.org; Fri, 13 May 2022 06:44:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1npP1s-0002yJ-Ds for pgsql-general@arkaria.postgresql.org; Fri, 13 May 2022 06:44:00 +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 1npP1s-0002yA-2u for pgsql-general@lists.postgresql.org; Fri, 13 May 2022 06:44:00 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1npP1n-0004aU-SS for pgsql-general@lists.postgresql.org; Fri, 13 May 2022 06:43:59 +0000 Received: by mail-pj1-x1031.google.com with SMTP id t11-20020a17090ad50b00b001d95bf21996so9982326pju.2 for ; Thu, 12 May 2022 23:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=Gzm6OaDgXgfyYkC5aicOofS1loTi2NpiORsRhoIjZ7Q=; b=XMDLF/J08E5tbe0x4Ntpd0S9iV5dGBvo1cLeA8B0UCyROQTZZBon/2NKfmSOw67YEY Y/1Hj2HjqcWimAV/WrRWJcE7rkSK6Ucy28hEXHezBnRkFIBesBOr6i5FNDzsPh6tcc5B 0w+2AXUi6hvbvkzAjif7VqRE6nNt5lmTSIotQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=Gzm6OaDgXgfyYkC5aicOofS1loTi2NpiORsRhoIjZ7Q=; b=LCUztEkncmLmzfguE9zoTp19h+dR+XLW4KpD1DeY4q6VhTthY4Rj0M2x1Bn0K85uhU hZ3Qha3qkJsWfmzrMu+FBuMxi8lGpQr6SnFT52oSyuC4A4skHsdmx36F1b3n7X8wgvMO 6AbbQ/cS0+cZA0Lpud3aWrB6fI6GxLPwKFAodSm9q2dVR1mu9A2hPOpybnRP3nsyoQoi EOdCo0LmT0mOEhKnTnc2D70vHfTqEPWm1UqRzI7k8Nu7+4TXlr5M7f9AutYyU/lLDYJZ 9Y4fluczmxA0HQMuCdw6WVM1EGnknHzmlLy0bY+IG6W1C3hrAdPNHm6GE8ljH4czxgZ+ 4vcw== X-Gm-Message-State: AOAM533dkfBzATfjJXc710Y+5YTKg577OuQEq8TLa3suok8Qs76roOO4 zugtvzfyJLTPYiY9maayeffpG9mu8WHO3Q== X-Google-Smtp-Source: ABdhPJzB47xdy2J7RUw4ujabd4sCtaSl3bRJj94YxwmJlyJgqFOXQfoTGDUSBAuZaJyAycfKwpLO+A== X-Received: by 2002:a17:90a:ba15:b0:1c6:7873:b192 with SMTP id s21-20020a17090aba1500b001c67873b192mr3445856pjr.76.1652424233521; Thu, 12 May 2022 23:43:53 -0700 (PDT) Received: from smtpclient.apple ([2601:646:101:7fda:c1dc:acd8:40c:d1ba]) by smtp.gmail.com with ESMTPSA id a10-20020a631a0a000000b003c6ab6ba06csm808912pga.79.2022.05.12.23.43.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2022 23:43:52 -0700 (PDT) From: Bryn Llewellyn Message-Id: <5F2AF0A2-DF85-42DF-A2C1-EBEB03E54F8F@yugabyte.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_43D2EF9A-91A4-4B1A-9891-9D19640B56A1" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Deferred constraint trigger semantics Date: Thu, 12 May 2022 23:43:51 -0700 In-Reply-To: <4e2de8ec77447a8347ea1923171afb6bcf77397b.camel@cybertec.at> Cc: pgsql-general list To: Laurenz Albe References: <5C29B392-6215-4791-8DD8-7B8977A637B7@yugabyte.com> <987A57EE-C893-43EE-BFF0-FAF1422526D4@yugabyte.com> <356843a91b48918d8e78d2accb932a46b7889161.camel@cybertec.at> <4e2de8ec77447a8347ea1923171afb6bcf77397b.camel@cybertec.at> X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_43D2EF9A-91A4-4B1A-9891-9D19640B56A1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > laurenz.albe@cybertec.at wrote: >=20 > Be "seeing" I didn't mean "show to the user". I mean that the code = that implements PostgreSQL constraints takes uncommitted data into = account. >=20 > The documentation describes that for the case of uniqueness in some = detail: >=20 > https://www.postgresql.org/docs/current/index-unique-checks.html >=20 > I'd say that the proper mental model is that you don't need to care. = The ACID properties are guarantees that the database makes, and these = guarantees are usually negative: "no sequence of actions can result in = the violation of a unique constraint" or "you don't get to see = uncommitted data". >=20 > The exact sequence of what happens during COMMIT is interesting, but = irrelevant to the programmer. All that counts is "a deferred constraint = is checked between the time that COMMIT starts processing and the time = that it returns". >=20 > If you want to know more, you have to start reading the code. It is = open source and well documented. Thanks for the quick reply, Laurenz. I'm signing off now (US/Pacific) = for a long weekend. I'll try to digest what you wrote on Monday.= --Apple-Mail=_43D2EF9A-91A4-4B1A-9891-9D19640B56A1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
laurenz.albe@cybertec.at wrote:

Be = "seeing" I didn't mean "show to the user". I mean that the code = that implements PostgreSQL constraints takes uncommitted data into = account.

The documentation describes that = for the case of uniqueness in some detail:

https://www.postgresql.org/docs/current/index-unique-checks.htm= l

I'd say that the proper mental model = is that you don't need to care. The ACID properties are guarantees = that the database makes, and these guarantees are usually negative: = "no sequence of actions can result in the violation of a unique = constraint" or "you don't get to see uncommitted data".

The exact sequence of what happens during = COMMIT is interesting, but irrelevant to the programmer.  All = that counts is "a deferred constraint is checked between the time = that COMMIT starts processing and the time that it returns".

If you want to know more, you have to start = reading the code. It is open source and well = documented.

Thanks for the quick = reply, Laurenz. I'm signing off now (US/Pacific) for a long = weekend. I'll try to digest what you wrote on = Monday.
= --Apple-Mail=_43D2EF9A-91A4-4B1A-9891-9D19640B56A1--