Re: cached plan must not change result type

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: cached plan must not change result type
Дата
Msg-id CADK3HHJn79rvd0Si7XtQ8EfsaGK04A4fPhoBDng8A8aJkR8hrQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: cached plan must not change result type  (Dave Cramer <davecramer@postgres.rocks>)
Ответы Re: cached plan must not change result type
Список pgsql-jdbc


On Sat, 30 Mar 2024 at 06:14, Dave Cramer <davecramer@postgres.rocks> wrote:


On Fri, 29 Mar 2024 at 19:42, James Pang <jamespang886@gmail.com> 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.


Dave
Thanks,

 


I think the best option for you is to turn off server side prepared statements with prepareThreshold=0

 Dave

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: cached plan must not change result type
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: cached plan must not change result type