Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function convert_from(character varying, unknown) does not exist in Postgres [duplicate]

Tags:

postgresql

When i'm trying to convert from unicode to utf8 in the code below "function convert_from(character varying, unknown) does not exist" error occurs.

select convert_from(artists, 'UTF8') from songs where     
to_tsvector('simple',convert_from(artists, 'UTF8')) 
  @@ plainto_tsquery('simple','alizee') 
limit 100

Column "artists" has "TEXT" type.

But when I'm running

select convert_from(E'\u0422\u0438\u043c\u0430\u0442\u0438', 'UTF8');

it works well.

How can I resolve this problem? I would appreciate any help. Thanks

like image 704
Mega4alik Avatar asked Jan 10 '23 14:01

Mega4alik


1 Answers

From documentation: convert_from(string bytea, src_encoding name). So cast artists to bytea:

select convert_from(artists::bytea, 'UTF8') from songs where     
to_tsvector('simple',convert_from(artists, 'UTF8')) 
  @@ plainto_tsquery('simple','alizee') 
limit 100
like image 53
klin Avatar answered Jan 13 '23 04:01

klin