From 5311960200b455cb5a30fb0774211543b726b7cd Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 1 Mar 2016 16:06:08 -0800 Subject: [PATCH 1/2] Make :master_port and :worker_$n_port available to all regression tests. There already exist tests that locally embed knowledge about port numbers, and there's more tests requiring that. Instead of copying \set's to several tests, make these port number variables available to all tests. --- .../regress/expected/multi_modifications.out | 8 +++----- .../regress/expected/multi_repair_shards.out | 18 ++++++++---------- src/test/regress/pg_regress_multi.pl | 18 +++++++++++++++--- src/test/regress/sql/multi_modifications.sql | 8 +++----- src/test/regress/sql/multi_repair_shards.sql | 19 ++++++++----------- 5 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/test/regress/expected/multi_modifications.out b/src/test/regress/expected/multi_modifications.out index 3b62f7c3801..d28f173ccd4 100644 --- a/src/test/regress/expected/multi_modifications.out +++ b/src/test/regress/expected/multi_modifications.out @@ -258,20 +258,18 @@ SELECT kind, limit_price FROM limit_orders WHERE id = 246; (1 row) -- Test that shards which miss a modification are marked unhealthy -\set first_worker_port 57637 -\set second_worker_port 57638 -- First: Mark all placements for a node as inactive UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE nodename = 'localhost' AND - nodeport = :first_worker_port; + nodeport = :worker_1_port; -- Second: Perform an INSERT to the remaining node INSERT INTO limit_orders VALUES (275, 'ADR', 140, '2007-07-02 16:32:15', 'sell', 43.67); -- Third: Mark the original placements as healthy again UPDATE pg_dist_shard_placement SET shardstate = 1 WHERE nodename = 'localhost' AND - nodeport = :first_worker_port; + nodeport = :worker_1_port; -- Fourth: Perform the same INSERT (primary key violation) INSERT INTO limit_orders VALUES (275, 'ADR', 140, '2007-07-02 16:32:15', 'sell', 43.67); WARNING: Bad result from localhost:57638 @@ -288,7 +286,7 @@ FROM pg_dist_shard_placement AS sp, pg_dist_shard AS s WHERE sp.shardid = s.shardid AND sp.nodename = 'localhost' -AND sp.nodeport = :second_worker_port +AND sp.nodeport = :worker_2_port AND sp.shardstate = 3 AND s.logicalrelid = 'limit_orders'::regclass; count diff --git a/src/test/regress/expected/multi_repair_shards.out b/src/test/regress/expected/multi_repair_shards.out index 8cdc949aa3a..bf76df9c53b 100644 --- a/src/test/regress/expected/multi_repair_shards.out +++ b/src/test/regress/expected/multi_repair_shards.out @@ -7,8 +7,6 @@ CREATE TABLE customer_engagements ( id integer, created_at date, event_data text CREATE INDEX ON customer_engagements (id); CREATE INDEX ON customer_engagements (created_at); CREATE INDEX ON customer_engagements (event_data); -\set first_worker_port 57637 -\set second_worker_port 57638 -- distribute the table SELECT master_create_distributed_table('customer_engagements', 'id', 'hash'); master_create_distributed_table @@ -37,24 +35,24 @@ INSERT INTO customer_engagements VALUES (1, '03-01-2015', 'third event'); SELECT shardid as newshardid FROM pg_dist_shard WHERE logicalrelid = 'customer_engagements'::regclass \gset -- now, update the second placement as unhealthy -UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :second_worker_port; +UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :worker_2_port; -- add a fake healthy placement for the tests INSERT INTO pg_dist_shard_placement (nodename, nodeport, shardid, shardstate, shardlength) - VALUES ('dummyhost', :second_worker_port, :newshardid, 1, 0); -SELECT master_copy_shard_placement(:newshardid, 'localhost', :first_worker_port, 'dummyhost', :second_worker_port); + VALUES ('dummyhost', :worker_2_port, :newshardid, 1, 0); +SELECT master_copy_shard_placement(:newshardid, 'localhost', :worker_1_port, 'dummyhost', :worker_2_port); ERROR: target placement must be in inactive state -- also try to copy from an inactive placement -SELECT master_copy_shard_placement(:newshardid, 'localhost', :second_worker_port, 'localhost', :first_worker_port); +SELECT master_copy_shard_placement(:newshardid, 'localhost', :worker_2_port, 'localhost', :worker_1_port); ERROR: source placement must be in finalized state -- "copy" this shard from the first placement to the second one -SELECT master_copy_shard_placement(:newshardid, 'localhost', :first_worker_port, 'localhost', :second_worker_port); +SELECT master_copy_shard_placement(:newshardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port); master_copy_shard_placement ----------------------------- (1 row) -- now, update first placement as unhealthy (and raise a notice) so that queries are not routed to there -UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :first_worker_port; +UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :worker_1_port; -- get the data from the second placement SELECT * FROM customer_engagements; id | created_at | event_data @@ -89,8 +87,8 @@ NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined SELECT shardid as remotenewshardid FROM pg_dist_shard WHERE logicalrelid = 'remote_engagements'::regclass \gset -- now, update the second placement as unhealthy -UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :remotenewshardid AND nodeport = :second_worker_port; +UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :remotenewshardid AND nodeport = :worker_2_port; -- oops! we don't support repairing shards backed by foreign tables -SELECT master_copy_shard_placement(:remotenewshardid, 'localhost', :first_worker_port, 'localhost', :second_worker_port); +SELECT master_copy_shard_placement(:remotenewshardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port); ERROR: cannot repair shard DETAIL: Repairing shards backed by foreign tables is not supported. diff --git a/src/test/regress/pg_regress_multi.pl b/src/test/regress/pg_regress_multi.pl index aa863021e9a..6c70536acae 100644 --- a/src/test/regress/pg_regress_multi.pl +++ b/src/test/regress/pg_regress_multi.pl @@ -14,6 +14,7 @@ use strict; use warnings; +use Fcntl; use Getopt::Long; @@ -124,11 +125,22 @@ () system("rm", ('-rf', "tmp_check/worker.$port")) == 0 or die "Could not remove worker directory"; } -# Prepare a wrapper directory in which 'psql' is a symlink to 'csql' +# Prepare directory in which 'psql' is a wrapper around 'csql', which +# also adds some variables to csql. system("mkdir", ('-p', "tmp_check/tmp-bin")) == 0 or die "Could not create tmp-bin directory"; -system("ln", ('-s', "$bindir/csql", "tmp_check/tmp-bin/psql")) == 0 - or die "Could not create psql to csql symlink"; +sysopen my $fh, "tmp_check/tmp-bin/psql", O_CREAT|O_TRUNC|O_RDWR, 0700 + or die "Could not create psql wrapper"; +print $fh "#!/bin/bash\n"; +print $fh "exec $bindir/csql "; +print $fh "--variable=master_port=$masterPort "; +for my $workeroff (0 .. $#workerPorts) +{ + my $port = $workerPorts[$workeroff]; + print $fh "--variable=worker_".($workeroff+1)."_port=$port "; +} +print $fh "\"\$@\"\n"; # pass on the commandline arguments +close $fh; system("mkdir", ('-p', 'tmp_check/master/log')) == 0 or die "Could not create master directory"; for my $port (@workerPorts) diff --git a/src/test/regress/sql/multi_modifications.sql b/src/test/regress/sql/multi_modifications.sql index 605f8905f90..dc439f01713 100644 --- a/src/test/regress/sql/multi_modifications.sql +++ b/src/test/regress/sql/multi_modifications.sql @@ -186,14 +186,12 @@ UPDATE limit_orders SET (kind, limit_price) = ('buy', DEFAULT) WHERE id = 246; SELECT kind, limit_price FROM limit_orders WHERE id = 246; -- Test that shards which miss a modification are marked unhealthy -\set first_worker_port 57637 -\set second_worker_port 57638 -- First: Mark all placements for a node as inactive UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE nodename = 'localhost' AND - nodeport = :first_worker_port; + nodeport = :worker_1_port; -- Second: Perform an INSERT to the remaining node INSERT INTO limit_orders VALUES (275, 'ADR', 140, '2007-07-02 16:32:15', 'sell', 43.67); @@ -202,7 +200,7 @@ INSERT INTO limit_orders VALUES (275, 'ADR', 140, '2007-07-02 16:32:15', 'sell', UPDATE pg_dist_shard_placement SET shardstate = 1 WHERE nodename = 'localhost' AND - nodeport = :first_worker_port; + nodeport = :worker_1_port; -- Fourth: Perform the same INSERT (primary key violation) INSERT INTO limit_orders VALUES (275, 'ADR', 140, '2007-07-02 16:32:15', 'sell', 43.67); @@ -214,7 +212,7 @@ FROM pg_dist_shard_placement AS sp, pg_dist_shard AS s WHERE sp.shardid = s.shardid AND sp.nodename = 'localhost' -AND sp.nodeport = :second_worker_port +AND sp.nodeport = :worker_2_port AND sp.shardstate = 3 AND s.logicalrelid = 'limit_orders'::regclass; diff --git a/src/test/regress/sql/multi_repair_shards.sql b/src/test/regress/sql/multi_repair_shards.sql index 15fd58e1340..7912f6a34bb 100644 --- a/src/test/regress/sql/multi_repair_shards.sql +++ b/src/test/regress/sql/multi_repair_shards.sql @@ -10,9 +10,6 @@ CREATE INDEX ON customer_engagements (id); CREATE INDEX ON customer_engagements (created_at); CREATE INDEX ON customer_engagements (event_data); -\set first_worker_port 57637 -\set second_worker_port 57638 - -- distribute the table SELECT master_create_distributed_table('customer_engagements', 'id', 'hash'); @@ -36,22 +33,22 @@ SELECT shardid as newshardid FROM pg_dist_shard WHERE logicalrelid = 'customer_e \gset -- now, update the second placement as unhealthy -UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :second_worker_port; +UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :worker_2_port; -- add a fake healthy placement for the tests INSERT INTO pg_dist_shard_placement (nodename, nodeport, shardid, shardstate, shardlength) - VALUES ('dummyhost', :second_worker_port, :newshardid, 1, 0); + VALUES ('dummyhost', :worker_2_port, :newshardid, 1, 0); -SELECT master_copy_shard_placement(:newshardid, 'localhost', :first_worker_port, 'dummyhost', :second_worker_port); +SELECT master_copy_shard_placement(:newshardid, 'localhost', :worker_1_port, 'dummyhost', :worker_2_port); -- also try to copy from an inactive placement -SELECT master_copy_shard_placement(:newshardid, 'localhost', :second_worker_port, 'localhost', :first_worker_port); +SELECT master_copy_shard_placement(:newshardid, 'localhost', :worker_2_port, 'localhost', :worker_1_port); -- "copy" this shard from the first placement to the second one -SELECT master_copy_shard_placement(:newshardid, 'localhost', :first_worker_port, 'localhost', :second_worker_port); +SELECT master_copy_shard_placement(:newshardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port); -- now, update first placement as unhealthy (and raise a notice) so that queries are not routed to there -UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :first_worker_port; +UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :newshardid AND nodeport = :worker_1_port; -- get the data from the second placement SELECT * FROM customer_engagements; @@ -74,7 +71,7 @@ SELECT shardid as remotenewshardid FROM pg_dist_shard WHERE logicalrelid = 'remo \gset -- now, update the second placement as unhealthy -UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :remotenewshardid AND nodeport = :second_worker_port; +UPDATE pg_dist_shard_placement SET shardstate = 3 WHERE shardid = :remotenewshardid AND nodeport = :worker_2_port; -- oops! we don't support repairing shards backed by foreign tables -SELECT master_copy_shard_placement(:remotenewshardid, 'localhost', :first_worker_port, 'localhost', :second_worker_port); +SELECT master_copy_shard_placement(:remotenewshardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port); From 53309461cb6528dcb4d7110b7db8dd625106b193 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 24 Feb 2016 15:20:05 -0800 Subject: [PATCH 2/2] Improve DDL replication related regression tests. The previous form of the test, utilizing DEBUG2, included too much output dependent on the specifc system and version. Reformulate it to explicitly connect to workers and show the schema there, when necessary. The only remaining difference in some of the remaining alternate regression test files was due to an older minor version release change. Remove those as well. --- .../expected/multi_generate_ddl_commands.out | 12 +- .../multi_generate_ddl_commands_0.out | 156 ---- .../expected/multi_index_statements.out | 136 +--- .../expected/multi_index_statements_0.out | 196 ----- .../expected/multi_master_protocol_0.out | 53 -- .../input/multi_alter_table_statements.source | 32 +- .../multi_alter_table_statements.source | 427 +++------- .../multi_alter_table_statements_0.source | 726 ------------------ .../regress/sql/multi_index_statements.sql | 21 +- 9 files changed, 160 insertions(+), 1599 deletions(-) delete mode 100644 src/test/regress/expected/multi_generate_ddl_commands_0.out delete mode 100644 src/test/regress/expected/multi_index_statements_0.out delete mode 100644 src/test/regress/expected/multi_master_protocol_0.out delete mode 100644 src/test/regress/output/multi_alter_table_statements_0.source diff --git a/src/test/regress/expected/multi_generate_ddl_commands.out b/src/test/regress/expected/multi_generate_ddl_commands.out index ef63548abd8..ff856b42340 100644 --- a/src/test/regress/expected/multi_generate_ddl_commands.out +++ b/src/test/regress/expected/multi_generate_ddl_commands.out @@ -84,9 +84,9 @@ CREATE TABLE pkey_table ( id bigint PRIMARY KEY ); SELECT table_ddl_command_array('pkey_table'); - table_ddl_command_array ------------------------------------------------------------------------------------------------------------------------------------------------------------------ - {"CREATE TABLE pkey_table (first_name text, last_name text, id bigint NOT NULL)","ALTER TABLE ONLY pkey_table ADD CONSTRAINT pkey_table_pkey PRIMARY KEY (id)"} + table_ddl_command_array +------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"CREATE TABLE pkey_table (first_name text, last_name text, id bigint NOT NULL)","ALTER TABLE public.pkey_table ADD CONSTRAINT pkey_table_pkey PRIMARY KEY (id)"} (1 row) -- as do unique indexes... @@ -95,9 +95,9 @@ CREATE TABLE unique_table ( username text UNIQUE not null ); SELECT table_ddl_command_array('unique_table'); - table_ddl_command_array ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE unique_table (user_id bigint NOT NULL, username text NOT NULL)","ALTER TABLE ONLY unique_table ADD CONSTRAINT unique_table_username_key UNIQUE (username)"} + table_ddl_command_array +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + {"CREATE TABLE unique_table (user_id bigint NOT NULL, username text NOT NULL)","ALTER TABLE public.unique_table ADD CONSTRAINT unique_table_username_key UNIQUE (username)"} (1 row) -- and indexes used for clustering diff --git a/src/test/regress/expected/multi_generate_ddl_commands_0.out b/src/test/regress/expected/multi_generate_ddl_commands_0.out deleted file mode 100644 index ff856b42340..00000000000 --- a/src/test/regress/expected/multi_generate_ddl_commands_0.out +++ /dev/null @@ -1,156 +0,0 @@ --- =================================================================== --- create test functions --- =================================================================== -CREATE FUNCTION table_ddl_command_array(regclass) - RETURNS text[] - AS 'citus' - LANGUAGE C STRICT; --- =================================================================== --- test ddl command generation functionality --- =================================================================== --- first make sure a simple table works -CREATE TABLE simple_table ( - first_name text, - last_name text, - id bigint -); -SELECT table_ddl_command_array('simple_table'); - table_ddl_command_array ----------------------------------------------------------------------------- - {"CREATE TABLE simple_table (first_name text, last_name text, id bigint)"} -(1 row) - --- ensure not-null constraints are propagated -CREATE TABLE not_null_table ( - city text, - id bigint not null -); -SELECT table_ddl_command_array('not_null_table'); - table_ddl_command_array ------------------------------------------------------------------ - {"CREATE TABLE not_null_table (city text, id bigint NOT NULL)"} -(1 row) - --- ensure tables not in search path are schema-prefixed -CREATE SCHEMA not_in_path CREATE TABLE simple_table (id bigint); -NOTICE: Citus partially supports CREATE SCHEMA for distributed databases -DETAIL: schema usage in joins and in some UDFs provided by Citus are not supported yet -SELECT table_ddl_command_array('not_in_path.simple_table'); - table_ddl_command_array -------------------------------------------------------------------------------------------------- - {"CREATE SCHEMA IF NOT EXISTS not_in_path","CREATE TABLE not_in_path.simple_table (id bigint)"} -(1 row) - --- even more complex constraints should be preserved... -CREATE TABLE column_constraint_table ( - first_name text, - last_name text, - age int CONSTRAINT non_negative_age CHECK (age >= 0) -); -SELECT table_ddl_command_array('column_constraint_table'); - table_ddl_command_array ---------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE column_constraint_table (first_name text, last_name text, age integer, CONSTRAINT non_negative_age CHECK (age >= 0))"} -(1 row) - --- including table constraints -CREATE TABLE table_constraint_table ( - bid_item_id bigint, - min_bid decimal not null, - max_bid decimal not null, - CONSTRAINT bids_ordered CHECK (min_bid > max_bid) -); -SELECT table_ddl_command_array('table_constraint_table'); - table_ddl_command_array ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE table_constraint_table (bid_item_id bigint, min_bid numeric NOT NULL, max_bid numeric NOT NULL, CONSTRAINT bids_ordered CHECK (min_bid > max_bid))"} -(1 row) - --- default values are supported -CREATE TABLE default_value_table ( - name text, - price decimal default 0.00 -); -SELECT table_ddl_command_array('default_value_table'); - table_ddl_command_array ------------------------------------------------------------------------------- - {"CREATE TABLE default_value_table (name text, price numeric DEFAULT 0.00)"} -(1 row) - --- of course primary keys work... -CREATE TABLE pkey_table ( - first_name text, - last_name text, - id bigint PRIMARY KEY -); -SELECT table_ddl_command_array('pkey_table'); - table_ddl_command_array -------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE pkey_table (first_name text, last_name text, id bigint NOT NULL)","ALTER TABLE public.pkey_table ADD CONSTRAINT pkey_table_pkey PRIMARY KEY (id)"} -(1 row) - --- as do unique indexes... -CREATE TABLE unique_table ( - user_id bigint not null, - username text UNIQUE not null -); -SELECT table_ddl_command_array('unique_table'); - table_ddl_command_array ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE unique_table (user_id bigint NOT NULL, username text NOT NULL)","ALTER TABLE public.unique_table ADD CONSTRAINT unique_table_username_key UNIQUE (username)"} -(1 row) - --- and indexes used for clustering -CREATE TABLE clustered_table ( - data json not null, - received_at timestamp not null -); -CREATE INDEX clustered_time_idx ON clustered_table (received_at); -CLUSTER clustered_table USING clustered_time_idx; -SELECT table_ddl_command_array('clustered_table'); - table_ddl_command_array ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE clustered_table (data json NOT NULL, received_at timestamp without time zone NOT NULL)","CREATE INDEX clustered_time_idx ON clustered_table USING btree (received_at)","ALTER TABLE clustered_table CLUSTER ON clustered_time_idx"} -(1 row) - --- fiddly things like storage type and statistics also work -CREATE TABLE fiddly_table ( - hostname char(255) not null, - os char(255) not null, - ip_addr inet not null, - traceroute text not null -); -ALTER TABLE fiddly_table - ALTER hostname SET STORAGE PLAIN, - ALTER os SET STORAGE MAIN, - ALTER ip_addr SET STORAGE EXTENDED, - ALTER traceroute SET STORAGE EXTERNAL, - ALTER ip_addr SET STATISTICS 500; -SELECT table_ddl_command_array('fiddly_table'); - table_ddl_command_array -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE TABLE fiddly_table (hostname character(255) NOT NULL, os character(255) NOT NULL, ip_addr inet NOT NULL, traceroute text NOT NULL)","ALTER TABLE ONLY fiddly_table ALTER COLUMN hostname SET STORAGE PLAIN, ALTER COLUMN os SET STORAGE MAIN, ALTER COLUMN ip_addr SET STORAGE EXTENDED, ALTER COLUMN ip_addr SET STATISTICS 500, ALTER COLUMN traceroute SET STORAGE EXTERNAL"} -(1 row) - --- test foreign tables using fake FDW -CREATE FOREIGN TABLE foreign_table ( - id bigint not null, - full_name text not null default '' -) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true'); -SELECT table_ddl_command_array('foreign_table'); -NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined - table_ddl_command_array -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - {"CREATE SERVER fake_fdw_server FOREIGN DATA WRAPPER fake_fdw","CREATE FOREIGN TABLE foreign_table (id bigint NOT NULL, full_name text DEFAULT ''::text NOT NULL) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true')"} -(1 row) - --- propagating views is not supported -CREATE VIEW local_view AS SELECT * FROM simple_table; -SELECT table_ddl_command_array('local_view'); -ERROR: local_view is not a regular or foreign table --- clean up -DROP VIEW IF EXISTS local_view; -DROP FOREIGN TABLE IF EXISTS foreign_table; -DROP TABLE IF EXISTS simple_table, not_null_table, column_constraint_table, - table_constraint_table, default_value_table, pkey_table, - unique_table, clustered_table, fiddly_table; diff --git a/src/test/regress/expected/multi_index_statements.out b/src/test/regress/expected/multi_index_statements.out index 7461e60250d..4132416e714 100644 --- a/src/test/regress/expected/multi_index_statements.out +++ b/src/test/regress/expected/multi_index_statements.out @@ -2,71 +2,19 @@ -- MULTI_INDEX_STATEMENTS -- -- Check that we can run CREATE INDEX and DROP INDEX statements on distributed --- tables. We increase the logging verbosity to verify that commands are --- propagated to all worker shards. -SET client_min_messages TO DEBUG2; +-- tables. -- -- CREATE INDEX -- -- Verify that we can create different types of indexes CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey); -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_orderkey_index" on table "lineitem" CREATE INDEX lineitem_partkey_desc_index ON lineitem (l_partkey DESC); -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_partkey_desc_index" on table "lineitem" CREATE INDEX lineitem_partial_index ON lineitem (l_shipdate) WHERE l_shipdate < '1995-01-01'; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_partial_index" on table "lineitem" +SET client_min_messages = ERROR; -- avoid version dependant warning about WAL CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey); -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_orderkey_hash_index" on table "lineitem" --- Verify that all indexes got created on the master node +RESET client_min_messages; +-- Verify that all indexes got created on the master node and one of the workers SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; schemaname | tablename | indexname | tablespace | indexdef ------------+-----------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------ @@ -78,6 +26,14 @@ SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) (6 rows) +\c - - - :worker_1_port +SELECT count(*) FROM pg_indexes WHERE tablename = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1); + count +------- + 6 +(1 row) + +\c - - - :master_port -- Verify that we error out on unsupported statement types CREATE INDEX CONCURRENTLY try_index ON lineitem (l_orderkey); ERROR: creating indexes concurrently on distributed tables is currently unsupported @@ -123,69 +79,27 @@ DROP INDEX CONCURRENTLY lineitem_orderkey_index; ERROR: dropping indexes concurrently on distributed tables is currently unsupported -- Verify that we can succesfully drop indexes DROP INDEX lineitem_orderkey_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 DROP INDEX lineitem_partkey_desc_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 DROP INDEX lineitem_partial_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -- Verify that we handle if exists statements correctly DROP INDEX non_existent_index; ERROR: index "non_existent_index" does not exist DROP INDEX IF EXISTS non_existent_index; NOTICE: index "non_existent_index" does not exist, skipping DROP INDEX IF EXISTS lineitem_orderkey_hash_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 DROP INDEX lineitem_orderkey_hash_index; ERROR: index "lineitem_orderkey_hash_index" does not exist --- Verify that all the indexes are also dropped from the master node -SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; - schemaname | tablename | indexname | tablespace | indexdef -------------+-----------+---------------------+------------+-------------------------------------------------------------------------------------- - public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) - public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) -(2 rows) +-- Verify that all the indexes are dropped from the master and one worker node. +-- As there's a primary key, so exclude those from this check. +SELECT indrelid::regclass, indexrelid::regclass FROM pg_index WHERE indrelid = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1)::regclass AND NOT indisprimary AND indexrelid::regclass::text NOT LIKE 'lineitem_time_index%'; + indrelid | indexrelid +----------+------------ +(0 rows) + +\c - - - :worker_1_port +SELECT indrelid::regclass, indexrelid::regclass FROM pg_index WHERE indrelid = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1)::regclass AND NOT indisprimary AND indexrelid::regclass::text NOT LIKE 'lineitem_time_index%';; + indrelid | indexrelid +----------+------------ +(0 rows) +\c - - - :master_port diff --git a/src/test/regress/expected/multi_index_statements_0.out b/src/test/regress/expected/multi_index_statements_0.out deleted file mode 100644 index 57c5b244a77..00000000000 --- a/src/test/regress/expected/multi_index_statements_0.out +++ /dev/null @@ -1,196 +0,0 @@ --- --- MULTI_INDEX_STATEMENTS --- --- Check that we can run CREATE INDEX and DROP INDEX statements on distributed --- tables. We increase the logging verbosity to verify that commands are --- propagated to all worker shards. -SET client_min_messages TO DEBUG2; --- --- CREATE INDEX --- --- Verify that we can create different types of indexes -CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey); -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_orderkey_index" on table "lineitem" -CREATE INDEX lineitem_partkey_desc_index ON lineitem (l_partkey DESC); -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_partkey_desc_index" on table "lineitem" -CREATE INDEX lineitem_partial_index ON lineitem (l_shipdate) - WHERE l_shipdate < '1995-01-01'; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: building index "lineitem_partial_index" on table "lineitem" -CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey); -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -WARNING: hash indexes are not WAL-logged and their use is discouraged -DEBUG: building index "lineitem_orderkey_hash_index" on table "lineitem" --- Verify that all indexes got created on the master node -SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; - schemaname | tablename | indexname | tablespace | indexdef -------------+-----------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------ - public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey) - public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey) - public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date) - public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC) - public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) - public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) -(6 rows) - --- Verify that we error out on unsupported statement types -CREATE INDEX CONCURRENTLY try_index ON lineitem (l_orderkey); -ERROR: creating indexes concurrently on distributed tables is currently unsupported -CREATE UNIQUE INDEX try_index ON lineitem (l_orderkey); -ERROR: creating unique indexes on distributed tables is currently unsupported -CREATE INDEX try_index ON lineitem (l_orderkey) TABLESPACE newtablespace; -ERROR: specifying tablespaces with CREATE INDEX statements is currently unsupported --- Verify that we error out in case of postgres errors on supported statement --- types. -CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey); -WARNING: could not receive query results from localhost:57638 -DETAIL: Client error: relation "lineitem_orderkey_index_102014" already exists -ERROR: could not execute DDL command on worker node shards -CREATE INDEX try_index ON lineitem USING gist (l_orderkey); -WARNING: could not receive query results from localhost:57638 -DETAIL: Client error: data type bigint has no default operator class for access method "gist" -ERROR: could not execute DDL command on worker node shards -CREATE INDEX try_index ON lineitem (non_existent_column); -WARNING: could not receive query results from localhost:57638 -DETAIL: Client error: column "non_existent_column" does not exist -ERROR: could not execute DDL command on worker node shards --- Verify that none of failed indexes got created on the master node -SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; - schemaname | tablename | indexname | tablespace | indexdef -------------+-----------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------ - public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey) - public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey) - public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date) - public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC) - public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) - public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) -(6 rows) - --- --- DROP INDEX --- --- Verify that we can't drop multiple indexes in a single command -DROP INDEX lineitem_orderkey_index, lineitem_partial_index; -ERROR: cannot drop multiple distributed objects in a single command -HINT: Try dropping each object in a separate DROP command. --- Verify that we error out on the CONCURRENTLY clause -DROP INDEX CONCURRENTLY lineitem_orderkey_index; -ERROR: dropping indexes concurrently on distributed tables is currently unsupported --- Verify that we can succesfully drop indexes -DROP INDEX lineitem_orderkey_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: EventTriggerInvoke 16541 -DROP INDEX lineitem_partkey_desc_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: EventTriggerInvoke 16541 -DROP INDEX lineitem_partial_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: EventTriggerInvoke 16541 --- Verify that we handle if exists statements correctly -DROP INDEX non_existent_index; -ERROR: index "non_existent_index" does not exist -DROP INDEX IF EXISTS non_existent_index; -NOTICE: index "non_existent_index" does not exist, skipping -DROP INDEX IF EXISTS lineitem_orderkey_hash_index; -DEBUG: applied command on shard 102014 on node localhost:57638 -DEBUG: applied command on shard 102014 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57637 -DEBUG: applied command on shard 102013 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57638 -DEBUG: applied command on shard 102012 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57637 -DEBUG: applied command on shard 102011 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57638 -DEBUG: applied command on shard 102010 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57637 -DEBUG: applied command on shard 102009 on node localhost:57638 -DEBUG: EventTriggerInvoke 16541 -DROP INDEX lineitem_orderkey_hash_index; -ERROR: index "lineitem_orderkey_hash_index" does not exist --- Verify that all the indexes are also dropped from the master node -SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; - schemaname | tablename | indexname | tablespace | indexdef -------------+-----------+---------------------+------------+-------------------------------------------------------------------------------------- - public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) - public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) -(2 rows) - diff --git a/src/test/regress/expected/multi_master_protocol_0.out b/src/test/regress/expected/multi_master_protocol_0.out deleted file mode 100644 index 3f502a931d7..00000000000 --- a/src/test/regress/expected/multi_master_protocol_0.out +++ /dev/null @@ -1,53 +0,0 @@ --- --- MULTI_MASTER_PROTOCOL --- --- Tests that check the metadata returned by the master node. -SELECT part_storage_type, part_key, part_replica_count, part_max_size, - part_placement_policy FROM master_get_table_metadata('lineitem'); - part_storage_type | part_key | part_replica_count | part_max_size | part_placement_policy --------------------+------------+--------------------+---------------+----------------------- - t | l_orderkey | 2 | 307200 | 2 -(1 row) - -SELECT * FROM master_get_table_ddl_events('lineitem'); - master_get_table_ddl_events ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - CREATE TABLE lineitem (l_orderkey bigint NOT NULL, l_partkey integer NOT NULL, l_suppkey integer NOT NULL, l_linenumber integer NOT NULL, l_quantity numeric(15,2) NOT NULL, l_extendedprice numeric(15,2) NOT NULL, l_discount numeric(15,2) NOT NULL, l_tax numeric(15,2) NOT NULL, l_returnflag character(1) NOT NULL, l_linestatus character(1) NOT NULL, l_shipdate date NOT NULL, l_commitdate date NOT NULL, l_receiptdate date NOT NULL, l_shipinstruct character(25) NOT NULL, l_shipmode character(10) NOT NULL, l_comment character varying(44) NOT NULL) - CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) - ALTER TABLE ONLY lineitem ADD CONSTRAINT lineitem_pkey PRIMARY KEY (l_orderkey, l_linenumber) -(3 rows) - -SELECT * FROM master_get_new_shardid(); - master_get_new_shardid ------------------------- - 102008 -(1 row) - -SELECT * FROM master_get_local_first_candidate_nodes(); - node_name | node_port ------------+----------- - localhost | 57638 - localhost | 57637 -(2 rows) - -SELECT * FROM master_get_round_robin_candidate_nodes(1); - node_name | node_port ------------+----------- - localhost | 57638 - localhost | 57637 -(2 rows) - -SELECT * FROM master_get_round_robin_candidate_nodes(2); - node_name | node_port ------------+----------- - localhost | 57637 - localhost | 57638 -(2 rows) - -SELECT * FROM master_get_active_worker_nodes(); - node_name | node_port ------------+----------- - localhost | 57638 - localhost | 57637 -(2 rows) - diff --git a/src/test/regress/input/multi_alter_table_statements.source b/src/test/regress/input/multi_alter_table_statements.source index a588de5d2d0..2b46cbc39bc 100644 --- a/src/test/regress/input/multi_alter_table_statements.source +++ b/src/test/regress/input/multi_alter_table_statements.source @@ -2,10 +2,9 @@ -- MULTI_ALTER_TABLE_STATEMENTS -- --- Check that we can run ALTER TABLE statements on distributed tables. We --- increase the logging verbosity to verify that commands are propagated to --- all worker shards. We also set the shardid sequence here so that the shardids --- in this test aren't affected by changes to the previous tests. +-- Check that we can run ALTER TABLE statements on distributed tables. +-- We set the shardid sequence here so that the shardids in this test +-- aren't affected by changes to the previous tests. ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 103000; CREATE TABLE lineitem_alter ( @@ -29,8 +28,6 @@ CREATE TABLE lineitem_alter ( SELECT master_create_distributed_table('lineitem_alter', 'l_orderkey', 'append'); \STAGE lineitem_alter FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -SET client_min_messages TO DEBUG2; - -- Verify that we can add columns ALTER TABLE lineitem_alter ADD COLUMN float_column FLOAT; @@ -39,6 +36,15 @@ ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER DEFAULT 1; ALTER TABLE lineitem_alter ADD COLUMN int_column2 INTEGER DEFAULT 2; ALTER TABLE lineitem_alter ADD COLUMN null_column INTEGER; +-- show changed schema on one worker +\c - - - :worker_1_port +SELECT attname, atttypid::regtype +FROM + (SELECT oid FROM pg_class WHERE relname LIKE 'lineitem_alter_%' ORDER BY relname LIMIT 1) pc + JOIN pg_attribute ON (pc.oid = pg_attribute.attrelid) +ORDER BY attnum; +\c - - - :master_port + \d lineitem_alter SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column; SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1; @@ -147,7 +153,19 @@ ALTER TABLE IF EXISTS lineitem_alter RENAME l_orderkey TO l_orderkey_renamed; -- node \d lineitem_alter +-- Check that the schema on the worker still looks reasonable +\c - - - :worker_1_port +SELECT attname, atttypid::regtype +FROM + (SELECT oid FROM pg_class WHERE relname LIKE 'lineitem_alter_%' ORDER BY relname LIMIT 1) pc + JOIN pg_attribute ON (pc.oid = pg_attribute.attrelid) +ORDER BY attnum; +\c - - - :master_port + -- Cleanup the table and its shards -RESET client_min_messages; SELECT master_apply_delete_command('DELETE FROM lineitem_alter'); DROP TABLE lineitem_alter; +-- check that nothing's left over on workers +\c - - - :worker_1_port +SELECT relname FROM pg_class WHERE relname LIKE 'lineitem_alter%'; +\c - - - :master_port diff --git a/src/test/regress/output/multi_alter_table_statements.source b/src/test/regress/output/multi_alter_table_statements.source index a5c0d17ef55..9466c3170ec 100644 --- a/src/test/regress/output/multi_alter_table_statements.source +++ b/src/test/regress/output/multi_alter_table_statements.source @@ -1,10 +1,9 @@ -- -- MULTI_ALTER_TABLE_STATEMENTS -- --- Check that we can run ALTER TABLE statements on distributed tables. We --- increase the logging verbosity to verify that commands are propagated to --- all worker shards. We also set the shardid sequence here so that the shardids --- in this test aren't affected by changes to the previous tests. +-- Check that we can run ALTER TABLE statements on distributed tables. +-- We set the shardid sequence here so that the shardids in this test +-- aren't affected by changes to the previous tests. ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 103000; CREATE TABLE lineitem_alter ( l_orderkey bigint not null, @@ -31,49 +30,51 @@ SELECT master_create_distributed_table('lineitem_alter', 'l_orderkey', 'append') (1 row) \STAGE lineitem_alter FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -SET client_min_messages TO DEBUG2; -- Verify that we can add columns ALTER TABLE lineitem_alter ADD COLUMN float_column FLOAT; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 ALTER TABLE lineitem_alter ADD COLUMN date_column DATE; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER DEFAULT 1; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17675 -DEBUG: drop auto-cascades to type pg_temp_17675[] ALTER TABLE lineitem_alter ADD COLUMN int_column2 INTEGER DEFAULT 2; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17675 -DEBUG: drop auto-cascades to type pg_temp_17675[] ALTER TABLE lineitem_alter ADD COLUMN null_column INTEGER; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 +-- show changed schema on one worker +\c - - - :worker_1_port +SELECT attname, atttypid::regtype +FROM + (SELECT oid FROM pg_class WHERE relname LIKE 'lineitem_alter_%' ORDER BY relname LIMIT 1) pc + JOIN pg_attribute ON (pc.oid = pg_attribute.attrelid) +ORDER BY attnum; + attname | atttypid +-----------------+------------------- + tableoid | oid + cmax | cid + xmax | xid + cmin | cid + xmin | xid + ctid | tid + l_orderkey | bigint + l_partkey | integer + l_suppkey | integer + l_linenumber | integer + l_quantity | numeric + l_extendedprice | numeric + l_discount | numeric + l_tax | numeric + l_returnflag | character + l_linestatus | character + l_shipdate | date + l_commitdate | date + l_receiptdate | date + l_shipinstruct | character + l_shipmode | character + l_comment | character varying + float_column | double precision + date_column | date + int_column1 | integer + int_column2 | integer + null_column | integer +(27 rows) + +\c - - - :master_port \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -114,55 +115,9 @@ SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1; -- Verify that SET|DROP DEFAULT works ALTER TABLE lineitem_alter ALTER COLUMN float_column SET DEFAULT 1; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 ALTER TABLE lineitem_alter ALTER COLUMN int_column1 DROP DEFAULT; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -- \stage to verify that default values take effect \STAGE lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -DEBUG: parse : SELECT * FROM master_get_table_metadata($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_table_ddl_events($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column; float_column | count --------------+------- @@ -179,19 +134,6 @@ SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1; -- Verify that SET NOT NULL works ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET NOT NULL; -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: verifying table "lineitem_alter" \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -220,28 +162,8 @@ DEBUG: verifying table "lineitem_alter" -- Drop default so that NULLs will be inserted for this column ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT; -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -- \stage should fail because it will try to insert NULLs for a NOT NULL column \STAGE lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -DEBUG: parse : SELECT * FROM master_get_table_metadata($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_table_ddl_events($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to ERROR: null value in column "int_column2" violates not-null constraint DETAIL: Failing row contains (1, 155190, 7706, 1, 17.00, 21168.23, 0.04, 0.02, N, O, 03-13-1996, 02-12-1996, 03-22-1996, DELIVER IN PERSON , TRUCK , egular courts above the, 1, null, null, null, null). CONTEXT: COPY lineitem_alter_103006, line 1: "1|155190|7706|1|17|21168.23|0.04|0.02|N|O|1996-03-13|1996-02-12|1996-03-22|DELIVER IN PERSON|TRUCK|e..." @@ -251,18 +173,6 @@ CONTEXT: COPY lineitem_alter_103006, line 1: "1|155190|7706|1|17|21168.23|0.04| \stage: failed to replicate shard to enough replicas -- Verify that DROP NOT NULL works ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL; -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -291,40 +201,6 @@ DEBUG: applied command on shard 103000 on node localhost:57637 -- \stage should succeed now \STAGE lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -DEBUG: parse : SELECT * FROM master_get_table_metadata($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_table_ddl_events($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to SELECT count(*) from lineitem_alter; count ------- @@ -340,27 +216,6 @@ SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP B (2 rows) ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE FLOAT; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17675 -DEBUG: drop auto-cascades to type pg_temp_17675[] \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -396,133 +251,21 @@ SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP B -- Verify that DROP COLUMN works ALTER TABLE lineitem_alter DROP COLUMN int_column1; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 ALTER TABLE lineitem_alter DROP COLUMN float_column; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: drop auto-cascades to default for table lineitem_alter column float_column ALTER TABLE lineitem_alter DROP COLUMN date_column; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -- Verify that IF EXISTS works as expected ALTER TABLE non_existent_table ADD COLUMN new_column INTEGER; ERROR: relation "non_existent_table" does not exist ALTER TABLE IF EXISTS non_existent_table ADD COLUMN new_column INTEGER; NOTICE: relation "non_existent_table" does not exist, skipping ALTER TABLE IF EXISTS lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE INTEGER; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17675 -DEBUG: drop auto-cascades to type pg_temp_17675[] ALTER TABLE lineitem_alter DROP COLUMN non_existent_column; WARNING: could not receive query results from localhost:57637 DETAIL: Client error: column "non_existent_column" of relation "lineitem_alter_103009" does not exist ERROR: could not execute DDL command on worker node shards ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS non_existent_column; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 NOTICE: column "non_existent_column" of relation "lineitem_alter" does not exist, skipping ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS int_column2; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -548,24 +291,6 @@ DEBUG: applied command on shard 103000 on node localhost:57637 -- Verify that we can execute commands with multiple subcommands ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER, ADD COLUMN int_column2 INTEGER; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -595,24 +320,6 @@ ALTER TABLE lineitem_alter ADD COLUMN int_column3 INTEGER, ERROR: alter table command is currently supported DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT and TYPE subcommands are supported. ALTER TABLE lineitem_alter DROP COLUMN int_column1, DROP COLUMN int_column2; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 \d lineitem_alter Table "public.lineitem_alter" Column | Type | Modifiers @@ -704,8 +411,48 @@ ERROR: renaming distributed tables or their objects is currently unsupported l_comment | character varying(44) | not null null_column | integer | +-- Check that the schema on the worker still looks reasonable +\c - - - :worker_1_port +SELECT attname, atttypid::regtype +FROM + (SELECT oid FROM pg_class WHERE relname LIKE 'lineitem_alter_%' ORDER BY relname LIMIT 1) pc + JOIN pg_attribute ON (pc.oid = pg_attribute.attrelid) +ORDER BY attnum; + attname | atttypid +-------------------------------+------------------- + tableoid | oid + cmax | cid + xmax | xid + cmin | cid + xmin | xid + ctid | tid + l_orderkey | bigint + l_partkey | integer + l_suppkey | integer + l_linenumber | integer + l_quantity | numeric + l_extendedprice | numeric + l_discount | numeric + l_tax | numeric + l_returnflag | character + l_linestatus | character + l_shipdate | date + l_commitdate | date + l_receiptdate | date + l_shipinstruct | character + l_shipmode | character + l_comment | character varying + ........pg.dropped.17........ | - + ........pg.dropped.18........ | - + ........pg.dropped.19........ | - + ........pg.dropped.20........ | - + null_column | integer + ........pg.dropped.22........ | - + ........pg.dropped.23........ | - +(29 rows) + +\c - - - :master_port -- Cleanup the table and its shards -RESET client_min_messages; SELECT master_apply_delete_command('DELETE FROM lineitem_alter'); master_apply_delete_command ----------------------------- @@ -713,3 +460,11 @@ SELECT master_apply_delete_command('DELETE FROM lineitem_alter'); (1 row) DROP TABLE lineitem_alter; +-- check that nothing's left over on workers +\c - - - :worker_1_port +SELECT relname FROM pg_class WHERE relname LIKE 'lineitem_alter%'; + relname +--------- +(0 rows) + +\c - - - :master_port diff --git a/src/test/regress/output/multi_alter_table_statements_0.source b/src/test/regress/output/multi_alter_table_statements_0.source deleted file mode 100644 index 0d13a8ee425..00000000000 --- a/src/test/regress/output/multi_alter_table_statements_0.source +++ /dev/null @@ -1,726 +0,0 @@ --- --- MULTI_ALTER_TABLE_STATEMENTS --- --- Check that we can run ALTER TABLE statements on distributed tables. We --- increase the logging verbosity to verify that commands are propagated to --- all worker shards. We also set the shardid sequence here so that the shardids --- in this test aren't affected by changes to the previous tests. -ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 103000; -CREATE TABLE lineitem_alter ( - l_orderkey bigint not null, - l_partkey integer not null, - l_suppkey integer not null, - l_linenumber integer not null, - l_quantity decimal(15, 2) not null, - l_extendedprice decimal(15, 2) not null, - l_discount decimal(15, 2) not null, - l_tax decimal(15, 2) not null, - l_returnflag char(1) not null, - l_linestatus char(1) not null, - l_shipdate date not null, - l_commitdate date not null, - l_receiptdate date not null, - l_shipinstruct char(25) not null, - l_shipmode char(10) not null, - l_comment varchar(44) not null - ); -SELECT master_create_distributed_table('lineitem_alter', 'l_orderkey', 'append'); - master_create_distributed_table ---------------------------------- - -(1 row) - -\STAGE lineitem_alter FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -SET client_min_messages TO DEBUG2; --- Verify that we can add columns -ALTER TABLE lineitem_alter ADD COLUMN float_column FLOAT; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -ALTER TABLE lineitem_alter ADD COLUMN date_column DATE; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER DEFAULT 1; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerTableRewrite(17676) -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17676 -DEBUG: drop auto-cascades to type pg_temp_17676[] -ALTER TABLE lineitem_alter ADD COLUMN int_column2 INTEGER DEFAULT 2; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerTableRewrite(17676) -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17676 -DEBUG: drop auto-cascades to type pg_temp_17676[] -ALTER TABLE lineitem_alter ADD COLUMN null_column INTEGER; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - float_column | double precision | - date_column | date | - int_column1 | integer | default 1 - int_column2 | integer | default 2 - null_column | integer | - -SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column; - float_column | count ---------------+------- - | 6000 -(1 row) - -SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1; - int_column1 | count --------------+------- - 1 | 6000 -(1 row) - --- Verify that SET|DROP DEFAULT works -ALTER TABLE lineitem_alter ALTER COLUMN float_column SET DEFAULT 1; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -ALTER TABLE lineitem_alter ALTER COLUMN int_column1 DROP DEFAULT; -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerInvoke 16541 --- \stage to verify that default values take effect -\STAGE lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -DEBUG: parse : SELECT * FROM master_get_table_metadata($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_table_ddl_events($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column; - float_column | count ---------------+------- - | 6000 - 1 | 6000 -(2 rows) - -SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1; - int_column1 | count --------------+------- - | 6000 - 1 | 6000 -(2 rows) - --- Verify that SET NOT NULL works -ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET NOT NULL; -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: verifying table "lineitem_alter" -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+-------------------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - float_column | double precision | default 1 - date_column | date | - int_column1 | integer | - int_column2 | integer | not null default 2 - null_column | integer | - --- Drop default so that NULLs will be inserted for this column -ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT; -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerInvoke 16541 --- \stage should fail because it will try to insert NULLs for a NOT NULL column -\STAGE lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -DEBUG: parse : SELECT * FROM master_get_table_metadata($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_table_ddl_events($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -ERROR: null value in column "int_column2" violates not-null constraint -DETAIL: Failing row contains (1, 155190, 7706, 1, 17.00, 21168.23, 0.04, 0.02, N, O, 03-13-1996, 02-12-1996, 03-22-1996, DELIVER IN PERSON , TRUCK , egular courts above the, 1, null, null, null, null). -CONTEXT: COPY lineitem_alter_103006, line 1: "1|155190|7706|1|17|21168.23|0.04|0.02|N|O|1996-03-13|1996-02-12|1996-03-22|DELIVER IN PERSON|TRUCK|e..." -ERROR: null value in column "int_column2" violates not-null constraint -DETAIL: Failing row contains (1, 155190, 7706, 1, 17.00, 21168.23, 0.04, 0.02, N, O, 03-13-1996, 02-12-1996, 03-22-1996, DELIVER IN PERSON , TRUCK , egular courts above the, 1, null, null, null, null). -CONTEXT: COPY lineitem_alter_103006, line 1: "1|155190|7706|1|17|21168.23|0.04|0.02|N|O|1996-03-13|1996-02-12|1996-03-22|DELIVER IN PERSON|TRUCK|e..." -\stage: failed to replicate shard to enough replicas --- Verify that DROP NOT NULL works -ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL; -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - float_column | double precision | default 1 - date_column | date | - int_column1 | integer | - int_column2 | integer | - null_column | integer | - --- \stage should succeed now -\STAGE lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|' -DEBUG: parse : SELECT * FROM master_get_table_metadata($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_table_ddl_events($1::text) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_new_shardid() -DEBUG: bind to -DEBUG: parse : SELECT * FROM master_get_round_robin_candidate_nodes($1::int8) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ($1::oid, $2::int8, $3::char, $4::text, $5::text) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -DEBUG: parse : INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename, nodeport) VALUES ($1::int8, $2::int4, $3::int8, $4::text, $5::int4) -DEBUG: bind to -SELECT count(*) from lineitem_alter; - count -------- - 18000 -(1 row) - --- Verify that SET DATA TYPE works -SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2; - int_column2 | pg_typeof | count --------------+-----------+------- - | integer | 6000 - 2 | integer | 12000 -(2 rows) - -ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE FLOAT; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerTableRewrite(17676) -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17676 -DEBUG: drop auto-cascades to type pg_temp_17676[] -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - float_column | double precision | default 1 - date_column | date | - int_column1 | integer | - int_column2 | double precision | - null_column | integer | - -SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2; - int_column2 | pg_typeof | count --------------+------------------+------- - | double precision | 6000 - 2 | double precision | 12000 -(2 rows) - --- Verify that DROP COLUMN works -ALTER TABLE lineitem_alter DROP COLUMN int_column1; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerInvoke 16541 -ALTER TABLE lineitem_alter DROP COLUMN float_column; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: drop auto-cascades to default for table lineitem_alter column float_column -DEBUG: EventTriggerInvoke 16541 -ALTER TABLE lineitem_alter DROP COLUMN date_column; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerInvoke 16541 --- Verify that IF EXISTS works as expected -ALTER TABLE non_existent_table ADD COLUMN new_column INTEGER; -ERROR: relation "non_existent_table" does not exist -ALTER TABLE IF EXISTS non_existent_table ADD COLUMN new_column INTEGER; -NOTICE: relation "non_existent_table" does not exist, skipping -ALTER TABLE IF EXISTS lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE INTEGER; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerTableRewrite(17676) -DEBUG: rewriting table "lineitem_alter" -DEBUG: drop auto-cascades to type pg_temp_17676 -DEBUG: drop auto-cascades to type pg_temp_17676[] -ALTER TABLE lineitem_alter DROP COLUMN non_existent_column; -WARNING: could not receive query results from localhost:57637 -DETAIL: Client error: column "non_existent_column" of relation "lineitem_alter_103009" does not exist -ERROR: could not execute DDL command on worker node shards -ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS non_existent_column; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -NOTICE: column "non_existent_column" of relation "lineitem_alter" does not exist, skipping -ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS int_column2; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerInvoke 16541 -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - null_column | integer | - --- Verify that we can execute commands with multiple subcommands -ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER, - ADD COLUMN int_column2 INTEGER; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - null_column | integer | - int_column1 | integer | - int_column2 | integer | - -ALTER TABLE lineitem_alter ADD COLUMN int_column3 INTEGER, - ALTER COLUMN int_column1 SET STATISTICS 10; -ERROR: alter table command is currently supported -DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT and TYPE subcommands are supported. -ALTER TABLE lineitem_alter DROP COLUMN int_column1, DROP COLUMN int_column2; -DEBUG: applied command on shard 103009 on node localhost:57637 -DEBUG: applied command on shard 103009 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57638 -DEBUG: applied command on shard 103008 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57637 -DEBUG: applied command on shard 103007 on node localhost:57638 -DEBUG: applied command on shard 103005 on node localhost:57637 -DEBUG: applied command on shard 103005 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57638 -DEBUG: applied command on shard 103004 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57637 -DEBUG: applied command on shard 103003 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57638 -DEBUG: applied command on shard 103002 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57637 -DEBUG: applied command on shard 103001 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57638 -DEBUG: applied command on shard 103000 on node localhost:57637 -DEBUG: EventTriggerInvoke 16541 -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - null_column | integer | - --- Verify that we cannot execute alter commands on the distribution column -ALTER TABLE lineitem_alter ALTER COLUMN l_orderkey DROP NOT NULL; -ERROR: cannot execute ALTER TABLE command involving partition column -ALTER TABLE lineitem_alter DROP COLUMN l_orderkey; -ERROR: cannot execute ALTER TABLE command involving partition column --- Verify that we error out on unsupported statement types -ALTER TABLE lineitem_alter ALTER COLUMN l_orderkey SET STATISTICS 100; -ERROR: alter table command is currently supported -DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT and TYPE subcommands are supported. -ALTER TABLE lineitem_alter DROP CONSTRAINT IF EXISTS non_existent_contraint; -ERROR: alter table command is currently supported -DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT and TYPE subcommands are supported. -ALTER TABLE lineitem_alter SET WITHOUT OIDS; -ERROR: alter table command is currently supported -DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT and TYPE subcommands are supported. --- Verify that we error out in case of postgres errors on supported statement --- types -ALTER TABLE lineitem_alter ADD COLUMN new_column non_existent_type; -WARNING: could not receive query results from localhost:57637 -DETAIL: Client error: type "non_existent_type" does not exist -ERROR: could not execute DDL command on worker node shards -ALTER TABLE lineitem_alter ALTER COLUMN null_column SET NOT NULL; -WARNING: could not receive query results from localhost:57637 -DETAIL: Client error: column "null_column" contains null values -ERROR: could not execute DDL command on worker node shards -ALTER TABLE lineitem_alter ALTER COLUMN l_partkey SET DEFAULT 'a'; -WARNING: could not receive query results from localhost:57637 -DETAIL: Client error: invalid input syntax for integer: "a" -ERROR: could not execute DDL command on worker node shards --- Verify that we error out on statements involving RENAME -ALTER TABLE lineitem_alter RENAME TO lineitem_renamed; -ERROR: renaming distributed tables or their objects is currently unsupported -ALTER TABLE lineitem_alter RENAME COLUMN l_orderkey TO l_orderkey_renamed; -ERROR: renaming distributed tables or their objects is currently unsupported -ALTER TABLE lineitem_alter RENAME CONSTRAINT constraint_a TO constraint_b; -ERROR: renaming distributed tables or their objects is currently unsupported --- Verify that IF EXISTS works as expected with RENAME statements -ALTER TABLE non_existent_table RENAME TO non_existent_table_renamed; -ERROR: relation "non_existent_table" does not exist -ALTER TABLE IF EXISTS non_existent_table RENAME TO non_existent_table_renamed; -NOTICE: relation "non_existent_table" does not exist, skipping -ALTER TABLE IF EXISTS non_existent_table RENAME COLUMN column1 TO column2; -NOTICE: relation "non_existent_table" does not exist, skipping -ALTER TABLE IF EXISTS lineitem_alter RENAME l_orderkey TO l_orderkey_renamed; -ERROR: renaming distributed tables or their objects is currently unsupported --- Verify that none of the failed alter table commands took effect on the master --- node -\d lineitem_alter - Table "public.lineitem_alter" - Column | Type | Modifiers ------------------+-----------------------+----------- - l_orderkey | bigint | not null - l_partkey | integer | not null - l_suppkey | integer | not null - l_linenumber | integer | not null - l_quantity | numeric(15,2) | not null - l_extendedprice | numeric(15,2) | not null - l_discount | numeric(15,2) | not null - l_tax | numeric(15,2) | not null - l_returnflag | character(1) | not null - l_linestatus | character(1) | not null - l_shipdate | date | not null - l_commitdate | date | not null - l_receiptdate | date | not null - l_shipinstruct | character(25) | not null - l_shipmode | character(10) | not null - l_comment | character varying(44) | not null - null_column | integer | - --- Cleanup the table and its shards -RESET client_min_messages; -SELECT master_apply_delete_command('DELETE FROM lineitem_alter'); - master_apply_delete_command ------------------------------ - 9 -(1 row) - -DROP TABLE lineitem_alter; diff --git a/src/test/regress/sql/multi_index_statements.sql b/src/test/regress/sql/multi_index_statements.sql index a9a4506ff96..f6032761396 100644 --- a/src/test/regress/sql/multi_index_statements.sql +++ b/src/test/regress/sql/multi_index_statements.sql @@ -3,10 +3,7 @@ -- -- Check that we can run CREATE INDEX and DROP INDEX statements on distributed --- tables. We increase the logging verbosity to verify that commands are --- propagated to all worker shards. - -SET client_min_messages TO DEBUG2; +-- tables. -- -- CREATE INDEX @@ -21,10 +18,15 @@ CREATE INDEX lineitem_partkey_desc_index ON lineitem (l_partkey DESC); CREATE INDEX lineitem_partial_index ON lineitem (l_shipdate) WHERE l_shipdate < '1995-01-01'; +SET client_min_messages = ERROR; -- avoid version dependant warning about WAL CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey); +RESET client_min_messages; --- Verify that all indexes got created on the master node +-- Verify that all indexes got created on the master node and one of the workers SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; +\c - - - :worker_1_port +SELECT count(*) FROM pg_indexes WHERE tablename = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1); +\c - - - :master_port -- Verify that we error out on unsupported statement types @@ -65,6 +67,9 @@ DROP INDEX IF EXISTS non_existent_index; DROP INDEX IF EXISTS lineitem_orderkey_hash_index; DROP INDEX lineitem_orderkey_hash_index; --- Verify that all the indexes are also dropped from the master node -SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname; - +-- Verify that all the indexes are dropped from the master and one worker node. +-- As there's a primary key, so exclude those from this check. +SELECT indrelid::regclass, indexrelid::regclass FROM pg_index WHERE indrelid = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1)::regclass AND NOT indisprimary AND indexrelid::regclass::text NOT LIKE 'lineitem_time_index%'; +\c - - - :worker_1_port +SELECT indrelid::regclass, indexrelid::regclass FROM pg_index WHERE indrelid = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1)::regclass AND NOT indisprimary AND indexrelid::regclass::text NOT LIKE 'lineitem_time_index%';; +\c - - - :master_port