citusdata / citusdata/citus

Altering (`ENUM`) types fails with err 57014

Open
#5,117 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Suppose we have an ENUM type:

```sql
CREATE TYPE RELEASE_PROCESSES AS ENUM ('MAIN', 'SECONDARY');
```

which we use in a reference table:

```sql
CREATE TABLE IF NOT EXISTS release_category
(
release_id INT NOT NULL,
process_name RELEASE_PROCESSES NOT NULL,
PRIMARY KEY (release_id, process_name),
FOREIGN KEY ( release_id )
REFERENCES release_reference ( id )
ON UPDATE CASCADE
ON DELETE CASCADE
);

SELECT create_reference_table('release_category');
```

with a bunch of data already in the table.

Now, if we attempt to update the ENUM, say to add a new item or alter something, we could do something like this:

```sql
BEGIN;

ALTER TYPE RELEASE_PROCESSES RENAME TO RELEASE_PROCESSES_OLD;

CREATE TYPE RELEASE_PROCESSES AS ENUM('MAIN', 'SECONDARY', 'OTHER');

ALTER TABLE release_category
ALTER COLUMN process_name
TYPE RELEASE_PROCESSES
USING process_name::TEXT::RELEASE_PROCESSES;

COMMIT;
```

This will throw an error saying:

```
[57014] ERROR: canceling statement due to user request
```

I tried running this sequentially too - though it shouldn't really matter on a ref table - using the following commands, but the same thing happened:

```sql
SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
SET LOCAL citus.max_adaptive_executor_pool_size TO 1;
```

It may, however, be noteworthy to mention that it does work for adding stuff if I run it as follows:

```sql
ALTER TYPE RELEASE_PROCESSES ADD VALUE 'OTHER';
```
but not in the initial format, which means we can't really alter existing values.

---

## Supplementary info:

**Postgres version**:
```
PostgreSQL 11.10 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, 64-bit
```

**Platform**:
```
Azure Database for PostgreSQL - Hyperscale
```

**Citus version**:
```
Citus Enterprise 9.4.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, 64-bit gitref: v9.4.2
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.