Skip site navigation (1) Skip section navigation (2)

BUG #1875: Function parameter names clash with table column names

From: "Byron" <byron(dot)hammond(at)westnet(dot)com(dot)au>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1875: Function parameter names clash with table column names
Date: 2005-09-10 16:46:44
Message-ID: 20050910164644.32CF0F0C65@svr2.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      1875
Logged by:          Byron
Email address:      byron(dot)hammond(at)westnet(dot)com(dot)au
PostgreSQL version: 8.0.3
Operating system:   Windows XP
Description:        Function parameter names clash with table column names
Details: 

-----------------------------
Error Details from PgAdminIII
-----------------------------
ERROR:  syntax error at or near "$1" at character 28
QUERY:  INSERT INTO test_table_0 ( $1 ,  $2 ,  $3 ) VALUES ( $4 ,  $5 ,  $6
)
CONTEXT:  PL/pgSQL function "test_function_0" line 2 at SQL statement

------------
Problem Code
------------
CREATE TABLE test_table_0 (
	a	varchar(255),
	b	varchar(255),
	c	varchar(255)
);

CREATE OR REPLACE FUNCTION test_function_0(a varchar, b varchar, c varchar)
RETURNS INTEGER AS $$
BEGIN
	INSERT INTO test_table_0 (a, b, c) VALUES (a, b, c);
	RETURN 1;
END
$$ LANGUAGE 'plpgsql';

SELECT test_function_0('a', 'b', 'c');

DROP FUNCTION test_function_0(varchar, varchar, varchar);
DROP TABLE test_table_0;

-------------------
Additional Comments
-------------------
It appears in this case that the parameter names of the 
function cannot be the same as the column names used
by the INSERT statement -- clashes.

Responses

pgsql-bugs by date

Next:From: Peter EisentrautDate: 2005-09-10 19:51:45
Subject: Re: BUG #1874: Non-Execute Privileges enforced on grant
Previous:From: Mark DienerDate: 2005-09-10 08:33:15
Subject: BUG #1874: Non-Execute Privileges enforced on grant

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group