Re: varattno remapping

Поиск
Список
Период
Сортировка
От Abbas Butt
Тема Re: varattno remapping
Дата
Msg-id CALtH27ffKsg+YL+=vivRy+wcd9Tnfpv-HYgtvGDj83RVNRbBpg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: varattno remapping  (Craig Ringer <craig@2ndquadrant.com>)
Ответы Re: varattno remapping
Re: varattno remapping
Список pgsql-hackers



On Tue, Dec 24, 2013 at 11:47 AM, Craig Ringer <craig@2ndquadrant.com> wrote:
On 12/24/2013 02:35 PM, Craig Ringer wrote:

> So the short version: Given the RTE for a simple view with only one base
> rel and an attribute number for a col in that view, and assuming that
> the view col is a simple reference to a col in the underlying base rel,
> is there any sane way to get the attribute number for the corresponding
> col on the base rel?

So, of course, I find it as soon as I post.

map_variable_attnos(...), also in src/backend/rewrite/rewriteManip.c .

Just generate the mapping table and go.

Could you please explain a little bit more how would you solve the posed problem using map_variable_attnos?

I was recently working on a similar problem and used the following algo to solve it.

I had to find to which column of the base table does a column in the select statement of the view query belong.
To relate a target list entry in the select query of the view to an actual column in base table here is what I did

First determine whether the var's varno refer to an RTE which is a view?
If yes then get the view query (RangeTblEntry::subquery) and see which element in the view query's target list does this var's varattno point to.
Get the varno of that target list entry. Look for that RTE in the view's query and see if that RTE is a real table then use that var making sure its varno now points to the actual table.

Thanks in advance.

 

Sorry for the noise folks.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



--
--
Abbas
Architect
Skype ID: gabbasb
www.enterprisedb.com

Follow us on Twitter

@EnterpriseDB

Visit EnterpriseDB for tutorials, webinars, whitepapers and more

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: varattno remapping
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: trailing comment ghost-timing