nikita-volkov / postgresql-binary

Encoders and decoders for the PostgreSQL's binary format
http://hackage.haskell.org/package/postgresql-binary
MIT License
21 stars 13 forks source link

Composite types #3

Closed mikeplus64 closed 9 years ago

mikeplus64 commented 9 years ago

This adds a vector dependency, hopefully that's not an issue given how ubiquitous it is.

Probably could do with some tests, I've only had a go (with success) at parsing the output of hasql-postgres array_agg(...) queries (using hasql-postgres to separate the elements). The only documentation about these is the source code, so I'm not certain if I'm following the "spec" exactly. I ended up just going through the raw output to figure out the layout, since that was more enlightening and straightforward than deciphering the C code.

nikita-volkov commented 9 years ago

Great job Mike!

I ended up just going through the raw output to figure out the layout, since that was more enlightening and straightforward than deciphering the C code.

Yeah, I remember doing the same thing.


As I see in the comments to your code, you've successfully reverse-engineered the format, thus resolving the hardest part of the work, as per my experience. However there remains some work to do before merging. We'll need an encoder implementation and some test-coverage.

Unfortunately I won't be able to join you to work on this this weekend. Hopefully I'll be able to jump in the next weekend. That is unless you finish the work yourself by the time.

mikeplus64 commented 9 years ago

I've added the encoder. I'm not really sure how best to "formally" test it other than that Encoder.composite (Decoder.composite a) == a holds and that the decoder works.

mikeplus64 commented 9 years ago

After some investigating, unfortunately, this encoder isn't very useful. It would have to go via the text format, since the binary format doesn't support inputting composite types at all.

edit: nope - the text format doesn't support it either

The encoder, since it's so simple, might still serve to help verify that the decoder works, I guess.