Something's definitely weird here.
You're sure it's an int4 column?
Are you using an unqualified table name in the FROM clause which your search_path might be re-directing to a different table with the same name in a different schema where column_name is text? Or to a temp table with the same name which would be first in the search path?
You didn't accidentally put single quotes instead of double quotes around column_name?
Trying to think of any other little oopsies that might be in play here.
From: Chamath Sajeewa <csgsajeewa@gmail.com>
Sent: Monday, July 27, 2020 12:51 PM
To: pgsql-novice@lists.postgresql.org
Subject: Pgsql error in coalesce
Hi,
There is table with int4 column. When select query is executed as "select coalesce(column_name, 255), query is failing with below error.
"COALESCE types text and integer cannot be mached".