Function call order dependency - Mailing list pgsql-hackers

From pgsql@mohawksoft.com
Subject Function call order dependency
Date
Msg-id 45362.71.232.149.185.1220444648.squirrel@mail.mohawksoft.com
Whole thread Raw
Responses Re: Function call order dependency  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Function call order dependency  ("Stephen R. van den Berg" <srb@cuci.nl>)
List pgsql-hackers
Is there a knowable order in which functions are called within a query in
PostgreSQL?

For example I'll use the Oracle "contains" function, though this is not
exactly what I'm doing, it just illustrates the issue clearly.

select *, score(1) from mytable where contains(mytable.title, 'Winding
Road', 1) order by score(1);

The "contains" function does a match against mytable.title for the term
'Winding Road' and both returns and saves an integer score which may be
retrieved later using the "score(...)" function. The integer used as a
parameter in score(...) and contains(...) is an index to reference which
score you need as more than one contains(...) call may be used in single
query.

This sets up an interesting issue, how can one ensure that "contains()" is
called prior to any "score()" function on each row? Is this possible? Is
there a specific order on which you can count?

Would it be something like: "where" clause first, left to right, followed
by select terms, left to right, and lastly the "order by" clause?


pgsql-hackers by date:

Previous
From: "Hitoshi Harada"
Date:
Subject: Re: Window functions patch v04 for the September commit fest
Next
From: Andrew Chernow
Date:
Subject: Re: libpq object hooks (libpq events)