I don't think that this type of solution should be discussed as an official
patch.
If it was, I would recommend solving the problem in source code when the
function is passed to the translator. That way each platform could fix the
code to work with as is needed and the code would be portable.
I ran into this problem about half a year ago and it didn't go anywhere,
then I saw a long discussion about it that also didn't go anywhere. I had
given up on using plpython until now because I actually need it. So I
figured out how to make it work and thought that it would be helpful to
others, but I couldn't figure out how to automate the fix.
Hopefully, aside from the issue of having CRs inside the actual program,
using the validator function/updating pg_proc directly won't cause any
harmful ramifications. I don't have access to any other platforms right now,
aside from Windows client connected to Linux server, so I really couldn't
reliably test any other situation.
Sim
"Tom Lane" <tgl@sss.pgh.pa.us> wrote in message
news:13832.1110815662@sss.pgh.pa.us...
> Michael Fuhr <mike@fuhr.org> writes:
> > Are there any problems with doing this? Is a VALIDATOR function
> > permitted to modify the function it's validating?
>
> Well, it's not *supposed* to, but the tuple is already stored so I
> guess an UPDATE on it will work. At the moment.
>
> > This wouldn't work if plpythonu ever installs a VALIDATOR, but you
> > might be able to use it until such time (barring objections about why
> > it's a Bad Idea, that is).
>
> The proposed hack seems far too simplistic to me ... what of CRs that
> are deliberately included in string literals?
>
> I don't know Python at all, so I don't know how complicated its lexical
> structure is, but ISTM you'd at least need enough smarts to distinguish
> literals from unquoted whitespace.
>
> The other small fly in the ointment is that when the server is running
> on Windows, I suppose we would have to *put in* rather than remove CRs.
> Sim probably doesn't care about that case, but we couldn't accept an
> official patch that doesn't handle it.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>