SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int > 11 AS version_above_eleven;
 version_above_eleven
---------------------------------------------------------------------
 t
(1 row)

SET citus.next_shard_id TO 20040000;
CREATE SCHEMA xact_enum_type;
SET search_path TO xact_enum_type;
SET citus.shard_count TO 4;
-- transaction block with simple type
BEGIN;
CREATE TYPE xact_enum_edit AS ENUM ('yes', 'no');
CREATE TABLE t1 (a int PRIMARY KEY, b xact_enum_edit);
SELECT create_distributed_table('t1','a');
 create_distributed_table
---------------------------------------------------------------------

(1 row)

INSERT INTO t1 VALUES (1, 'yes');
SELECT * FROM t1;
 a |  b
---------------------------------------------------------------------
 1 | yes
(1 row)

COMMIT;
BEGIN;
ALTER TYPE xact_enum_edit ADD VALUE 'maybe';
ABORT;
-- maybe should not be on the workers
SELECT string_agg(enumlabel, ',' ORDER BY enumsortorder ASC) FROM pg_enum WHERE enumtypid = 'xact_enum_type.xact_enum_edit'::regtype;
 string_agg
---------------------------------------------------------------------
 yes,no
(1 row)

SELECT run_command_on_workers($$SELECT string_agg(enumlabel, ',' ORDER BY enumsortorder ASC) FROM pg_enum WHERE enumtypid = 'xact_enum_type.xact_enum_edit'::regtype;$$);
    run_command_on_workers
---------------------------------------------------------------------
 (localhost,57637,t,"yes,no")
 (localhost,57638,t,"yes,no")
(2 rows)

BEGIN;
ALTER TYPE xact_enum_edit ADD VALUE 'maybe';
COMMIT;
-- maybe should be on the workers (pg12 and above)
SELECT string_agg(enumlabel, ',' ORDER BY enumsortorder ASC) FROM pg_enum WHERE enumtypid = 'xact_enum_type.xact_enum_edit'::regtype;
  string_agg
---------------------------------------------------------------------
 yes,no,maybe
(1 row)

SELECT run_command_on_workers($$SELECT string_agg(enumlabel, ',' ORDER BY enumsortorder ASC) FROM pg_enum WHERE enumtypid = 'xact_enum_type.xact_enum_edit'::regtype;$$);
       run_command_on_workers
---------------------------------------------------------------------
 (localhost,57637,t,"yes,no,maybe")
 (localhost,57638,t,"yes,no,maybe")
(2 rows)

-- clear objects
SET client_min_messages TO error; -- suppress cascading objects dropping
DROP SCHEMA xact_enum_type CASCADE;
SELECT run_command_on_workers($$DROP SCHEMA xact_enum_type CASCADE;$$);
      run_command_on_workers
---------------------------------------------------------------------
 (localhost,57637,t,"DROP SCHEMA")
 (localhost,57638,t,"DROP SCHEMA")
(2 rows)

