forked from mpartel/postgres-protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postgres_protobuf--0.1.sql
50 lines (43 loc) · 1.32 KB
/
postgres_protobuf--0.1.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION postgres_protobuf" to load this file. \quit
CREATE FUNCTION protobuf_extension_version()
RETURNS BIGINT
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
-- Query functions are STABLE, not IMMUTABLE, because they reads
-- `postgres_protobuf_descriptors`. This means that the functions
-- can't be used in index expressions.
CREATE FUNCTION protobuf_query(
IN TEXT, -- Query
IN BYTEA -- Binary protobuf
)
RETURNS TEXT
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
CREATE FUNCTION protobuf_query_multi(
IN TEXT, -- Query
IN BYTEA -- Binary protobuf
)
RETURNS SETOF TEXT
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
CREATE FUNCTION protobuf_to_json_text(
IN TEXT, -- protobuf type
IN BYTEA -- Binary protobuf
)
RETURNS TEXT
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
CREATE FUNCTION protobuf_from_json_text(
IN TEXT, -- protobuf type
IN TEXT -- JSON text
)
RETURNS BYTEA
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT STABLE;
CREATE TABLE protobuf_file_descriptor_sets (
name TEXT NOT NULL,
file_descriptor_set BYTEA NOT NULL,
PRIMARY KEY (name)
);
SELECT pg_catalog.pg_extension_config_dump ('protobuf_file_descriptor_sets', '');