postgresql

Postgres: "ERROR: cached plan must not change result type"


This exception is being thrown by the PostgreSQL 8.3.7 server to my application. Does anyone know what this error means and what I can do about it?

ERROR:  cached plan must not change result type
STATEMENT:  select code,is_deprecated from country where code=$1

Solution

  • I figured out what was causing this error.

    My application opened a database connection and prepared a SELECT statement for execution.

    Meanwhile, another script was modifying the database table, changing the data type of one of the columns being returned in the above SELECT statement.

    I resolved this by restarting the application after the database table was modified. This reset the database connection, allowing the prepared statement to execute without errors.