public inbox for [email protected]  
help / color / mirror / Atom feed
From: Igor Korot <[email protected]>
To: David G. Johnston <[email protected]>
Cc: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: Where the info is stored
Date: Sat, 28 Feb 2026 23:34:58 -0600
Message-ID: <CA+FnnTwaK-Z26KeqoPsAkKPJHo9OjMJdSse8tXE-KSFV9y0g_Q@mail.gmail.com> (raw)
In-Reply-To: <CAKFQuwbTpwDiUy=azMGk8tMo7w2ysWC1h02NmURCqGRqcAhSCw@mail.gmail.com>
References: <CA+FnnTwmt7BOqwZnsB5LOq47U+wzRc86wXaea9B0KEXfK2O+Kw@mail.gmail.com>
	<CAKFQuwa2ef9Bxz79Q8JtVNxmMABN829EJqiLKXxB5=5AEHyr9w@mail.gmail.com>
	<CAKFQuwa9PsXitAWuG1hg-8EPOu0AdB2TiANaBRJfgSrdjioa+Q@mail.gmail.com>
	<CA+FnnTz51Ond5HGkDgKvRB6ERi3pr5Q1wTnwoMK8rCwsm79_sA@mail.gmail.com>
	<CAKFQuwa7rK-NfVwHT7_Nob6S=GN-tKK7F1+eLQ-FQZMsW3gd8g@mail.gmail.com>
	<CA+FnnTw0bNsDBKFEQKsrjFZKqiZgRVZ27zhgXs5sqCLW=bwBVw@mail.gmail.com>
	<CA+FnnTwEWFq1BopZ4o_kEg3SuZvGE+Xhg1sur=c_HjcZ_FjTag@mail.gmail.com>
	<CAKFQuwbTpwDiUy=azMGk8tMo7w2ysWC1h02NmURCqGRqcAhSCw@mail.gmail.com>

Hi, David,

On Sat, Feb 28, 2026 at 7:42 PM David G. Johnston
<[email protected]> wrote:
>
> On Sat, Feb 28, 2026 at 6:34 PM Igor Korot <[email protected]> wrote:
>>
>> And why there is no WHERE populated?
>>
>> Thank you.
>>
>> On Sat, Feb 28, 2026 at 7:05 PM Igor Korot <[email protected]> wrote:
>> >
>> > Hi, David,
>> >
>> > On Sat, Feb 28, 2026 at 7:02 PM David G. Johnston
>> > <[email protected]> wrote:
>> > >
>> > > On Saturday, February 28, 2026, Igor Korot <[email protected]> wrote:
>> > >>
>> > >> FROM pg_constraint co, pg_namespace n, pg_class
>> > >>
>> > >> As you can see only the constraint name and the tablespace are
>> > >> populated correctly.
>> > >
>> > >
>> > > Constraints don’t have included columns.  Only indexes do.  You need to query the index, not the constraint.
>> >
>> > I literally copied your query into my code and it didn't populated
>> > anything...
>> >
>> > Am I missing something?
>>
>
> I trimmed your query to emphasize/point-out that you were querying pg_constraint and that doing so to find included columns is doomed to failure (I suppose it could have been used to find the index, but in this case it wasn't.  I haven't explored that approach.).  You should step back and consider why you thought the fragment I included in my reply, a bare FROM clause, would somehow be executable since it is in no way a valid query.

draft=#  WITH idx AS(  SELECT i.indexrelid, i.indrelid, i.indnkeyatts,
i.indkey::int2[] AS indkey FROM pg_index i, pg_class ic, pg_namespace
ns WHERE ic.oid = i.indexrelid AND ns.oid = ic.relnamespace AND
ns.nspname = 'public' AND ic.relname = 'leagues_new' ), ords AS (
SELECT idx.indexrelid, idx.indrelid, idx.indnkeyatts, s.ord,
idx.indkey[s.ord] AS attnum FROM idx CROSS JOIN LATERAL
generate_subscripts(idx.indkey, 1) AS s(ord) ) SELECT ns.nspname,
ic.relname, tc.relname, a.attname, CASE WHEN ords.ord <
ords.indnkeyatts THEN 'key' ELSE 'include' END, ords.ord + 1 AS
index_position  FROM pg_attribute a, ords, pg_class ic, pg_namespace
ns, pg_class tc WHERE a.attrelid = ords.indrelid AND a.attnum =
ords.attnum AND NOT a.attisdropped AND ic.oid = ords.indexrelid AND
ns.oid = ic.relnamespace AND tc.oid = ords.indrelid AND ords.ord >
ords.indnkeyatts;
 nspname | relname | relname | attname | case | index_position
---------+---------+---------+---------+------+----------------
(0 rows)

draft=#

This is an exact replica of your query from the first post where you put it.

I only removed AS statements.

As you can see 0 rows are returned.

Thank you.

>
> David J.
>






view thread (14+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Where the info is stored
  In-Reply-To: <CA+FnnTwaK-Z26KeqoPsAkKPJHo9OjMJdSse8tXE-KSFV9y0g_Q@mail.gmail.com>

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

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