How get column-wise table info from an arbitrary query?

Поиск
Список
Период
Сортировка
От Kenneth Tilton
Тема How get column-wise table info from an arbitrary query?
Дата
Msg-id CAECCA8agjz9SDaRQmKhy2U=_id4827MvC_h7tvAhLoTfeh-uag@mail.gmail.com
обсуждение исходный текст
Ответы Re: How get column-wise table info from an arbitrary query?
Re: How get column-wise table info from an arbitrary query?
Список pgsql-general
I am porting from MySQL some code that has to take an arbitrary query involving joins and build up a dictionary (in an HLL talking to Postgres over a socket) where each column name will be the key. The catch is that there will be duplicate entries where two joined tables have the same column such as "id", so I have to get the source table for each column. Here is a sample query:

   select * from providers p inner join provider_types pt on pt.id = p.provider_type_id;

I actually figured out how to get the table OID which would suffice, but I am porting MySQL code that could get fully qualified column names including a table alias if that were used. We allow other code to look up values in the dictionary with the alias as a prefix as a convenience, eg. "p.id" or "pt.id".

I can easily fake this if we predefine a unique alias<->table pairing (which we follow anyway), but if Postgres itself offers this it would be that much cleaner. So:

Is there any way on an arbitrary query to determine column names qualified by table aliases?

Thx, kt

--
Kenneth Tilton

Director of Software Development

MCNA Dental Plans
200 West Cypress Creek Road
Suite 500
Fort Lauderdale, FL 33309
ktilton@mcna.net (Email)

www.mcna.net (Website)CONFIDENTIALITY NOTICE: This electronic mail may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic mail or its contents by persons other than the intended recipient(s) is strictly prohibited. If you have received this communication in error, please notify the sender immediately by reply e-mail so that we may correct our internal records. Please then delete the original message. Thank you.


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: Permission denied in file_fdw (Windows)
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: How get column-wise table info from an arbitrary query?