pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Igor Korot <ikorot01@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Erik Wienhold <ewie@ewie.name>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Get table catalog from pg_indexes
Date: Sun, 27 Nov 2022 14:20:55 -0800
Message-ID: <6c498970-0286-e3bd-748f-c1ad48dadc86@aklaver.com> (raw)
In-Reply-To: <CA+FnnTyYbNfbnekXGP=tpuFWpw_bFX7-xDVasyWFcsoSHZeDMw@mail.gmail.com>
References: <CA+FnnTxHT4K+oRrVytEDVMmG1nLcH9zkMb-_wx-FyKJOJ__zTQ@mail.gmail.com>
	<1113989301.734580.1669571975787@office.mailbox.org>
	<CA+FnnTxVpKiusfntzfEaYPm8g0=VBk0h+URebXdUtFNcp2RNiQ@mail.gmail.com>
	<CAKFQuwaO3gauZGVpkAipq59bX0MvpAXRx-ts-iOd7R_+2jV9tg@mail.gmail.com>
	<CA+FnnTyYbNfbnekXGP=tpuFWpw_bFX7-xDVasyWFcsoSHZeDMw@mail.gmail.com>

On 11/27/22 14:11, Igor Korot wrote:
> David,
> 
> On Sun, Nov 27, 2022 at 12:55 PM David G. Johnston
> <david.g.johnston@gmail.com> wrote:
>>
>> On Sun, Nov 27, 2022 at 11:42 AM Igor Korot <ikorot01@gmail.com> wrote:
>>>
>>>
>>> It doesn't say anything about "current" DB - only the DB.
>>
>>
>> Yes, but you must be connected to some database in order to execute this command: "the database" refers to this database you are connected to.
> 
> Yes, I am and I get that.
> 
>>
>> The catalogs are not information_schema.
>>
>>>
>>> However, I think I can try "SELECT 1 FROM <catalog>.pg_indexes...".
>>> Will this work?
>>>
>>
>> What is that even supposed to mean?  It also seems simple enough to just do that asking "will this work" is a waste of time.  Just try it.
> 
> Apparently it looks like this query fails to execute.
> I am connected to the "draft" database and running
> 
> SELECT 1 FROM draft.pg_indexes;
> 
> gives:
> 
> [quote]
> ERROR:schema "draft" does not exist
> [/quote]

Because the layout is catalog.schema.table so:

SELECT 1 FROM draft.pg_catalog.pg_indexes;

Just because this works don't leap to assumption that:

<some_other_catalog>.pg_catalog.pg_indexes

will work. This only works with the current database name.

> 
> Thank you/
> 
>>
>> David J.
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (18+ messages)  latest in thread

Message-ID: <6c498970-0286-e3bd-748f-c1ad48dadc86@aklaver.com>
Permalink:  ../6c498970-0286-e3bd-748f-c1ad48dadc86@aklaver.com/
Also on:    postgresql.org/message-id/6c498970-0286-e3bd-748f-c1ad48dadc86@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, ikorot01@gmail.com, david.g.johnston@gmail.com, ewie@ewie.name
  Subject: Re: Get table catalog from pg_indexes
  In-Reply-To: <6c498970-0286-e3bd-748f-c1ad48dadc86@aklaver.com>
  References: <CA+FnnTxHT4K+oRrVytEDVMmG1nLcH9zkMb-_wx-FyKJOJ__zTQ@mail.gmail.com> <1113989301.734580.1669571975787@office.mailbox.org> <CA+FnnTxVpKiusfntzfEaYPm8g0=VBk0h+URebXdUtFNcp2RNiQ@mail.gmail.com> <CAKFQuwaO3gauZGVpkAipq59bX0MvpAXRx-ts-iOd7R_+2jV9tg@mail.gmail.com> <CA+FnnTyYbNfbnekXGP=tpuFWpw_bFX7-xDVasyWFcsoSHZeDMw@mail.gmail.com> <6c498970-0286-e3bd-748f-c1ad48dadc86@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox