Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fn7hi-0007wx-LI for pgsql-general@arkaria.postgresql.org; Tue, 07 Aug 2018 19:31:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fn7hg-0004dr-4W for pgsql-general@arkaria.postgresql.org; Tue, 07 Aug 2018 19:31:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fn7hf-0004dk-Sv for pgsql-general@lists.postgresql.org; Tue, 07 Aug 2018 19:31:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fn7hc-0007bo-JB for pgsql-general@postgresql.org; Tue, 07 Aug 2018 19:31:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w77JVU6Q014796; Tue, 7 Aug 2018 15:31:30 -0400 From: Tom Lane To: Marcelo Lacerda cc: pgsql-general@postgresql.org Subject: Re: check_function_bodies not doing much In-reply-to: References: Comments: In-reply-to Marcelo Lacerda message dated "Tue, 07 Aug 2018 16:17:18 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14794.1533670290.1@sss.pgh.pa.us> Date: Tue, 07 Aug 2018 15:31:30 -0400 Message-ID: <14795.1533670290@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Marcelo Lacerda writes: > I was trying to get postgres to warn me that I'm referencing a table that > it doesn't exists inside a function so I was told on the IRC to check the > setting "check_function_bodies", however when I use it in a plpgsql > function it doesn't actually check if the tables in the body exist. Is this > the correct behavior? Yes. It's supposed to be a syntax check, not a check that the function would work when executed. (Depending on the particular PL you're using, which you didn't mention, it might be a pretty weak syntax check too.) An example of why a thorough check would be inadvisable is that a trigger function might contain references to OLD and NEW that are in code paths protected by checks on the trigger event type. That could be perfectly OK, but a static check couldn't tell. I believe there are some external tools floating around that check things more aggressively, and hence with a higher rate of false positives. regards, tom lane