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 1w1YR9-000Opm-0t for pgsql-general@arkaria.postgresql.org; Sat, 14 Mar 2026 23:30:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w1YR7-00376u-0p for pgsql-general@arkaria.postgresql.org; Sat, 14 Mar 2026 23:30:26 +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 1w1YR6-00376m-1C for pgsql-general@lists.postgresql.org; Sat, 14 Mar 2026 23:30:25 +0000 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w1YR4-00000000AV1-2IZn for pgsql-general@lists.postgresql.org; Sat, 14 Mar 2026 23:30:24 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 867CB1D00012; Sat, 14 Mar 2026 19:30:21 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Sat, 14 Mar 2026 19:30:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1773531021; x=1773617421; bh=FbaqhQD7ZsWsr6rWZ91bTrW/j1HXooN8PA2nwaEQXao=; b= ZAqLVAwWx88lDT6C8JBfhu6Lqjcl1Iq0zcV2hDtQtuBvznQ8wdu6Z80SUVjNNH1g YQXEkbQvWN+ySUCUMKNUN3P1a5pnr0IjeqiMxrBS6sGViIkHgdlHrIrxu7AktNBo UU8rj2JiGGlohDKjPGWsmHM2tqOlG7WpKrThdNiv91l/Porn8sMAlx8mI+GBLhOb UvyVGgXJihKgihNIwQ0H0g0Iv3+uTt4L7S/m1qWWAVuN1NuhPneCexp/P4WeDZh5 6bKwFqnuiku0WjEKMbph5SUtk/9IgvHdgQmFpe0fJm6UMQkvfGmBXJhbeFozhoHh NwAjJz/fEzcUPNcfWA/c8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1773531021; x=1773617421; bh=F baqhQD7ZsWsr6rWZ91bTrW/j1HXooN8PA2nwaEQXao=; b=T8vLH6p9Bl8R0r4Ge rgL57PHLgL0bB5fxn66WFzzUwkLrFqvnxa26eKOs/5lnJwrRvO7XQGfkqTyXo57f Mt4JBlwoFFmes2f02MRJs+xbtKgyoit5B2727IpFL9F3CY1EC28s6iGntJe9Bk9I 3ldqmhrj8eL+YKNguOI0mrakvMMKslA1N48dwMlFHdKW7Pb0oE6cALOIqTtHP9QN nR4oLtoIG5AEv+yOQekfElVkG/6G/a60VF/yJgh/NKgBQuhCDQb9XlJ+isZJNKsR K7w+Rm6vpD/PbvC22Je015KcljIVvZQhOZiOh14cS94qcxI5bRcqU9aG66FiEVln oFikA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvleefkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpeehhedugeehteejffejjeetheegfeehjedtgefhheffuedu keeigeetheekhfejheenucffohhmrghinhepihgsmhdrtghomhdpghhithhhuhgsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggu rhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepfe dpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhkohhrohhttddusehgmhgrihhl rdgtohhmpdhrtghpthhtohepuggrvhhiugdrghdrjhhohhhnshhtohhnsehgmhgrihhlrd gtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshht ghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 14 Mar 2026 19:30:20 -0400 (EDT) Message-ID: <3547f40b-08b9-4d0c-bba8-f1c26d0bf09d@aklaver.com> Date: Sat, 14 Mar 2026 16:30:19 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Does included columns part of the PK To: Igor Korot , "David G. Johnston" , "pgsql-generallists.postgresql.org" References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/14/26 9:56 AM, Igor Korot wrote: > Hi, > > On Sat, Mar 14, 2026 at 8:51 AM David G. Johnston > > wrote: > > On Saturday, March 14, 2026, Adrian Klaver > > 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-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 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 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