mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 11:45:11 +08:00
Remove experimental multinode functions
This commit removes the following functions: - timescaledb_experimental.block_new_chunks - timescaledb_experimental.allow_new_chunks - timescaledb_experimental.subscription_exec - timescaledb_experimental.move_chunk - timescaledb_experimental.copy_chunk - timescaledb_experimental.cleanup_copy_chunk_operation
This commit is contained in:
parent
83cf5605a5
commit
11df1dd648
@ -28,7 +28,6 @@ set(SOURCE_FILES
|
||||
hypertable.sql
|
||||
chunk.sql
|
||||
ddl_internal.sql
|
||||
ddl_experimental.sql
|
||||
util_time.sql
|
||||
util_internal_table_ddl.sql
|
||||
chunk_constraint.sql
|
||||
|
@ -89,16 +89,6 @@ END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.chunk_drop_replica(chunk regclass,node_name name) RETURNS void LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.chunk_drop_replica(regclass,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
PERFORM _timescaledb_functions.chunk_drop_replica($1,$2);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.chunk_id_from_relid(relid oid) RETURNS integer LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
@ -202,16 +192,6 @@ END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.create_chunk_replica_table(chunk regclass,data_node_name name) RETURNS void LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.create_chunk_replica_table(regclass,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
PERFORM _timescaledb_functions.create_chunk_replica_table($1,$2);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.create_chunk_table(hypertable regclass,slices jsonb,schema_name name,table_name name) RETURNS boolean LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
@ -232,44 +212,6 @@ END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.data_node_chunk_info(node_name name,schema_name_in name,table_name_in name) RETURNS TABLE (chunk_id integer, chunk_schema name, chunk_name name, table_bytes bigint, index_bytes bigint, toast_bytes bigint, total_bytes bigint) LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.data_node_chunk_info(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
RETURN QUERY SELECT * FROM _timescaledb_functions.data_node_chunk_info($1,$2,$3);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.data_node_compressed_chunk_stats(node_name name,schema_name_in name,table_name_in name) RETURNS TABLE (chunk_schema name, chunk_name name, compression_status text, before_compression_table_bytes bigint, before_compression_index_bytes bigint, before_compression_toast_bytes bigint, before_compression_total_bytes bigint, after_compression_table_bytes bigint, after_compression_index_bytes bigint, after_compression_toast_bytes bigint, after_compression_total_bytes bigint) LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.data_node_compressed_chunk_stats(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
RETURN QUERY SELECT * FROM _timescaledb_functions.data_node_compressed_chunk_stats($1,$2,$3);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.data_node_hypertable_info(node_name name,schema_name_in name,table_name_in name) RETURNS TABLE (table_bytes bigint, index_bytes bigint, toast_bytes bigint, total_bytes bigint) LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.data_node_hypertable_info(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
RETURN QUERY SELECT * FROM _timescaledb_functions.data_node_hypertable_info($1,$2,$3);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.data_node_index_size(node_name name,schema_name_in name,table_name_in name) RETURNS TABLE (hypertable_id INTEGER, total_bytes BIGINT) LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.data_node_index_size(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
RETURN QUERY SELECT * FROM _timescaledb_functions.data_node_index_size($1,$2,$3);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.drop_chunk(chunk regclass) RETURNS boolean LANGUAGE PLPGSQL AS $$
|
||||
@ -292,16 +234,6 @@ END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.drop_stale_chunks(node_name name,chunks integer[]=NULL) RETURNS void LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.drop_stale_chunks(name,integer[]) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
PERFORM _timescaledb_functions.drop_stale_chunks($1,$2);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
-- We cannot create a wrapper function in plpgsql for the aggregate transition
|
||||
-- functions because plpgsql cannot deal with datatype internal but since these
|
||||
-- are used in an aggregation context and cannot be called directly and will
|
||||
@ -436,15 +368,6 @@ END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.health() RETURNS TABLE (node_name NAME, healthy BOOL, in_recovery BOOL, error TEXT) LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'function _timescaledb_internal.health() is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
RETURN QUERY SELECT * FROM _timescaledb_functions.health();
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.hypertable_constraint_add_table_fk_constraint(user_ht_constraint_name name,user_ht_schema_name name,user_ht_table_name name,compress_ht_id integer) RETURNS void LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
@ -1005,12 +928,3 @@ END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
||||
CREATE OR REPLACE PROCEDURE _timescaledb_internal.wait_subscription_sync(schema_name name,table_name name,retry_count integer=18000,retry_delay_ms numeric=0.2) LANGUAGE PLPGSQL AS $$
|
||||
BEGIN
|
||||
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
|
||||
RAISE WARNING 'procedure _timescaledb_internal.wait_subscription_sync(name,name,integer,numeric) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
|
||||
END IF;
|
||||
CALL _timescaledb_functions.wait_subscription_sync($1,$2,$3,$4);
|
||||
END$$
|
||||
SET search_path TO pg_catalog,pg_temp;
|
||||
|
||||
|
@ -1,49 +0,0 @@
|
||||
-- This file and its contents are licensed under the Apache License 2.0.
|
||||
-- Please see the included NOTICE for copyright information and
|
||||
-- LICENSE-APACHE for a copy of the license.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Experimental DDL functions and APIs.
|
||||
--
|
||||
-- Users should not rely on these functions unless they accept that
|
||||
-- they can change and/or be removed at any time.
|
||||
------------------------------------------------------------------------
|
||||
|
||||
-- Block new chunk creation on a data node for a distributed
|
||||
-- hypertable. NULL hypertable means it will block chunks for all
|
||||
-- distributed hypertables
|
||||
CREATE OR REPLACE FUNCTION timescaledb_experimental.block_new_chunks(data_node_name NAME, hypertable REGCLASS = NULL, force BOOLEAN = FALSE) RETURNS INTEGER
|
||||
AS '@MODULE_PATHNAME@', 'ts_data_node_block_new_chunks' LANGUAGE C VOLATILE;
|
||||
|
||||
-- Allow chunk creation on a blocked data node for a distributed
|
||||
-- hypertable. NULL hypertable means it will allow chunks for all
|
||||
-- distributed hypertables
|
||||
CREATE OR REPLACE FUNCTION timescaledb_experimental.allow_new_chunks(data_node_name NAME, hypertable REGCLASS = NULL) RETURNS INTEGER
|
||||
AS '@MODULE_PATHNAME@', 'ts_data_node_allow_new_chunks' LANGUAGE C VOLATILE;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE timescaledb_experimental.move_chunk(
|
||||
chunk REGCLASS,
|
||||
source_node NAME = NULL,
|
||||
destination_node NAME = NULL,
|
||||
operation_id NAME = NULL)
|
||||
AS '@MODULE_PATHNAME@', 'ts_move_chunk_proc' LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE timescaledb_experimental.copy_chunk(
|
||||
chunk REGCLASS,
|
||||
source_node NAME = NULL,
|
||||
destination_node NAME = NULL,
|
||||
operation_id NAME = NULL)
|
||||
AS '@MODULE_PATHNAME@', 'ts_copy_chunk_proc' LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION timescaledb_experimental.subscription_exec(
|
||||
subscription_command TEXT
|
||||
) RETURNS VOID AS '@MODULE_PATHNAME@', 'ts_subscription_exec' LANGUAGE C VOLATILE;
|
||||
|
||||
-- A copy_chunk or move_chunk procedure call involves multiple nodes and
|
||||
-- depending on the data size can take a long time. Failures are possible
|
||||
-- when this long running activity is ongoing. We need to be able to recover
|
||||
-- and cleanup such failed chunk copy/move activities and it's done via this
|
||||
-- procedure
|
||||
CREATE OR REPLACE PROCEDURE timescaledb_experimental.cleanup_copy_chunk_operation(
|
||||
operation_id NAME)
|
||||
AS '@MODULE_PATHNAME@', 'ts_copy_chunk_cleanup_proc' LANGUAGE C;
|
@ -1,8 +1,9 @@
|
||||
DROP VIEW IF EXISTS _timescaledb_internal.hypertable_chunk_local_size;
|
||||
DROP VIEW IF EXISTS _timescaledb_internal.compressed_chunk_stats;
|
||||
|
||||
-- only do stub here to not introduce dependency in shared object in update chain
|
||||
CREATE FUNCTION @extschema@.create_distributed_restore_point(
|
||||
name TEXT
|
||||
) RETURNS TABLE(node_name NAME, node_type TEXT, restore_point pg_lsn)
|
||||
AS '@MODULE_PATHNAME@', 'ts_create_distributed_restore_point' LANGUAGE C VOLATILE STRICT;
|
||||
AS $$SELECT NULL::name,NULL::text,NULL::pg_lsn;$$ LANGUAGE SQL VOLATILE STRICT;
|
||||
|
||||
|
@ -90,9 +90,10 @@ ALTER TABLE _timescaledb_catalog.continuous_agg
|
||||
DROP PROCEDURE IF EXISTS timescaledb_experimental.move_chunk(REGCLASS, NAME, NAME);
|
||||
DROP PROCEDURE IF EXISTS timescaledb_experimental.copy_chunk(REGCLASS, NAME, NAME);
|
||||
|
||||
-- we only create stub here to prevent dependency on a specific so
|
||||
CREATE OR REPLACE FUNCTION timescaledb_experimental.subscription_exec(
|
||||
subscription_command TEXT
|
||||
) RETURNS VOID AS '@MODULE_PATHNAME@', 'ts_subscription_exec' LANGUAGE C VOLATILE;
|
||||
) RETURNS VOID AS '' LANGUAGE SQL VOLATILE;
|
||||
|
||||
-- Recreate chunk_copy_operation table with newly added `compress_chunk_name` column
|
||||
--
|
||||
|
@ -85,12 +85,31 @@ DROP PROCEDURE IF EXISTS _timescaledb_functions.wait_subscription_sync;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.health;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.drop_stale_chunks;
|
||||
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.create_chunk_replica_table;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.chunk_drop_replica;
|
||||
DROP PROCEDURE IF EXISTS _timescaledb_internal.wait_subscription_sync;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.health;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.drop_stale_chunks;
|
||||
|
||||
ALTER TABLE _timescaledb_catalog.remote_txn DROP CONSTRAINT remote_txn_remote_transaction_id_check;
|
||||
|
||||
DROP TYPE IF EXISTS @extschema@.rxid CASCADE;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.rxid_in;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.rxid_out;
|
||||
|
||||
DROP TYPE IF EXISTS @extschema@.rxid;
|
||||
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.data_node_hypertable_info;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.data_node_chunk_info;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.data_node_compressed_chunk_stats;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_functions.data_node_index_size;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.data_node_hypertable_info;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.data_node_chunk_info;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.data_node_compressed_chunk_stats;
|
||||
DROP FUNCTION IF EXISTS _timescaledb_internal.data_node_index_size;
|
||||
|
||||
DROP FUNCTION IF EXISTS timescaledb_experimental.block_new_chunks;
|
||||
DROP FUNCTION IF EXISTS timescaledb_experimental.allow_new_chunks;
|
||||
DROP FUNCTION IF EXISTS timescaledb_experimental.subscription_exec;
|
||||
DROP PROCEDURE IF EXISTS timescaledb_experimental.move_chunk;
|
||||
DROP PROCEDURE IF EXISTS timescaledb_experimental.copy_chunk;
|
||||
DROP PROCEDURE IF EXISTS timescaledb_experimental.cleanup_copy_chunk_operation;
|
||||
|
||||
|
@ -248,7 +248,6 @@ CREATE FUNCTION _timescaledb_functions.drop_stale_chunks(
|
||||
) RETURNS VOID
|
||||
AS '@MODULE_PATHNAME@', 'ts_chunks_drop_stale' LANGUAGE C VOLATILE;
|
||||
|
||||
|
||||
CREATE FUNCTION _timescaledb_functions.rxid_in(cstring) RETURNS @extschema@.rxid
|
||||
AS '@MODULE_PATHNAME@', 'ts_remote_txn_id_in' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
||||
|
||||
@ -261,6 +260,8 @@ CREATE TYPE @extschema@.rxid (
|
||||
output = _timescaledb_functions.rxid_out
|
||||
);
|
||||
|
||||
ALTER TABLE _timescaledb_catalog.remote_txn ADD CONSTRAINT remote_txn_remote_transaction_id_check CHECK (remote_transaction_id::@extschema@.rxid IS NOT NULL);
|
||||
|
||||
CREATE FUNCTION _timescaledb_functions.data_node_hypertable_info(
|
||||
node_name NAME,
|
||||
schema_name_in name,
|
||||
@ -308,3 +309,31 @@ CREATE FUNCTION _timescaledb_functions.data_node_index_size(node_name name, sche
|
||||
RETURNS TABLE ( hypertable_id INTEGER, total_bytes BIGINT)
|
||||
AS '@MODULE_PATHNAME@' , 'ts_dist_remote_hypertable_index_info' LANGUAGE C VOLATILE STRICT;
|
||||
|
||||
CREATE FUNCTION timescaledb_experimental.block_new_chunks(data_node_name NAME, hypertable REGCLASS = NULL, force BOOLEAN = FALSE) RETURNS INTEGER
|
||||
AS '@MODULE_PATHNAME@', 'ts_data_node_block_new_chunks' LANGUAGE C VOLATILE;
|
||||
|
||||
CREATE FUNCTION timescaledb_experimental.allow_new_chunks(data_node_name NAME, hypertable REGCLASS = NULL) RETURNS INTEGER
|
||||
AS '@MODULE_PATHNAME@', 'ts_data_node_allow_new_chunks' LANGUAGE C VOLATILE;
|
||||
|
||||
CREATE PROCEDURE timescaledb_experimental.move_chunk(
|
||||
chunk REGCLASS,
|
||||
source_node NAME = NULL,
|
||||
destination_node NAME = NULL,
|
||||
operation_id NAME = NULL)
|
||||
AS '@MODULE_PATHNAME@', 'ts_move_chunk_proc' LANGUAGE C;
|
||||
|
||||
CREATE PROCEDURE timescaledb_experimental.copy_chunk(
|
||||
chunk REGCLASS,
|
||||
source_node NAME = NULL,
|
||||
destination_node NAME = NULL,
|
||||
operation_id NAME = NULL)
|
||||
AS '@MODULE_PATHNAME@', 'ts_copy_chunk_proc' LANGUAGE C;
|
||||
|
||||
CREATE FUNCTION timescaledb_experimental.subscription_exec(
|
||||
subscription_command TEXT
|
||||
) RETURNS VOID AS '@MODULE_PATHNAME@', 'ts_subscription_exec' LANGUAGE C VOLATILE;
|
||||
|
||||
CREATE PROCEDURE timescaledb_experimental.cleanup_copy_chunk_operation(
|
||||
operation_id NAME)
|
||||
AS '@MODULE_PATHNAME@', 'ts_copy_chunk_cleanup_proc' LANGUAGE C;
|
||||
|
||||
|
@ -47,10 +47,6 @@ CROSSMODULE_WRAPPER(job_alter_set_hypertable_id);
|
||||
|
||||
CROSSMODULE_WRAPPER(reorder_chunk);
|
||||
CROSSMODULE_WRAPPER(move_chunk);
|
||||
CROSSMODULE_WRAPPER(move_chunk_proc);
|
||||
CROSSMODULE_WRAPPER(copy_chunk_proc);
|
||||
CROSSMODULE_WRAPPER(copy_chunk_cleanup_proc);
|
||||
CROSSMODULE_WRAPPER(subscription_exec);
|
||||
|
||||
CROSSMODULE_WRAPPER(policies_add);
|
||||
CROSSMODULE_WRAPPER(policies_remove);
|
||||
@ -421,12 +417,8 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = {
|
||||
.job_run = error_no_default_fn_pg_community,
|
||||
.job_execute = job_execute_default_fn,
|
||||
|
||||
.move_chunk = error_no_default_fn_pg_community,
|
||||
.move_chunk_proc = error_no_default_fn_pg_community,
|
||||
.copy_chunk_proc = error_no_default_fn_pg_community,
|
||||
.copy_chunk_cleanup_proc = error_no_default_fn_pg_community,
|
||||
.subscription_exec = error_no_default_fn_pg_community,
|
||||
.reorder_chunk = error_no_default_fn_pg_community,
|
||||
.move_chunk = error_no_default_fn_pg_community,
|
||||
|
||||
.policies_add = error_no_default_fn_pg_community,
|
||||
.policies_remove = error_no_default_fn_pg_community,
|
||||
|
@ -88,10 +88,6 @@ typedef struct CrossModuleFunctions
|
||||
|
||||
PGFunction reorder_chunk;
|
||||
PGFunction move_chunk;
|
||||
PGFunction move_chunk_proc;
|
||||
PGFunction copy_chunk_proc;
|
||||
PGFunction subscription_exec;
|
||||
PGFunction copy_chunk_cleanup_proc;
|
||||
|
||||
/* Vectorized queries */
|
||||
bool (*push_down_aggregation)(PlannerInfo *root, AggPath *aggregation_path, Path *subpath);
|
||||
|
@ -1,7 +1,6 @@
|
||||
set(SOURCES
|
||||
chunk_api.c
|
||||
chunk.c
|
||||
chunk_copy.c
|
||||
data_node.c
|
||||
deparse.c
|
||||
dist_util.c
|
||||
|
1415
tsl/src/chunk_copy.c
1415
tsl/src/chunk_copy.c
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* This file and its contents are licensed under the Timescale License.
|
||||
* Please see the included NOTICE for copyright information and
|
||||
* LICENSE-TIMESCALE for a copy of the license.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
extern void chunk_copy(Oid chunk_relid, const char *src_node, const char *dst_node,
|
||||
const char *op_id, bool delete_on_src_node);
|
||||
extern void chunk_copy_cleanup(const char *operation_id);
|
@ -124,10 +124,6 @@ CrossModuleFunctions tsl_cm_functions = {
|
||||
|
||||
.reorder_chunk = tsl_reorder_chunk,
|
||||
.move_chunk = tsl_move_chunk,
|
||||
.move_chunk_proc = tsl_move_chunk_proc,
|
||||
.copy_chunk_proc = tsl_copy_chunk_proc,
|
||||
.copy_chunk_cleanup_proc = tsl_copy_chunk_cleanup_proc,
|
||||
.subscription_exec = tsl_subscription_exec,
|
||||
|
||||
.policies_add = policies_add,
|
||||
.policies_remove = policies_remove,
|
||||
|
@ -64,7 +64,6 @@
|
||||
|
||||
#include "annotations.h"
|
||||
#include "chunk.h"
|
||||
#include "chunk_copy.h"
|
||||
#include "chunk_index.h"
|
||||
#include "hypertable_cache.h"
|
||||
#include "indexing.h"
|
||||
@ -206,186 +205,6 @@ tsl_move_chunk(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement a distributed chunk copy/move operation.
|
||||
*
|
||||
* We use a procedure because multiple steps need to be performed via multiple
|
||||
* transactions across the access node and the two datanodes that are involved.
|
||||
* The progress of the various stages/steps are tracked in the
|
||||
* CHUNK_COPY_OPERATION catalog table
|
||||
*/
|
||||
static void
|
||||
tsl_copy_or_move_chunk_proc(FunctionCallInfo fcinfo, bool delete_on_src_node)
|
||||
{
|
||||
Oid chunk_id = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
|
||||
const char *src_node_name = PG_ARGISNULL(1) ? NULL : NameStr(*PG_GETARG_NAME(1));
|
||||
const char *dst_node_name = PG_ARGISNULL(2) ? NULL : NameStr(*PG_GETARG_NAME(2));
|
||||
const char *op_id = PG_ARGISNULL(3) ? NULL : NameStr(*PG_GETARG_NAME(3));
|
||||
int rc;
|
||||
bool nonatomic = fcinfo->context && IsA(fcinfo->context, CallContext) &&
|
||||
!castNode(CallContext, fcinfo->context)->atomic;
|
||||
|
||||
TS_PREVENT_FUNC_IF_READ_ONLY();
|
||||
|
||||
PreventInTransactionBlock(true, get_func_name(FC_FN_OID(fcinfo)));
|
||||
|
||||
/* src_node and dst_node both have to be non-NULL */
|
||||
if (src_node_name == NULL || dst_node_name == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid source or destination node")));
|
||||
|
||||
if (!OidIsValid(chunk_id))
|
||||
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid chunk")));
|
||||
|
||||
if ((rc = SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0)) != SPI_OK_CONNECT)
|
||||
elog(ERROR, "SPI_connect failed: %s", SPI_result_code_string(rc));
|
||||
|
||||
/* Lock down search_path */
|
||||
rc = SPI_exec("SET LOCAL search_path TO pg_catalog, pg_temp", 0);
|
||||
if (rc < 0)
|
||||
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), (errmsg("could not set search_path"))));
|
||||
|
||||
/* perform the actual distributed chunk move after a few sanity checks */
|
||||
chunk_copy(chunk_id, src_node_name, dst_node_name, op_id, delete_on_src_node);
|
||||
|
||||
if ((rc = SPI_finish()) != SPI_OK_FINISH)
|
||||
elog(ERROR, "SPI_finish failed: %s", SPI_result_code_string(rc));
|
||||
}
|
||||
|
||||
Datum
|
||||
tsl_move_chunk_proc(PG_FUNCTION_ARGS)
|
||||
{
|
||||
tsl_copy_or_move_chunk_proc(fcinfo, true);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Datum
|
||||
tsl_copy_chunk_proc(PG_FUNCTION_ARGS)
|
||||
{
|
||||
tsl_copy_or_move_chunk_proc(fcinfo, false);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Datum
|
||||
tsl_subscription_exec(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid save_userid;
|
||||
int save_sec_context;
|
||||
const char *subscription_cmd = PG_ARGISNULL(0) ? NULL : text_to_cstring(PG_GETARG_TEXT_P(0));
|
||||
int res;
|
||||
List *parsetree_list;
|
||||
ListCell *parsetree_item;
|
||||
|
||||
if (!subscription_cmd)
|
||||
PG_RETURN_VOID();
|
||||
|
||||
/*
|
||||
* Subscription command needs a superuser
|
||||
* so switch to that context. But first check that the passed in user has atleast
|
||||
* REPLICATION privileges to justify the use of this function
|
||||
*/
|
||||
if (!superuser() && !has_rolreplication(GetUserId()))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser or replication role to use this function"))));
|
||||
|
||||
GetUserIdAndSecContext(&save_userid, &save_sec_context);
|
||||
SetUserIdAndSecContext(BOOTSTRAP_SUPERUSERID, save_sec_context | SECURITY_LOCAL_USERID_CHANGE);
|
||||
|
||||
/*
|
||||
* Parse the SQL string into a list of raw parse trees.
|
||||
*/
|
||||
parsetree_list = pg_parse_query(subscription_cmd);
|
||||
|
||||
/*
|
||||
* Check that we have received a "SUBSCRIPTION" related command only. Anything else
|
||||
* needs to error out
|
||||
*/
|
||||
foreach (parsetree_item, parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = lfirst_node(RawStmt, parsetree_item);
|
||||
|
||||
/* We are only interested in "CREATE/DROP SUBSCRIPTION" and "ALTER SUBSCRIPTION" stmts */
|
||||
switch (nodeTag(parsetree->stmt))
|
||||
{
|
||||
case T_CreateSubscriptionStmt:
|
||||
break;
|
||||
|
||||
case T_AlterSubscriptionStmt:
|
||||
break;
|
||||
|
||||
case T_DropSubscriptionStmt:
|
||||
break;
|
||||
|
||||
default:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("this function only accepts SUBSCRIPTION commands")));
|
||||
}
|
||||
}
|
||||
|
||||
if (SPI_connect() != SPI_OK_CONNECT)
|
||||
elog(ERROR, "could not connect to SPI");
|
||||
|
||||
/* Lock down search_path */
|
||||
res = SPI_exec("SET LOCAL search_path TO pg_catalog, pg_temp", 0);
|
||||
if (res < 0)
|
||||
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), (errmsg("could not set search_path"))));
|
||||
|
||||
res = SPI_execute(subscription_cmd, false /* read_only */, 0 /*count*/);
|
||||
|
||||
if (res < 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
(errmsg("error in subscription cmd \"%s\"", subscription_cmd))));
|
||||
|
||||
if ((res = SPI_finish()) != SPI_OK_FINISH)
|
||||
elog(ERROR, "SPI_finish failed: %s", SPI_result_code_string(res));
|
||||
|
||||
/* Restore the earlier user */
|
||||
SetUserIdAndSecContext(save_userid, save_sec_context);
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
Datum
|
||||
tsl_copy_chunk_cleanup_proc(PG_FUNCTION_ARGS)
|
||||
{
|
||||
const char *operation_id = PG_ARGISNULL(0) ? NULL : NameStr(*PG_GETARG_NAME(0));
|
||||
int rc;
|
||||
bool nonatomic = fcinfo->context && IsA(fcinfo->context, CallContext) &&
|
||||
!castNode(CallContext, fcinfo->context)->atomic;
|
||||
|
||||
TS_PREVENT_FUNC_IF_READ_ONLY();
|
||||
|
||||
PreventInTransactionBlock(true, get_func_name(FC_FN_OID(fcinfo)));
|
||||
|
||||
/* valid input has to be provided */
|
||||
if (operation_id == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("invalid chunk copy operation id")));
|
||||
|
||||
if ((rc = SPI_connect_ext(nonatomic ? SPI_OPT_NONATOMIC : 0)) != SPI_OK_CONNECT)
|
||||
elog(ERROR, "SPI_connect failed: %s", SPI_result_code_string(rc));
|
||||
|
||||
/* Lock down search_path */
|
||||
rc = SPI_exec("SET LOCAL search_path TO pg_catalog, pg_temp", 0);
|
||||
if (rc < 0)
|
||||
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), (errmsg("could not set search_path"))));
|
||||
|
||||
/* perform the cleanup/repair depending on the stage */
|
||||
chunk_copy_cleanup(operation_id);
|
||||
|
||||
if ((rc = SPI_finish()) != SPI_OK_FINISH)
|
||||
elog(ERROR, "SPI_finish failed: %s", SPI_result_code_string(rc));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
void
|
||||
reorder_chunk(Oid chunk_id, Oid index_id, bool verbose, Oid wait_id, Oid destination_tablespace,
|
||||
Oid index_tablespace)
|
||||
|
@ -9,9 +9,5 @@
|
||||
|
||||
extern Datum tsl_reorder_chunk(PG_FUNCTION_ARGS);
|
||||
extern Datum tsl_move_chunk(PG_FUNCTION_ARGS);
|
||||
extern Datum tsl_move_chunk_proc(PG_FUNCTION_ARGS);
|
||||
extern Datum tsl_copy_chunk_proc(PG_FUNCTION_ARGS);
|
||||
extern Datum tsl_copy_chunk_cleanup_proc(PG_FUNCTION_ARGS);
|
||||
extern Datum tsl_subscription_exec(PG_FUNCTION_ARGS);
|
||||
extern void reorder_chunk(Oid chunk_id, Oid index_id, bool verbose, Oid wait_id,
|
||||
Oid destination_tablespace, Oid index_tablespace);
|
||||
|
@ -79,26 +79,6 @@ ERROR: hypertable cannot be NULL
|
||||
SELECT _timescaledb_internal.create_compressed_chunk(0,0,0,0,0,0,0,0,0,0);
|
||||
WARNING: function _timescaledb_internal.create_compressed_chunk(regclass,regclass,bigint,bigint,bigint,bigint,bigint,bigint,bigint,bigint) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
|
||||
ERROR: invalid Oid
|
||||
SELECT _timescaledb_internal.data_node_chunk_info(NULL,NULL,NULL);
|
||||
WARNING: function _timescaledb_internal.data_node_chunk_info(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
|
||||
data_node_chunk_info
|
||||
(0 rows)
|
||||
|
||||
SELECT _timescaledb_internal.data_node_compressed_chunk_stats(NULL,NULL,NULL);
|
||||
WARNING: function _timescaledb_internal.data_node_compressed_chunk_stats(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
|
||||
data_node_compressed_chunk_stats
|
||||
(0 rows)
|
||||
|
||||
SELECT _timescaledb_internal.data_node_hypertable_info(NULL,NULL,NULL);
|
||||
WARNING: function _timescaledb_internal.data_node_hypertable_info(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
|
||||
data_node_hypertable_info
|
||||
(0 rows)
|
||||
|
||||
SELECT _timescaledb_internal.data_node_index_size(NULL,NULL,NULL);
|
||||
WARNING: function _timescaledb_internal.data_node_index_size(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
|
||||
data_node_index_size
|
||||
(0 rows)
|
||||
|
||||
SELECT _timescaledb_internal.drop_chunk(0);
|
||||
WARNING: function _timescaledb_internal.drop_chunk(regclass) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
|
||||
ERROR: chunk not found
|
||||
|
@ -58,10 +58,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
_timescaledb_functions.create_chunk(regclass,jsonb,name,name,regclass)
|
||||
_timescaledb_functions.create_chunk_table(regclass,jsonb,name,name)
|
||||
_timescaledb_functions.create_compressed_chunk(regclass,regclass,bigint,bigint,bigint,bigint,bigint,bigint,bigint,bigint)
|
||||
_timescaledb_functions.data_node_chunk_info(name,name,name)
|
||||
_timescaledb_functions.data_node_compressed_chunk_stats(name,name,name)
|
||||
_timescaledb_functions.data_node_hypertable_info(name,name,name)
|
||||
_timescaledb_functions.data_node_index_size(name,name,name)
|
||||
_timescaledb_functions.dimension_info_in(cstring)
|
||||
_timescaledb_functions.dimension_info_out(_timescaledb_internal.dimension_info)
|
||||
_timescaledb_functions.drop_chunk(regclass)
|
||||
@ -125,8 +121,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
_timescaledb_functions.relation_size(regclass)
|
||||
_timescaledb_functions.repair_relation_acls()
|
||||
_timescaledb_functions.restart_background_workers()
|
||||
_timescaledb_functions.rxid_in(cstring)
|
||||
_timescaledb_functions.rxid_out(rxid)
|
||||
_timescaledb_functions.set_chunk_default_data_node(regclass,name)
|
||||
_timescaledb_functions.show_chunk(regclass)
|
||||
_timescaledb_functions.start_background_workers()
|
||||
@ -158,7 +152,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
_timescaledb_internal.cagg_watermark_materialized(integer)
|
||||
_timescaledb_internal.calculate_chunk_interval(integer,bigint,bigint)
|
||||
_timescaledb_internal.chunk_constraint_add_table_constraint(_timescaledb_catalog.chunk_constraint)
|
||||
_timescaledb_internal.chunk_drop_replica(regclass,name)
|
||||
_timescaledb_internal.chunk_id_from_relid(oid)
|
||||
_timescaledb_internal.chunk_index_clone(oid)
|
||||
_timescaledb_internal.chunk_index_replace(oid,oid)
|
||||
@ -170,16 +163,10 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
_timescaledb_internal.compressed_chunk_remote_stats(name,name)
|
||||
_timescaledb_internal.continuous_agg_invalidation_trigger()
|
||||
_timescaledb_internal.create_chunk(regclass,jsonb,name,name,regclass)
|
||||
_timescaledb_internal.create_chunk_replica_table(regclass,name)
|
||||
_timescaledb_internal.create_chunk_table(regclass,jsonb,name,name)
|
||||
_timescaledb_internal.create_compressed_chunk(regclass,regclass,bigint,bigint,bigint,bigint,bigint,bigint,bigint,bigint)
|
||||
_timescaledb_internal.data_node_chunk_info(name,name,name)
|
||||
_timescaledb_internal.data_node_compressed_chunk_stats(name,name,name)
|
||||
_timescaledb_internal.data_node_hypertable_info(name,name,name)
|
||||
_timescaledb_internal.data_node_index_size(name,name,name)
|
||||
_timescaledb_internal.drop_chunk(regclass)
|
||||
_timescaledb_internal.drop_dist_ht_invalidation_trigger(integer)
|
||||
_timescaledb_internal.drop_stale_chunks(name,integer[])
|
||||
_timescaledb_internal.finalize_agg(text,name,name,name[],bytea,anyelement)
|
||||
_timescaledb_internal.finalize_agg_ffunc(internal,text,name,name,name[],bytea,anyelement)
|
||||
_timescaledb_internal.finalize_agg_sfunc(internal,text,name,name,name[],bytea,anyelement)
|
||||
@ -194,7 +181,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
_timescaledb_internal.get_os_info()
|
||||
_timescaledb_internal.get_partition_for_key(anyelement)
|
||||
_timescaledb_internal.get_partition_hash(anyelement)
|
||||
_timescaledb_internal.health()
|
||||
_timescaledb_internal.hypertable_constraint_add_table_fk_constraint(name,name,name,integer)
|
||||
_timescaledb_internal.hypertable_invalidation_log_delete(integer)
|
||||
_timescaledb_internal.hypertable_local_size(name,name)
|
||||
@ -241,7 +227,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
_timescaledb_internal.to_unix_microseconds(timestamp with time zone)
|
||||
_timescaledb_internal.tsl_loaded()
|
||||
_timescaledb_internal.unfreeze_chunk(regclass)
|
||||
_timescaledb_internal.wait_subscription_sync(name,name,integer,numeric)
|
||||
debug_waitpoint_enable(text)
|
||||
debug_waitpoint_id(text)
|
||||
debug_waitpoint_release(text)
|
||||
@ -323,16 +308,10 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text
|
||||
timescaledb_post_restore()
|
||||
timescaledb_pre_restore()
|
||||
timescaledb_experimental.add_policies(regclass,boolean,"any","any","any","any")
|
||||
timescaledb_experimental.allow_new_chunks(name,regclass)
|
||||
timescaledb_experimental.alter_policies(regclass,boolean,"any","any","any","any")
|
||||
timescaledb_experimental.block_new_chunks(name,regclass,boolean)
|
||||
timescaledb_experimental.cleanup_copy_chunk_operation(name)
|
||||
timescaledb_experimental.copy_chunk(regclass,name,name,name)
|
||||
timescaledb_experimental.move_chunk(regclass,name,name,name)
|
||||
timescaledb_experimental.remove_all_policies(regclass,boolean)
|
||||
timescaledb_experimental.remove_policies(regclass,boolean,text[])
|
||||
timescaledb_experimental.show_policies(regclass)
|
||||
timescaledb_experimental.subscription_exec(text)
|
||||
timescaledb_experimental.time_bucket_ng(interval,date)
|
||||
timescaledb_experimental.time_bucket_ng(interval,date,date)
|
||||
timescaledb_experimental.time_bucket_ng(interval,timestamp with time zone)
|
||||
|
@ -24,10 +24,6 @@ SELECT _timescaledb_internal.compressed_chunk_remote_stats(NULL,NULL);
|
||||
SELECT _timescaledb_internal.create_chunk(0,NULL,NULL,NULL,0);
|
||||
SELECT _timescaledb_internal.create_chunk_table(0,NULL,NULL,NULL);
|
||||
SELECT _timescaledb_internal.create_compressed_chunk(0,0,0,0,0,0,0,0,0,0);
|
||||
SELECT _timescaledb_internal.data_node_chunk_info(NULL,NULL,NULL);
|
||||
SELECT _timescaledb_internal.data_node_compressed_chunk_stats(NULL,NULL,NULL);
|
||||
SELECT _timescaledb_internal.data_node_hypertable_info(NULL,NULL,NULL);
|
||||
SELECT _timescaledb_internal.data_node_index_size(NULL,NULL,NULL);
|
||||
SELECT _timescaledb_internal.drop_chunk(0);
|
||||
SELECT _timescaledb_internal.drop_dist_ht_invalidation_trigger(0);
|
||||
SELECT _timescaledb_internal.freeze_chunk(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user