Re: Multiple parameters with the same name for functions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gevik Babakhani <pgdev(at)xs4all(dot)nl>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Multiple parameters with the same name for functions.
Date: 2009-04-26 21:31:08
Message-ID: 24975.1240781468@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gevik Babakhani <pgdev(at)xs4all(dot)nl> writes:
> As I was working on my code generator app, I noticed that one is able to
> create a function with multiple parameters with the same name.

I'm pretty sure this has come up before and we concluded that
prohibiting it in CREATE FUNCTION wasn't terribly exciting. For
instance there is no compelling reason I shouldn't be able to define

create function sum(addend int, addend int) returns ...

In the context of plpgsql specifically, it might make sense to
disallow it. I notice that plpgsql is pretty sloppy about other
cases of conflicting declarations:

regression=# create function foo() returns void as $$
regression$# declare
regression$# id int := 1;
regression$# id text := 'foo';
regression$# begin
regression$# raise notice '%', id;
regression$# end$$ language plpgsql;
ERROR: syntax error at or near "id"
LINE 4: id text := 'foo';
^
regression=#

OK, failure is expected, but "syntax error"?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sam Halliday 2009-04-26 22:13:16 Re: RFE: Transparent encryption on all fields
Previous Message Martijn van Oosterhout 2009-04-26 21:15:29 Re: To know what a macro does