In one of my select statements I've got the following error:
ERROR: failed to find conversion function from unknown to text
********** Error **********
ERROR: failed to find conversion function from unknown to text
SQL state: XX000
This was easy to fix using cast
, but I do not fully understand why it happened. I will ilustrate my confusion with two simple statements.
This one is OK:
select 'text'
union all
select 'text';
This will return error:
with t as (select 'text')
select * from t
union all
select 'text'
I know I can fix it easily:
with t as (select 'text'::text)
select * from t
union all
select 'text'
Why does the conversion fail in the second example? Is there some logic I do not understand or this will be fixed in future version of PostgreSQL?
PostgreSQL 9.1.9
The same behavior on PostgreSQL 9.2.4 (SQL Fiddle)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…