EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
533 stars 163 forks source link

Error on insert bytea >= 2 Kb into MySql #179

Open nea14e opened 5 years ago

nea14e commented 5 years ago

I am trying to make an insert Postgres bytea -> MySql longblob

Thousands of rows with small bytea (~1 Kb each) are processed as expected by just one INSERT INTO ... SELECT ..., but 1 row with 2.1 Kb bytea always causes an error (even when I try to insert it single):

[XX000] ERROR: invalid memory alloc request size 18446744073709551615

(For the same bytea size in error is the same always.)

But I can export this row from Posgres as INSERT INTO command and make insert via MySql console directly, so the error not on the MySql side.

nea14e commented 5 years ago

Found workaround: Postgres bytea -> MySQL text additional column -> UPDATE in MySQL to unpack to longblob:

UPDATE table1
SET img_blob = UNHEX(SUBSTRING(img_temp_text FROM 3));

But I don't know speed of this workaround. And it is just a workaround of course.

miguelanruiz commented 1 year ago

Hey there @nea14e,

So, what you mean is to use the column as a text type and create an additional one that unpacks this as a binary?

Best regards,

miguelanruiz commented 1 year ago

Hey there @nea14e,

I can assure you that your idea works correctly. Thanks for your help.

Good day,