public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dave Cramer <[email protected]>
To: James Pang <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: [email protected]
Cc: Laurenz Albe <[email protected]>
Subject: Re: cached plan must not change result type
Date: Sat, 30 Mar 2024 08:27:07 -0400
Message-ID: <CADK3HHJn79rvd0Si7XtQ8EfsaGK04A4fPhoBDng8A8aJkR8hrQ@mail.gmail.com> (raw)
In-Reply-To: <CADK3HHKj=UEr_veXPs+XgD6=0GLJG6pAUN66Vcx0mxYCeuJVHA@mail.gmail.com>
References: <CAHgTRfcg2jGnjSqq1NVuMDtCjRU3aOXWrhXn1L=92Ka_Ug6euw@mail.gmail.com>
	<[email protected]>
	<CAHgTRfe+REHqYoQJ_ykj_p416PbdHz+UN06-R3PVr6auMx4w2g@mail.gmail.com>
	<CAHgTRfeXGN9d7vgg8LtwpNYw_+f-zmMYsOc1U9rhXkGcwWtNng@mail.gmail.com>
	<CADK3HHLkuDpfVKfzckH5z-e1_Z8DH-9WdOWaafbJ4HRuRqnsdg@mail.gmail.com>
	<[email protected]>
	<CADK3HHLx1u-RbR_v5UbmK_v4_sOfzHxdYwxtn5QRRWV-=Re6MQ@mail.gmail.com>
	<CAHgTRfeJop+-t8b1v3U85_hhAL2o15R1cHqkVyhxWLj7B4KWLg@mail.gmail.com>
	<CADK3HHKj=UEr_veXPs+XgD6=0GLJG6pAUN66Vcx0mxYCeuJVHA@mail.gmail.com>

On Sat, 30 Mar 2024 at 06:14, Dave Cramer <[email protected]> wrote:

>
>
> On Fri, 29 Mar 2024 at 19:42, James Pang <[email protected]> wrote:
>
>>    we did DDL "alter table ... alter column increase varchar(512) to
>> varchar(1024)", after that done, hours later, new query select on this
>> table still failed this error.  From this
>> https://jdbc.postgresql.org/documentation/server-prepare/#re-execution-of-failed-statements
>> , looks like pgjdbc try to handle this exception and retry, but in our
>> case, it did not happen.  Could you direct me how to make this retry work?
>> we only want new transactions,queries work that after the DDL changes.
>>
>> protected boolean willHealViaReparse(SQLException e) {
>>     if (e == null || e.getSQLState() == null) {
>>       return false;
>>     }
>>
>>     // "prepared statement \"S_2\" does not exist"
>>     if
>> (PSQLState.INVALID_SQL_STATEMENT_NAME.getState().equals(e.getSQLState())) {
>>       return true;
>>     }
>>     if (!PSQLState.NOT_IMPLEMENTED.getState().equals(e.getSQLState())) {
>>       return false;
>>     }
>>
>>     if (!(e instanceof PSQLException)) {
>>       return false;
>>     }
>>
>>     PSQLException pe = (PSQLException) e;
>>
>>     ServerErrorMessage serverErrorMessage = pe.getServerErrorMessage();
>>     if (serverErrorMessage == null) {
>>       return false;
>>     }
>>     // "cached plan must not change result type"
>>     String routine = serverErrorMessage.getRoutine();
>>     return "RevalidateCachedQuery".equals(routine) // 9.2+
>>         || "RevalidateCachedPlan".equals(routine); // <= 9.1
>>   }
>>
>>
> This only works if there was no transaction.
>
>
> https://github.com/pgjdbc/pgjdbc/blob/0fbd31d43b1013829da3a8f21120d8bb94df803d/pgjdbc/src/main/java/...
>
>
> Dave
>
>> Thanks,
>>
>
>
>
>>
>>
I think the best option for you is to turn off server side prepared
statements with prepareThreshold=0

 Dave


view thread (13+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: cached plan must not change result type
  In-Reply-To: <CADK3HHJn79rvd0Si7XtQ8EfsaGK04A4fPhoBDng8A8aJkR8hrQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox