Re: Function call order dependency
От | pgsql@mohawksoft.com |
---|---|
Тема | Re: Function call order dependency |
Дата | |
Msg-id | 46690.64.119.130.186.1220460385.squirrel@mail.mohawksoft.com обсуждение исходный текст |
Ответ на | Re: Function call order dependency ("Robert Haas" <robertmhaas@gmail.com>) |
Список | 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 >
В списке pgsql-hackers по дате отправления: