pg_protobuf

pg_protobuf

pg_protobuf : Protobuf support for PostgreSQL

Overview

ID Extension Package Version Category License Language
4260
pg_protobuf
pg_protobuf
1.0
UTIL
MIT
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
pgjq
pgqr
gzip
bzip
zstd
http
pg_net
pg_curl

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0
18
17
16
15
14
pg_protobuf -
RPM
PIGSTY
1.0
18
17
16
15
14
pg_protobuf_$v -
DEB
PIGSTY
1.0
18
17
16
15
14
postgresql-$v-pg-protobuf -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el8.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el9.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el9.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el10.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el10.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
Package Version OS ORG SIZE File URL
pg_protobuf_18 1.0 el8.x86_64 pigsty 14.8 KiB pg_protobuf_18-1.0-1PIGSTY.el8.x86_64.rpm
pg_protobuf_18 1.0 el8.aarch64 pigsty 15.0 KiB pg_protobuf_18-1.0-1PIGSTY.el8.aarch64.rpm
pg_protobuf_18 1.0 el9.x86_64 pigsty 14.1 KiB pg_protobuf_18-1.0-1PIGSTY.el9.x86_64.rpm
pg_protobuf_18 1.0 el9.aarch64 pigsty 14.1 KiB pg_protobuf_18-1.0-1PIGSTY.el9.aarch64.rpm
pg_protobuf_18 1.0 el10.x86_64 pigsty 14.2 KiB pg_protobuf_18-1.0-1PIGSTY.el10.x86_64.rpm
pg_protobuf_18 1.0 el10.aarch64 pigsty 14.2 KiB pg_protobuf_18-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-protobuf 1.0 d12.x86_64 pigsty 40.6 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-protobuf 1.0 d12.aarch64 pigsty 41.5 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-protobuf 1.0 d13.x86_64 pigsty 40.6 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-protobuf 1.0 d13.aarch64 pigsty 41.6 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-protobuf 1.0 u22.x86_64 pigsty 44.6 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-protobuf 1.0 u22.aarch64 pigsty 44.5 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-protobuf 1.0 u24.x86_64 pigsty 42.5 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-protobuf 1.0 u24.aarch64 pigsty 42.7 KiB postgresql-18-pg-protobuf_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_protobuf_17 1.0 el8.x86_64 pigsty 14.8 KiB pg_protobuf_17-1.0-1PIGSTY.el8.x86_64.rpm
pg_protobuf_17 1.0 el8.aarch64 pigsty 15.0 KiB pg_protobuf_17-1.0-1PIGSTY.el8.aarch64.rpm
pg_protobuf_17 1.0 el9.x86_64 pigsty 14.1 KiB pg_protobuf_17-1.0-1PIGSTY.el9.x86_64.rpm
pg_protobuf_17 1.0 el9.aarch64 pigsty 14.1 KiB pg_protobuf_17-1.0-1PIGSTY.el9.aarch64.rpm
pg_protobuf_17 1.0 el10.x86_64 pigsty 14.2 KiB pg_protobuf_17-1.0-1PIGSTY.el10.x86_64.rpm
pg_protobuf_17 1.0 el10.aarch64 pigsty 14.2 KiB pg_protobuf_17-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-protobuf 1.0 d12.x86_64 pigsty 40.0 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-protobuf 1.0 d12.aarch64 pigsty 40.7 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-protobuf 1.0 d13.x86_64 pigsty 39.9 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-protobuf 1.0 d13.aarch64 pigsty 40.8 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-protobuf 1.0 u22.x86_64 pigsty 44.9 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-protobuf 1.0 u22.aarch64 pigsty 44.8 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-protobuf 1.0 u24.x86_64 pigsty 41.9 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pg-protobuf 1.0 u24.aarch64 pigsty 42.1 KiB postgresql-17-pg-protobuf_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_protobuf_16 1.0 el8.x86_64 pigsty 14.7 KiB pg_protobuf_16-1.0-1PIGSTY.el8.x86_64.rpm
pg_protobuf_16 1.0 el8.aarch64 pigsty 15.0 KiB pg_protobuf_16-1.0-1PIGSTY.el8.aarch64.rpm
pg_protobuf_16 1.0 el9.x86_64 pigsty 14.1 KiB pg_protobuf_16-1.0-1PIGSTY.el9.x86_64.rpm
pg_protobuf_16 1.0 el9.aarch64 pigsty 14.1 KiB pg_protobuf_16-1.0-1PIGSTY.el9.aarch64.rpm
pg_protobuf_16 1.0 el10.x86_64 pigsty 14.2 KiB pg_protobuf_16-1.0-1PIGSTY.el10.x86_64.rpm
pg_protobuf_16 1.0 el10.aarch64 pigsty 14.2 KiB pg_protobuf_16-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-protobuf 1.0 d12.x86_64 pigsty 39.8 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-protobuf 1.0 d12.aarch64 pigsty 40.5 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-protobuf 1.0 d13.x86_64 pigsty 39.7 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-protobuf 1.0 d13.aarch64 pigsty 40.7 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-protobuf 1.0 u22.x86_64 pigsty 44.6 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-protobuf 1.0 u22.aarch64 pigsty 44.5 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-protobuf 1.0 u24.x86_64 pigsty 41.6 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pg-protobuf 1.0 u24.aarch64 pigsty 41.9 KiB postgresql-16-pg-protobuf_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_protobuf_15 1.0 el8.x86_64 pigsty 15.0 KiB pg_protobuf_15-1.0-1PIGSTY.el8.x86_64.rpm
pg_protobuf_15 1.0 el8.aarch64 pigsty 15.2 KiB pg_protobuf_15-1.0-1PIGSTY.el8.aarch64.rpm
pg_protobuf_15 1.0 el9.x86_64 pigsty 14.5 KiB pg_protobuf_15-1.0-1PIGSTY.el9.x86_64.rpm
pg_protobuf_15 1.0 el9.aarch64 pigsty 14.6 KiB pg_protobuf_15-1.0-1PIGSTY.el9.aarch64.rpm
pg_protobuf_15 1.0 el10.x86_64 pigsty 14.5 KiB pg_protobuf_15-1.0-1PIGSTY.el10.x86_64.rpm
pg_protobuf_15 1.0 el10.aarch64 pigsty 14.8 KiB pg_protobuf_15-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-protobuf 1.0 d12.x86_64 pigsty 38.7 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-protobuf 1.0 d12.aarch64 pigsty 39.4 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-protobuf 1.0 d13.x86_64 pigsty 38.6 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-protobuf 1.0 d13.aarch64 pigsty 39.5 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-protobuf 1.0 u22.x86_64 pigsty 43.6 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-protobuf 1.0 u22.aarch64 pigsty 43.6 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-protobuf 1.0 u24.x86_64 pigsty 40.7 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pg-protobuf 1.0 u24.aarch64 pigsty 41.0 KiB postgresql-15-pg-protobuf_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_protobuf_14 1.0 el8.x86_64 pigsty 15.0 KiB pg_protobuf_14-1.0-1PIGSTY.el8.x86_64.rpm
pg_protobuf_14 1.0 el8.aarch64 pigsty 15.2 KiB pg_protobuf_14-1.0-1PIGSTY.el8.aarch64.rpm
pg_protobuf_14 1.0 el9.x86_64 pigsty 14.5 KiB pg_protobuf_14-1.0-1PIGSTY.el9.x86_64.rpm
pg_protobuf_14 1.0 el9.aarch64 pigsty 14.6 KiB pg_protobuf_14-1.0-1PIGSTY.el9.aarch64.rpm
pg_protobuf_14 1.0 el10.x86_64 pigsty 14.5 KiB pg_protobuf_14-1.0-1PIGSTY.el10.x86_64.rpm
pg_protobuf_14 1.0 el10.aarch64 pigsty 14.8 KiB pg_protobuf_14-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-protobuf 1.0 d12.x86_64 pigsty 38.5 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-protobuf 1.0 d12.aarch64 pigsty 39.3 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-protobuf 1.0 d13.x86_64 pigsty 38.5 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-protobuf 1.0 d13.aarch64 pigsty 39.4 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-protobuf 1.0 u22.x86_64 pigsty 43.5 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-protobuf 1.0 u22.aarch64 pigsty 43.4 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-protobuf 1.0 u24.x86_64 pigsty 40.5 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pg-protobuf 1.0 u24.aarch64 pigsty 40.8 KiB postgresql-14-pg-protobuf_1.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_protobuf;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_protobuf;		# install via package name, for the active PG version

