[HACKERS] Given a view relation OID, how to construct a Query?

2015-12-09 Thread Eric Ridge
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

Re: [HACKERS] Given a view relation OID, how to construct a Query?

2015-12-09 Thread Tom Lane
Eric Ridge writes: > On Wed, Dec 9, 2015 at 4:04 PM Tom Lane wrote: >> Open the relation and use get_view_query(), perhaps. > I figured there was something simple, but I couldn't find it. Thanks! > Sadly, it's static. FWIW, it's exposed in 9.4 and up.

Re: [HACKERS] Given a view relation OID, how to construct a Query?

2015-12-09 Thread Tom Lane
Eric Ridge writes: > 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. Open the relation and use get_view_query(), perhaps. regards, tom lane --

Re: [HACKERS] Given a view relation OID, how to construct a Query?

2015-12-09 Thread Eric Ridge
On Wed, Dec 9, 2015 at 5:07 PM Tom Lane wrote: > > FWIW, it's exposed in 9.4 and up. But in older branches you could > probably just copy it, it's not that big. > That's good to know, thanks. I did copy it and it's almost 3x faster than going through SPI. Thanks again for

Re: [HACKERS] Given a view relation OID, how to construct a Query?

2015-12-09 Thread Eric Ridge
On Wed, Dec 9, 2015 at 4:04 PM Tom Lane wrote: > Eric Ridge writes: > > 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. > > Open the relation and use