Skip to content

Commit

Permalink
Remove the timescaledb_fdw foreign data wrapper
Browse files Browse the repository at this point in the history
This is the fdw implementation that was used for communication
between multinode instances.
  • Loading branch information
svenklemm committed Dec 13, 2023
1 parent 4e17247 commit c914d19
Show file tree
Hide file tree
Showing 47 changed files with 17 additions and 11,561 deletions.
6 changes: 2 additions & 4 deletions cmake/ScriptFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ set(PRE_INSTALL_SOURCE_FILES
pre_install/types.post.sql # Must be before tables.sql
pre_install/tables.sql
pre_install/cache.sql
pre_install/insert_data.sql
pre_install/fdw_functions.sql
pre_install/timescaledb_fdw.sql)
pre_install/insert_data.sql)

# Source files that define functions and need to be rerun in update
set(PRE_INSTALL_FUNCTION_FILES
pre_install/types.functions.sql
pre_install/fdw_functions.sql)
)

# The rest of the source files defining mostly functions
set(SOURCE_FILES
Expand Down
14 changes: 0 additions & 14 deletions sql/pre_install/fdw_functions.sql

This file was deleted.

7 changes: 0 additions & 7 deletions sql/pre_install/timescaledb_fdw.sql

This file was deleted.

4 changes: 4 additions & 0 deletions sql/updates/latest-dev.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ ALTER EXTENSION timescaledb DROP TABLE _timescaledb_catalog.hypertable_compressi
DROP VIEW IF EXISTS timescaledb_information.compression_settings;
DROP TABLE _timescaledb_catalog.hypertable_compression;

DROP FOREIGN DATA WRAPPER IF EXISTS timescaledb_fdw;
DROP FUNCTION IF EXISTS @[email protected]_fdw_handler();
DROP FUNCTION IF EXISTS @[email protected]_fdw_validator(text[], oid);

6 changes: 6 additions & 0 deletions sql/updates/reverse-dev.sql
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ GRANT SELECT ON _timescaledb_catalog.hypertable_compression TO PUBLIC;
DROP VIEW timescaledb_information.compression_settings;
ALTER EXTENSION timescaledb DROP TABLE _timescaledb_catalog.compression_settings;
DROP TABLE _timescaledb_catalog.compression_settings;

CREATE FUNCTION @[email protected]_fdw_handler() RETURNS fdw_handler AS '@MODULE_PATHNAME@', 'ts_timescaledb_fdw_handler' LANGUAGE C STRICT;
CREATE FUNCTION @[email protected]_fdw_validator(text[], oid) RETURNS void AS '@MODULE_PATHNAME@', 'ts_timescaledb_fdw_validator' LANGUAGE C STRICT;

CREATE FOREIGN DATA WRAPPER timescaledb_fdw HANDLER @[email protected]_fdw_handler VALIDATOR @[email protected]_fdw_validator;

111 changes: 0 additions & 111 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
#include <catalog/pg_class_d.h>
#include <postgres.h>
#include <foreign/foreign.h>
#include <nodes/parsenodes.h>
#include <nodes/nodes.h>
#include <nodes/makefuncs.h>
Expand Down Expand Up @@ -407,55 +406,6 @@ add_chunk_oid(Hypertable *ht, Oid chunk_relid, void *vargs)
}
}

static bool
block_on_foreign_server(const char *const server_name)
{
const ForeignServer *server;

Assert(server_name != NULL);
server = GetForeignServerByName(server_name, true);
if (NULL != server)
{
Oid ts_fdwid = get_foreign_data_wrapper_oid(EXTENSION_FDW_NAME, false);
if (server->fdwid == ts_fdwid)
return true;
}
return false;
}

static DDLResult
process_create_foreign_server_start(ProcessUtilityArgs *args)
{
CreateForeignServerStmt *stmt = (CreateForeignServerStmt *) args->parsetree;

if (strcmp(EXTENSION_FDW_NAME, stmt->fdwname) == 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("operation not supported for a TimescaleDB data node"),
errhint("Use add_data_node() to add data nodes to a "
"distributed database.")));

return DDL_CONTINUE;
}

static void
process_drop_foreign_server_start(DropStmt *stmt)
{
ListCell *lc;

foreach (lc, stmt->objects)
{
const char *servername = strVal(lfirst(lc));

if (block_on_foreign_server(servername))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("operation not supported on a TimescaleDB data node"),
errhint("Use delete_data_node() to remove data nodes from a "
"distributed database.")));
}
}

static void
process_drop_trigger_start(ProcessUtilityArgs *args, DropStmt *stmt)
{
Expand Down Expand Up @@ -492,55 +442,6 @@ process_drop_trigger_start(ProcessUtilityArgs *args, DropStmt *stmt)
ts_cache_release(hcache);
}

static DDLResult
process_create_foreign_table_start(ProcessUtilityArgs *args)
{
CreateForeignTableStmt *stmt = (CreateForeignTableStmt *) args->parsetree;

if (block_on_foreign_server(stmt->servername))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("operation not supported"),
errdetail(
"It is not possible to create stand-alone TimescaleDB foreign tables.")));

