Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w1euD-000UTn-2n for pgsql-general@arkaria.postgresql.org; Sun, 15 Mar 2026 06:24:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w1euC-003ga4-2e for pgsql-general@arkaria.postgresql.org; Sun, 15 Mar 2026 06:24:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w1euC-003gZw-1A for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2026 06:24:53 +0000 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w1euA-00000000Cwz-3HaW for pgsql-general@lists.postgresql.org; Sun, 15 Mar 2026 06:24:51 +0000 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-78fc4425b6bso34121147b3.1 for ; Sat, 14 Mar 2026 23:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773555890; cv=none; d=google.com; s=arc-20240605; b=QHxQgHiZdTSViZqbLjzmJ9rdDuRLrIf+mvCLNTbkHZhlFUmKaAeQRxLXVdmHC6u/mF 9Rly/g7FnJejWzPdx8LzbHZY7B4OsINnMj1DibPxL0Ojcpyr9XPmD6PyZaXi4Xv/s2Lt ofHrKS2Nwmv4IT2I2RUY46gJy9PDvQPZk84ko0DIvyxVs42gU5bpx01AV7/Vmr5v9tnH 3gjVLqznyVQsbqtYPe9iOK/JTAzXYT3ZlU6yfPDMheKCGmAD2ulU/RHkNLNiCT+oLV0F dRfweO5gH+G2qknvOszLK7yI6O6iW88zuPNPqK0YMOZ7LPtrMG2yIwD3eVFz6lKPB8Ph DPIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vhicu23O/sLiBB2xuw+Vicjv0gBXmgk/mf5Z3gqG1jE=; fh=AYt33OsdnSbYzbstvra7so5Ft04mlQMIF5rkGCuamPw=; b=hvrzDA621M+K9AbjNPAqJj8mM9f/l8R1FNUTutt2uZW91u9UEVEetsHrbwmVRj2jMt m+X+QbfUbuj1SxtVfkA1uYh9qZ82pjbk0k1hdEEHPlC4hjdkouyBap3PBj5Q1aQ8BrEn npfIhE+4M2L7uXpMpT7fBzKIksixbB5FNx0z0BFFyrq78NrDBqDzKt0G4qQYNjJVUIFO xgemr6WocKj3RUhoFE4Fdy4OiX2gzkpGVjG9SNItvJjLBmvTTslE2BsaeSe3vwT7n/L0 1+iXgiVgmq5nL/4TJBA0iy99bJdRZbqTjf5iCLQ9F8j/gO6na6CTR7kIh68cOWju23g7 PGGQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773555890; x=1774160690; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vhicu23O/sLiBB2xuw+Vicjv0gBXmgk/mf5Z3gqG1jE=; b=M6NAc2rBYnDJbAGm1TdiNscAuEh97Dv14uuYQon050vx6Sy53p9FKvpccqVQ6tdqgi 2QMHOOrxnrw85xAafr4WTeuamsSo0ftPN6PC6+uTGNFbqQw184tZBH56y90whtNO0sb5 lOpUs4uprgRDOU2FesZS2W0h6YocDQbmoLsoakmYWVZ/B3N02z+NTEpv63MirUv8GHNG eP57Iqi6nm2DgvnOsD3AIoPMWs6nSo/zyr9nkQXbpIgRvviI59BFiwb3T4CLk36zSuc5 LWzkXr5WDQB+xl5AZuOyoLBMWyZnmaiZZS2cFCcYF2siKTxH51JFPOZT2leahN5N9vzL Le6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773555890; x=1774160690; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vhicu23O/sLiBB2xuw+Vicjv0gBXmgk/mf5Z3gqG1jE=; b=b+LC1OvKUjwXYBdcn30/pOYEi6vq8pYbxZmAVitcIUwCFbWpmD65mqli6Gpy9qcSAQ qaEuPr3KLeKKH8BeZqEw5wagtGLLMCG0n/yHwGnN8SmQ2SSlamHKt5C3hMqpJF3DHW6n F65C6piVM3HDsLjfTfWlx3agN5gG02uXEpWClfO+NZnlmbFCNSu7y+00lbLwzHQ3bzhS k51uyOTiv/rJgEjGd7RnTyD49KJn5yLoxrl3RiCJJztRaEpzSGYXwnFc1PrYIitfw0kY ADTVcmvEjYIJM1ChFCa/YXQRLmCKEkU+bpBqyDwfjfa0lrZF0DYvxRScj4mW6lusYin2 a6Tg== X-Forwarded-Encrypted: i=1; AJvYcCW3G2lJkAbIH6nu8wWqvYaP5oibyehGkNgdChRZNY3rNmnkVOfQ5bzCeWnRwZbil2jJHuHQgvQBkzs6kQgq@lists.postgresql.org X-Gm-Message-State: AOJu0Yy8kbMkBad+0kBXj6/wBVXJLvOVe4H7OxlMSODlsV4t7DvP/0Pz XlWe5KMub0dRQg0yHwTQBG5VTXGaKK9eXimWgP6FUYNdRNJp3VNYVeucR4FzTyA3eJdvduwmhCs yRSY3LW19wdPP5k6dM8tJM3bJ1v2joCo= X-Gm-Gg: ATEYQzzpOPV8oTRBqkprsJPcLNcYAuMxyKqT74gLvG+wpNzv4nwZzXrz4sS6DML6zZh 5PTesPMK66k64B6D/5oRd4NwpMjQrI5zqx8cEzHW0mBSUcfsDt1EMbwI8SDywSYuspVe1Wrwjaa qkfnWwxuCRNAqq7VneBvGuRgnxML3YW29B7hlARLxM2SCbOVtNV/MsDMAdRCXIczMlvfiaKZyt4 XO7FAyxiIDmdDQjrKtNvvn26YdqoXODP4cN14H6r6kjE9ZRB93cJZnMbnJyqk/BdmOCTGgReWr4 k0P1WN78hqHXg8R45f5Vsgccvq1SFvDa6+BiPTK1wZJINuKlysyJOg== X-Received: by 2002:a05:690c:22c9:b0:79a:2a47:56f8 with SMTP id 00721157ae682-79a2a476fccmr60738067b3.44.1773555890403; Sat, 14 Mar 2026 23:24:50 -0700 (PDT) MIME-Version: 1.0 References: <3547f40b-08b9-4d0c-bba8-f1c26d0bf09d@aklaver.com> In-Reply-To: <3547f40b-08b9-4d0c-bba8-f1c26d0bf09d@aklaver.com> From: Igor Korot Date: Sun, 15 Mar 2026 01:24:38 -0500 X-Gm-Features: AaiRm5347UELDp17cHchZtFP1c8nsmv494w3DjTX85c2VVZL9WNzvMPzOBa6pGo Message-ID: Subject: Re: Does included columns part of the PK To: Adrian Klaver Cc: "David G. Johnston" , "pgsql-generallists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Adrian, On Sat, Mar 14, 2026 at 6:30=E2=80=AFPM Adrian Klaver wrote: > > On 3/14/26 9:56 AM, Igor Korot wrote: > > Hi, > > > > On Sat, Mar 14, 2026 at 8:51=E2=80=AFAM David G. Johnston > > > wrote: > > > > On Saturday, March 14, 2026, Adrian Klaver > > > wrot= e: > > > > 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 =E2=80=9Cthey=E2=80=9D - =E2=80=9CHe=E2=80=9D. =F0=9F=98=8A > > > > And yes - that=E2=80=99s what I=E2=80=99m referring to. > > From here: > > > https://www.ibm.com/docs/en/db2-for-zos/12.0.0?topic=3Dfunctions-sqlprima= rykeys-get-primary-key-columns-table: > > 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 tab= le. > 4 COLUMN_NAME VARCHAR(128) NOT NULL Primary key column name. > 5 KEY_SEQ SMALLINT NOT NULL Column sequence number in the pri= mary key, > starting with 1. > 6 PK_NAME VARCHAR(128) Primary key identifier. Contains a null v= alue if > not applicable to the data > > Lets start with the beginning: draft=3D# 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 =3D 50, deduplicate_items =3D OFF )); CREATE TABLE draft=3D# > 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 To= m 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 =3D column_name > attnum =3D key_seq > ic.relname =3D pk_name > nspname =3D table_schem > tc.relname =3D 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