pig install pg_protobuf -v 18;   # install for PG 18
pig install pg_protobuf -v 17;   # install for PG 17
pig install pg_protobuf -v 16;   # install for PG 16
pig install pg_protobuf -v 15;   # install for PG 15
pig install pg_protobuf -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_protobuf;

Usage

pg_protobuf: Protocol Buffers support for PostgreSQL

Provides functions to decode Protocol Buffer binary data directly in SQL without schema definitions.

Functions

  • protobuf_decode(bytea) RETURNS cstring – Decode protobuf binary into a human-readable format
  • protobuf_get_int(bytea, int) RETURNS bigint – Extract an integer field by field number
  • protobuf_get_string(bytea, int) RETURNS text – Extract a string field by field number
  • protobuf_get_bytes(bytea, int) RETURNS bytea – Extract raw bytes by field number
  • protobuf_get_bool(bytea, int) RETURNS boolean – Extract a boolean field by field number
  • protobuf_get_float(bytea, int) RETURNS real – Extract a float field by field number
  • protobuf_get_double(bytea, int) RETURNS double precision – Extract a double field by field number
  • protobuf_get_sfixed32(bytea, int) RETURNS int – Extract a signed fixed 32-bit field
  • protobuf_get_sfixed64(bytea, int) RETURNS bigint – Extract a signed fixed 64-bit field
  • protobuf_get_int_multi(bytea, int) RETURNS bigint[] – Extract repeated integer fields
  • protobuf_get_string_multi(bytea, int) RETURNS text[] – Extract repeated string fields
  • protobuf_get_bytes_multi(bytea, int) RETURNS bytea[] – Extract repeated bytes fields
  • protobuf_get_bool_multi(bytea, int) RETURNS boolean[] – Extract repeated boolean fields
  • protobuf_get_float_multi(bytea, int) RETURNS real[] – Extract repeated float fields
  • protobuf_get_double_multi(bytea, int) RETURNS double precision[] – Extract repeated double fields
  • protobuf_get_sfixed32_multi(bytea, int) RETURNS int[] – Extract repeated sfixed32 fields
  • protobuf_get_sfixed64_multi(bytea, int) RETURNS bigint[] – Extract repeated sfixed64 fields

Example

CREATE EXTENSION pg_protobuf;

-- Create a table with protobuf data
CREATE TABLE heroes (x bytea);

-- Define accessor functions for specific fields
CREATE FUNCTION hero_name(x bytea) RETURNS text AS $$
BEGIN
  RETURN protobuf_get_string(x, 512);
END $$ LANGUAGE plpgsql IMMUTABLE;

CREATE FUNCTION hero_hp(x bytea) RETURNS bigint AS $$
BEGIN
  RETURN protobuf_get_int(x, 2);
END $$ LANGUAGE plpgsql IMMUTABLE;

-- Create an index on a protobuf field
CREATE INDEX hero_name_idx ON heroes USING btree(hero_name(x));

-- Query by protobuf field
SELECT hero_name(x) FROM heroes ORDER BY hero_name(x) LIMIT 10;

Limitations

  • No modification of Protobuf data
  • Enums readable via protobuf_get_int
  • Unsigned types not directly supported (no unsigned integers in PostgreSQL)
  • [packed=true] not supported by *_multi procedures (use protobuf_get_bytes* instead)
Last updated on