From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marcelo Lacerda <marceloslacerda@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: check_function_bodies not doing much
Date: Tue, 07 Aug 2018 15:31:30 -0400
Message-ID: <14795.1533670290@sss.pgh.pa.us> (raw)
In-Reply-To: <CAPmRTtMC=4ZTZ_-oobpyDUqewn7r2WHzza-UPnx8cdbKmuG-TA@mail.gmail.com>
References: <CAPmRTtMC=4ZTZ_-oobpyDUqewn7r2WHzza-UPnx8cdbKmuG-TA@mail.gmail.com>
Marcelo Lacerda <marceloslacerda@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, marceloslacerda@gmail.com
Subject: Re: check_function_bodies not doing much
In-Reply-To: <14795.1533670290@sss.pgh.pa.us>
References: <CAPmRTtMC=4ZTZ_-oobpyDUqewn7r2WHzza-UPnx8cdbKmuG-TA@mail.gmail.com> <14795.1533670290@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox