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 1scUas-007nYq-TR for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Aug 2024 18:44:06 +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 1scUaq-005NU0-Be for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Aug 2024 18:44:04 +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 1scUap-005NTr-Td for pgsql-hackers@lists.postgresql.org; Fri, 09 Aug 2024 18:44:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1scUan-003vUS-1x for pgsql-hackers@lists.postgresql.org; Fri, 09 Aug 2024 18:44:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 479IhxvN2833458; Fri, 9 Aug 2024 14:43:59 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org cc: Robert Haas Subject: is_superuser versus set_config_option's parallelism check MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2833456.1723229039.1@sss.pgh.pa.us> Date: Fri, 09 Aug 2024 14:43:59 -0400 Message-ID: <2833457.1723229039@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I came across this misbehavior: regression=# create or replace function foo() returns text as $$select current_setting('role')$$ language sql parallel safe set role = postgres; CREATE FUNCTION regression=# select foo(); foo ---------- postgres (1 row) regression=# set debug_parallel_query to 1; SET regression=# select foo(); ERROR: cannot set parameters during a parallel operation CONTEXT: parallel worker What is failing is the attempt to update the "is_superuser" GUC as a side-effect of setting "role". That's coming from here: /* * GUC_ACTION_SAVE changes are acceptable during a parallel operation, * because the current worker will also pop the change. We're probably * dealing with a function having a proconfig entry. Only the function's * body should observe the change, and peer workers do not share in the * execution of a function call started by this worker. * * Other changes might need to affect other workers, so forbid them. */ if (IsInParallelMode() && changeVal && action != GUC_ACTION_SAVE) // throw error Since we're using GUC_ACTION_SET to set "is_superuser", this spits up. The simplest fix would be to hack this test to allow the action anyway when context == PGC_INTERNAL, excusing that as "assume the caller knows what it's doing". That feels pretty grotty though. Perhaps a cleaner way would be to move this check to some higher code level, but I'm not sure where would be a good place. Thoughts? regards, tom lane