mirror of https://github.com/citusdata/citus.git
Add tests for create_distributed_table_concurrently
parent
7701ca12e0
commit
d8d2ce3c49
|
@ -399,11 +399,12 @@ UndistributeTable(TableConversionParameters *params)
|
|||
|
||||
ErrorIfUnsupportedCascadeObjects(params->relationId);
|
||||
|
||||
ErrorIfTableHasIdentityColumn(params->relationId);
|
||||
|
||||
params->conversionType = UNDISTRIBUTE_TABLE;
|
||||
params->shardCountIsNull = true;
|
||||
TableConversionState *con = CreateTableConversion(params);
|
||||
|
||||
ErrorIfTableHasIdentityColumn(params->relationId);
|
||||
|
||||
return ConvertTable(con);
|
||||
}
|
||||
|
||||
|
|
|
@ -304,8 +304,6 @@ create_distributed_table_concurrently(PG_FUNCTION_ARGS)
|
|||
shardCountIsStrict = true;
|
||||
}
|
||||
|
||||
ErrorIfTableHasUnsupportedIdentityColumn(relationId);
|
||||
|
||||
CreateDistributedTableConcurrently(relationId, distributionColumnName,
|
||||
distributionMethod,
|
||||
colocateWithTableName,
|
||||
|
@ -434,6 +432,8 @@ CreateDistributedTableConcurrently(Oid relationId, char *distributionColumnName,
|
|||
|
||||
WarnIfTableHaveNoReplicaIdentity(relationId);
|
||||
|
||||
ErrorIfTableHasUnsupportedIdentityColumn(relationId);
|
||||
|
||||
List *shardList = LoadShardIntervalList(relationId);
|
||||
|
||||
/*
|
||||
|
|
|
@ -3981,7 +3981,7 @@ ErrorIfTableHasUnsupportedIdentityColumn(Oid relationId)
|
|||
{
|
||||
Relation relation = relation_open(relationId, AccessShareLock);
|
||||
TupleDesc tupleDescriptor = RelationGetDescr(relation);
|
||||
relation_close(relation, NoLock);
|
||||
relation_close(relation, AccessShareLock);
|
||||
|
||||
for (int attributeIndex = 0; attributeIndex < tupleDescriptor->natts;
|
||||
attributeIndex++)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
CREATE SCHEMA generated_identities;
|
||||
SET search_path TO generated_identities;
|
||||
SET client_min_messages to ERROR;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT 1 from citus_add_node('localhost', :master_port, groupId=>0);
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -13,6 +14,8 @@ CREATE TABLE smallint_identity_column (
|
|||
);
|
||||
SELECT create_distributed_table('smallint_identity_column', 'a');
|
||||
ERROR: cannot complete operation on a table with smallint/int identity column
|
||||
SELECT create_distributed_table_concurrently('smallint_identity_column', 'a');
|
||||
ERROR: cannot complete operation on a table with smallint/int identity column
|
||||
SELECT create_reference_table('smallint_identity_column');
|
||||
ERROR: cannot complete operation on a table with smallint/int identity column
|
||||
SELECT citus_add_local_table_to_metadata('smallint_identity_column');
|
||||
|
@ -28,6 +31,8 @@ CREATE TABLE int_identity_column (
|
|||
);
|
||||
SELECT create_distributed_table('int_identity_column', 'a');
|
||||
ERROR: cannot complete operation on a table with smallint/int identity column
|
||||
SELECT create_distributed_table_concurrently('int_identity_column', 'a');
|
||||
ERROR: cannot complete operation on a table with smallint/int identity column
|
||||
SELECT create_reference_table('int_identity_column');
|
||||
ERROR: cannot complete operation on a table with smallint/int identity column
|
||||
SELECT citus_add_local_table_to_metadata('int_identity_column');
|
||||
|
@ -37,6 +42,7 @@ SELECT citus_add_local_table_to_metadata('int_identity_column');
|
|||
(1 row)
|
||||
|
||||
DROP TABLE int_identity_column;
|
||||
RESET citus.shard_replication_factor;
|
||||
CREATE TABLE bigint_identity_column (
|
||||
a bigint GENERATED BY DEFAULT AS IDENTITY,
|
||||
b int
|
||||
|
@ -161,10 +167,6 @@ SET search_path TO generated_identities;
|
|||
SET client_min_messages to ERROR;
|
||||
INSERT INTO partitioned_table (c)
|
||||
SELECT s FROM generate_series(10,20) s;
|
||||
INSERT INTO partitioned_table (a,b,c) VALUES (997,997,997);
|
||||
ERROR: cannot insert a non-DEFAULT value into column "b"
|
||||
DETAIL: Column "b" is an identity column defined as GENERATED ALWAYS.
|
||||
HINT: Use OVERRIDING SYSTEM VALUE to override.
|
||||
INSERT INTO partitioned_table (a,c) VALUES (998,998);
|
||||
INSERT INTO partitioned_table (a,b,c) OVERRIDING SYSTEM VALUE VALUES (999,999,999);
|
||||
SELECT * FROM partitioned_table ORDER BY c ASC;
|
||||
|
@ -283,17 +285,19 @@ SELECT * FROM reference_table ORDER BY c ASC;
|
|||
(20 rows)
|
||||
|
||||
DROP TABLE reference_table;
|
||||
-- https://github.com/citusdata/citus/issues/6694
|
||||
CREATE TABLE color (
|
||||
color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE,
|
||||
color_name VARCHAR NOT NULL
|
||||
);
|
||||
SELECT create_distributed_table('color', 'color_id');
|
||||
create_distributed_table
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table_concurrently('color', 'color_id');
|
||||
create_distributed_table_concurrently
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
RESET citus.shard_replication_factor;
|
||||
-- https://github.com/citusdata/citus/issues/6694
|
||||
CREATE USER identity_test_user;
|
||||
GRANT INSERT ON color TO identity_test_user;
|
||||
GRANT USAGE ON SCHEMA generated_identities TO identity_test_user;
|
||||
|
|
|
@ -1323,9 +1323,10 @@ SELECT * FROM multi_extension.print_extension_changes();
|
|||
-- Snapshot of state at 11.3-1
|
||||
ALTER EXTENSION citus UPDATE TO '11.3-1';
|
||||
SELECT * FROM multi_extension.print_extension_changes();
|
||||
previous_object | current_object
|
||||
previous_object | current_object
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
| function worker_modify_identity_columns(regclass) void
|
||||
(1 row)
|
||||
|
||||
DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff;
|
||||
-- show running version
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
CREATE SCHEMA generated_identities;
|
||||
SET search_path TO generated_identities;
|
||||
SET client_min_messages to ERROR;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
|
||||
SELECT 1 from citus_add_node('localhost', :master_port, groupId=>0);
|
||||
|
||||
|
@ -9,6 +10,7 @@ CREATE TABLE smallint_identity_column (
|
|||
a smallint GENERATED BY DEFAULT AS IDENTITY
|
||||
);
|
||||
SELECT create_distributed_table('smallint_identity_column', 'a');
|
||||
SELECT create_distributed_table_concurrently('smallint_identity_column', 'a');
|
||||
SELECT create_reference_table('smallint_identity_column');
|
||||
SELECT citus_add_local_table_to_metadata('smallint_identity_column');
|
||||
|
||||
|
@ -19,9 +21,12 @@ CREATE TABLE int_identity_column (
|
|||
a int GENERATED BY DEFAULT AS IDENTITY
|
||||
);
|
||||
SELECT create_distributed_table('int_identity_column', 'a');
|
||||
SELECT create_distributed_table_concurrently('int_identity_column', 'a');
|
||||
SELECT create_reference_table('int_identity_column');
|
||||
SELECT citus_add_local_table_to_metadata('int_identity_column');
|
||||
DROP TABLE int_identity_column;
|
||||
RESET citus.shard_replication_factor;
|
||||
|
||||
|
||||
CREATE TABLE bigint_identity_column (
|
||||
a bigint GENERATED BY DEFAULT AS IDENTITY,
|
||||
|
@ -98,8 +103,6 @@ SET client_min_messages to ERROR;
|
|||
INSERT INTO partitioned_table (c)
|
||||
SELECT s FROM generate_series(10,20) s;
|
||||
|
||||
INSERT INTO partitioned_table (a,b,c) VALUES (997,997,997);
|
||||
|
||||
INSERT INTO partitioned_table (a,c) VALUES (998,998);
|
||||
|
||||
INSERT INTO partitioned_table (a,b,c) OVERRIDING SYSTEM VALUE VALUES (999,999,999);
|
||||
|
@ -147,13 +150,15 @@ SELECT * FROM reference_table ORDER BY c ASC;
|
|||
|
||||
DROP TABLE reference_table;
|
||||
|
||||
-- https://github.com/citusdata/citus/issues/6694
|
||||
CREATE TABLE color (
|
||||
color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE,
|
||||
color_name VARCHAR NOT NULL
|
||||
);
|
||||
SELECT create_distributed_table('color', 'color_id');
|
||||
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table_concurrently('color', 'color_id');
|
||||
RESET citus.shard_replication_factor;
|
||||
-- https://github.com/citusdata/citus/issues/6694
|
||||
CREATE USER identity_test_user;
|
||||
GRANT INSERT ON color TO identity_test_user;
|
||||
GRANT USAGE ON SCHEMA generated_identities TO identity_test_user;
|
||||
|
|
Loading…
Reference in New Issue