Skip to content

Commit

Permalink
PG16: Remove support of Multi-Node
Browse files Browse the repository at this point in the history
Since multi-node has being deprecated we'll not support it on PG16. In
the following releases we're working on completely remove it from the
TimescaleDB.
  • Loading branch information
fabriziomello committed Oct 12, 2023
1 parent ecd88f8 commit 52a0e99
Show file tree
Hide file tree
Showing 39 changed files with 10,381 additions and 12,564 deletions.
32 changes: 32 additions & 0 deletions sql/updates/pre-update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,35 @@ WHERE
)
;

-- ERROR if trying to update the extension on PG16 using Multi-Node
DO $$
DECLARE
data_nodes TEXT;
dist_hypertables TEXT;
BEGIN
IF current_setting('server_version_num')::int >= 160000 THEN
SELECT string_agg(format('%I.%I', hypertable_schema, hypertable_name), ', ')
INTO dist_hypertables
FROM timescaledb_information.hypertables
WHERE is_distributed IS TRUE;

IF dist_hypertables IS NOT NULL THEN
RAISE USING
ERRCODE = 'feature_not_supported',
MESSAGE = 'cannot upgrade because multi-node is not supported on PostgreSQL >= 16',
DETAIL = 'The following distributed hypertables should be migrated to regular: '||dist_hypertables;
END IF;

SELECT string_agg(format('%I', node_name), ', ')
INTO data_nodes
FROM timescaledb_information.data_nodes;

IF data_nodes IS NOT NULL THEN
RAISE USING
ERRCODE = 'feature_not_supported',
MESSAGE = 'cannot upgrade because multi-node is not supported on PostgreSQL >= 16',
DETAIL = 'The following data nodes should be removed: '||data_nodes;
END IF;
END IF;
END $$;

8 changes: 8 additions & 0 deletions src/hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "debug_assert.h"
#include "osm_callbacks.h"
#include "error_utils.h"
#include "compat/compat.h"

Oid
ts_rel_get_owner(Oid relid)
Expand Down Expand Up @@ -2046,6 +2047,13 @@ ts_hypertable_create(PG_FUNCTION_ARGS)
Datum
ts_hypertable_distributed_create(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("distributed hypertable is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16."),
errdetail("Use the \"create_hypertable\" to create a regular hypertable instead.")));
#endif
return ts_hypertable_create_time_prev(fcinfo, true);
}

Expand Down
40 changes: 40 additions & 0 deletions tsl/src/data_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,18 +857,37 @@ data_node_add_internal(PG_FUNCTION_ARGS, bool set_distid)
Datum
data_node_add(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("adding data node is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif
return data_node_add_internal(fcinfo, true);
}

Datum
data_node_add_without_dist_id(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("adding data node is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif
return data_node_add_internal(fcinfo, false);
}

Datum
data_node_attach(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("attaching data node is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif

const char *node_name = PG_ARGISNULL(0) ? NULL : PG_GETARG_CSTRING(0);
Oid table_id = PG_GETARG_OID(1);
bool if_not_attached = PG_ARGISNULL(2) ? false : PG_GETARG_BOOL(2);
Expand Down Expand Up @@ -1404,6 +1423,13 @@ data_node_block_new_chunks(PG_FUNCTION_ARGS)
Datum
data_node_detach(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("detaching data node is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif

const char *node_name = PG_ARGISNULL(0) ? NULL : NameStr(*PG_GETARG_NAME(0));
Oid table_id = PG_ARGISNULL(1) ? InvalidOid : PG_GETARG_OID(1);
bool all_hypertables = PG_ARGISNULL(1);
Expand Down Expand Up @@ -1601,6 +1627,13 @@ append_data_node_option(List *new_options, List **current_options, const char *n
Datum
data_node_alter(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("alter data node is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif

const char *node_name = PG_ARGISNULL(0) ? NULL : NameStr(*PG_GETARG_NAME(0));
const char *host = PG_ARGISNULL(1) ? NULL : TextDatumGetCString(PG_GETARG_DATUM(1));
const char *database = PG_ARGISNULL(2) ? NULL : NameStr(*PG_GETARG_NAME(2));
Expand Down Expand Up @@ -1826,6 +1859,13 @@ drop_data_node_database(const ForeignServer *server)
Datum
data_node_delete(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("deleting data node is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif

const char *node_name = PG_ARGISNULL(0) ? NULL : PG_GETARG_CSTRING(0);
bool if_exists = PG_ARGISNULL(1) ? false : PG_GETARG_BOOL(1);
bool force = PG_ARGISNULL(2) ? false : PG_GETARG_BOOL(2);
Expand Down
7 changes: 7 additions & 0 deletions tsl/src/dist_backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ create_restore_point_datum(TupleDesc tupdesc, const char *node_name, XLogRecPtr
Datum
create_distributed_restore_point(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("creating distributed restore point is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif

const char *name = TextDatumGetCString(PG_GETARG_DATUM(0));
DistCmdResult *result_cmd;
FuncCallContext *funcctx;
Expand Down
7 changes: 7 additions & 0 deletions tsl/src/remote/dist_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ ts_dist_cmd_close_prepared_command(PreparedDistCmd *command)
Datum
ts_dist_cmd_exec(PG_FUNCTION_ARGS)
{
#if PG16_GE
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("distributed command execution is not supported"),
errhint("Multi-node is not supported anymore on PostgreSQL >= 16.")));
#endif

const char *query = PG_ARGISNULL(0) ? NULL : TextDatumGetCString(PG_GETARG_DATUM(0));
ArrayType *data_nodes = PG_ARGISNULL(1) ? NULL : PG_GETARG_ARRAYTYPE_P(1);
bool transactional = PG_ARGISNULL(2) ? true : PG_GETARG_BOOL(2);
Expand Down
Loading

0 comments on commit 52a0e99

Please sign in to comment.