Skip to content

Commit

Permalink
fix(core-database-postgres): store vendor field in bytea (#3048)
Browse files Browse the repository at this point in the history
* We support utf8 strings for vendor field
* \u0000 (nul byte) is a valid utf8 string
* PostgreSQL cannot store \u0000 in VARCHAR

It follows that we cannot use VARCHAR for storing vendor field.
So use bytea for that.
  • Loading branch information
vasild authored and spkjp committed Oct 10, 2019
1 parent 892a610 commit 63dc252
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ALTER TABLE transactions
ALTER COLUMN vendor_field_hex SET DATA TYPE varchar(255)
USING
ENCODE(('\x' || ENCODE(vendor_field_hex, 'escape'))::bytea, 'escape');
UPDATE transactions SET vendor_field_hex = ('\x' || ENCODE(vendor_field_hex, 'escape'))::BYTEA;

ALTER TABLE transactions RENAME vendor_field_hex TO vendor_field;
ALTER TABLE transactions RENAME vendor_field_hex TO vendor_field;

0 comments on commit 63dc252

Please sign in to comment.