timescaledb/sql/updates/latest-dev.sql
Brian Rowe 79fb46456f Rename server to data node
The timescale clustering code so far has been written referring to the
remote databases as 'servers'.  This terminology is a bit overloaded,
and in particular we don't enforce any network topology limitations
that the term 'server' would suggest.  In light of this we've decided
to change to use the term 'node' when referring to the different
databases in a distributed database.  Specifically we refer to the
frontend as an 'access node' and to the backends as 'data nodes',
though we may omit the access or data qualifier where it's unambiguous.

As the vast bulk of the code so far has been written for the case where
there was a single access node, almost all instances of 'server' were
references to data nodes.  This change has updated the code to rename
those instances.
2020-05-27 17:31:09 +02:00

57 lines
2.5 KiB
SQL

-- Add new function definitions, columns and tables for distributed hypertables
DROP FUNCTION IF EXISTS create_hypertable(regclass,name,name,integer,name,name,anyelement,boolean,boolean,regproc,boolean,text,regproc,regproc);
ALTER TABLE _timescaledb_catalog.hypertable ADD COLUMN replication_factor SMALLINT NULL CHECK (replication_factor > 0);
-- Table for hypertable -> node mappings
CREATE TABLE IF NOT EXISTS _timescaledb_catalog.hypertable_data_node (
hypertable_id INTEGER NOT NULL REFERENCES _timescaledb_catalog.hypertable(id),
node_hypertable_id INTEGER NULL,
node_name NAME NOT NULL,
block_chunks BOOLEAN NOT NULL,
UNIQUE(node_hypertable_id, node_name),
UNIQUE(hypertable_id, node_name)
);
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.hypertable_data_node', '');
GRANT SELECT ON _timescaledb_catalog.hypertable_data_node TO PUBLIC;
-- Table for chunk -> nodes mappings
CREATE TABLE IF NOT EXISTS _timescaledb_catalog.chunk_data_node (
chunk_id INTEGER NOT NULL REFERENCES _timescaledb_catalog.chunk(id),
node_chunk_id INTEGER NOT NULL,
node_name NAME NOT NULL,
UNIQUE(node_chunk_id, node_name),
UNIQUE(chunk_id, node_name)
);
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.chunk_data_node', '');
GRANT SELECT ON _timescaledb_catalog.chunk_data_node TO PUBLIC;
--placeholder to allow creation of functions below
CREATE TYPE rxid;
CREATE OR REPLACE FUNCTION _timescaledb_internal.rxid_in(cstring) RETURNS rxid
AS '@MODULE_PATHNAME@', 'ts_remote_txn_id_in' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE OR REPLACE FUNCTION _timescaledb_internal.rxid_out(rxid) RETURNS cstring
AS '@MODULE_PATHNAME@', 'ts_remote_txn_id_out' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
CREATE TYPE rxid (
internallength = 16,
input = _timescaledb_internal.rxid_in,
output = _timescaledb_internal.rxid_out
);
CREATE TABLE _timescaledb_catalog.remote_txn (
data_node_name NAME, --this is really only to allow us to cleanup stuff on a per-node basis.
remote_transaction_id TEXT CHECK (remote_transaction_id::rxid is not null),
PRIMARY KEY (remote_transaction_id)
);
CREATE INDEX IF NOT EXISTS remote_txn_data_node_name_idx
ON _timescaledb_catalog.remote_txn(data_node_name);
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.remote_txn', '');
GRANT SELECT ON _timescaledb_catalog.remote_txn TO PUBLIC;