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 1w2FwU-000860-1r for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2026 21:57:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2FwT-00De7g-1C for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2026 21:57:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2FwT-00De7M-02 for pgsql-general@lists.postgresql.org; Mon, 16 Mar 2026 21:57:41 +0000 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w2FwQ-00000000UtZ-0WVN for pgsql-general@postgresql.org; Mon, 16 Mar 2026 21:57:40 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 1AEAE14002D0; Mon, 16 Mar 2026 17:57:37 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Mon, 16 Mar 2026 17:57:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc: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=1773698257; x=1773784657; bh=1Fgm13oB6IAZSifRqB7MB3mP2/luzedEHbjLZFjmQz8=; b= g3a1QtqSdp1tBNqrHj6ECQTpJFBPyw7WmeFQvkL3nvPOt0ifsFD3N3dskuUVjFvl FGCnbok5Gtq/fyUZBjrLBrBPJ4rsRJaBUygGN3XfLjRtXbXm/9yEx1BRVuqWZ8W/ UPml9yyaqhMJ4PwW3UeGCbuio7FEpvtC/2aKgCEUAY2Y1OVnKXWzB2dNy+1erHJW C/t0mN4XdYkqRP5ljTugmhvGmj6yQGebrmuZU6byCknQHdkK03+BptUO49ZfbZLb wwfV3aMzIfj02E+NEYbwgx/Y8w1MO9n1wjqxivbtS7Tu4Zvyhj+cLofZS8qR9Tgx B3QIkBIAmshuU7Uzb8wIZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1773698257; x= 1773784657; bh=1Fgm13oB6IAZSifRqB7MB3mP2/luzedEHbjLZFjmQz8=; b=5 kHUI5MqIPyhNNOsh7AKCXI+gaFdGWemtHCj/HzXbwBuaQo9f1Ux7LDotEKcnvf9e ze/Xmyv1FFwMhV3ve36hmaaDUNsJ1Ye8cL+Zxf/N5h4PFG6fQJdRyYR0Z2G106bO JxeNIqbM11D4GYITVDOkYbr+swfZG/S4EviI0akfNotDpo9VNcZev/P/aHKboYNe /A+YhWnjnDTcEx4DJVtLytcIfpKH/Z9+3EG+DEHm+MZ9mzyuDO39xBhm6M+Z4XM9 byZ0bLsKQTohbM5A29Q8sJepYhJHR3d8eiGZvytQAp8i4JvDaLAv41kmG0UUepqY n/njWmvdhQAJDUuUgfrsQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvleelhedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegouf hushhpvggtthffohhmrghinhculdegledmnecujfgurhepkfffgggfuffvvehfhfgjtgfg sehtkeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirg hnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepffff feeiffdukefgvefgheduteffieegvddtffduheejfffgudfhgeettdegteeunecuffhomh grihhnpegsphgrrdhsthdpphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepihhkohhrohhttddusehgmhgrihhlrdgtohhmpdhrtghpthhtoh epphhgshhqlhdqghgvnhgvrhgrlhesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 Mar 2026 17:57:36 -0400 (EDT) Message-ID: Date: Mon, 16 Mar 2026 14:57:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Does included columns part of the PK To: Igor Korot Cc: pgsql-general References: <3547f40b-08b9-4d0c-bba8-f1c26d0bf09d@aklaver.com> <2c31c118-7f8a-4359-9c4f-4cabd9df4262@aklaver.com> <7461c77a-4536-4f53-b951-99b9ca33db79@aklaver.com> <105a9d1a-c219-401a-9b81-4d77dde901f5@aklaver.com> 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/16/26 2:51 PM, Igor Korot wrote: > Adrian, > > On Mon, Mar 16, 2026 at 2:40 PM Adrian Klaver wrote: >> >> On 3/16/26 2:30 PM, Adrian Klaver wrote: >>> On 3/16/26 11:47 AM, Igor Korot wrote: >>> >>> Reply to list also. >>> Ccing list. >>>> Adrian, >>>> >>>> >>>> >>>> On Mon, Mar 16, 2026, 8:03 AM Adrian Klaver >>> > wrote: >>>> >>>> On 3/15/26 6:23 PM, Igor Korot wrote: >>>> > Hi, Adrian, >>>> > >>>> > Here is the log file from running in ODBC mode: https://bpa.st/ >>>> Z2DWG >>>> >>>> I have no idea what this is trying to show? >>>> >>>> >>>> The log shows ODBC connection and then at the end - call to >>>> SQLPrimaryKeys(). >>> >>> Where? >>> >>> I don't see that in either the link you posted or the text file Greg >>> sent to the list. >>> >>>> >>>> If you run it against the table I posted above, you will get 3 fields. >>>> Whereas it should be just one. >>> >>> Again, run it how? >> >> Alright I see what you are talking about now. I'm not using the ODBC >> driver just it's query. In psql : >> >> 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) >> ); >> >> >> SELECT >> ta.attname, >> ia.attnum, >> ic.relname, >> n.nspname, >> tc.relname >> FROM >> pg_catalog.pg_attribute ta, >> pg_catalog.pg_attribute ia, >> pg_catalog.pg_class tc, >> pg_catalog.pg_index i, >> pg_catalog.pg_namespace n, >> pg_catalog.pg_class ic >> WHERE >> tc.relname = 'leagues_new' >> AND n.nspname = 'public' >> AND tc.oid = i.indrelid >> AND n.oid = tc.relnamespace >> AND i.indisprimary = 't' >> AND ia.attrelid = i.indexrelid >> AND ta.attrelid = i.indrelid >> AND ta.attnum = i.indkey[ia.attnum - 1] >> AND (NOT ta.attisdropped) >> AND (NOT ia.attisdropped) >> AND ic.oid = i.indexrelid >> ORDER BY >> ia.attnum; >> >> yields >> >> attname | attnum | relname | nspname | relname >> -------------+--------+------------------+---------+------------- >> id | 1 | leagues_new_pkey | public | leagues_new >> drafttype | 2 | leagues_new_pkey | public | leagues_new >> scoringtype | 3 | leagues_new_pkey | public | leagues_new > > Correct. > > And according to the second reply it should yeld just the first record. > > I'm going to forward this to the ODBC list... I have not worked it out yet but would start with: AND ta.attnum = i.indkey[ia.attnum - 1] per www.postgresql.org/docs/current/catalog-pg-index.html " indkey int2vector (references pg_attribute.attnum) ... This is an array of indnatts values that indicate which table columns this index indexes. For example, a value of 1 3 would mean that the first and the third table columns make up the index entries. Key columns come before non-key (included) columns. ... " Though there is the below from the same page: "indnatts int2 The total number of columns in the index (duplicates pg_class.relnatts); this number includes both key and included attributes indnkeyatts int2 The number of key columns in the index, not counting any included columns, which are merely stored and do not participate in the index semantics " > > Thank you. > >> >> >>> >>>> >>>> Thank you. >>>> >> >> >> -- >> Adrian Klaver >> adrian.klaver@aklaver.com -- Adrian Klaver adrian.klaver@aklaver.com