Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mM6Lo-0005QM-Ua for pgsql-jdbc@arkaria.postgresql.org; Fri, 03 Sep 2021 10:23:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mM6Ln-0003Tc-Kd for pgsql-jdbc@arkaria.postgresql.org; Fri, 03 Sep 2021 10:23:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mM6Ln-0003TU-DS for pgsql-jdbc@lists.postgresql.org; Fri, 03 Sep 2021 10:23:11 +0000 Received: from out-28.smtp.github.com ([192.30.252.211]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mM6Lk-0008G0-P3 for pgsql-jdbc@lists.postgresql.org; Fri, 03 Sep 2021 10:23:10 +0000 Received: from github.com (hubbernetes-node-577fdb3.ash1-iad.github.net [10.56.110.69]) by smtp.github.com (Postfix) with ESMTPA id 79CFA900574 for ; Fri, 3 Sep 2021 03:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1630664586; bh=DbN8a3q9EyFlTc4B2AQb/85LZjdP+MgPlParTr6KdaY=; h=Date:From:To:Subject:From; b=CNpDtM63gdbOmNHuFZ9/FH+cL7fyRR1kT4nilywD0TAOUsDrPktkKk1MT7DRA3MAm CF7EhU5lDlyDIKXclsJ4Dh3mUKtqD+lASFLGpYyONiqqJRpavtk1z0RG0eG/fXqMKr BKj+WPv0ETNeaHhaHXK4pObXrTD2D+tQqDuGl6Oc= Date: Fri, 03 Sep 2021 03:23:06 -0700 From: chalmagr To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] c59658: Fix updateable result set when there are primary k... Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Branch: refs/heads/release/42.2 Home: https://github.com/pgjdbc/pgjdbc Commit: c596587aa52db6573d5cf41f29f1f6b8afe29cb5 https://github.com/pgjdbc/pgjdbc/commit/c596587aa52db6573d5cf41f29f1f6b8afe29cb5 Author: chalmagr 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