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 1nkpTu-0002HC-3w for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Apr 2022 15:58:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nkpTt-000621-09 for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Apr 2022 15:58:01 +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 1nkpTs-00061s-N6 for pgsql-hackers@lists.postgresql.org; Sat, 30 Apr 2022 15:58:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nkpTq-0001l7-Oy for pgsql-hackers@lists.postgresql.org; Sat, 30 Apr 2022 15:58:00 +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 23UFvtcS610684; Sat, 30 Apr 2022 11:57:55 -0400 From: Tom Lane To: Pavel Stehule cc: PostgreSQL Hackers Subject: Re: Missing can't-assign-to-constant checks in plpgsql In-reply-to: References: <214453.1651182729@sss.pgh.pa.us> Comments: In-reply-to Pavel Stehule message dated "Fri, 29 Apr 2022 00:11:09 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <610682.1651334275.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sat, 30 Apr 2022 11:57:55 -0400 Message-ID: <610683.1651334275@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Pavel Stehule writes: > čt 28. 4. 2022 v 23:52 odesílatel Tom Lane napsal: >> Perhaps the OPEN change is a little too aggressive, since if >> you give the refcursor variable some non-null initial value, >> OPEN won't change it; in that usage a CONSTANT marking could >> be allowed. But I really seriously doubt that anybody out >> there is marking such variables as constants, so I thought >> throwing the error at compile time was better than postponing >> it to runtime so we could handle that. >> >> Regardless of which way we handle that point, I'm inclined to >> change this only in HEAD. Probably people wouldn't thank us >> for making the back branches more strict. > +1 After sleeping on it, I got cold feet about breaking arguably legal code, so I made OPEN check at runtime instead. Which was probably a good thing anyway, because it made me notice that exec_stmt_forc() needed a check too. AFAICS there are no other places in pl_exec.c that are performing assignments to variables not checked at parse time. Pushed that way. regards, tom lane