From: | pgsql(at)mohawksoft(dot)com |
---|---|
To: | "Robert Haas" <robertmhaas(at)gmail(dot)com> |
Cc: | "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Function call order dependency |
Date: | 2008-09-03 16:46:25 |
Message-ID: | 46690.64.119.130.186.1220460385.squirrel@mail.mohawksoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>> I was kind of afraid of that. So, how could one implement such a
>> function
>> set?
>
> Write a function (say, score_contains) that returns NULL whenever
> contains would return false, and the score otherwise.
>
> SELECT * FROM (
> SELECT *, score_contains(mytable.title, 'Winding Road', 1) AS
> score FROM mytable
> ) x WHERE x.score IS NOT NULL
> ORDER BY x.score
That could work, and while it fits my example, my actual need is a bit
more complex. For instance, say I have two variables (I actually have a
few that I need)
select myvar1(1), myvar2(1), myvar3(1) from mytable where
myfunction(mytable.column, 'some text to search for', 1) > 2;
How could I ensure that (1) "myfunction" is called prior to myvar1(),
myvar2(), and myvar3()? I think the answer is that I can't. So, the
obvious solution is to pass all the variables to all the functions and
have it first come first served.
The next issue is something like this:
select *, myvar1(t1.col1,t2.col2,1), myvar2(t1.col1.t2.col2,1) from t1,t2
where myfunction(t1.col1,t2.col2,1) > 10 order by
myvar3(t1.col1,t2.col2,1) desc;
Using a "first come first served" strategy, is there any discontinuity
between the function calls for t1.col1 and t2.col2. Will they all be
called for a particular combination of t1.col1 and t2.col2, in some
unpredictable order before the next row(s) combination is evaluated or
will I have to execute the underlying algorithm for each and every call?
>
> ...Robert
>
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-09-03 16:55:44 | Re: libpq object hooks (libpq events) |
Previous Message | pgsql | 2008-09-03 16:34:59 | Re: Function call order dependency |