From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Igor Korot <ikorot01@gmail.com>
Cc: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Connecting pg_attribute with pg_namespace
Date: Sat, 31 Oct 2026 17:48:12 -0400
Message-ID: <311744.1793483292@sss.pgh.pa.us> (raw)
In-Reply-To: <92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com>
References: <CA+FnnTxQm4ppiWvW018rJ9F8ZoiEJ7sXtFbNU-r=_92_cEtJUQ@mail.gmail.com>
<CANzqJaBbwVDh-Toan6aiPA=HKqbVk7poZ7D8VnhBDJJHwAbjAw@mail.gmail.com>
<CA+FnnTyp_g2rABTzMU7Hrsk4V-UN1gmZicOuzGeqBwPOcKoesA@mail.gmail.com>
<92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 10/31/26 3:04 PM, Igor Korot wrote:
>> I have a schema name as a string.
>> Should I cast that value to something when I write
>> "pg_class.relnamespace = 'public'"?
> select relname from pg_catalog.pg_class where relname = 'cell_per' and
> relnamespace = 'public'::regnamespace;
Given that the original requirement was
>>> SELECT attnum FROM pg_attribute WHERE attrelid = 'my_table_name';
maybe just
SELECT attnum FROM pg_attribute
WHERE attrelid = 'my_schema_name.my_table_name'::regclass;
? But doing the joins explicitly is probably more adaptable
to more-complex cases.
regards, tom lane
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: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, ikorot01@gmail.com, ronljohnsonjr@gmail.com
Subject: Re: Connecting pg_attribute with pg_namespace
In-Reply-To: <311744.1793483292@sss.pgh.pa.us>
References: <CA+FnnTxQm4ppiWvW018rJ9F8ZoiEJ7sXtFbNU-r=_92_cEtJUQ@mail.gmail.com> <CANzqJaBbwVDh-Toan6aiPA=HKqbVk7poZ7D8VnhBDJJHwAbjAw@mail.gmail.com> <CA+FnnTyp_g2rABTzMU7Hrsk4V-UN1gmZicOuzGeqBwPOcKoesA@mail.gmail.com> <92aca255-3ca3-4cb1-aec5-593b7eb3c275@aklaver.com> <311744.1793483292@sss.pgh.pa.us>
* 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