Getting list of tables used within a query

From: Marek Lewczuk <newsy(at)lewczuk(dot)com>
To: PGSQL <pgsql-general(at)postgresql(dot)org>
Subject: Getting list of tables used within a query
Date: 2009-07-16 08:51:33
Message-ID: daadfdc20907160151r790e11ah83c7df5916205bf1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Massa, Harald Armin 2009-07-16 08:53:37 overwrite the encoding of a database
Previous Message Andreas Wenk 2009-07-16 08:46:40 Re: best practice transitioning from one datatype to another