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 1oMB3N-00063d-Lv for pgsql-general@arkaria.postgresql.org; Thu, 11 Aug 2022 16:29: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 1oMB3M-0000kM-Ib for pgsql-general@arkaria.postgresql.org; Thu, 11 Aug 2022 16:29: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 1oMB3M-0000kD-4q for pgsql-general@lists.postgresql.org; Thu, 11 Aug 2022 16:29:00 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oMB3K-00060m-0X for pgsql-general@lists.postgresql.org; Thu, 11 Aug 2022 16:28:59 +0000 Received: by mail-pg1-x52b.google.com with SMTP id h132so17545666pgc.10 for ; Thu, 11 Aug 2022 09:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=to:references:message-id:cc:date:in-reply-to:from:subject :mime-version:from:to:cc; bh=K4QxTGuP579gcMZBbZP/xn8VHvEo7+y5LXx+v6z4sqM=; b=kKfIs1+v/R49Xb5xDoy9je0sWSCAL8o/l4/Be40KdtxqWz9BpqdQNOLcaDE6CPcB/s Bl1Fq5FrP2jcjAO9H+w4yRjjznkn/3hErP0p5HonAXi3JqFBhgWPCdRZjo/x3ZwAuuXu xpo0c3LNnpmyJejH7qEup/1h5CGKYCrgJ2XW4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:cc:date:in-reply-to:from:subject :mime-version:x-gm-message-state:from:to:cc; bh=K4QxTGuP579gcMZBbZP/xn8VHvEo7+y5LXx+v6z4sqM=; b=O8eecncVUbr/IAydbU2+MYOuL8Fb9zZFVivcJJlU4ZD/fE/RyG8MCmj3+nPuju6iqg 7ru1ZV3g+3BDOo2QSn+dZ34pjlQ0r2qboUFkWVb23Jjbb0cFTtOWpq98htJEjLP0qWbj bAhGFSWugfbIk63cy38cc/2hrO4IkTv6T9Vc0DNA5l1MU0O02SpfOntcPepNJ/xcoStn YEMXY3I0iSnAbfxA3VALVk/55DCB+sFjCFrf7tIh2LSFvEnS9hL3e0iaFSuaEiua4NbS Wy6ukFFEgSAmuQIHL2vsJkUiZPl7baShtaWzBKGll3iNRzjMcvj1VqNzdlQib6Ofm3a6 q3Fg== X-Gm-Message-State: ACgBeo3HkBV8JiUk3xKKzN4hfQtJrmzxsG1tQr1pBOD/jH1UeU7dzhQV /ANXfepaqrjm0bjpEW+sDdMCKA== X-Google-Smtp-Source: AA6agR7awAiWocNDfd2mF0cC/KWsXwFa0QTZiVxkqH1Jjot3zDc8O6im7ItanJuZkKX7i/DEWmLyAA== X-Received: by 2002:a65:6048:0:b0:412:73c7:cca9 with SMTP id a8-20020a656048000000b0041273c7cca9mr28066673pgp.257.1660235335908; Thu, 11 Aug 2022 09:28:55 -0700 (PDT) Received: from smtpclient.apple ([2601:646:101:7fda:9d98:dd0:780b:f812]) by smtp.gmail.com with ESMTPSA id t9-20020aa79469000000b0052d52de6726sm4233982pfq.124.2022.08.11.09.28.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Aug 2022 09:28:55 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_D09DEC4E-30EC-41AC-9646-B4917E75BA51" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Surprising results from current_role in a "security invoker" trigger function in a "cascade delete via FK" scenario From: Bryn Llewellyn X-Priority: 3 In-Reply-To: Date: Thu, 11 Aug 2022 09:28:52 -0700 Cc: "David G. Johnston" , pgsql-general list Message-Id: <98604D47-FBA4-41FF-93D0-96167F1EC14D@yugabyte.com> References: <6EA46B7D-7775-4524-96EC-E32599AA46EC@yugabyte.com> <615A1F2A-EB13-43D8-A97C-6344DD9C892F@yugabyte.com> To: Karsten Hilbert 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=_D09DEC4E-30EC-41AC-9646-B4917E75BA51 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Karsten.Hilbert@gmx.net wrote: >=20 >> bryn@yugabyte.com wrote: >>=20 >> I'll be happy to make a smaller example. It will, however, need to = create=E2=80=A6 After all, how would I know which of the eight to skip = while I don't know the intended rules for the current_role? >=20 > You'd certainly start out with all eight but then whittle down to what = still exhibits the problem and post that. Do you know where I can read a statement of the intended rules here? I = appreciate that one is doomed who tries to deduce the rules that govern = a software system's behavior by using just empirical testing. (And = reading source code hoping to deduce the behavior that the programmer = intended is hardly better.) I used the subject "surprising results" to mean "Results that surprise = me, Bryn". The results might well not surprise somebody who knows the = rules. Several cases that I've asked about before on this list were = surprising for me because I was too dim-witted to find where, in the PG = docs, the rules were stated. And in those cases, I was delighted to be = pointed to the appropriate doc and to receive some helpful instruction. = That's what I'm hoping for here. Notice that I didn't consider "for insert" or "for update" triggers. But = you can contrive a cascade effect with these, too. For example, table = "t1" might have a trigger that inserts or updates a row in table "t2" = for a purpose like maintaining a change history. And "t2" might, in = turn, have a trigger for who-knows-what purpose (maybe to enforce a = write-once-read-many regime for the values in certain columns). This is why I'd very much like to start by studying a clear statement of = the intention in scenarios in the same general class as the one that I = showed.= --Apple-Mail=_D09DEC4E-30EC-41AC-9646-B4917E75BA51 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Karsten.Hilbert@gmx.net wrote:


I'll be happy to make a smaller = example. It will, however, need to create=E2=80=A6 After all, how would = I know which of the eight to skip while I don't know the intended rules = for the current_role?
You'd certainly start out with all eight but then whittle = down to what still exhibits the problem and post that.

Do you know where I can read a statement of = the intended rules here? I appreciate that one is doomed who tries to = deduce the rules that govern a software system's behavior by using just = empirical testing. (And reading source code hoping to deduce the = behavior that the programmer intended is hardly better.)

I used the subject = "surprising results" to mean "Results that surprise me, Bryn". The = results might well not surprise somebody who knows the rules. Several = cases that I've asked about before on this list were surprising for me = because I was too dim-witted to find where, in the PG docs, the rules = were stated. And in those cases, I was delighted to be pointed to the = appropriate doc and to receive some helpful instruction. That's what I'm = hoping for here.

Notice that I didn't consider "for insert" or "for update" = triggers. But you can contrive a cascade effect with these, too. For = example, table "t1" might have a trigger that inserts or updates a row = in table "t2" for a purpose like maintaining a change history. And "t2" = might, in turn, have a trigger for who-knows-what purpose (maybe to = enforce a write-once-read-many regime for the values in certain = columns).

This = is why I'd very much like to start by studying a clear statement of the = intention in scenarios in the same general class as the one that I = showed.
= --Apple-Mail=_D09DEC4E-30EC-41AC-9646-B4917E75BA51--