Getting relations accessed by a query using the raw query string

Поиск
Список
Период
Сортировка
От Amin
Тема Getting relations accessed by a query using the raw query string
Дата
Msg-id CAF-KA89hG0Z09gcwkqTaa+v3ivXba8xMr4xn6a_DqTyAe-G38w@mail.gmail.com
обсуждение исходный текст
Список pgsql-hackers
Hi,

Having a query string, I am trying to use the postgres parser to find which relations the query accesses. This is what I currently have:

const char *query_string="select * from dummytable;";
List *parsetree_list=pg_parse_query(query_string);
ListCell *parsetree_item;

foreach(parsetree_item,parsetree_list){
      RawStmt *parsetree=lfirst_node(RawStmt,parsetree_item);
      Query *query=parse_analyze(parsetree,query_string,NULL,0,NULL);
}

However, when I inspect the variable "query", it is not populated correctly. For example, commandType is set to CMD_DELETE while I have passed a SELECT query.
- What am I doing wrong?
- Once I get the query correctly, how can I get the list of relations it gets access to?
- Or any other ways to get the list of relations from raw query string through postgres calls?

Thank you!

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

Предыдущее
От: Peter Smith
Дата:
Сообщение: Re: Perform streaming logical transactions by background workers and parallel apply
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: 011_crash_recovery.pl intermittently fails