Given a view relation OID, how to construct a Query?

Поиск
Список
Период
Сортировка
От Eric Ridge
Тема Given a view relation OID, how to construct a Query?
Дата
Msg-id CANcm6wZs7=pzCbErBfSDt0JRUkEsqpRGwvh=ihGnoLdioK24Gg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Given a view relation OID, how to construct a Query?
Список pgsql-hackers
I'm doing some extension development (in C) and have a situation where I need to examine the target list of a view, but all I have is the view's oid.

An approach that works is (pseudocode):
   SPI_connect();
   "SELECT ev_action FROM pg_catalog.pg_rewrite WHERE rulename = '_RETURN' and ev_class=?oid";
   Query *query = linitial(stringToNode(ev_action));
   ...
   SPI_finish();

I backed into this by tracing through pg_getviewdef().  Is there a more direct way to do this without going through SPI?

I also looked at using postgres.c#pg_analyze_and_rewrite() against a query like "SELECT * FROM viewname" but the target list of the actual query wasn't what I was expecting (individual entry tags don't match those of the SPI approach above).

Thanks for your time!

eric

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Making tab-complete.c easier to maintain