Re: Regarding the correct and best way to fetching a tablename incontrib module

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Regarding the correct and best way to fetching a tablename incontrib module
Дата
Msg-id 20180626062240.GG31353@paquier.xyz
обсуждение исходный текст
Ответ на Regarding the correct and best way to fetching a tablename in contrib module  (Gaurav Mishra <gamish215@gmail.com>)
Список pgsql-hackers
On Mon, Jun 25, 2018 at 07:06:06PM +0530, Gaurav Mishra wrote:
> here what i expect as a output :
>
> create extension table_name-extract;
>
> select extract_tablename();
>
> table-name  datatype-name
> new_table  name new
> new_table1 name1 new1
>
> extract_tablename : this function should give me a table name with
> data_type inside contrib module so that i can use in the extension .

It is possible to know what is the set of objects registered within an
extension using a lookup to system catalogs.  The internal set of
queries used by psql is full of good patterns, so why not looking at
what psql -E does when using psql shortcuts and build up a query which
does what you are looking for?  If you filter the set of objects by type
(a table), then you can look at pg_attribute and get all the column names
you are looking for.  There is also not special need to write C code for
that.
--
Michael

Вложения

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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Loaded footgun open_datasync on Windows
Следующее
От: Prabhat Sahu
Дата:
Сообщение: "Access privileges" is missing after pg_dumpall