Re: patch: plpgsql - access records with rec.(expr)

From: Matt <matt(at)kynx(dot)org>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: plpgsql - access records with rec.(expr)
Date: 2004-11-22 10:06:55
Message-ID: 1101118015.4229.24.camel@matt.kynx.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2004-11-22 12:37:46 another plperl bug
Previous Message Neil Conway 2004-11-22 08:28:47 Re: patch: plpgsql - access records with rec.(expr)