>
> if I want to write a function for getting the view.field's source
> table.field
> how could I achieve it?
>
This sounds like a real challange.
Throughout the years I've had to learn it's always a pain to
retrieve system catalog information - no matter which
DBMS is in use.
On the other hand, you have to face the fact that
view.field's sources are not necessarily directly derived
from a table.field.
A view.field's source may be any expression including aggregates.
So, the only way I can think of achieving that is
SELECT definition from pg_views where viewname='<your view name>';
and then your function has to parse the result. Good luck.
Regards, Christoph