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 1w2HW0-0009X5-0a for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2026 23:38: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 1w2HVz-00EK2Q-0M for pgsql-general@arkaria.postgresql.org; Mon, 16 Mar 2026 23:38:27 +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 1w2HVy-00EK2I-2A for pgsql-general@lists.postgresql.org; Mon, 16 Mar 2026 23:38:26 +0000 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2HVv-000000005uY-1Eej for pgsql-general@postgresql.org; Mon, 16 Mar 2026 23:38:25 +0000 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-797ab169454so52237047b3.3 for ; Mon, 16 Mar 2026 16:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773704304; cv=none; d=google.com; s=arc-20240605; b=AmRrp4P2EtYbELoSkfHKmZOW+VmRZmWUvbI5PoHgE59d9/S9WdcCSW++4IYIM7FLm8 J2w2dnXIOrlTQwYNDGdeyzgxsd357suXAapWiicpGRFb+x+mAitucpRxxwyMlpzOjv/m K5OqHobXhytXHPOBbjxmyhzeFgRW0DswhwgMHKWqvkTo6w5/5Nb542dAr7VF3MJfr6J4 jptjRaGa2zxsp2pOflWNO+6lhxb7dJFd6b34d39aapijK2VAppLYlH9bSKpUOeI2MzI0 NQx3s7mcIToeT1W475SxT/Bu314tgFLH8GX0AmdQE8O0jcnMRMXaCNARmoGoP9NJpkFN iFiw== 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=CRISS/CZ93vqmvyUFsmny4J8OZcF79f/l0NEvn6FoKw=; fh=cQaUnmuwjuR9OsxDL7SxCVBwEjDYlbKL9Ym3U6WPyC4=; b=gxW3RAX44rEGbmeeMPWNslvULRtPwuRPul6F6TjO7KS3jyMNAc22cUVHH7YF47NImN MpC2Efboqmpa10Cs2Vj7wXcthoL6IsmyfFbxIUU3+XNNZ/eqHEGPd8dnrzPdgwC2MmEt dh+gkXsJJOA76QGlJzskS63lhG6oazg1DoWRrsAAsOYuAWOqXKJRVJQ+FjdE4RssWQKl 94qvyVRTqGslsyeVmXo6BAig9VBS55RqPAYc6Q9ZZpmw0gVIC3tEmWoQ9CQvhN1IJWnY yns3xTW7QghrmjnXNt2vMz6I21PcO03jiY7WRZ33F8LKPDpM/rbP8lnv81iWC0Zn8NJN 24aA==; darn=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=1773704304; x=1774309104; darn=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=CRISS/CZ93vqmvyUFsmny4J8OZcF79f/l0NEvn6FoKw=; b=evyJDIlo7j6Ts1H7toxMV/eOYQsOw+yFi8qDnZlPgO/M9HS/k3wmnjWYkILXlN0WMK Uvh1/vL3nxZFztai5voP8k/ztzKj10tlvp1raPZOfM/QfExORCZFFle4jjZTEKxzF6wU x8F7708NdzW2b1uIPYVIbn8HFAb7gCo9jtHDZ6R1KSHUDrSRcE8ZhLU1HM3VhiECG6Km veS4PoBmMOaziee2H76s3W6E+pkF/Ak/25CYd0wmcON8EmD5tjXW7pW0NqjeDti66nZP vqT+raZdxrk9fkvjaUuU6XZ65/aZ5hi9EFxSnX2VkhRx/T4sXtxPRhRcUIn2D0fbk5/F FWXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773704304; x=1774309104; 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=CRISS/CZ93vqmvyUFsmny4J8OZcF79f/l0NEvn6FoKw=; b=n4/8D8nBWc1mgrz+E1zAnLJK4gNBoL+fZz1784QsDgj8Tw/PmnORFb+63XInvkSaHr abk2kvIa6bTCXa4Ffi803k0VbIAl3y/C/BMTtflxu/vXWG0aED2ykqbPQZLBhQjrDmZE IDzrcYnFk5Qq+K8t3GZb3F7sNGF7da3NxiqP6CXygZFg4oz0kquukrwFu3T3iTA07dGS LncDa8d+V+480vUj9CuKijNLAnDR4B4jvJPL09pF8iyyuYNSRpFvtuG/8pEdoJLOEo1U 8jEsjWyVR2VBSHZKSxIt75vDjrXCuEhACZZ0StL9MADYjhkZxzqI2J+U/p7BtXC4UFjt nUdQ== X-Gm-Message-State: AOJu0Yzm5DHsqWwbR02joJpF/+GXu8rKZmbMjGFkOggu3ooJHaAqJb1p UKoRfsGDoUqz1p0zrQY3r0XQWGO6BJClhoBej8j4mzAfGzor6kkEGH8YBn9p6PSGK984kEOy72I vrua+p+HyevpOIpBZBsXL3Hj0LWbVLOSvyA== X-Gm-Gg: ATEYQzzIwhVcRBIGPw/34qQKvaJXda/HdT/pTzMKdO+PfhILYt5bKE+T74TMzxRZS4M eCiW4ohccW65LzLIu1zhzOXgVOEzk5yBmoMsZuW3nJtBdw3tw/U3bf3x+kqw4ih2NhTSmxG/QV4 pPZrKqmFS6KEcndYLw+yULcJFTg58sjTsAfHWPODjSswZrkJ2X82Y0yTY27Uvd1AkWeuxewnAap pfD7UuQzjOwXP+VRcWhS+1AOn24c46mKd9J2Ki9NL1LC6uZRM0KoewipnshpwhdIekYNLj4RnOA 7O1YOyv1rxPbhdp2Dg3u+OqfE0lkb0L8g+eQ0crlzr8IocxNVRfTh1vwpqzBpS2cAwzEy5E= X-Received: by 2002:a05:690c:1d:b0:79a:4fe4:ff3a with SMTP id 00721157ae682-79a4fe507eamr50237607b3.3.1773704303929; Mon, 16 Mar 2026 16:38:23 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Igor Korot Date: Mon, 16 Mar 2026 16:38:22 -0700 X-Gm-Features: AaiRm51np2XeGjVDwlOYOJqY_DiT0IVKNRZdP_4LEsd-B5InrzKY9iU-ryqHz7o Message-ID: Subject: Re: Does included columns part of the PK To: Adrian Klaver Cc: pgsql-general 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 Adrian, Most important - do you agree that those fields should not be in this recordset? Thank you. On Mon, Mar 16, 2026 at 2:57=E2=80=AFPM Adrian Klaver wrote: > > On 3/16/26 2:51 PM, Igor Korot wrote: > > Adrian, > > > > On Mon, Mar 16, 2026 at 2:40=E2=80=AFPM 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=E2=80=AFAM 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 field= s. > >>>> 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 =3D 50, deduplicate_items =3D 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 =3D 'leagues_new' > >> AND n.nspname =3D 'public' > >> AND tc.oid =3D i.indrelid > >> AND n.oid =3D tc.relnamespace > >> AND i.indisprimary =3D 't' > >> AND ia.attrelid =3D i.indexrelid > >> AND ta.attrelid =3D i.indrelid > >> AND ta.attnum =3D i.indkey[ia.attnum - 1] > >> AND (NOT ta.attisdropped) > >> AND (NOT ia.attisdropped) > >> AND ic.oid =3D 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 =3D 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