pg_protobuf
提供Protobuf函数支持
pg_protobuf · 提供Protobuf函数支持
概览
| ID | 扩展 | 软件包 | 版本 | 类别 | 许可证 | 编程语言 |
|---|---|---|---|---|---|---|
| 4120 | pg_protobuf | pg_protobuf | 1.0 | UTIL | MIT | C |
| 属性 | 可执行文件 | 动态库 | 需要预加载 | 需要建扩展 | 可迁移 | 可信 |
|---|---|---|---|---|---|---|
| --s-d-r | 否 | 是 | 否 | 是 | 是 | 否 |
软件包
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| el8.aarch64 | N/A | 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 |
| u26.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u26.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
源码
安装
在数据库中创建扩展。
用法
该扩展提供无需 schema 定义即可在 SQL 中直接解码 Protocol Buffer 二进制数据的函数。
函数
protobuf_decode(bytea) RETURNS cstring– 将 protobuf 二进制数据解码为可读格式protobuf_get_int(bytea, int) RETURNS bigint– 按字段编号提取整数字段protobuf_get_string(bytea, int) RETURNS text– 按字段编号提取字符串字段protobuf_get_bytes(bytea, int) RETURNS bytea– 按字段编号提取原始字节protobuf_get_bool(bytea, int) RETURNS boolean– 按字段编号提取布尔字段protobuf_get_float(bytea, int) RETURNS real– 按字段编号提取浮点字段protobuf_get_double(bytea, int) RETURNS double precision– 按字段编号提取双精度字段protobuf_get_sfixed32(bytea, int) RETURNS int– 提取有符号定长 32 位字段protobuf_get_sfixed64(bytea, int) RETURNS bigint– 提取有符号定长 64 位字段protobuf_get_int_multi(bytea, int) RETURNS bigint[]– 提取重复整数字段protobuf_get_string_multi(bytea, int) RETURNS text[]– 提取重复字符串字段protobuf_get_bytes_multi(bytea, int) RETURNS bytea[]– 提取重复字节字段protobuf_get_bool_multi(bytea, int) RETURNS boolean[]– 提取重复布尔字段protobuf_get_float_multi(bytea, int) RETURNS real[]– 提取重复浮点字段protobuf_get_double_multi(bytea, int) RETURNS double precision[]– 提取重复双精度字段protobuf_get_sfixed32_multi(bytea, int) RETURNS int[]– 提取重复 sfixed32 字段protobuf_get_sfixed64_multi(bytea, int) RETURNS bigint[]– 提取重复 sfixed64 字段
示例
限制
- 不支持修改 Protobuf 数据
- 枚举值可通过
protobuf_get_int读取 - 不直接支持无符号类型(PostgreSQL 中没有无符号整数)
*_multi函数不支持[packed=true](可改用protobuf_get_bytes*)