dolthub / pg2mysql

Script to convert Postgres dump files to MySQL dump files
Apache License 2.0
38 stars 10 forks source link

Hex format for MySQL #41

Closed alfredosilvestre-natixis closed 1 year ago

alfredosilvestre-natixis commented 1 year ago

There is an issue when importing hex into MySQL comming from a Postgres dump.

Example in Postgres dump:

INSERT INTO public.ipaddress VALUES ('4f6ae4b5-8eb1-4966-8457-e19d9c19850d', '\x7ee572fa');

Result in MySQL:

+----------------------------------+----------------------+
| id                               | host                 |
+----------------------------------+----------------------+
| 00015636142b499ea8a782606466f4b7 | 0x783765653537326661 |
+----------------------------------+----------------------+

What works inserting in MySQL:

INSERT INTO public.ipaddress VALUES ('4f6ae4b5-8eb1-4966-8457-e19d9c19850d', X'7ee572fa');

Result in MySQL:

+----------------------------------+------------+
| id                               | host       |
+----------------------------------+------------+
| 00015636142b499ea8a782606466f4b7 | 0x7EE572FA |
+----------------------------------+------------+

Right now we are using perl to replace:

perl -p -i -e 's/'\''\\x(\S+)'\''/X'\''$1'\''/g' "${MYSQL_DUMP}.sql"