Protocol buffer support for Postgres - Mailing list pgsql-hackers

From 陈天舟
Subject Protocol buffer support for Postgres
Date
Msg-id CAMr4XPLDTrL1b=GrnwhhEjQJE5KdPGL+BrA-yvMMc0dGYb9hCw@mail.gmail.com
Whole thread Raw
Responses Re: Protocol buffer support for Postgres  (Craig Ringer <craig@2ndquadrant.com>)
Re: Protocol buffer support for Postgres  (José Luis Tallón <jltallon@adv-solutions.net>)
Re: Protocol buffer support for Postgres  (David Fetter <david@fetter.org>)
List pgsql-hackers
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?
(2) The input/output will be already serialized protocol buffer. The protocol buffer schema will be used to validate the column value when storing/retrieving the data. It may be possible to skip the check upon retrieving, instead the check can be done anytime the column schema is changed.

Approach 2:

Still creating a datatype "PROTOBUF", but internally it uses "JSON" type. So PROTOBUF is just a wrapper type doing the conversion and schema validation on the fly. The benefit of this is it can leverage the JSON support. The downside is it can only support the common features available in both Protocol Buffer and JSON. e.g. Protocol Buffer annotation is a quite useful feature which is not available in JSON.

I would like to hear some thoughts about having Protocol Buffer for Postgres as well as the approach tackling it.

Thanks
Tianzhou

pgsql-hackers by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Parallel SAFE information missing in CREATE OR REPLACE FUNCTION definition
Next
From: Craig Ringer
Date:
Subject: Re: Protocol buffer support for Postgres