dbTalk Databases Forums  

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

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] plpgsql - variable's names conflict with table field in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pavel Stehule
 
Posts: n/a

Default Re: [BUGS] plpgsql - variable's names conflict with table field - 02-17-2004 , 09:53 AM






On Tue, 17 Feb 2004, Tom Lane wrote:

Quote:
Pavel Stehule <stehule (AT) kix (DOT) fsv.cvut.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.
I haven't problem with it. I found it when I ported procedures from Solid
db. Can You add big warning about it to plpgsql documentation? This is
very tricky "bug". Insert reports syntax error, ok. But Select reports nothink.

Regard
Pavel

Quote:
regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.