pg-redis-fdw / redis_fdw

A PostgreSQL foreign data wrapper for Redis
494 stars 68 forks source link

ERROR: invalid byte sequence for encoding "UTF8": 0x86 #31

Open rinshadka opened 3 years ago

rinshadka commented 3 years ago

Hi, I am having a Redis Key "ial:imapapi123" which is actually in MessagePack format. While accessing in redis-cli, it is showing like below:-

2021-07-28 21_22_19-redis-cli

Regarding this I got an information like - read the value from Redis as a Buffer not String and then use a messagepack decoder on it.

But for FDW, I have used below method to create the foreign table:-

CREATE FOREIGN TABLE ial (key text, val text[]) SERVER redis_server OPTIONS (database '0', tabletype 'hash', tablekeyprefix 'ial:');

The foreign table was created , but while selecting getting this error:-

2021-07-29 13_36_41-su

Is there any method to decode from MessagePack format and show the content in foreign table?

Thanks.

rinshadka commented 3 years ago

Hi, did you get a chance to check this, or any workaround?

Thanks.

adunstan commented 3 years ago

You can get binary values from a hash using the singleton_key pattern. e.g. this should work:

CREATE FOREIGN TABLE ial (key text, value bytea) SERVER redis_server OPTIONS (database '0', tabletype 'hash', singleton_key  'ial:imapapp123');

Making it work for a non singleton pattern would involve some coding, for which I don't currently have time.

Except if there's a binary zero in it. I'll see what I can do.