The idea of the day ain’t directly from me, I’m just helping with a very thin subpart of the problem. The problem, I can’t say much about, let’s just assume you want to reduce the storage of MD5 in your database, so you want to abuse bit strings. A solution to use them works fine, but the datatype is still missing some facilities, for example going from and to hexadecimal representation in text.
The problem was raised this week on IRC and this time again I felt it would be a good occasion for a blog entry: how to load an XML file content into a single field?
The usual tool used to import files is COPY, but it’ll want each line of the file to host a text representation of a database tuple, so it doesn’t apply to the case at hand. RhodiumToad was online and offered the following code to solve the problem: