[pgjdbc/pgjdbc] c59658: Fix updateable result set when there are primary k...

From: chalmagr <noreply(at)github(dot)com>
To: pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: [pgjdbc/pgjdbc] c59658: Fix updateable result set when there are primary k...
Date: 2021-09-03 10:23:06
Message-ID: pgjdbc/pgjdbc/push/refs/heads/release/42.2/77c7d9-c59658@github.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Branch: refs/heads/release/42.2
Home: https://github.com/pgjdbc/pgjdbc
Commit: c596587aa52db6573d5cf41f29f1f6b8afe29cb5
https://github.com/pgjdbc/pgjdbc/commit/c596587aa52db6573d5cf41f29f1f6b8afe29cb5
Author: chalmagr <chalmagr(at)hotmail(dot)com>
Date: 2021-09-03 (Fri, 03 Sep 2021)

Changed paths:
M pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java
M pgjdbc/src/main/java/org/postgresql/jdbc/PgResultSet.java
M pgjdbc/src/test/java/org/postgresql/test/jdbc2/UpdateableResultTest.java

Log Message:
-----------
Fix updateable result set when there are primary keys and unique keys (#2228)

* fix: change to updatable result set to use correctly primary or unique keys

Fix issues introduced in PR# 2199 causing problems when updating tables with PK and UK.
Originally updatable result sets support only primary keys, with the aforementioned change
and this fix unique keys are also eligible to enable updatable result set. This change will
find the better suited primary or unique key that has all the available columns in the query, but
if no match is found it will continue to fail as it used to.

Closes issue 2196

* fix: changes to updatable result set to disable use of unique keys with nullable columns

Adding logic to ensure all columns in the constraint (primary/unique) are non-nullable (always true for PKs) to guarantee 1-1 updates

* fix: removal of added code after nullable unique keys are excluded

No need to have IS NULL when nullable keys are not allowed to guarantee 1-1 updates

* fix: exclude indices with expressions for updatable result sets

Indices with expressions cannot be used (unless expression parsing / resolution
is implemented properly - currently don't see a way to get individual list elements
from pg_index.indexprs to enable proper expression filtering (pg_get_expr gives the
expression, but unable to map this to a specific attribute in the index)

Co-authored-by: Marquez Grabia, Christian <Christian(dot)MarquezGrabia(at)sabre(dot)com>

Browse pgsql-jdbc by date

  From Date Subject
Next Message ldh@laurent-hasson.com 2021-09-08 19:13:01 Duplicate tables information through metadata queries
Previous Message Dave Cramer 2021-08-17 17:24:19 Re: defaultRowFetchSize and no known snapshots error