Getting list of tables used within a query - Mailing list pgsql-general

From Marek Lewczuk
Subject Getting list of tables used within a query
Date
Msg-id daadfdc20907160151r790e11ah83c7df5916205bf1@mail.gmail.com
Whole thread Raw
Responses Re: Getting list of tables used within a query
List pgsql-general
Hi,
for need of our application we need to get list of tables, that are
used within given SELECT query - we need them in order to track
changes of the data, that may be returned by the query - it is some
kind of caching mechanism, that checks db data modifications. Right
now we create a temporary view and after that we use
information_schema.view_table_usage - it works fine, but it has two
disadvantages - firstly is quite slow and secondly only owner of the
tables can do that, which means that application must use two types of
connections, one for normal operations and second for getting list of
tables. Is there any other way to achieve that without need of using
owner role and without creating a view ? Browsing the PG source I see
that include/parser/.. can be used, but its quite complicated
(especially for me as I'm not to good in C programming) - maybe anyone
has some examples how to use parser to achieve my goals or maybe
someone already has got working code that does similar things ?

Best wishes,
ML

pgsql-general by date:

Previous
From: Andreas Wenk
Date:
Subject: Re: best practice transitioning from one datatype to another
Next
From: Rafael Martinez
Date:
Subject: Problems with 8.4, FLOAT8PASSBYVAL and x86_64 GNU/Linux