return DDL_CONTINUE;
}

static DDLResult
process_alter_foreign_server(ProcessUtilityArgs *args)
{
AlterForeignServerStmt *stmt = (AlterForeignServerStmt *) args->parsetree;
ForeignServer *server = GetForeignServerByName(stmt->servername, true);
Oid fdwid = get_foreign_data_wrapper_oid(EXTENSION_FDW_NAME, false);
ListCell *lc;

if (server != NULL && server->fdwid == fdwid)
{
if (stmt->has_version)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("version not supported"),
errdetail(
"It is not possible to set a version on the data node configuration.")));

/* Options are validated by the FDW, but we need to block available option
* since that must be handled via alter_data_node(). */
foreach (lc, stmt->options)
{
DefElem *elem = lfirst(lc);

if (strcmp(elem->defname, "available") == 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot set \"available\" using ALTER SERVER"),
errhint("Use alter_data_node() to set \"available\".")));
}
}

return DDL_CONTINUE;
}

static void
process_altertableschema(ProcessUtilityArgs *args)
{
Expand Down Expand Up @@ -1795,9 +1696,6 @@ process_drop_start(ProcessUtilityArgs *args)
case OBJECT_VIEW:
process_drop_view_start(args, stmt);
break;
case OBJECT_FOREIGN_SERVER:
process_drop_foreign_server_start(stmt);
break;
case OBJECT_TRIGGER:
process_drop_trigger_start(args, stmt);
break;
Expand Down Expand Up @@ -4217,15 +4115,6 @@ process_ddl_command_start(ProcessUtilityArgs *args)

switch (nodeTag(args->parsetree))
{
case T_CreateForeignTableStmt:
handler = process_create_foreign_table_start;
break;
case T_AlterForeignServerStmt:
handler = process_alter_foreign_server;
break;
case T_CreateForeignServerStmt:
handler = process_create_foreign_server_start;
break;
case T_AlterObjectSchemaStmt:
handler = process_alterobjectschema;
break;
Expand Down
6 changes: 0 additions & 6 deletions src/ts_catalog/continuous_agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,15 +1151,9 @@ drop_continuous_agg(FormData_continuous_agg *cadata, bool drop_user_view)
if (!raw_hypertable_has_other_caggs)
{
hypertable_invalidation_log_delete(form.raw_hypertable_id);
if (ts_cm_functions->remote_invalidation_log_delete)
ts_cm_functions->remote_invalidation_log_delete(form.raw_hypertable_id,
HypertableIsRawTable);
}

ts_materialization_invalidation_log_delete_inner(form.mat_hypertable_id);
if (ts_cm_functions->remote_invalidation_log_delete)
ts_cm_functions->remote_invalidation_log_delete(form.mat_hypertable_id,
HypertableIsMaterialization);

if (!raw_hypertable_has_other_caggs)
{
Expand Down
2 changes: 1 addition & 1 deletion test/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ cd ${EXE_DIR}/sql

# create database and install timescaledb
${PSQL} "$@" -U $TEST_ROLE_SUPERUSER -d postgres -v ECHO=none -c "CREATE DATABASE \"${TEST_DBNAME}\";"
${PSQL} "$@" -U $TEST_ROLE_SUPERUSER -d ${TEST_DBNAME} -v ECHO=none -c "SET client_min_messages=error; CREATE EXTENSION timescaledb; GRANT USAGE ON FOREIGN DATA WRAPPER timescaledb_fdw TO ${TEST_ROLE_1};"
${PSQL} "$@" -U $TEST_ROLE_SUPERUSER -d ${TEST_DBNAME} -v ECHO=none -c "SET client_min_messages=error; CREATE EXTENSION timescaledb;"
${PSQL} "$@" -U $TEST_ROLE_SUPERUSER -d ${TEST_DBNAME} -v ECHO=none -v MODULE_PATHNAME="'timescaledb-${EXT_VERSION}'" -v TSL_MODULE_PATHNAME="'timescaledb-tsl-${EXT_VERSION}'" < ${TEST_SUPPORT_FILE} >/dev/null 2>&1
export TEST_DBNAME

Expand Down
1 change: 0 additions & 1 deletion tsl/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,5 @@ install(TARGETS ${TSL_LIBRARY_NAME} DESTINATION ${PG_PKGLIBDIR})
add_subdirectory(bgw_policy)
add_subdirectory(compression)
add_subdirectory(continuous_aggs)
add_subdirectory(fdw)
add_subdirectory(nodes)
add_subdirectory(remote)
1 change: 0 additions & 1 deletion tsl/src/data_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "extension.h"
#include "cache.h"
#include "chunk.h"
#include "fdw/fdw.h"
#include "remote/async.h"
#include "remote/connection.h"
#include "remote/connection_cache.h"
Expand Down
Loading

0 comments on commit c914d19

Please sign in to comment.