Re: function calls in WHERE clause

From: "Lee Harr" <missive(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: function calls in WHERE clause
Date: 2004-09-09 00:31:46
Message-ID: BAY2-F23QgeDKvPEkGh0000bf3e@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2004-09-08, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>"Lee Harr" <missive(at)hotmail(dot)com> writes:
>>I should note that this_program() is defined as VOLATILE.
>
>So don't do that ;-)
>

I had a feeling that was the answer... Actually, that was my
first thought, but then I looked back at the definition of
this_program() it was marked volatile. No other function
is marked like that, so it must be that without that it just
was not working right.

I think the problem is that at other times, calls to this_program()
in the same transaction might have different results.

I have this giant Pl/PgSQL function that runs reports every
night. It goes through each schema (program)
calling that schema's report function, etc, etc.

>>It was a while ago, but I believe this is because I have
>>a this_program() defined in each schema and they
>>return a different value depending on which schema
>>you are in when you call the function...
>
>But each one of these is individually immutable, no? If it's not,
>how are you expecting your query-builder function to give the same
>answers as before?
>

So I guess I lied... :o(

It is immutable here where I am working now, but I am trying to
use the same function that needs to be mutable someplace
else... So either I need to just define a totally separate
this_program_immutable() function or go with my Pl/PgSQL
wrapper -- which is already written and working well.
So I guess that is that :o)

Thank you!

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Christian Imbeault 2004-09-09 01:36:40 FYI, Sybase performance study on Linux
Previous Message Tom Lane 2004-09-08 23:12:35 Re: How to determine a database is intact?