Thread: Exception while updating result set

Exception while updating result set

From
Prasanth
Date:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth

Re: Exception while updating result set

From
Prasanth
Date:
Hi,

Does anyone have any thoughts on this?

Thanks,
Prasanth

On 3/18/21 5:20 PM, Prasanth wrote:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth

Re: Exception while updating result set

From
Dave Cramer
Date:


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

Does anyone have any thoughts on this?

Thanks,
Prasanth

On 3/18/21 5:20 PM, Prasanth wrote:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth


What is the query ? 

Re: Exception while updating result set

From
Prasanth
Date:
Sorry did not get the below email, just saw it in the website. Below is the sql.

"SELECT * FROM accounting_periods where plan_id = 30756 order by start_date";

Thanks,
Prasanth

On Thu, 25 Mar 2021 at 12:00, Prasanth <dbadmin(at)pangburngroup(dot)com> wrote:

> Hi,
>
> Does anyone have any thoughts on this?
>
> Thanks,
> Prasanth
>
> On 3/18/21 5:20 PM, Prasanth wrote:
>
> Hi,
>
> The following code generates an exception shown below. Commenting out the
> refreshRow() call would solve the issue. This exception happens only in
> driver versions 42.2.13 and above. Is this a bug in the driver?
>
> ResultSet rs =
> connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
> rs.next();
> rs.updateDate("start_date", Date.valueOf("2020-01-01"));
> rs.updateDate("end_date", Date.valueOf("2020-12-31"));
> rs.updateRow();
> rs.refreshRow();
> rs.updateDate("end_date", Date.valueOf("2020-12-30"));
> rs.updateRow(); // Exception occurs at this line.
>
>
> Exception in thread "main" java.lang.IllegalArgumentException: Attempted
> to write to readonly tuple
> at org.postgresql.core.Tuple.set(Tuple.java:96)
> at
> org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
> at
> org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
> at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)
>
> Thanks,
> Prasanth
>
> What is the query ?


From:Dave Cramer <davecramer(at)postgres(dot)rocks>
To:dbadmin(at)pangburngroup(dot)com
Cc:pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject:Re: Exception while updating result set
Date:2021-03-29 14:19:13
Message-ID:CADK3HHK8WPCxbhoE4dTt=U0jpmtGWMT0okXY5oj5SAE1b7T26Q@mail.gmail.com
Views:Raw Message | Whole Thread | Download mbox | Resend email
Lists:pgsql-jdbc


On 3/25/21 11:00 AM, Prasanth wrote:
Hi,

Does anyone have any thoughts on this?

Thanks,
Prasanth

On 3/18/21 5:20 PM, Prasanth wrote:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth


Re: Exception while updating result set

From
Prasanth
Date:
Seems like if we call rs.absolute(1)  after refreshRow() (to move to the row we are already on) prior to the second update on the same row the exception doesn't occur.

String sql = "SELECT * FROM accounting_periods where plan_id = 30756 order by start_date";
> ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
> rs.next();
> rs.updateDate("start_date", Date.valueOf("2020-01-01"));
> rs.updateDate("end_date", Date.valueOf("2020-12-31"));
> rs.updateRow();
> rs.refreshRow();
rs.absolute(1);  // adding this call avoids the exception
> rs.updateDate("end_date", Date.valueOf("2020-12-30"));
> rs.updateRow(); // Exception doesn't occur now. if the rs.absolute(1) is removed exception occurs again.

Also correction to my prior statement, this issue occurs with jdbc driver version 42.2.11 and above.

Thanks,
Prasanth


On 6/25/21 2:43 PM, Prasanth wrote:
Sorry did not get the below email, just saw it in the website. Below is the sql.

"SELECT * FROM accounting_periods where plan_id = 30756 order by start_date";

Thanks,
Prasanth

On Thu, 25 Mar 2021 at 12:00, Prasanth <dbadmin(at)pangburngroup(dot)com> wrote:

> Hi,
>
> Does anyone have any thoughts on this?
>
> Thanks,
> Prasanth
>
> On 3/18/21 5:20 PM, Prasanth wrote:
>
> Hi,
>
> The following code generates an exception shown below. Commenting out the
> refreshRow() call would solve the issue. This exception happens only in
> driver versions 42.2.13 and above. Is this a bug in the driver?
>
> ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
> rs.next();
> rs.updateDate("start_date", Date.valueOf("2020-01-01"));
> rs.updateDate("end_date", Date.valueOf("2020-12-31"));
> rs.updateRow();
> rs.refreshRow();
> rs.updateDate("end_date", Date.valueOf("2020-12-30"));
> rs.updateRow(); // Exception occurs at this line.
>
>
> Exception in thread "main" java.lang.IllegalArgumentException: Attempted
> to write to readonly tuple
> at org.postgresql.core.Tuple.set(Tuple.java:96)
> at
> org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
> at
> org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
> at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)
>
> Thanks,
> Prasanth
>
> What is the query ?


From:Dave Cramer <davecramer(at)postgres(dot)rocks>
To:dbadmin(at)pangburngroup(dot)com
Cc:pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject:Re: Exception while updating result set
Date:2021-03-29 14:19:13
Message-ID:CADK3HHK8WPCxbhoE4dTt=U0jpmtGWMT0okXY5oj5SAE1b7T26Q@mail.gmail.com
Views:Raw Message | Whole Thread | Download mbox | Resend email
Lists:pgsql-jdbc


On 3/25/21 11:00 AM, Prasanth wrote:
Hi,

Does anyone have any thoughts on this?

Thanks,
Prasanth

On 3/18/21 5:20 PM, Prasanth wrote:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth



Re: Exception while updating result set

From
Dave Cramer
Date:
I can look at this Monday. Can you create an issue on github https://github.com/pgjdbc/pgjdbc

