[PATCH] Generic type subscription

Dmitry Dolgov <9erthalion6@gmail.com>

From: Dmitry Dolgov <9erthalion6@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2016-09-09T11:29:23Z
Lists: pgsql-hackers

Attachments

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.

[1]:
https://www.postgresql.org/message-id/flat/CA+q6zcV8qvGcDXurwwgUbwACV86Th7G80pnubg42e-p9gsSf=g@mail.gmail.com#CA+q6zcV8qvGcDXurwwgUbwACV86Th7G80pnubg42e-p9gsSf=g@mail.gmail.com
[2]:
https://www.postgresql.org/message-id/flat/CA+q6zcX3mdxGCgdThzuySwH-ApyHHM-G4oB1R0fn0j2hZqqkLQ@mail.gmail.com#CA+q6zcX3mdxGCgdThzuySwH-ApyHHM-G4oB1R0fn0j2hZqqkLQ@mail.gmail.com

Commits

  1. Throw error when assigning jsonb scalar instead of a composite object

  2. Filling array gaps during jsonb subscripting

  3. Implementation of subscripting for jsonb

  4. Support subscripting of arbitrary types, not only arrays.

  5. Remove obsoleted code relating to targetlist SRF evaluation.

  6. Include <sys/select.h> where needed