From bd213a0970f693fd3baf63605dbe5d919ae12afa Mon Sep 17 00:00:00 2001 From: Gokhan Gulbiz Date: Fri, 10 Mar 2023 11:19:35 +0300 Subject: [PATCH] Add tests for a columnar table with identity columns --- .../regress/expected/generated_identity.out | 40 ++++++++++++++++++- src/test/regress/sql/generated_identity.sql | 18 +++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/test/regress/expected/generated_identity.out b/src/test/regress/expected/generated_identity.out index 29177e993..4ff4974f9 100644 --- a/src/test/regress/expected/generated_identity.out +++ b/src/test/regress/expected/generated_identity.out @@ -17,7 +17,7 @@ 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 +ERROR: cannot complete operation on a table with identity column SELECT citus_add_local_table_to_metadata('smallint_identity_column'); citus_add_local_table_to_metadata --------------------------------------------------------------------- @@ -34,7 +34,7 @@ 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 +ERROR: cannot complete operation on a table with identity column SELECT citus_add_local_table_to_metadata('int_identity_column'); citus_add_local_table_to_metadata --------------------------------------------------------------------- @@ -312,5 +312,41 @@ INSERT INTO color(color_name) VALUES ('Blue'); \c - postgres - :master_port SET search_path TO generated_identities; SET client_min_messages to ERROR; +DROP TABLE Color; +CREATE TABLE color ( + color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE, + color_name VARCHAR NOT NULL +) USING columnar; +SELECT create_distributed_table('color', 'color_id'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +INSERT INTO color(color_name) VALUES ('Blue'); +\d+ color + Table "generated_identities.color" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------------------------------------------------------------------- + color_id | bigint | | not null | generated always as identity | plain | | + color_name | character varying | | not null | | extended | | +Indexes: + "color_color_id_key" UNIQUE CONSTRAINT, btree (color_id) + +\c - - - :worker_1_port +SET search_path TO generated_identities; +\d+ color + Table "generated_identities.color" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------------------------------------------------------------------- + color_id | bigint | | not null | generated always as identity | plain | | + color_name | character varying | | not null | | extended | | +Indexes: + "color_color_id_key" UNIQUE CONSTRAINT, btree (color_id) + +INSERT INTO color(color_name) VALUES ('Red'); +\c - postgres - :master_port +SET search_path TO generated_identities; +SET client_min_messages to ERROR; DROP SCHEMA generated_identities CASCADE; DROP USER identity_test_user; diff --git a/src/test/regress/sql/generated_identity.sql b/src/test/regress/sql/generated_identity.sql index 3638a1079..a72335f5f 100644 --- a/src/test/regress/sql/generated_identity.sql +++ b/src/test/regress/sql/generated_identity.sql @@ -178,5 +178,23 @@ INSERT INTO color(color_name) VALUES ('Blue'); SET search_path TO generated_identities; SET client_min_messages to ERROR; +DROP TABLE Color; +CREATE TABLE color ( + color_id BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE, + color_name VARCHAR NOT NULL +) USING columnar; +SELECT create_distributed_table('color', 'color_id'); +INSERT INTO color(color_name) VALUES ('Blue'); +\d+ color + +\c - - - :worker_1_port +SET search_path TO generated_identities; +\d+ color +INSERT INTO color(color_name) VALUES ('Red'); + +\c - postgres - :master_port +SET search_path TO generated_identities; +SET client_min_messages to ERROR; + DROP SCHEMA generated_identities CASCADE; DROP USER identity_test_user;