From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Gaurav Mishra <gamish215(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Regarding the correct and best way to fetching a tablename in contrib module |
Date: | 2018-06-26 06:22:40 |
Message-ID: | 20180626062240.GG31353@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Prabhat Sahu | 2018-06-26 06:42:58 | "Access privileges" is missing after pg_dumpall |
Previous Message | Michael Paquier | 2018-06-26 06:12:02 | Re: Loaded footgun open_datasync on Windows |