From: | Amin <amin(dot)fallahi(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Traversing targetlist to find accessed columns |
Date: | 2022-12-02 02:17:31 |
Message-ID: | CAF-KA88taQOdRs5-SPJRoS0qEKbr=wg7XvPbf5Hy_NSaHYGnPg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
Having a query, I am trying to find out all the columns that need to be
accessed (their varattno and vartype). I have access to a targetlist
representing a tree like this. So, I am looking for a function that
recursively traverses the tree and gives me the VARs. So, for SELECT
a,b,b+c from tab; I am interested in [a,b]. Is such a function currently
implemented in postgresql? How can I use it?
:targetlist (
> {TARGETENTRY
> :expr
> {VAR
> :varno 1
> :varattno 1
> :vartype 23
> :vartypmod -1
> :varcollid 0
> :varlevelsup 0
> :varnosyn 1
> :varattnosyn 1
> :location 7
> }
> :resno 1
> :resname l_orderkey
> :ressortgroupref 0
> :resorigtbl 24805
> :resorigcol 1
> :resjunk false
> }
> {TARGETENTRY
> :expr
> {VAR
> :varno 1
> :varattno 2
> :vartype 23
> :vartypmod -1
> :varcollid 0
> :varlevelsup 0
> :varnosyn 1
> :varattnosyn 2
> :location 18
> }
> :resno 2
> :resname l_partkey
> :ressortgroupref 0
> :resorigtbl 24805
> :resorigcol 2
> :resjunk false
> }
> {TARGETENTRY
> :expr
> {OPEXPR
> :opno 551
> :opfuncid 177
> :opresulttype 23
> :opretset false
> :opcollid 0
> :inputcollid 0
> :args (
> {OPEXPR
> :opno 551
> :opfuncid 177
> :opresulttype 23
> :opretset false
> :opcollid 0
> :inputcollid 0
> :args (
> {VAR
> :varno 1
> :varattno 1
> :vartype 23
> :vartypmod -1
> :varcollid 0
> :varlevelsup 0
> :varnosyn 1
> :varattnosyn 1
> :location 28
> }
> {VAR
> :varno 1
> :varattno 2
> :vartype 23
> :vartypmod -1
> :varcollid 0
> :varlevelsup 0
> :varnosyn 1
> :varattnosyn 2
> :location 39
> }
> )
> :location 38
> }
> {VAR
> :varno 1
> :varattno 3
> :vartype 23
> :vartypmod -1
> :varcollid 0
> :varlevelsup 0
> :varnosyn 1
> :varattnosyn 3
> :location 49
> }
> )
> :location 48
> }
> :resno 3
> :resname ?column?
> :ressortgroupref 0
> :resorigtbl 0
> :resorigcol 0
> :resjunk false
> }
> )
>
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2022-12-02 02:36:03 | Re: Using WaitEventSet in the postmaster |
Previous Message | Andres Freund | 2022-12-02 02:10:17 | Re: Using AF_UNIX sockets always for tests on Windows |