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 1nh0NC-0005wT-4K for pgsql-general@arkaria.postgresql.org; Wed, 20 Apr 2022 02:47:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nh0NB-00041G-0Q for pgsql-general@arkaria.postgresql.org; Wed, 20 Apr 2022 02:47:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nh0NA-00040r-KJ for pgsql-general@lists.postgresql.org; Wed, 20 Apr 2022 02:47:16 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nh0N8-0003VD-DU for pgsql-general@lists.postgresql.org; Wed, 20 Apr 2022 02:47:15 +0000 Received: by mail-pg1-x534.google.com with SMTP id t4so309730pgc.1 for ; Tue, 19 Apr 2022 19:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=e8QF9eXCyt0DTiyOH9l+PiqadTsHXzb18yfB43B12W8=; b=Zwmaizqtpm0pGNhggmXbxneAwo1bv6eJ5uvpYh9VuhTCjXY2iXe6L9c0ea7wKdRzYQ nrhXXqyfYHP7DRXrL+4fBSPwpuTOcw68foTng/Ur9OmNRu3Kq/1zoMFwJXRTfAh7VGUD PLHWOHExd/mKdqhHjBNJ1oHMFXmT7vH1KU7yCGvmNZkMDyha+zxzwcfNSefJkTz0I613 8dT4H3MXriVqVZ46x/kGGA+MdcDmfRo3CBRgqYjJ0ooJtY8+IPGs/oxi7jiZX5ArH4iY Z4M2/fiuyVD+3aq+rcRSF7IAVzkpIysSusMoQDKikNqbNiV9yBm5jYe18/ElNxtnQdIu Myow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=e8QF9eXCyt0DTiyOH9l+PiqadTsHXzb18yfB43B12W8=; b=v7MXSm1EWtHFpEBEhvyoLuso7NffquWcfoEE5XJ2Ce+ti3HeaTHDcDGNihnFKXbqY9 Am3u2fQ/V4j1aB+nMbDkoCFTFOXdiwbNbMj5P912kpa8pEfX6Q2a3KXagQ+hbSWoh/6h H/vsUZ4PVpmRcursTHOut5/8ppaZlyvt2Oq8wqefu8gh1rRdP5vWEVmuEazbqtW2gQL0 sbShKtRvbspwbqSUFmekZ+sfxDhdqA/mH+FLIy1fFi7XTlGj+V18/+/DIOh7eoRsGU2D Mg1J8eOPh85WHFn9PtZKgWa2GC3Ewl/89cM7YPVMqw2D8yZKbfNrGxLXrXc/u5YBtrUi O7zg== X-Gm-Message-State: AOAM532Bh0QqXb1YDwK5GgD6DJ8GS/q40tRbOr61OOTMayjUmsnJlXv5 D+zRbBwvb9JSeX7G3/6RPMs= X-Google-Smtp-Source: ABdhPJzMtoIFACUK6tSJ0FZFymWWhQw8Y6JR+SSayL4MxCoJU8hm3TDlg0I7+1/di58cG/vIPL/ZPg== X-Received: by 2002:a63:4412:0:b0:3a9:e7e1:81a6 with SMTP id r18-20020a634412000000b003a9e7e181a6mr12435661pga.532.1650422833192; Tue, 19 Apr 2022 19:47:13 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-fd0b-6d68-0208-e235-7ce3.dynamic-ip6.hinet.net. [2001:b011:1005:fd0b:6d68:208:e235:7ce3]) by smtp.gmail.com with ESMTPSA id u12-20020a17090a890c00b001b8efcf8e48sm20994179pjn.14.2022.04.19.19.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 19:47:12 -0700 (PDT) Date: Wed, 20 Apr 2022 10:47:07 +0800 From: Julien Rouhaud To: "David G. Johnston" Cc: Bryn Llewellyn , pgsql-general list Subject: Re: Unexpected result from ALTER =?utf-8?Q?FUNCTION?= =?utf-8?B?4oCU?= looks like a bug Message-ID: <20220420024707.zvhpbr5ztermdmm6@jrouhaud> References: <8AC9A37F-99BD-446F-A2F7-B89AD0022774@yugabyte.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Apr 19, 2022 at 07:21:19PM -0700, David G. Johnston wrote: > On Tue, Apr 19, 2022 at 7:07 PM Bryn Llewellyn wrote: > > > *SUMMARY* > > > > This part of the syntax diagram for "alter function": > > > > *ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] > > action [ … ]* > > > > says that the first "action" can be followed (without punctuation) by > > zero, one, or many other actions. A semantic rule says that no particular > > action can be specified more than once. My tests used these possible > > actions: > > > > *alter function s1.f()security invokerset timezone = 'UTC'stable* > > *parallel safe* > > *;* > > > > It brings this new status: > > > > > > > > * name | type | security | proconfig > > | volatility > > | parallel ------+------+----------+---------------------------------------------------------+------------+------------ f > > | func | invoker | {TimeZone=UTC} > > | stable | restricted* > > > > This is the bug. > > > > It has room for improvement from a user experience perspective. > > While I haven't experimented with this for confirmation, what you are > proposing here (set + parallel safe) is an impossible runtime combination > (semantic rule) but perfectly valid to write syntactically. Your function > must either be restricted or unsafe per the rules for specifying parallel > mode. > > If this is indeed what is happening then the documentation should make note > of it. Whether the server should emit a notice or warning in this > situation is less clear. I'm doubting we would introduce an error at this > point but probably should have when parallelism was first added to the > system. That's not the problem here though, as you can still end up with the wanted result using 2 queries. Also, the PARALLEL part is entirely ignored, so if you wanted to mark the function as PARALLEL UNSAFE because you're also doing a SET that would make it incompatible it would also be ignored, same if you use a RESET clause. AFAICT the problem is that SET / RESET part is messing with the HeapTuple, so you can't use the procForm reference afterwards. Simply processing parallel_item before set_items fixes the problem, as in the attached.