Re: plpgsql - variable's names conflict with table field names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: plpgsql - variable's names conflict with table field names
Date: 2004-02-17 15:01:16
Message-ID: 10330.1077030076@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> writes:
> When I declare variable with same name as field of table, then I
> have a problem with insert cmd in plpgsql procedure.

Don't do that.

> Is it plpgsql error or my bug?

You could argue it either way, perhaps, but it's unlikely to get
changed. In general plpgsql cannot tell whether a variable name
appearing in a SQL command ought to be substituted for or not, and so it
just always does it. I think trying to be smart would create as many
pitfalls as it'd solve. The best practice is not to use plpgsql
variable names that match table or field names you need to access in the
same procedure.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Boes 2004-02-17 15:44:20 pg_autovacuum bug with temp tables?
Previous Message hessam 2004-02-17 12:03:34 memory does not return back