setval() relation does not exist for reference tables
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
Hi,
Running this works: (distributed_table)
```
CREATE TABLE accounts (
id serial PRIMARY KEY,
username VARCHAR ( 50 ) NOT NULL DEFAULT ('boz')
);
SELECT setval(pg_get_serial_sequence('"accounts"', 'id'), coalesce(max("id"), 1), max("id") IS NOT null) from accounts;
SELECT create_distributed_table('accounts', 'id');
SELECT setval(pg_get_serial_sequence('"accounts"', 'id'), coalesce(max("id"), 1), max("id") IS NOT null) from accounts;
DROP TABLE accounts;
```
But running this doesn't: (reference_table)
```
CREATE TABLE accounts (
id serial PRIMARY KEY,
username VARCHAR ( 50 ) NOT NULL DEFAULT ('boz')
);
SELECT setval(pg_get_serial_sequence('"accounts"', 'id'), coalesce(max("id"), 1), max("id") IS NOT null) from accounts;
SELECT create_reference_table('accounts');
SELECT setval(pg_get_serial_sequence('"accounts"', 'id'), coalesce(max("id"), 1), max("id") IS NOT null) from accounts;
DROP TABLE accounts;
```
```
[42P01] ERROR: relation "accounts" does not exist
```
Why am I running this specific SQL query? because [Django](https://github.com/django/django/blob/806efe912b846c1fde250c9321d8334b7517cd56/django/db/backends/postgresql/operations.py#L175)
Am I missing something? or have I found a bug in citus? or is this a limitation of some kind?
P.S: Tested on citus verions 10.1.2 and 10.2.3
Contributor guide
Assessment
This issue has not been assessed yet.