The following bug has been logged online: Bug reference: 3649 Logged by: Audrius Meskauskas Email address: [EMAIL PROTECTED] PostgreSQL version: PostgreSQL 8.1. Operating system: SUSE Description: Confusing error message: ERROR: syntax error at or near "$1" Details:
When defining the PL/pgSQL function, the error message "ERROR: syntax error at or near "$1" " appears in the case when the name of the local variable clashes with the name of the database table. If find this message highly unsupportative, as it does not provide any hint about the real reason of the problem. The test case: -- Checks if the same sensor is not measuring at the same time -- for another point. create or replace function test() returns void as ' declare -- dttx integer; -- and this works dtt integer; -- syntax error at or near "$1" v varchar; begin select dtt.serial into v from dtt where id = 1; end; ' LANGUAGE plpgsql; In this example, the variable name dtt conflicts with the table name dtt. The problem may look trivial here, but it is distillation from much larger code where it was not easy to locate. Expected behavior: message like "variabe name dtt conflicts with table name" or at least "naming conflict" if it seems too problematic to implement. ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend