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 1lV4KJ-0001IO-5R for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Apr 2021 03:30:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lV4KH-00034v-On for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Apr 2021 03:30:25 +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 1lV4KH-00034i-Hh for pgsql-hackers@lists.postgresql.org; Sat, 10 Apr 2021 03:30:25 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lV4KB-0006TQ-2o for pgsql-hackers@lists.postgresql.org; Sat, 10 Apr 2021 03:30:24 +0000 Received: by mail-pg1-x530.google.com with SMTP id b17so5295788pgh.7 for ; Fri, 09 Apr 2021 20:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ye4P4sofdvTXvWXNM2MOzbBBzwK0gL4D7uBUTbh1Vd8=; b=BbsoznyMoogKVJKnevwfGnoCARY3nn8rArFH6tTn+GfvBnQtBu50m3sfzewD/TnU+Y ZdjCiHT2BYJrMZuZYou2zqebRSNoonxQmc50hC47JLBTVKRWX0+wgqdI/we6LYsYbStB oE2p0oGsO2ibn5ZxFuRcURgbn/SBk8q5dWpss= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ye4P4sofdvTXvWXNM2MOzbBBzwK0gL4D7uBUTbh1Vd8=; b=e2V10Cde5lX4v0DUZ+PEeYrPstHsNGuh93p8ePPAKjk5gvGNAnBWVidJfnP5hGj5oD 2KF1p+4N1ZETg98G4AJ9282s/WjDvT0bKox7B/90ZeVbjFffl84bDHObWsEQLdFkQTB3 oTWIueGKFmF03wcEk+pwbL+UnsCmjbAPUoCYOKdA1isuqGHoZt1+jVJgzb9CbJkwP992 VWme1ho8DOpV3Gce3e6T+aPWybyV0kjCnuitL0S/cJvGM++McjYcojExxntRMm9ajDzT t5hNv0n0Rxho3JlqLn2s8H4OGH12SGunRdKYGD4NA3wElsy/BAf/Rl9xo8gRMiUhjD1h Lmqw== X-Gm-Message-State: AOAM530lcLNgZovHMX5XMbB5IHX5eAu8H4jH4/6Kk+wuDKbUZjJAUqlT dPhhwDA4ufeDyShd9HX6JPlEhw== X-Google-Smtp-Source: ABdhPJxHjl2OfmaIgCK6GKfccsZEeSKmgxyUroQ6tMlf63xLRwj3203tQDSEdb8YCR3/It2HkAbpJQ== X-Received: by 2002:a63:cd01:: with SMTP id i1mr16167118pgg.262.1618025417656; Fri, 09 Apr 2021 20:30:17 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id hi5sm2865202pjb.31.2021.04.09.20.30.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Apr 2021 20:30:17 -0700 (PDT) Date: Fri, 9 Apr 2021 20:30:14 -0700 From: Noah Misch To: Tom Lane Cc: Julien Rouhaud , Michael Paquier , Andres Freund , Peter Eisentraut , Jaime Casanova , PostgreSQL Hackers Subject: Re: SQL-standard function body Message-ID: <20210410033014.GA993491@rfd.leadboat.com> References: <01c65ea6-e5bf-22f4-cacc-6d0f6853a965@2ndquadrant.com> <1646498.1617826937@sss.pgh.pa.us> <1819824.1617858962@sss.pgh.pa.us> <20210408052759.7bmyawm4djnrux6y@alap3.anarazel.de> <1820954.1617860500@sss.pgh.pa.us> <20210408063514.houn2s3yxcorukdf@alap3.anarazel.de> <20210408111121.lsh6cvwjgk6ku7m5@nol> <2197698.1617984583@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2197698.1617984583@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 09, 2021 at 12:09:43PM -0400, Tom Lane wrote: > Finally, 0003 might be a bit controversial: it changes the stored > prosrc for new-style SQL functions to be the query text of the CREATE > FUNCTION command. The main argument I can see being made against this > is that it'll bloat the pg_proc entry. But I think that that's > not a terribly reasonable concern Such storage cost should be acceptable, but ... > The real value of 0003 of course would be to get an error cursor at > runtime A key benefit of $SUBJECT is the function body following DDL renames: create table foo (); insert into foo default values; create function count_it() returns int begin atomic return (select count(*) from foo); end; select count_it(); insert into foo default values; alter table foo rename to some_new_long_table_name; select count_it(); -- still works After the rename, any stored prosrc is obsolete. To show accurate error cursors, deparse prosqlbody and use that in place of prosrc.