Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move type support functions into _timescaledb_functions schema #5545

Merged
merged 1 commit into from Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions sql/pre_install/types.functions.sql
Expand Up @@ -14,29 +14,29 @@
-- validation constraint for columns of type ts_interval.

--the textual input/output is simply base64 encoding of the binary representation
CREATE OR REPLACE FUNCTION _timescaledb_internal.compressed_data_in(CSTRING)
CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_in(CSTRING)
RETURNS _timescaledb_internal.compressed_data
AS '@MODULE_PATHNAME@', 'ts_compressed_data_in'
LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION _timescaledb_internal.compressed_data_out(_timescaledb_internal.compressed_data)
CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_out(_timescaledb_internal.compressed_data)
RETURNS CSTRING
AS '@MODULE_PATHNAME@', 'ts_compressed_data_out'
LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION _timescaledb_internal.compressed_data_send(_timescaledb_internal.compressed_data)
CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_send(_timescaledb_internal.compressed_data)
RETURNS BYTEA
AS '@MODULE_PATHNAME@', 'ts_compressed_data_send'
LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION _timescaledb_internal.compressed_data_recv(internal)
CREATE OR REPLACE FUNCTION _timescaledb_functions.compressed_data_recv(internal)
RETURNS _timescaledb_internal.compressed_data
AS '@MODULE_PATHNAME@', 'ts_compressed_data_recv'
LANGUAGE C IMMUTABLE STRICT;

-- Remote transation ID implementation
CREATE OR REPLACE FUNCTION _timescaledb_internal.rxid_in(cstring) RETURNS @extschema@.rxid
CREATE OR REPLACE FUNCTION _timescaledb_functions.rxid_in(cstring) RETURNS @extschema@.rxid
AS '@MODULE_PATHNAME@', 'ts_remote_txn_id_in' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE OR REPLACE FUNCTION _timescaledb_internal.rxid_out(@extschema@.rxid) RETURNS cstring
CREATE OR REPLACE FUNCTION _timescaledb_functions.rxid_out(@extschema@.rxid) RETURNS cstring
AS '@MODULE_PATHNAME@', 'ts_remote_txn_id_out' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
12 changes: 6 additions & 6 deletions sql/pre_install/types.post.sql
Expand Up @@ -9,17 +9,17 @@ CREATE TYPE _timescaledb_internal.compressed_data (
INTERNALLENGTH = VARIABLE,
STORAGE = EXTERNAL,
ALIGNMENT = double, --needed for alignment in ARRAY type compression
INPUT = _timescaledb_internal.compressed_data_in,
OUTPUT = _timescaledb_internal.compressed_data_out,
RECEIVE = _timescaledb_internal.compressed_data_recv,
SEND = _timescaledb_internal.compressed_data_send
INPUT = _timescaledb_functions.compressed_data_in,
OUTPUT = _timescaledb_functions.compressed_data_out,
RECEIVE = _timescaledb_functions.compressed_data_recv,
SEND = _timescaledb_functions.compressed_data_send
);

