Skip to content

Commit

Permalink
Consider any "0A000" error a possible cached plan changed error
Browse files Browse the repository at this point in the history
jackc committed Mar 5, 2022

Verified

This commit was signed with the committer’s verified signature.
Byron Sebastian Thiel
1 parent ded272b commit b7a85d1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions stmtcache/lru.go
Original file line number Diff line number Diff line change
@@ -102,10 +102,14 @@ func (c *LRU) StatementErrored(sql string, err error) {
return
}

isInvalidCachedPlanError := pgErr.Severity == "ERROR" &&
pgErr.Code == "0A000" &&
pgErr.Message == "cached plan must not change result type"
if isInvalidCachedPlanError {
// https://github.com/jackc/pgx/issues/1162
//
// We used to look for the message "cached plan must not change result type". However, that message can be localized.
// Unfortunately, error code "0A000" - "FEATURE NOT SUPPORTED" is used for many different errors and the only way to
// tell the difference is by the message. But all that happens is we clear a statement that we otherwise wouldn't
// have so it should be safe.
possibleInvalidCachedPlanError := pgErr.Code == "0A000"
if possibleInvalidCachedPlanError {
c.stmtsToClear = append(c.stmtsToClear, sql)
}
}

0 comments on commit b7a85d1

Please sign in to comment.