Thx

On Fri, Jun 25, 2021, 3:43 PM Prasanth <dbadmin@pangburngroup.com> wrote:
Sorry did not get the below email, just saw it in the website. Below is the sql.

"SELECT * FROM accounting_periods where plan_id = 30756 order by start_date";

Thanks,
Prasanth

On Thu, 25 Mar 2021 at 12:00, Prasanth <dbadmin(at)pangburngroup(dot)com> wrote:

> Hi,
>
> Does anyone have any thoughts on this?
>
> Thanks,
> Prasanth
>
> On 3/18/21 5:20 PM, Prasanth wrote:
>
> Hi,
>
> The following code generates an exception shown below. Commenting out the
> refreshRow() call would solve the issue. This exception happens only in
> driver versions 42.2.13 and above. Is this a bug in the driver?
>
> ResultSet rs =
> connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
> rs.next();
> rs.updateDate("start_date", Date.valueOf("2020-01-01"));
> rs.updateDate("end_date", Date.valueOf("2020-12-31"));
> rs.updateRow();
> rs.refreshRow();
> rs.updateDate("end_date", Date.valueOf("2020-12-30"));
> rs.updateRow(); // Exception occurs at this line.
>
>
> Exception in thread "main" java.lang.IllegalArgumentException: Attempted
> to write to readonly tuple
> at org.postgresql.core.Tuple.set(Tuple.java:96)
> at
> org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
> at
> org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
> at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)
>
> Thanks,
> Prasanth
>
> What is the query ?


From:Dave Cramer <davecramer(at)postgres(dot)rocks>
To:dbadmin(at)pangburngroup(dot)com
Cc:pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject:Re: Exception while updating result set
Date:2021-03-29 14:19:13
Message-ID:CADK3HHK8WPCxbhoE4dTt=U0jpmtGWMT0okXY5oj5SAE1b7T26Q@mail.gmail.com
Views:Raw Message | Whole Thread | Download mbox | Resend email
Lists:pgsql-jdbc


On 3/25/21 11:00 AM, Prasanth wrote:
Hi,

Does anyone have any thoughts on this?

Thanks,
Prasanth

On 3/18/21 5:20 PM, Prasanth wrote:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth


Re: Exception while updating result set

From
Prasanth
Date:
https://github.com/pgjdbc/pgjdbc/issues/2194

Thanks,
Prasanth

On 6/26/21 5:49 AM, Dave Cramer wrote:
I can look at this Monday. Can you create an issue on github https://github.com/pgjdbc/pgjdbc

Thx

On Fri, Jun 25, 2021, 3:43 PM Prasanth <dbadmin@pangburngroup.com> wrote:
Sorry did not get the below email, just saw it in the website. Below is the sql.

"SELECT * FROM accounting_periods where plan_id = 30756 order by start_date";

Thanks,
Prasanth

On Thu, 25 Mar 2021 at 12:00, Prasanth <dbadmin(at)pangburngroup(dot)com> wrote:

> Hi,
>
> Does anyone have any thoughts on this?
>
> Thanks,
> Prasanth
>
> On 3/18/21 5:20 PM, Prasanth wrote:
>
> Hi,
>
> The following code generates an exception shown below. Commenting out the
> refreshRow() call would solve the issue. This exception happens only in
> driver versions 42.2.13 and above. Is this a bug in the driver?
>
> ResultSet rs =
> connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
> rs.next();
> rs.updateDate("start_date", Date.valueOf("2020-01-01"));
> rs.updateDate("end_date", Date.valueOf("2020-12-31"));
> rs.updateRow();
> rs.refreshRow();
> rs.updateDate("end_date", Date.valueOf("2020-12-30"));
> rs.updateRow(); // Exception occurs at this line.
>
>
> Exception in thread "main" java.lang.IllegalArgumentException: Attempted
> to write to readonly tuple
> at org.postgresql.core.Tuple.set(Tuple.java:96)
> at
> org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
> at
> org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
> at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)
>
> Thanks,
> Prasanth
>
> What is the query ?


From:Dave Cramer <davecramer(at)postgres(dot)rocks>
To:dbadmin(at)pangburngroup(dot)com
Cc:pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject:Re: Exception while updating result set
Date:2021-03-29 14:19:13
Message-ID:CADK3HHK8WPCxbhoE4dTt=U0jpmtGWMT0okXY5oj5SAE1b7T26Q@mail.gmail.com
Views:Raw Message | Whole Thread | Download mbox | Resend email
Lists:pgsql-jdbc


On 3/25/21 11:00 AM, Prasanth wrote:
Hi,

Does anyone have any thoughts on this?

Thanks,
Prasanth

On 3/18/21 5:20 PM, Prasanth wrote:
Hi,

The following code generates an exception shown below. Commenting out the refreshRow() call would solve the issue. This exception happens only in driver versions 42.2.13 and above. Is this a bug in the driver?

        ResultSet rs = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ).executeQuery(sql);
        rs.next();
        rs.updateDate("start_date", Date.valueOf("2020-01-01"));
        rs.updateDate("end_date", Date.valueOf("2020-12-31"));
        rs.updateRow();
        rs.refreshRow();
        rs.updateDate("end_date", Date.valueOf("2020-12-30"));
        rs.updateRow(); // Exception occurs at this line.


Exception in thread "main" java.lang.IllegalArgumentException: Attempted to write to readonly tuple
    at org.postgresql.core.Tuple.set(Tuple.java:96)
    at org.postgresql.jdbc.PgResultSet.setRowBufferColumn(PgResultSet.java:1680)
    at org.postgresql.jdbc.PgResultSet.updateRowBuffer(PgResultSet.java:1733)
    at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1378)

Thanks,
Prasanth