I am interested in adding Protocol Buffer support for Postgres. Protocol Buffer occupies less space than JSON. More importantly, it has schema and is forward/backward compatible. All these make it a very good format for persistency.
Here are two rough ideas I have right now:
Approach 1:
Creating a datatype "PROTOBUF" similar as "JSON" and implement all the similar support (e.g. indexing) as done for "JSON" Type.
(1) Since each protocol buffer column requires a schema. I am not sure where is the best place to store that schema info. Should it be in a CONSTRAINT (but I am not able to find the doc referring any custom constraint), or should it be in the COMMENT or somewhere else?
I can't really imagine how you'd do that without adding a new catalog like we have for enum members. A typmod isn't sufficient since you need a whole lot more than an integer, and typmods aren't tracked throughout the server that well.