GORM Playground Link

https://github.com/go-gorm/playground/pull/523

Description

When Prepared Statements are enabled in gorm (using the PrepareStmt: true attribute in gorm.Config when creating a connection), if multiple database migrations are performed, when AutoMigrate is called multiple times to add new columns in a Table the following error is observed:

    main_test.go:55: Failed, got error: ERROR: cached plan must not change result type (SQLSTATE 0A000)

The issue seems related to Prepared Statements caching.

See the provided playground link for a reproducible case, more details and logs.

This error is observed when using gorm.io/gorm v1.23.10 (the latest gorm 1.x version at the moment of writing this message). This was detected when we were working in updating gorm.io/gorm v1.21.7 to v1.23.10. In v1.21.7 the issue does not seem to happen.

Comment From: a631807682

Upgrade postgres driver version, duplicated of https://github.com/go-gorm/postgres/issues/102

Comment From: miguelsorianod

Hi @a631807682. As you can see in the playground link the version that is being used is gorm.io/driver/postgres v1.3.10 which is currently the latest tagged version and the issue can still be reproduced.

Can we reopen this issue?

Thank you.

Comment From: a631807682

complete via https://github.com/go-gorm/postgres/pull/138