Re: patch: plpgsql - access records with rec.(expr) - Mailing list pgsql-hackers

From Matt
Subject Re: patch: plpgsql - access records with rec.(expr)
Date
Msg-id 1101118015.4229.24.camel@matt.kynx.org
Whole thread Raw
In response to Re: patch: plpgsql - access records with rec.(expr)  (Neil Conway <neilc@samurai.com>)
Responses Re: patch: plpgsql - access records with rec.(expr)  (Neil Conway <neilc@samurai.com>)
List pgsql-hackers
Hi Neil,

Thanks for the comments. I've actually got (yet) another version ready
to go, which fixes the compile warnings and adds some sanity checks.
I'll post it as soon as I've got beta5 downloaded and tried out :)

> FYI, one thing I want to implement is an EVALUATE statement in plpgsql
> (analogous to eval() in Perl, for example). If I understand your use
> case, I think this will help somewhat, although of course it is still
> clumsier than direct syntactic support.

This would execute a string and pass back the result? I'm sure I'll find
a use for it at some point :)

> >   rec.('foo')
> 
> I don't like this: it implicitly coerces a string literal into an
> identifier (i.e. a column name). Treating data as code can be useful,
> but I think we need to make it more obvious to the user. I think a
> proper EVALUATE statement might be a better solution.

See your point. But what about NEW.($1)?

> > 5. Because of the way the expression is parsed (looking for closing
> > parenth), this will choke if you try and put a function in there. Would
> > it be better to use curly braces '{expr}' or another character to mark
> > the expression?
> 
> How much thought went into choosing parentheses? (i.e. is a similar
> syntax used in the procedural languages in other DBs?)

Only used them because of the small note I saw on the developer's TODO
about accessing cols by ordinal - the example there was rec.(1). But I
was wrong about functions not working there - plpgsql_read_expression()
is smarter than that, as you say.

OK, download is done. I've got some more general ideas which relate to
this. I'll post along with updated version.

Matt



pgsql-hackers by date:

Previous
From: Neil Conway
Date:
Subject: Re: patch: plpgsql - access records with rec.(expr)
Next
From: "Andrew Dunstan"
Date:
Subject: another plperl bug