Hi,
Regarding to the previous conversations [1], [2], here is a patch (with some
improvements from Nikita Glukhov) for the generic type subscription. It allows
to define type-specific subscription logic for any data type and has
implementations for the array and jsonb types. There are following changes in this
patch:
* A new column for `pg_type` (`regproc typsubscription`) which points out a
type-specific subscription procedure for particular data type. It can be none
(and it's a default value), which means that this data type doesn't support
subscription.
* Type-specific code (e.g. any kind of verification, type coercion, actual
data extraction and update) in the array subscription implementation was
separated from generic code into `array_subscription` procedure. Generic
implementation assumes that subscription expression can be in form `[a]` or
`[a:b]`, and there isn't any restrictions for type of `a` and `b`.
* Using the same api a new subscription logic was implemented for `jsonb` type
in `jsonb_subscription` procedure. Several changes were introduced into jsonb
functions just to be able to share common code.
I believe that this patch is more or less in good shape, so I would like to know
what do you think about it? Feedback is welcome.