public inbox for pgsql-odbc@postgresql.org
help / color / mirror / Atom feedFrom: Igor Korot <ikorot01@gmail.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Does included columns part of the PK
Date: Sun, 15 Mar 2026 01:24:38 -0500
Message-ID: <CA+FnnTwLvp1wweqWJkw1+sg4x+pM_oGVmfc-3TaPpE_557=A_A@mail.gmail.com> (raw)
In-Reply-To: <3547f40b-08b9-4d0c-bba8-f1c26d0bf09d@aklaver.com>
References: <CA+FnnTz7+dbyk5Gn2iM-eo1Xvfax15yjBevmCCfvo0-UVW1K7Q@mail.gmail.com>
<b3f6ecfb-8772-4e15-a772-8e64fb573d49@aklaver.com>
<CAKFQuwYswndGOm6vnsoNSTWHEC5d29bvYokymtDEY_cyW54FEQ@mail.gmail.com>
<CA+FnnTyFVn4Ebx9kP-5vooZwpATwV5Euc8Nt6TGmEuR6oDYd9A@mail.gmail.com>
<3547f40b-08b9-4d0c-bba8-f1c26d0bf09d@aklaver.com>
Hi, Adrian,
On Sat, Mar 14, 2026 at 6:30 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>
> On 3/14/26 9:56 AM, Igor Korot wrote:
> > Hi,
> >
> > On Sat, Mar 14, 2026 at 8:51 AM David G. Johnston
> > <david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>> wrote:
> >
> > On Saturday, March 14, 2026, Adrian Klaver
> > <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
> >
> > On 3/14/26 12:09 AM, Igor Korot wrote:
> >
> > Hi, ALL,
> > Have one weird question ;-)
> >
> > When I connect with ODBC and call SQLPrimaryKey() the
> > function returns
> >
> >
> > Are you actually using the SQLPrimaryKeys(), not SQLPrimaryKey()?
> >
> > all fields including
> > "included" fields.
> >
> >
> > Define 'included' fields.
> >
> >
> > They are referring to the unique index that backs the PK constraint.
> >
> >
> > Not “they” - “He”. 😊
> >
> > And yes - that’s what I’m referring to.
>
> From here:
>
>
> https://www.ibm.com/docs/en/db2-for-zos/12.0.0?topic=functions-sqlprimarykeys-get-primary-key-column...:
>
> 1 TABLE_CAT VARCHAR(128) This is always null.
> 2 TABLE_SCHEM VARCHAR(128) The name of the schema containing TABLE_NAME.
> 3 TABLE_NAME VARCHAR(128) NOT NULL Name of the specified table.
> 4 COLUMN_NAME VARCHAR(128) NOT NULL Primary key column name.
> 5 KEY_SEQ SMALLINT NOT NULL Column sequence number in the primary key,
> starting with 1.
> 6 PK_NAME VARCHAR(128) Primary key identifier. Contains a null value if
> not applicable to the data
>
>
Lets start with the beginning:
draft=# CREATE TABLE leagues_new(id serial, name varchar(100),
drafttype smallint, scoringtype smallint, roundvalues smallint,
leaguetype char(5), salary integer, benchplayers smallint, primary
key(id) INCLUDE (drafttype, scoringtype) WITH( fillfactor = 50,
deduplicate_items = OFF ));
CREATE TABLE
draft=#
> From here:
>
> https://github.com/postgresql-interfaces/psqlodbc/blob/main/info.c
>
> At line 4035 in SQLPrimaryKeys()
>
> For case 1
>
> /*
> * Simplified query to remove assumptions about number of
> * possible index columns. Courtesy of Tom Lane - thomas
> * 2000-03-21
> */
>
> [...]
>
> "select ta.attname, ia.attnum, ic.relname, n.nspname, tc.relname"
> " from pg_catalog.pg_attribute ta ... "
>
>
> case 2
>
> select ta.attname, ia.attnum, ic.relname, n.nspname, NULL"
> " from pg_catalog.pg_attribute ta, ..."
>
> If I am following correctly then:
>
> attname = column_name
> attnum = key_seq
> ic.relname = pk_name
> nspname = table_schem
> tc.relname = table_name
>
>
> So how are using it in your code and what are the actual results?
>
> Also what is showing up in the Postgres logs?
>
> >
> > Thank you.
> >
> >
> > David J.
> >
>
>
> --
> Adrian Klaver
> adrian.klaver@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 using the --to and --cc options:
reply via email
To: pgsql-odbc@postgresql.org
Cc: ikorot01@gmail.com, adrian.klaver@aklaver.com, david.g.johnston@gmail.com, pgsql-general@lists.postgresql.org
Subject: Re: Does included columns part of the PK
In-Reply-To: <CA+FnnTwLvp1wweqWJkw1+sg4x+pM_oGVmfc-3TaPpE_557=A_A@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