mirror of https://github.com/citusdata/citus.git
Handle foreign tables and update tests
parent
21138784a3
commit
8006765504
|
@ -236,7 +236,7 @@ GetDependencyCreateDDLCommands(const ObjectAddress *dependency)
|
|||
return NIL;
|
||||
}
|
||||
|
||||
if (relKind == RELKIND_RELATION || relKind == RELKIND_PARTITIONED_TABLE)
|
||||
if (relKind == RELKIND_RELATION || relKind == RELKIND_PARTITIONED_TABLE || relKind == RELKIND_FOREIGN_TABLE)
|
||||
{
|
||||
Oid relationId = dependency->objectId;
|
||||
if (IsCitusTable(relationId) && !IsTableOwnedByExtension(relationId))
|
||||
|
|
|
@ -683,6 +683,7 @@ SupportedDependencyByCitus(const ObjectAddress *address)
|
|||
if (relKind == RELKIND_COMPOSITE_TYPE ||
|
||||
relKind == RELKIND_RELATION ||
|
||||
relKind == RELKIND_PARTITIONED_TABLE ||
|
||||
relKind == RELKIND_FOREIGN_TABLE ||
|
||||
relKind == RELKIND_SEQUENCE)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -696,10 +696,13 @@ SetUpObjectMetadata(WorkerNode *workerNode)
|
|||
metadataCommand);
|
||||
|
||||
/* add the truncate trigger command after the table became distributed */
|
||||
char *truncateTriggerCreateCommand =
|
||||
TruncateTriggerCreateCommand(cacheEntry->relationId);
|
||||
metadataSnapshotCommandList = lappend(metadataSnapshotCommandList,
|
||||
truncateTriggerCreateCommand);
|
||||
if (!IsForeignTable(clusteredTableId))
|
||||
{
|
||||
char *truncateTriggerCreateCommand =
|
||||
TruncateTriggerCreateCommand(clusteredTableId);
|
||||
metadataSnapshotCommandList = lappend(metadataSnapshotCommandList,
|
||||
truncateTriggerCreateCommand);
|
||||
}
|
||||
|
||||
/* add the pg_dist_shard{,placement} entries */
|
||||
List *shardIntervalList = LoadShardIntervalList(clusteredTableId);
|
||||
|
|
|
@ -471,6 +471,7 @@ ErrorIfCurrentUserCanNotDistributeObject(ObjectType type, ObjectAddress *addr,
|
|||
break;
|
||||
}
|
||||
|
||||
case OBJECT_FOREIGN_TABLE:
|
||||
case OBJECT_TABLE:
|
||||
{
|
||||
/* table distribution already does the ownership check, so we can stick to that over acl_check */
|
||||
|
|
|
@ -173,7 +173,6 @@ SELECT master_get_active_worker_nodes();
|
|||
SELECT citus_disable_node('localhost.noexist', 2345);
|
||||
ERROR: node at "localhost.noexist:2345" does not exist
|
||||
-- drop the table without leaving a shard placement behind (messes up other tests)
|
||||
-- TODO: Replication ref table multiple times
|
||||
SELECT master_activate_node('localhost', :worker_2_port);
|
||||
master_activate_node
|
||||
----------------------
|
||||
|
|
|
@ -416,40 +416,6 @@ SELECT * FROM run_command_on_workers($$SELECT * FROM (SELECT pg_identify_object_
|
|||
localhost | 57638 | t | (extension,{ltree},{})
|
||||
(2 rows)
|
||||
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
NOTICE: dropping metadata on the node (localhost,57637)
|
||||
stop_metadata_sync_to_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_2_port);
|
||||
NOTICE: dropping metadata on the node (localhost,57638)
|
||||
stop_metadata_sync_to_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- Show that we don't have any object metadata after stopping syncing
|
||||
SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object;$$) ORDER BY 1,2;
|
||||
nodename | nodeport | success | result
|
||||
---------------------------------------------------------------------
|
||||
localhost | 57637 | t |
|
||||
localhost | 57638 | t |
|
||||
(2 rows)
|
||||
|
||||
-- Revert the settings for following tests
|
||||
RESET citus.enable_ddl_propagation;
|
||||
RESET citus.shard_replication_factor;
|
||||
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
start_metadata_sync_to_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT start_metadata_sync_to_node('localhost', :worker_2_port);
|
||||
start_metadata_sync_to_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ SET search_path = sequence_default, public;
|
|||
|
||||
|
||||
-- test both distributed and citus local tables
|
||||
table pg_dist_node;
|
||||
SELECT 1 FROM citus_add_node('localhost', :master_port, groupId => 0);
|
||||
-- Cannot add a column involving DEFAULT nextval('..') because the table is not empty
|
||||
CREATE SEQUENCE seq_0;
|
||||
|
@ -52,43 +51,17 @@ SELECT * FROM seq_test_0_local_table ORDER BY 1, 2 LIMIT 5;
|
|||
ALTER SEQUENCE seq_0 AS bigint;
|
||||
ALTER SEQUENCE seq_0_local_table AS bigint;
|
||||
|
||||
-- we can change other things like increment
|
||||
-- if metadata is not synced to workers
|
||||
-- we can't change sequences as we mark them as distributed
|
||||
-- even if metadata sync is stopped
|
||||
BEGIN;
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_2_port);
|
||||
CREATE SEQUENCE seq_13;
|
||||
CREATE SEQUENCE seq_13_local_table;
|
||||
CREATE TABLE seq_test_13 (x int, y int);
|
||||
CREATE TABLE seq_test_13_local_table (x int, y int);
|
||||
SELECT create_distributed_table('seq_test_13','x');
|
||||
SELECT citus_add_local_table_to_metadata('seq_test_13_local_table');
|
||||
ALTER TABLE seq_test_13 ADD COLUMN z int DEFAULT nextval('seq_13');
|
||||
ALTER TABLE seq_test_13_local_table ADD COLUMN z int DEFAULT nextval('seq_13_local_table');
|
||||
|
||||
ALTER SEQUENCE seq_13 INCREMENT BY 2;
|
||||
ALTER SEQUENCE seq_13_local_table INCREMENT BY 2;
|
||||
\d seq_13
|
||||
\d seq_13_local_table
|
||||
|
||||
|
||||
-- check that we can add serial pseudo-type columns
|
||||
-- when metadata is not synced to workers
|
||||
TRUNCATE seq_test_0;
|
||||
ALTER TABLE seq_test_0 ADD COLUMN w00 smallserial;
|
||||
ALTER TABLE seq_test_0 ADD COLUMN w01 serial2;
|
||||
ALTER TABLE seq_test_0 ADD COLUMN w10 serial;
|
||||
ALTER TABLE seq_test_0 ADD COLUMN w11 serial4;
|
||||
ALTER TABLE seq_test_0 ADD COLUMN w20 bigserial;
|
||||
ALTER TABLE seq_test_0 ADD COLUMN w21 serial8;
|
||||
|
||||
TRUNCATE seq_test_0_local_table;
|
||||
ALTER TABLE seq_test_0_local_table ADD COLUMN w00 smallserial;
|
||||
ALTER TABLE seq_test_0_local_table ADD COLUMN w01 serial2;
|
||||
ALTER TABLE seq_test_0_local_table ADD COLUMN w10 serial;
|
||||
ALTER TABLE seq_test_0_local_table ADD COLUMN w11 serial4;
|
||||
ALTER TABLE seq_test_0_local_table ADD COLUMN w20 bigserial;
|
||||
ALTER TABLE seq_test_0_local_table ADD COLUMN w21 serial8;
|
||||
|
||||
ROLLBACK;
|
||||
|
||||
|
|
|
@ -177,14 +177,6 @@ SELECT * FROM run_command_on_workers($$SELECT * FROM (SELECT pg_identify_object_
|
|||
SELECT * FROM (SELECT pg_identify_object_as_address(classid, objid, objsubid) as obj_identifier from citus.pg_dist_object) as obj_identifiers where obj_identifier::text like '%{ltree}%';
|
||||
SELECT * FROM run_command_on_workers($$SELECT * FROM (SELECT pg_identify_object_as_address(classid, objid, objsubid) as obj_identifier from citus.pg_dist_object) as obj_identifiers where obj_identifier::text like '%{ltree}%';$$) ORDER BY 1,2;
|
||||
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
SELECT stop_metadata_sync_to_node('localhost', :worker_2_port);
|
||||
|
||||
-- Show that we don't have any object metadata after stopping syncing
|
||||
SELECT * FROM run_command_on_workers($$SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object;$$) ORDER BY 1,2;
|
||||
|
||||
-- Revert the settings for following tests
|
||||
RESET citus.enable_ddl_propagation;
|
||||
RESET citus.shard_replication_factor;
|
||||
SELECT start_metadata_sync_to_node('localhost', :worker_1_port);
|
||||
SELECT start_metadata_sync_to_node('localhost', :worker_2_port);
|
||||
|
|
Loading…
Reference in New Issue