Message-ID: From: "davecramer (@davecramer)" To: "postgresql-interfaces/psqlodbc" Date: Sun, 12 Apr 2026 11:40:57 +0000 Subject: [postgresql-interfaces/psqlodbc] PR #171: Fix SQLPrimaryKeys to exclude INCLUDE columns from results List-Id: X-GitHub-Author-Id: 406518 X-GitHub-Author-Login: davecramer X-GitHub-Issue: 171 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: merged X-GitHub-Type: pull_request X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/pull/171 Content-Type: text/plain; charset=utf-8 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