mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 18:43:18 +08:00
"create_distributed_hypertable" fails on the datanodes if the columns involved in the underlying non-default schema-qualified PG table are using user defined types (UDTs) from another non-standard schema. This happens because we explicitly set the namespace during the table creation on the datanode which doesn't allow us to lookup other schemas. We now unconditionally schema-qualify the UDT while sending the SQL from access node to the datanode to avoid this. Includes test case changes. Issue reported by and general fix provided by @phemmer Fixes #3543
82 lines
2.7 KiB
Perl
82 lines
2.7 KiB
Perl
# 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.
|
|
|
|
# test a simple multi node cluster creation and basic operations
|
|
use strict;
|
|
use warnings;
|
|
use AccessNode;
|
|
use DataNode;
|
|
use TestLib;
|
|
use Test::More tests => 12;
|
|
|
|
#Initialize all the multi-node instances
|
|
my $an = AccessNode->create('an');
|
|
|
|
my $dn1 = DataNode->create('dn1');
|
|
my $dn2 = DataNode->create('dn2');
|
|
|
|
$an->add_data_node($dn1);
|
|
$an->add_data_node($dn2);
|
|
|
|
#Create a distributed hypertable and insert a few rows
|
|
$an->safe_psql(
|
|
'postgres',
|
|
qq[
|
|
CREATE TABLE test(time timestamp NOT NULL, device int, temp float);
|
|
SELECT create_distributed_hypertable('test', 'time', 'device', 3);
|
|
INSERT INTO test SELECT t, (abs(timestamp_hash(t::timestamp)) % 10) + 1, 0.10 FROM generate_series('2018-03-02 1:00'::TIMESTAMPTZ, '2018-03-08 1:00', '1 hour') t;
|
|
]);
|
|
|
|
#Check that chunks are shown appropriately on all nodes of the multi-node setup
|
|
my $query = q[SELECT * from show_chunks('test');];
|
|
|
|
#Query Access node
|
|
$an->psql_is(
|
|
'postgres', $query, q[_timescaledb_internal._dist_hyper_1_1_chunk
|
|
_timescaledb_internal._dist_hyper_1_2_chunk
|
|
_timescaledb_internal._dist_hyper_1_3_chunk
|
|
_timescaledb_internal._dist_hyper_1_4_chunk], 'AN shows correct set of chunks'
|
|
);
|
|
|
|
#Query datanode1
|
|
$dn1->psql_is(
|
|
'postgres',
|
|
$query,
|
|
"_timescaledb_internal._dist_hyper_1_1_chunk\n_timescaledb_internal._dist_hyper_1_3_chunk\n_timescaledb_internal._dist_hyper_1_4_chunk",
|
|
'DN1 shows correct set of chunks');
|
|
|
|
#Query datanode2
|
|
$dn2->psql_is(
|
|
'postgres', $query,
|
|
"_timescaledb_internal._dist_hyper_1_2_chunk",
|
|
'DN2 shows correct set of chunks');
|
|
|
|
# Check that distributed tables in non-default schema and also containing user created types
|
|
# in another schema are created properly
|
|
$query = q[CREATE SCHEMA myschema];
|
|
$an->safe_psql('postgres', "$query; CALL distributed_exec('$query');");
|
|
$query =
|
|
q[CREATE TYPE public.full_address AS (city VARCHAR(90), street VARCHAR(90))];
|
|
$an->safe_psql('postgres', "$query; CALL distributed_exec('$query');");
|
|
|
|
# Create a table in the myschema schema using this unqualified UDT. Should work
|
|
$an->safe_psql('postgres',
|
|
"CREATE TABLE myschema.test (time timestamp, a full_address);");
|
|
|
|
# A distributed table creation followed by sample INSERT should succeed now
|
|
$an->safe_psql('postgres',
|
|
"SELECT create_distributed_hypertable('myschema.test', 'time');");
|
|
$an->safe_psql('postgres',
|
|
"INSERT INTO myschema.test VALUES ('2018-03-02 1:00', ('Kilimanjaro', 'Diamond St'));"
|
|
);
|
|
$an->psql_is(
|
|
'postgres',
|
|
"SELECT * from myschema.test",
|
|
q[2018-03-02 01:00:00|(Kilimanjaro,"Diamond St")],
|
|
'AN shows correct data with UDT from different schema');
|
|
|
|
done_testing();
|
|
|
|
1;
|