--
-- Remote transaction ID
--
CREATE TYPE @extschema@.rxid (
internallength = 16,
input = _timescaledb_internal.rxid_in,
output = _timescaledb_internal.rxid_out
input = _timescaledb_functions.rxid_in,
output = _timescaledb_functions.rxid_out
);
7 changes: 7 additions & 0 deletions sql/updates/latest-dev.sql
Expand Up @@ -50,3 +50,10 @@ DROP FUNCTION IF EXISTS _timescaledb_internal.hypertable_from_main_table(regclas
DROP FUNCTION IF EXISTS _timescaledb_internal.main_table_from_hypertable(integer);
DROP FUNCTION IF EXISTS _timescaledb_internal.time_literal_sql(bigint, regtype);

ALTER FUNCTION _timescaledb_internal.compressed_data_in(CSTRING) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.compressed_data_out(_timescaledb_internal.compressed_data) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.compressed_data_send(_timescaledb_internal.compressed_data) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.compressed_data_recv(internal) SET SCHEMA _timescaledb_functions;

ALTER FUNCTION _timescaledb_internal.rxid_in(cstring) SET SCHEMA _timescaledb_functions;
ALTER FUNCTION _timescaledb_internal.rxid_out(@extschema@.rxid) SET SCHEMA _timescaledb_functions;
8 changes: 8 additions & 0 deletions sql/updates/reverse-dev.sql
Expand Up @@ -113,6 +113,14 @@ ALTER FUNCTION _timescaledb_functions.bookend_finalfunc(internal, anyelement, "a
ALTER FUNCTION _timescaledb_functions.bookend_serializefunc(internal) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.bookend_deserializefunc(bytea, internal) SET SCHEMA _timescaledb_internal;

ALTER FUNCTION _timescaledb_functions.compressed_data_in(CSTRING) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.compressed_data_out(_timescaledb_internal.compressed_data) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.compressed_data_send(_timescaledb_internal.compressed_data) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.compressed_data_recv(internal) SET SCHEMA _timescaledb_internal;

ALTER FUNCTION _timescaledb_functions.rxid_in(cstring) SET SCHEMA _timescaledb_internal;
ALTER FUNCTION _timescaledb_functions.rxid_out(@extschema@.rxid) SET SCHEMA _timescaledb_internal;

DROP SCHEMA _timescaledb_functions;

CREATE FUNCTION _timescaledb_internal.is_main_table(
Expand Down
6 changes: 3 additions & 3 deletions tsl/test/expected/remote_txn_id.out
Expand Up @@ -2,11 +2,11 @@
-- Please see the included NOTICE for copyright information and
-- LICENSE-TIMESCALE for a copy of the license.
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE FUNCTION _timescaledb_internal.test_remote_txn_id()
CREATE FUNCTION _timescaledb_functions.test_remote_txn_id()
RETURNS void
AS :TSL_MODULE_PATHNAME, 'ts_test_remote_txn_id'
LANGUAGE C STRICT;
SELECT _timescaledb_internal.test_remote_txn_id();
SELECT _timescaledb_functions.test_remote_txn_id();
test_remote_txn_id
--------------------

Expand All @@ -23,7 +23,7 @@ create table tbl_w_rxid(
);
CREATE UNIQUE INDEX idx_name ON tbl_w_rxid ((txn_id::text));
INSERT INTO tbl_w_rxid VALUES ('ts-1-10-20-30'), ('ts-1-11-20-30'), ('ts-1-10-21-30');
SELECT txn_id, _timescaledb_internal.rxid_in(_timescaledb_internal.rxid_out(txn_id))::text = txn_id::text FROM tbl_w_rxid;
SELECT txn_id, _timescaledb_functions.rxid_in(_timescaledb_functions.rxid_out(txn_id))::text = txn_id::text FROM tbl_w_rxid;
txn_id | ?column?
---------------+----------
ts-1-10-20-30 | t
Expand Down
12 changes: 6 additions & 6 deletions tsl/test/shared/expected/extension.out
Expand Up @@ -22,6 +22,10 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_functions.bookend_deserializefunc(bytea,internal)
_timescaledb_functions.bookend_finalfunc(internal,anyelement,"any")
_timescaledb_functions.bookend_serializefunc(internal)
_timescaledb_functions.compressed_data_in(cstring)
_timescaledb_functions.compressed_data_out(_timescaledb_internal.compressed_data)
_timescaledb_functions.compressed_data_recv(internal)
_timescaledb_functions.compressed_data_send(_timescaledb_internal.compressed_data)
_timescaledb_functions.first_combinefunc(internal,internal)
_timescaledb_functions.first_sfunc(internal,anyelement,"any")
_timescaledb_functions.hist_combinefunc(internal,internal)
Expand All @@ -31,6 +35,8 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_functions.hist_sfunc(internal,double precision,double precision,double precision,integer)
_timescaledb_functions.last_combinefunc(internal,internal)
_timescaledb_functions.last_sfunc(internal,anyelement,"any")
_timescaledb_functions.rxid_in(cstring)
_timescaledb_functions.rxid_out(rxid)
_timescaledb_internal.alter_job_set_hypertable_id(integer,regclass)
_timescaledb_internal.attach_osm_table_chunk(regclass,regclass)
_timescaledb_internal.cagg_migrate_create_plan(_timescaledb_catalog.continuous_agg,text,boolean,boolean)
Expand Down Expand Up @@ -59,10 +65,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_internal.chunks_remote_size(name,name)
_timescaledb_internal.compressed_chunk_local_stats(name,name)
_timescaledb_internal.compressed_chunk_remote_stats(name,name)
_timescaledb_internal.compressed_data_in(cstring)
_timescaledb_internal.compressed_data_out(_timescaledb_internal.compressed_data)
_timescaledb_internal.compressed_data_recv(internal)
_timescaledb_internal.compressed_data_send(_timescaledb_internal.compressed_data)
_timescaledb_internal.continuous_agg_invalidation_trigger()
_timescaledb_internal.create_chunk(regclass,jsonb,name,name,regclass)
_timescaledb_internal.create_chunk_replica_table(regclass,name)
Expand Down Expand Up @@ -126,8 +128,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
_timescaledb_internal.relation_size(regclass)
_timescaledb_internal.remote_txn_heal_data_node(oid)
_timescaledb_internal.restart_background_workers()
_timescaledb_internal.rxid_in(cstring)
_timescaledb_internal.rxid_out(rxid)
_timescaledb_internal.set_chunk_default_data_node(regclass,name)
_timescaledb_internal.set_dist_id(uuid)
_timescaledb_internal.set_peer_dist_id(uuid)
Expand Down
6 changes: 3 additions & 3 deletions tsl/test/sql/remote_txn_id.sql
Expand Up @@ -3,12 +3,12 @@
-- LICENSE-TIMESCALE for a copy of the license.

\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE FUNCTION _timescaledb_internal.test_remote_txn_id()
CREATE FUNCTION _timescaledb_functions.test_remote_txn_id()
RETURNS void
AS :TSL_MODULE_PATHNAME, 'ts_test_remote_txn_id'
LANGUAGE C STRICT;

SELECT _timescaledb_internal.test_remote_txn_id();
SELECT _timescaledb_functions.test_remote_txn_id();

SELECT 'ts-1-10-20-30'::rxid;

Expand All @@ -20,7 +20,7 @@ CREATE UNIQUE INDEX idx_name ON tbl_w_rxid ((txn_id::text));

INSERT INTO tbl_w_rxid VALUES ('ts-1-10-20-30'), ('ts-1-11-20-30'), ('ts-1-10-21-30');

SELECT txn_id, _timescaledb_internal.rxid_in(_timescaledb_internal.rxid_out(txn_id))::text = txn_id::text FROM tbl_w_rxid;
SELECT txn_id, _timescaledb_functions.rxid_in(_timescaledb_functions.rxid_out(txn_id))::text = txn_id::text FROM tbl_w_rxid;

\set ON_ERROR_STOP 0
INSERT INTO tbl_w_rxid VALUES ('ts-1-10-20-30');
Expand Down