mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-15 01:53:41 +08:00
Remove dblink dependency.
The dblink extension is blacklisted by some cloud-hosting providers and is an unnecessary dependency for single-node operation. Since we don't plan to use dblink to implement clustering this PR removes the dependency.
This commit is contained in:
parent
6142d94d41
commit
a78f1570ba
@ -10,10 +10,9 @@ RUN apt-get update && apt-get install -y \
|
||||
postgresql-server-dev-$PG_MAJOR \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir -p /build/{src/deps,test/results}
|
||||
RUN mkdir -p /build/{src,test/results}
|
||||
COPY sql /build/sql
|
||||
COPY src/*.c src/*.h build/src/
|
||||
COPY src/deps/*.h build/src/deps/
|
||||
COPY test/expected /build/test/
|
||||
COPY test/sql /build/test/
|
||||
COPY test/runner.sh /build/test/runner.sh
|
||||
|
4
Makefile
4
Makefile
@ -34,8 +34,7 @@ SRCS = \
|
||||
src/insert.c \
|
||||
src/planner.c \
|
||||
src/process_utility.c \
|
||||
src/sort_transform.c \
|
||||
src/xact.c
|
||||
src/sort_transform.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
DEPS = $(SRCS:.c=.d)
|
||||
@ -57,7 +56,6 @@ REGRESS_OPTS = \
|
||||
--port=$(TEST_PGPORT) \
|
||||
--user=$(TEST_PGUSER) \
|
||||
--load-language=plpgsql \
|
||||
--load-extension=dblink \
|
||||
--load-extension=postgres_fdw \
|
||||
--load-extension=$(EXTENSION)
|
||||
|
||||
|
37
NOTICE
37
NOTICE
@ -222,40 +222,3 @@ TimescaleDB (TM)
|
||||
limitations under the License.
|
||||
|
||||
|
||||
========================================================================
|
||||
dblink headers (src/deps/)
|
||||
========================================================================
|
||||
|
||||
/*
|
||||
* dblink.h
|
||||
*
|
||||
* Functions returning results from a remote database
|
||||
*
|
||||
* Joe Conway <mail@joeconway.com>
|
||||
* And contributors:
|
||||
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
||||
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
||||
*
|
||||
* contrib/dblink/dblink.h
|
||||
* Copyright (c) 2001-2016, PostgreSQL Global Development Group
|
||||
* ALL RIGHTS RESERVED;
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose, without fee, and without a written agreement
|
||||
* is hereby granted, provided that the above copyright notice and this
|
||||
* paragraph and the following two paragraphs appear in all copies.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
|
||||
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
* DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
* ON AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAS NO OBLIGATIONS TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -53,7 +53,7 @@ necessary libraries:
|
||||
```bash
|
||||
# Modify postgresql.conf to uncomment this line and add required libraries.
|
||||
# For example:
|
||||
shared_preload_libraries = 'dblink,timescaledb'
|
||||
shared_preload_libraries = 'timescaledb'
|
||||
```
|
||||
|
||||
To get started you'll now need to restart PostgreSQL and add a
|
||||
@ -100,7 +100,7 @@ necessary libraries, and then restart PostgreSQL:
|
||||
```bash
|
||||
# Modify postgresql.conf to uncomment this line and add required libraries.
|
||||
# For example:
|
||||
shared_preload_libraries = 'dblink,timescaledb'
|
||||
shared_preload_libraries = 'timescaledb'
|
||||
|
||||
# Then, restart PostgreSQL
|
||||
```
|
||||
|
@ -24,7 +24,7 @@ docker run -d \
|
||||
$IMAGE_NAME $BIN_CMD \
|
||||
-csynchronous_commit=off -cwal_writer_delay=1000 \
|
||||
-cmax_locks_per_transaction=1000 \
|
||||
-cshared_preload_libraries=pg_stat_statements,dblink,timescaledb \
|
||||
-cshared_preload_libraries=pg_stat_statements,timescaledb \
|
||||
-cvacuum_cost_delay=20 -cautovacuum_max_workers=1 \
|
||||
-clog_autovacuum_min_duration=1000 -cshared_buffers=1GB \
|
||||
-ceffective_cache_size=3GB -cwork_mem=52428kB \
|
||||
|
@ -35,3 +35,12 @@ BEGIN
|
||||
PERFORM _timescaledb_internal.on_trigger_error(TG_OP, TG_TABLE_SCHEMA, TG_TABLE_NAME);
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.clustering_not_supported()
|
||||
RETURNS VOID LANGUAGE PLPGSQL AS
|
||||
$BODY$
|
||||
BEGIN
|
||||
RAISE EXCEPTION 'Clustering not supported'
|
||||
USING ERRCODE = 'IO101';
|
||||
END
|
||||
$BODY$;
|
||||
|
@ -259,8 +259,7 @@ BEGIN
|
||||
IF meta_database = current_database() THEN
|
||||
EXECUTE sql_stmt;
|
||||
ELSE
|
||||
PERFORM * FROM dblink(format('host=%s port=%s dbname=%s user=%s password=%s',
|
||||
meta_hostname, meta_port, meta_database, username, password), sql_stmt) AS r(t TEXT);
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
END IF;
|
||||
END
|
||||
$BODY$;
|
||||
|
@ -1,12 +1,8 @@
|
||||
--This file provides a utility for executing dblink commands transactionally (almost) with the local transaction.
|
||||
--This file provides a utility for executing remote commands transactionally (almost) with the local transaction.
|
||||
--Most command executed by the *_exec functions will be committed only when the local transaction commits.
|
||||
|
||||
--Registers a dblink connection to be commited on local pre-commit or aborted on local abort.
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.register_dblink_precommit_connection(text) RETURNS VOID
|
||||
AS '$libdir/timescaledb', 'register_dblink_precommit_connection' LANGUAGE C VOLATILE STRICT;
|
||||
|
||||
--Called by _timescaledb_internal.meta_transaction_exec to start a transaction. Should not be called directly.
|
||||
--Returns the dblink connection name for the started transaction.
|
||||
--Returns the connection name for the started transaction.
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.meta_transaction_start()
|
||||
RETURNS TEXT LANGUAGE PLPGSQL VOLATILE AS
|
||||
$BODY$
|
||||
@ -14,17 +10,7 @@ DECLARE
|
||||
conn_exists BOOLEAN;
|
||||
conn_name TEXT = 'meta_conn';
|
||||
BEGIN
|
||||
SELECT conn_name = ANY (conn) INTO conn_exists
|
||||
FROM dblink_get_connections() conn;
|
||||
|
||||
IF conn_exists IS NULL OR NOT conn_exists THEN
|
||||
--tells c code to commit in precommit.
|
||||
PERFORM dblink_connect(conn_name, _timescaledb_internal.get_meta_server_name());
|
||||
PERFORM dblink_exec(conn_name, 'BEGIN');
|
||||
PERFORM _timescaledb_internal.register_dblink_precommit_connection(conn_name);
|
||||
END IF;
|
||||
|
||||
RETURN conn_name;
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
@ -40,8 +26,7 @@ DECLARE
|
||||
conn_name TEXT;
|
||||
BEGIN
|
||||
IF _timescaledb_internal.get_meta_database_name() <> current_database() THEN
|
||||
SELECT _timescaledb_internal.meta_transaction_start() INTO conn_name;
|
||||
PERFORM * FROM dblink(conn_name, sql_code) AS t(r TEXT);
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
ELSE
|
||||
EXECUTE sql_code;
|
||||
END IF;
|
||||
@ -61,8 +46,7 @@ DECLARE
|
||||
return_value TEXT;
|
||||
BEGIN
|
||||
IF _timescaledb_internal.get_meta_database_name() <> current_database() THEN
|
||||
SELECT _timescaledb_internal.meta_transaction_start() INTO conn_name;
|
||||
SELECT t.r INTO return_value FROM dblink(conn_name, sql_code) AS t(r TEXT);
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
ELSE
|
||||
EXECUTE sql_code INTO return_value;
|
||||
END IF;
|
||||
@ -83,8 +67,7 @@ DECLARE
|
||||
return_value TEXT;
|
||||
BEGIN
|
||||
IF _timescaledb_internal.get_meta_database_name() <> current_database() THEN
|
||||
SELECT t.r INTO return_value
|
||||
FROM dblink(_timescaledb_internal.get_meta_server_name(), sql_code) AS t(r TEXT);
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
ELSE
|
||||
EXECUTE sql_code INTO return_value;
|
||||
END IF;
|
||||
@ -93,7 +76,7 @@ END
|
||||
$BODY$;
|
||||
|
||||
--Called by _timescaledb_meta.node_transaction_exec_with_return to start a transaction. Should not be called directly.
|
||||
--Returns the dblink connection name for the started transaction.
|
||||
--Returns the connection name for the started transaction.
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_meta.node_transaction_start(database_name NAME, server_name NAME)
|
||||
RETURNS TEXT LANGUAGE PLPGSQL VOLATILE AS
|
||||
$BODY$
|
||||
@ -105,19 +88,7 @@ BEGIN
|
||||
RETURN NULL;
|
||||
END IF;
|
||||
|
||||
conn_name = 'conn_'|| server_name;
|
||||
|
||||
SELECT conn_name = ANY (conn) INTO conn_exists
|
||||
FROM dblink_get_connections() conn;
|
||||
|
||||
IF conn_exists IS NULL OR NOT conn_exists THEN
|
||||
--tells c code to commit in precommit.
|
||||
PERFORM dblink_connect(conn_name, server_name);
|
||||
PERFORM dblink_exec(conn_name, 'BEGIN');
|
||||
PERFORM _timescaledb_internal.register_dblink_precommit_connection(conn_name);
|
||||
END IF;
|
||||
|
||||
RETURN conn_name;
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
END
|
||||
$BODY$;
|
||||
|
||||
@ -138,7 +109,7 @@ BEGIN
|
||||
SELECT _timescaledb_meta.node_transaction_start(database_name, server_name) INTO conn_name;
|
||||
|
||||
IF conn_name IS NOT NULL THEN
|
||||
SELECT t.r INTO return_value FROM dblink(conn_name, sql_code) AS t(r TEXT);
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
ELSE
|
||||
EXECUTE sql_code INTO return_value;
|
||||
END IF;
|
||||
@ -160,7 +131,7 @@ DECLARE
|
||||
return_value TEXT;
|
||||
BEGIN
|
||||
IF database_name <> current_database() THEN
|
||||
SELECT t.r INTO return_value FROM dblink(server_name, sql_code) AS t(r TEXT);
|
||||
PERFORM _timescaledb_internal.clustering_not_supported();
|
||||
ELSE
|
||||
EXECUTE sql_code INTO return_value;
|
||||
END IF;
|
||||
|
@ -21,7 +21,7 @@ BEGIN
|
||||
LIMIT 1;
|
||||
|
||||
IF node_row IS NULL THEN
|
||||
PERFORM _timescaledb_internal.setup_main_immmediate(node_database, username, password);
|
||||
--PERFORM _timescaledb_internal.setup_main_immmediate(node_database, username, password);
|
||||
PERFORM _timescaledb_meta_api.join_cluster(meta_database, meta_hostname, meta_port,
|
||||
node_database, node_hostname, node_port,
|
||||
username, password);
|
||||
|
@ -144,14 +144,4 @@ $BODY$
|
||||
SET client_min_messages = WARNING --supress notices for trigger drops
|
||||
;
|
||||
|
||||
-- Run setup_main() above with immediate effect by calling through dblink().
|
||||
CREATE OR REPLACE FUNCTION _timescaledb_internal.setup_main_immmediate(
|
||||
database NAME,
|
||||
username TEXT,
|
||||
password TEXT
|
||||
)
|
||||
RETURNS TEXT LANGUAGE SQL AS
|
||||
$BODY$
|
||||
SELECT * FROM dblink(format('dbname=%s user=%s password=%s', database, username, password),
|
||||
'SELECT _timescaledb_internal.setup_main()') AS r(t TEXT);
|
||||
$BODY$;
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
-- Can't load extensions from extension
|
||||
-- \ir ../../common/extensions.sql
|
||||
CREATE EXTENSION IF NOT EXISTS dblink;
|
||||
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
|
||||
|
||||
\ir ../../common/types.sql
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* dblink.h
|
||||
*
|
||||
* Functions returning results from a remote database
|
||||
*
|
||||
* Joe Conway <mail@joeconway.com>
|
||||
* And contributors:
|
||||
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
||||
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
||||
*
|
||||
* contrib/dblink/dblink.h
|
||||
* Copyright (c) 2001-2016, PostgreSQL Global Development Group
|
||||
* ALL RIGHTS RESERVED;
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose, without fee, and without a written agreement
|
||||
* is hereby granted, provided that the above copyright notice and this
|
||||
* paragraph and the following two paragraphs appear in all copies.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
|
||||
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||
* DOCUMENTATION, EVEN IF THE AUTHOR OR DISTRIBUTORS HAVE BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* THE AUTHOR AND DISTRIBUTORS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
* ON AN "AS IS" BASIS, AND THE AUTHOR AND DISTRIBUTORS HAS NO OBLIGATIONS TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DBLINK_H
|
||||
#define DBLINK_H
|
||||
|
||||
#include "fmgr.h"
|
||||
|
||||
/*
|
||||
* External declarations
|
||||
*/
|
||||
extern Datum dblink_connect(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_disconnect(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_open(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_close(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_fetch(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_record(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_send_query(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_get_result(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_get_connections(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_is_busy(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_cancel_query(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_error_message(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_exec(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_get_pkey(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_build_sql_insert(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_build_sql_delete(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_build_sql_update(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_current_query(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_get_notify(PG_FUNCTION_ARGS);
|
||||
extern Datum dblink_fdw_validator(PG_FUNCTION_ARGS);
|
||||
|
||||
#endif /* DBLINK_H */
|
@ -29,9 +29,6 @@ extern void _planner_fini(void);
|
||||
extern void _process_utility_init(void);
|
||||
extern void _process_utility_fini(void);
|
||||
|
||||
extern void _xact_init(void);
|
||||
extern void _xact_fini(void);
|
||||
|
||||
extern void _PG_init(void);
|
||||
extern void _PG_fini(void);
|
||||
|
||||
@ -44,13 +41,11 @@ _PG_init(void)
|
||||
_cache_invalidate_init();
|
||||
_planner_init();
|
||||
_process_utility_init();
|
||||
_xact_init();
|
||||
}
|
||||
|
||||
void
|
||||
_PG_fini(void)
|
||||
{
|
||||
_xact_fini();
|
||||
_process_utility_fini();
|
||||
_planner_fini();
|
||||
_cache_invalidate_fini();
|
||||
|
107
src/xact.c
107
src/xact.c
@ -1,107 +0,0 @@
|
||||
#include <postgres.h>
|
||||
#include <fmgr.h>
|
||||
#include <utils/memutils.h>
|
||||
#include <utils/builtins.h>
|
||||
#include <access/xact.h>
|
||||
|
||||
#include "deps/dblink.h"
|
||||
|
||||
void _xact_init(void);
|
||||
void _xact_fini(void);
|
||||
|
||||
static List *callbackConnections = NIL;
|
||||
|
||||
Datum register_dblink_precommit_connection(PG_FUNCTION_ARGS);
|
||||
|
||||
/* Function to register dblink connections for remote commit/abort on local pre-commit/abort. */
|
||||
PG_FUNCTION_INFO_V1(register_dblink_precommit_connection);
|
||||
Datum
|
||||
register_dblink_precommit_connection(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/*
|
||||
* allocate this stuff in top-level transaction context, so that it
|
||||
* survives till commit
|
||||
*/
|
||||
MemoryContext old = MemoryContextSwitchTo(TopTransactionContext);
|
||||
|
||||
char *connectionName = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||
|
||||
callbackConnections = lappend(callbackConnections, connectionName);
|
||||
|
||||
MemoryContextSwitchTo(old);
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/*
|
||||
* Commits dblink connections registered with register_dblink_precommit_connection.
|
||||
* Look at meta_commands.sql for example usage. Remote commits happen in pre-commit.
|
||||
* Remote aborts happen on abort.
|
||||
* */
|
||||
static void
|
||||
io_xact_callback(XactEvent event, void *arg)
|
||||
{
|
||||
ListCell *cell;
|
||||
|
||||
if (list_length(callbackConnections) == 0)
|
||||
return;
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case XACT_EVENT_PARALLEL_PRE_COMMIT:
|
||||
case XACT_EVENT_PRE_COMMIT:
|
||||
foreach(cell, callbackConnections)
|
||||
{
|
||||
char *connection = (char *) lfirst(cell);
|
||||
|
||||
DirectFunctionCall3(dblink_exec,
|
||||
PointerGetDatum(cstring_to_text(connection)),
|
||||
PointerGetDatum(cstring_to_text("COMMIT")),
|
||||
BoolGetDatum(true)); /* throw error */
|
||||
DirectFunctionCall1(dblink_disconnect, PointerGetDatum(cstring_to_text(connection)));
|
||||
}
|
||||
break;
|
||||
case XACT_EVENT_PARALLEL_ABORT:
|
||||
case XACT_EVENT_ABORT:
|
||||
|
||||
/*
|
||||
* Be quite careful here. Cannot throw any errors (or infinite
|
||||
* loop) and cannot use PG_TRY either. Make sure to test with
|
||||
* c-asserts on.
|
||||
*/
|
||||
foreach(cell, callbackConnections)
|
||||
{
|
||||
char *connection = (char *) lfirst(cell);
|
||||
|
||||
DirectFunctionCall3(dblink_exec,
|
||||
PointerGetDatum(cstring_to_text(connection)),
|
||||
PointerGetDatum(cstring_to_text("ABORT")),
|
||||
BoolGetDatum(false));
|
||||
DirectFunctionCall1(dblink_disconnect, PointerGetDatum(cstring_to_text(connection)));
|
||||
}
|
||||
break;
|
||||
case XACT_EVENT_PRE_PREPARE:
|
||||
case XACT_EVENT_PREPARE:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot prepare a transaction that has open dblink constraint_exclusion_options")));
|
||||
break;
|
||||
case XACT_EVENT_PARALLEL_COMMIT:
|
||||
case XACT_EVENT_COMMIT:
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unkown xact event: %d", event);
|
||||
}
|
||||
callbackConnections = NIL;
|
||||
}
|
||||
|
||||
void
|
||||
_xact_init(void)
|
||||
{
|
||||
RegisterXactCallback(io_xact_callback, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_xact_fini(void)
|
||||
{
|
||||
UnregisterXactCallback(io_xact_callback, NULL);
|
||||
}
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
|
@ -5,7 +5,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
|
@ -5,7 +5,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -7,7 +7,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\c single
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -7,7 +7,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\c single
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
|
@ -7,7 +7,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\c single
|
||||
|
@ -7,7 +7,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\c single
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
|
@ -1,14 +1,14 @@
|
||||
--make sure diff only has explain output not result output
|
||||
\! diff ../results/sql_query_results_optimized.out ../results/sql_query_results_unoptimized.out
|
||||
12a13
|
||||
11a12
|
||||
> SET timescaledb.disable_optimizations= 'true';
|
||||
55,56c56,57
|
||||
54,55c55,56
|
||||
< QUERY PLAN
|
||||
< ------------------------------------------------------------------------------------------------------
|
||||
---
|
||||
> QUERY PLAN
|
||||
> --------------------------------------------------------------------------------
|
||||
58,64c59,64
|
||||
57,63c58,63
|
||||
< -> GroupAggregate
|
||||
< Group Key: (date_trunc('minute'::text, _hyper_1_0_replica."time"))
|
||||
< -> Result
|
||||
@ -23,10 +23,10 @@
|
||||
> Group Key: date_trunc('minute'::text, _hyper_1_0_replica."time")
|
||||
> -> Result
|
||||
> -> Append
|
||||
66,67d65
|
||||
65,66d64
|
||||
< -> Sort
|
||||
< Sort Key: (date_trunc('minute'::text, _hyper_1_1_0_partition."time")) DESC
|
||||
69,71c67,69
|
||||
68,70c66,68
|
||||
< -> Index Scan using "1-time_plain" on _hyper_1_1_0_1_data
|
||||
< -> Index Scan using "2-time_plain" on _hyper_1_1_0_2_data
|
||||
< (14 rows)
|
||||
@ -34,7 +34,7 @@
|
||||
> -> Seq Scan on _hyper_1_1_0_1_data
|
||||
> -> Seq Scan on _hyper_1_1_0_2_data
|
||||
> (11 rows)
|
||||
99,105c97,102
|
||||
98,104c96,101
|
||||
< -> GroupAggregate
|
||||
< Group Key: (date_trunc('minute'::text, _hyper_1_0_replica."time"))
|
||||
< -> Result
|
||||
@ -49,10 +49,10 @@
|
||||
> Group Key: date_trunc('minute'::text, _hyper_1_0_replica."time")
|
||||
> -> Result
|
||||
> -> Append
|
||||
108,109d104
|
||||
107,108d103
|
||||
< -> Sort
|
||||
< Sort Key: (date_trunc('minute'::text, _hyper_1_1_0_partition."time")) DESC
|
||||
112,116c107,111
|
||||
111,115c106,110
|
||||
< -> Index Scan using "1-time_plain" on _hyper_1_1_0_1_data
|
||||
< Index Cond: ("time" < 'Wed Dec 31 16:15:00 1969 PST'::timestamp with time zone)
|
||||
< -> Index Scan using "2-time_plain" on _hyper_1_1_0_2_data
|
||||
|
@ -5,7 +5,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
setup_timescaledb
|
||||
|
@ -6,7 +6,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\o
|
||||
@ -83,14 +82,8 @@ FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
|
||||
\echo 'The rest of the queries will be the same in output between UTC and EST'
|
||||
The rest of the queries will be the same in output between UTC and EST
|
||||
--have to set the timezones on both Test1 and test2. Have to also kill ongoing dblinks as their sessions cache the timezone setting.
|
||||
SET timezone = 'UTC';
|
||||
ALTER DATABASE single SET timezone ='UTC';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
time | sum
|
||||
@ -101,11 +94,6 @@ FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
|
||||
SET timezone = 'EST';
|
||||
ALTER DATABASE single SET timezone ='EST';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
time | sum
|
||||
@ -116,11 +104,6 @@ FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
|
||||
SET timezone = 'UTC';
|
||||
ALTER DATABASE single SET timezone ='UTC';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT *
|
||||
FROM PUBLIC."testNs"
|
||||
WHERE "timeCustom" >= TIMESTAMP '2009-11-10T23:00:00'
|
||||
@ -134,11 +117,6 @@ AND "timeCustom" < TIMESTAMP '2009-11-12T01:00:00' ORDER BY "timeCustom" DESC;
|
||||
|
||||
SET timezone = 'EST';
|
||||
ALTER DATABASE single SET timezone ='EST';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT *
|
||||
FROM PUBLIC."testNs"
|
||||
WHERE "timeCustom" >= TIMESTAMP '2009-11-10T23:00:00'
|
||||
@ -152,11 +130,6 @@ AND "timeCustom" < TIMESTAMP '2009-11-12T01:00:00' ORDER BY "timeCustom" DESC;
|
||||
|
||||
SET timezone = 'UTC';
|
||||
ALTER DATABASE single SET timezone ='UTC';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC LIMIT 2;
|
||||
time | sum
|
||||
@ -167,11 +140,6 @@ FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC LIMIT 2;
|
||||
|
||||
SET timezone = 'EST';
|
||||
ALTER DATABASE single SET timezone ='EST';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
dblink_disconnect
|
||||
-------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC LIMIT 2;
|
||||
time | sum
|
||||
|
@ -7,7 +7,6 @@ SET client_min_messages = NOTICE;
|
||||
CREATE DATABASE single;
|
||||
\c single
|
||||
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "dblink"
|
||||
psql:include/create_single_db.sql:7: NOTICE: installing required extension "postgres_fdw"
|
||||
SELECT setup_timescaledb(hostname => 'fakehost'); -- fakehost makes sure there is no network connection
|
||||
\c single
|
||||
|
@ -54,22 +54,18 @@ SELECT date_group("timeCustom", '100 days') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
|
||||
\echo 'The rest of the queries will be the same in output between UTC and EST'
|
||||
--have to set the timezones on both Test1 and test2. Have to also kill ongoing dblinks as their sessions cache the timezone setting.
|
||||
SET timezone = 'UTC';
|
||||
ALTER DATABASE single SET timezone ='UTC';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
|
||||
SET timezone = 'EST';
|
||||
ALTER DATABASE single SET timezone ='EST';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC;
|
||||
|
||||
SET timezone = 'UTC';
|
||||
ALTER DATABASE single SET timezone ='UTC';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
|
||||
SELECT *
|
||||
FROM PUBLIC."testNs"
|
||||
@ -78,7 +74,6 @@ AND "timeCustom" < TIMESTAMP '2009-11-12T01:00:00' ORDER BY "timeCustom" DESC;
|
||||
|
||||
SET timezone = 'EST';
|
||||
ALTER DATABASE single SET timezone ='EST';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
SELECT *
|
||||
FROM PUBLIC."testNs"
|
||||
WHERE "timeCustom" >= TIMESTAMP '2009-11-10T23:00:00'
|
||||
@ -86,13 +81,11 @@ AND "timeCustom" < TIMESTAMP '2009-11-12T01:00:00' ORDER BY "timeCustom" DESC;
|
||||
|
||||
SET timezone = 'UTC';
|
||||
ALTER DATABASE single SET timezone ='UTC';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC LIMIT 2;
|
||||
|
||||
SET timezone = 'EST';
|
||||
ALTER DATABASE single SET timezone ='EST';
|
||||
SELECT dblink_disconnect(conn) FROM unnest(dblink_get_connections()) conn;
|
||||
SELECT date_group("timeCustom", '1 day') AS time, sum(series_0)
|
||||
FROM PUBLIC."testNs" GROUP BY time ORDER BY time ASC LIMIT 2;
|
||||
|
||||
|
@ -2,5 +2,5 @@
|
||||
comment = 'Enables scalable inserts and complex queries for time-series data'
|
||||
default_version = '0.0.7-beta'
|
||||
module_pathname = '$libdir/timescaledb'
|
||||
requires = 'dblink, postgres_fdw'
|
||||
requires = 'postgres_fdw'
|
||||
relocatable = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user