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 1m1Yh2-00036N-Tg for pgsql-jdbc@arkaria.postgresql.org; Thu, 08 Jul 2021 18:24:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m1Yh1-0004WD-P4 for pgsql-jdbc@arkaria.postgresql.org; Thu, 08 Jul 2021 18:24:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1Yh1-0004W5-AZ for pgsql-jdbc@lists.postgresql.org; Thu, 08 Jul 2021 18:24:11 +0000 Received: from mail.nqadmin.com ([12.230.133.169]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1Ygy-0000AX-Kg for pgsql-jdbc@lists.postgresql.org; Thu, 08 Jul 2021 18:24:10 +0000 Received: internal info suppressed Received: (from root@localhost) by mail.nqadmin.com (8.14.7/8.14.7/Submit) id 168IO7DR006785; Thu, 8 Jul 2021 13:24:07 -0500 Received: from ppasalalinux.nqadmin.com (ppasalalinux.nqadmin.com [192.168.0.234]) by mail.nqadmin.com with SMTP id 3y7r5si9jze5knaimm7q2j84jw; Thu, 08 Jul 2021 13:24:07 -0500 (CDT) (envelope-from dbadmin@pangburngroup.com) Reply-To: dbadmin@pangburngroup.com Subject: Re: ResultSet updates are not retained - 42.2.23 To: Dave Cramer Cc: pgsql-jdbc@lists.postgresql.org References: <83846059-d513-5617-6076-af9110f55485@pangburngroup.com> From: Prasanth Message-ID: Date: Thu, 8 Jul 2021 13:24:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------3193C7190B2E25943C7BBDF7" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------3193C7190B2E25943C7BBDF7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit This table is more than 20 years old I don't have the original create table DDL. I can pull the DDL from DBeaver would that help? Thanks, Prasanth On 7/8/21 1:18 PM, Dave Cramer wrote: > > > On Thu, 8 Jul 2021 at 14:13, Prasanth > wrote: > > Thank you for the quick response. Created a new test table and tried the same on that and it is working as expected. So probably something unique about this table. > > > Can I get the entire table definition as in create table .... Something in .23 broke it.  > > Thanks, > > Dave  > > > Test on new table > Starting Value: 2021-01-01 > After Update: 2020-01-01 > After Requery: 2020-01-01 > > Test on plan_data > Starting Value: 2021-01-01 > After Update: 2020-01-01 > After Requery: 2021-01-01 > > Below are the details about the columns in question. The table has 100+ columns. > >  attrelid |         attname          | atttypid | attstattarget | attlen | attnum | attndims | attcacheoff | atttypmod | attbyval | attstorage | attalign | attnotnull | atthasdef | atthasmissing > | attidentity | attgenerated | attisdropped | attislocal | attinhcount | attcollation | attacl | attoptions | attfdwoptions | attmissingval > ----------+--------------------------+----------+---------------+--------+--------+----------+-------------+-----------+----------+------------+----------+------------+-----------+---------------+-------------+--------------+--------------+------------+-------------+--------------+--------+------------+---------------+--------------- >  10525600 | accounting_current_start |     1082 |            -1 |      4 |     26 |        0 |          -1 |        -1 | t        | p          | i        | f          | f         | f             > |             |              | f            | t          |           0 |            0 |        |            |               | >  10525600 | plan_id                  |       23 |            -1 |      4 |      1 |        0 |          -1 |        -1 | t        | p          | i        | t          | t         | f             > |             |              | f            | t          |           0 |            0 |        |            |               | > (2 rows) > > Thanks, > Prasanth > > On 7/8/21 12:08 PM, Dave Cramer wrote: >> >> >> On Thu, 8 Jul 2021 at 12:00, Prasanth > wrote: >> >> Hi, >> >> With the latest release 42.2.23 ResultSet updates are not propagated to the database. Below is a sample code to verify the issue. In the below code we are querying the record using the >> primary key in that table. >> >> import java.sql.Connection; >> import java.sql.Date; >> import java.sql.DriverManager; >> import java.sql.ResultSet; >> import java.sql.SQLException; >> >> public class RowSet { >> >>     public void test () throws SQLException, ClassNotFoundException { >>         Class.forName("org.postgresql.Driver"); >>         Connection connection = DriverManager.getConnection("jdbc:postgresql://192.168.0.100:5432/testdb ", "postgres", "xxxxxxxxxxxxxxxx"); >>         connection.setAutoCommit(false); >>         String sql = "SELECT * FROM plan_data where plan_id = 30756"; >>         ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql); >>         rs.next(); >>         System.out.println("Starting Value: " + rs.getDate("accounting_current_start")); >>         rs.updateDate("accounting_current_start", Date.valueOf("2020-01-01")); >>         rs.updateRow(); >>         System.out.println("After Update: " + rs.getDate("accounting_current_start")); >>         connection.commit(); >>         >>         sql = "SELECT * FROM plan_data where plan_id = 30756"; >>         rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql); >>         rs.next(); >>         System.out.println("After Requery: " + rs.getDate("accounting_current_start")); >>         >>         connection.close();        >>     } >>     >>     public static void main(String args[]) {        >>         try { >>             new RowSet().test(); >>         } catch (SQLException e) {        >>             e.printStackTrace(); >>         } catch (ClassNotFoundException e) { >>             e.printStackTrace(); >>         } >>     } >> >> } >> >> >> >> ----------------OUTPUT  with 42.2.23 ----------- >> Starting Value: 2021-01-01 >> After Update: 2020-01-01 >> After Requery: 2021-01-01 >> >> >> Update accounting_current_start to 2021-01-01 using a query directly on the database and rerun with 42.2.22 >> >> ----------------OUTPUT  with 42.2.22 ----------- >> Starting Value: 2021-01-01 >> After Update: 2020-01-01 >> After Requery: 2020-01-01 >> >> Thanks, >> Prasanth >> >> >> On 7/6/21 10:41 AM, Dave Cramer wrote: >>> Branch: refs/tags/REL42.2.23 >>> Home: https://github.com/pgjdbc/pgjdbc >>> >>> >> >> >> Can you tell me what the schema of plan_data is ? >> >> I just tried and it worked fine >> >> @Test public void testUpdateDate() throws Exception{ >> Date testDate = Date.valueOf("2021-01-01"); >> TestUtil.execute( "insert into hasdate values (1,'2021-01-01'::date)", con); >> con.setAutoCommit(false); >> String sql = "SELECT * FROM hasdate where id=1"; >> ResultSet rs = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql); >> assertTrue(rs.next()); >> assertEquals(testDate, rs.getDate("dt")); >> rs.updateDate("dt", Date.valueOf("2020-01-01")); >> rs.updateRow(); >> assertEquals(Date.valueOf("2020-01-01"), rs.getDate("dt")); >> System.out.println("After Update: " + rs.getDate("dt")); >> con.commit(); >> rs = con.createStatement().executeQuery("select dt from hasdate where id=1"); >> assertTrue(rs.next()); >> assertEquals(Date.valueOf("2020-01-01"), rs.getDate("dt")); >> rs.close(); >> } >> >> Dave  > --------------3193C7190B2E25943C7BBDF7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit This table is more than 20 years old I don't have the original create table DDL. I can pull the DDL from DBeaver would that help?

Thanks,
Prasanth

On 7/8/21 1:18 PM, Dave Cramer wrote:


On Thu, 8 Jul 2021 at 14:13, Prasanth <dbadmin@pangburngroup.com> wrote:
Thank you for the quick response. Created a new test table and tried the same on that and it is working as expected. So probably something unique about this table.

Can I get the entire table definition as in create table .... Something in .23 broke it. 

Thanks,

Dave 

Test on new table
Starting Value: 2021-01-01
After Update: 2020-01-01
After Requery: 2020-01-01

Test on plan_data
Starting Value: 2021-01-01
After Update: 2020-01-01
After Requery: 2021-01-01

Below are the details about the columns in question. The table has 100+ columns.

 attrelid |         attname          | atttypid | attstattarget | attlen | attnum | attndims | attcacheoff | atttypmod | attbyval | attstorage | attalign | attnotnull | atthasdef | atthasmissing | attidentity | attgenerated | attisdropped | attislocal | attinhcount | attcollation | attacl | attoptions | attfdwoptions | attmissingval
----------+--------------------------+----------+---------------+--------+--------+----------+-------------+-----------+----------+------------+----------+------------+-----------+---------------+-------------+--------------+--------------+------------+-------------+--------------+--------+------------+---------------+---------------
 10525600 | accounting_current_start |     1082 |            -1 |      4 |     26 |        0 |          -1 |        -1 | t        | p          | i        | f          | f         | f             |             |              | f            | t          |           0 |            0 |        |            |               |
 10525600 | plan_id                  |       23 |            -1 |      4 |      1 |        0 |          -1 |        -1 | t        | p          | i        | t          | t         | f             |             |              | f            | t          |           0 |            0 |        |            |               |
(2 rows)

Thanks,
Prasanth

On 7/8/21 12:08 PM, Dave Cramer wrote:


On Thu, 8 Jul 2021 at 12:00, Prasanth <dbadmin@pangburngroup.com> wrote:
Hi,

With the latest release 42.2.23 ResultSet updates are not propagated to the database. Below is a sample code to verify the issue. In the below code we are querying the record using the primary key in that table.

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class RowSet {

    public void test () throws SQLException, ClassNotFoundException {
        Class.forName("org.postgresql.Driver");
        Connection connection = DriverManager.getConnection("jdbc:postgresql://192.168.0.100:5432/testdb", "postgres", "xxxxxxxxxxxxxxxx");
        connection.setAutoCommit(false);
        String sql = "SELECT * FROM plan_data where plan_id = 30756";
        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        System.out.println("Starting Value: " + rs.getDate("accounting_current_start"));
        rs.updateDate("accounting_current_start", Date.valueOf("2020-01-01"));
        rs.updateRow();
        System.out.println("After Update: " + rs.getDate("accounting_current_start"));
        connection.commit();
       
        sql = "SELECT * FROM plan_data where plan_id = 30756";
        rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        System.out.println("After Requery: " + rs.getDate("accounting_current_start"));
       
        connection.close();       
    }
   
    public static void main(String args[]) {       
        try {
            new RowSet().test();
        } catch (SQLException e) {       
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

}



----------------OUTPUT  with 42.2.23 -----------
Starting Value: 2021-01-01
After Update: 2020-01-01
After Requery: 2021-01-01


Update accounting_current_start to 2021-01-01 using a query directly on the database and rerun with 42.2.22

----------------OUTPUT  with 42.2.22 -----------
Starting Value: 2021-01-01
After Update: 2020-01-01
After Requery: 2020-01-01

Thanks,
Prasanth


On 7/6/21 10:41 AM, Dave Cramer wrote:
  Branch: refs/tags/REL42.2.23
  Home:   https://github.com/pgjdbc/pgjdbc




Can you tell me what the schema of plan_data is ?

I just tried and it worked fine

@Test
public void testUpdateDate() throws Exception{
  Date testDate = Date.valueOf("2021-01-01");
  TestUtil.execute( "insert into hasdate values (1,'2021-01-01'::date)", con);
  con.setAutoCommit(false);
  String sql = "SELECT * FROM hasdate where id=1";
  ResultSet rs = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
  assertTrue(rs.next());
  assertEquals(testDate, rs.getDate("dt"));
  rs.updateDate("dt", Date.valueOf("2020-01-01"));
  rs.updateRow();
  assertEquals(Date.valueOf("2020-01-01"), rs.getDate("dt"));
  System.out.println("After Update: " + rs.getDate("dt"));
  con.commit();
  rs = con.createStatement().executeQuery("select dt from hasdate where id=1");
  assertTrue(rs.next());
  assertEquals(Date.valueOf("2020-01-01"), rs.getDate("dt"));
  rs.close();
}

Dave 


--------------3193C7190B2E25943C7BBDF7--