postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: davecramer (@davecramer) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: [postgresql-interfaces/psqlodbc] PR #171:  Fix SQLPrimaryKeys to exclude INCLUDE columns from results
Date: Sun, 12 Apr 2026 11:40:57 +0000
Message-ID: <[email protected]> (raw)

  When a PRIMARY KEY is created with an INCLUDE clause (PostgreSQL 11+),
  SQLPrimaryKeys incorrectly returned both the key columns and the
  included columns. For example, given PRIMARY KEY (a, b) INCLUDE (c, d),
  all four columns were returned instead of just a and b.

  The root cause was that the pg_attribute join on the index relation
  iterated over all index attributes without distinguishing key columns
  from included columns. Fix by adding a filter on i.indnkeyatts when
  connected to PostgreSQL >= 11, which limits results to only the actual
  key attributes. Both query paths in PGAPI_PrimaryKeys are fixed.

  Add a regression test that creates a table with a composite primary key
  using INCLUDE and verifies only the key columns are returned.

fixes #170 

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: github://postgresql-interfaces/psqlodbc
  Cc: [email protected], [email protected]
  Subject: Re: [postgresql-interfaces/psqlodbc] PR #171:  Fix SQLPrimaryKeys to exclude INCLUDE columns from results
  In-Reply-To: <<[email protected]>>

* 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