pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/RO
4+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2019-03-23 fb50d3f03f  Add unreachable "break" to satisfy -Wimplicit-fallthrough.
* pgsql: Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/RO
@ 2019-03-21 15:52  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2019-03-21 15:52 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/ROUTINE.

These commands allow the argument type list to be omitted if there is
just one object that matches by name.  However, if that syntax was
used with DROP IF EXISTS and there was more than one match, you got
a "function ... does not exist, skipping" notice message rather than a
truthful complaint about the ambiguity.  This was basically due to
poor factorization and a rats-nest of logic, so refactor the relevant
lookup code to make it cleaner.

Note that this amounts to narrowing the scope of which sorts of
error conditions IF EXISTS will bypass.  Per discussion, we only
intend it to skip no-such-object cases, not multiple-possible-matches
cases.

Per bug #15572 from Ash Marath.  Although this definitely seems like
a bug, it's not clear that people would thank us for changing the
behavior in minor releases, so no back-patch.

David Rowley, reviewed by Julien Rouhaud and Pavel Stehule

Discussion: https://postgr.es/m/15572-ed1b9ed09503de8a@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bfb456c1b9656d5b717b84d833f62cf712b21726

Modified Files
--------------
src/backend/parser/parse_func.c              | 396 ++++++++++++++++++---------
src/include/parser/parse_func.h              |   4 +-
src/test/regress/expected/drop_if_exists.out |  29 ++
src/test/regress/sql/drop_if_exists.sql      |  24 ++
4 files changed, 328 insertions(+), 125 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/RO
@ 2019-03-23 02:33  Andres Freund <andres@anarazel.de>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Andres Freund @ 2019-03-23 02:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; David Rowley <david.rowley@2ndquadrant.com>; +Cc: pgsql-committers@lists.postgresql.org

Hi,

On 2019-03-21 15:52:23 +0000, Tom Lane wrote:
> Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/ROUTINE.
> 
> These commands allow the argument type list to be omitted if there is
> just one object that matches by name.  However, if that syntax was
> used with DROP IF EXISTS and there was more than one match, you got
> a "function ... does not exist, skipping" notice message rather than a
> truthful complaint about the ambiguity.  This was basically due to
> poor factorization and a rats-nest of logic, so refactor the relevant
> lookup code to make it cleaner.
> 
> Note that this amounts to narrowing the scope of which sorts of
> error conditions IF EXISTS will bypass.  Per discussion, we only
> intend it to skip no-such-object cases, not multiple-possible-matches
> cases.
> 
> Per bug #15572 from Ash Marath.  Although this definitely seems like
> a bug, it's not clear that people would thank us for changing the
> behavior in minor releases, so no back-patch.
> 
> David Rowley, reviewed by Julien Rouhaud and Pavel Stehule
> 
> Discussion: https://postgr.es/m/15572-ed1b9ed09503de8a@postgresql.org

I now get:

/home/andres/src/postgresql/src/backend/parser/parse_func.c: In function ‘LookupFuncWithArgs’:
/home/andres/src/postgresql/src/backend/parser/parse_func.c:2285:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
     switch (objtype)
     ^~~~~~
/home/andres/src/postgresql/src/backend/parser/parse_func.c:2336:4: note: here
    case FUNCLOOKUP_AMBIGUOUS:
    ^~~~

which seems like a somewhat righteous complaint? I'd just add a break to
silence it (which can't be reached, because all paths ought to error
out).

Greetings,

Andres Freund




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/RO
@ 2019-03-23 02:39  David Rowley <david.rowley@2ndquadrant.com>
  parent: Andres Freund <andres@anarazel.de>
  0 siblings, 1 reply; 4+ messages in thread

From: David Rowley @ 2019-03-23 02:39 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-committers@lists.postgresql.org

On Sat, 23 Mar 2019 at 15:33, Andres Freund <andres@anarazel.de> wrote:
> I now get:
>
> /home/andres/src/postgresql/src/backend/parser/parse_func.c: In function ‘LookupFuncWithArgs’:
> /home/andres/src/postgresql/src/backend/parser/parse_func.c:2285:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
>      switch (objtype)
>      ^~~~~~
> /home/andres/src/postgresql/src/backend/parser/parse_func.c:2336:4: note: here
>     case FUNCLOOKUP_AMBIGUOUS:
>     ^~~~
>
> which seems like a somewhat righteous complaint? I'd just add a break to
> silence it (which can't be reached, because all paths ought to error
> out).

hmm. Surprised your compiler can't see that's not possible. I guess we
just need a break on line 2335.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/RO
@ 2019-03-23 05:27  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David Rowley <david.rowley@2ndquadrant.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2019-03-23 05:27 UTC (permalink / raw)
  To: David Rowley <david.rowley@2ndquadrant.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-committers@lists.postgresql.org

David Rowley <david.rowley@2ndquadrant.com> writes:
> On Sat, 23 Mar 2019 at 15:33, Andres Freund <andres@anarazel.de> wrote:
>> I now get:
>> /home/andres/src/postgresql/src/backend/parser/parse_func.c:2285:5: warning: this statement may fall through [-Wimplicit-fallthrough=]

> hmm. Surprised your compiler can't see that's not possible. I guess we
> just need a break on line 2335.

Yeah, this no doubt is connected to what I noticed in commit 41c912cad:
    
    Testing with gcc 8.0.1 (Fedora 28's current version), I found that
    I also had to put explicit "break"s after elog(ERROR) or ereport(ERROR);
    apparently, for this purpose gcc doesn't recognize that those don't
    return.  That seems like possibly a gcc bug, but it's fine because
    in most places we did that anyway; so this amounts to a visit from the
    style police.

Will add the break shortly.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-03-23 05:27 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 15:52 pgsql: Improve error reporting for DROP FUNCTION/PROCEDURE/AGGREGATE/RO Tom Lane <tgl@sss.pgh.pa.us>
2019-03-23 02:33 ` Andres Freund <andres@anarazel.de>
2019-03-23 02:39   ` David Rowley <david.rowley@2ndquadrant.com>
2019-03-23 05:27     ` Tom Lane <tgl@sss.pgh.pa.us>

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