Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Adding column to compressed table fails if NULL is used as constraint #5151

Closed
ikkala opened this issue Jan 5, 2023 · 2 comments · Fixed by #5152
Closed

[Bug]: Adding column to compressed table fails if NULL is used as constraint #5151

ikkala opened this issue Jan 5, 2023 · 2 comments · Fixed by #5152

Comments

@ikkala
Copy link

ikkala commented Jan 5, 2023

What type of bug is this?

Incorrect result, Unexpected error

What subsystems and features are affected?

Command processing, Compression

What happened?

Following error occur in case of the following statement:

ALTER TABLE table1 ADD COLUMN column1 jsonb NULL;

ERROR: cannot add column with constraints to a hypertable that has compression enabled

On the other hand, following works:
ALTER TABLE table1 ADD COLUMN column1 jsonb;

TimescaleDB version affected

2.8.1

PostgreSQL version used

13.9

What operating system did you use?

Docker image timescale/timescaledb-ha:pg13.9-ts2.8.1-p3

What installation method did you use?

Docker

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

No response

How can we reproduce the bug?

CREATE TABLE "table1" (
  "ts" timestamptz NOT NULL,
  "column0" bigint NULL
);
SELECT create_hypertable(
  'table1',
  'ts'
);

ALTER TABLE table1 SET (
  timescaledb.compress
);
SELECT add_compression_policy('table1', INTERVAL '1d');

-- The following fails:
ALTER TABLE table1 ADD COLUMN column1 jsonb NULL;
@ikkala ikkala added the bug label Jan 5, 2023
@fabriziomello
Copy link
Contributor

Good catch @ikkala! Thanks for reporting, providing a fix for it!

@fabriziomello fabriziomello self-assigned this Jan 5, 2023
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Jan 5, 2023
Adding new column with NULL constraint to a compressed hypertable is
raising an error but it make no sense because NULL constraints in
Postgres does nothing, I mean it is useless and exist just for
compatibility with other database systems:
https://www.postgresql.org/docs/current/ddl-constraints.html#id-1.5.4.6.6

Fixed it by ignoring the NULL constraints when we check for `ALTER TABLE
.. ADD COLUMN ..` to a compressed hypertable.

Fixes timescale#5151
fabriziomello added a commit to fabriziomello/timescaledb that referenced this issue Jan 5, 2023
Adding new column with NULL constraint to a compressed hypertable is
raising an error but it make no sense because NULL constraints in
Postgres does nothing, I mean it is useless and exist just for
compatibility with other database systems:
https://www.postgresql.org/docs/current/ddl-constraints.html#id-1.5.4.6.6

Fixed it by ignoring the NULL constraints when we check for `ALTER TABLE
.. ADD COLUMN ..` to a compressed hypertable.

Fixes timescale#5151
@ikkala
Copy link
Author

ikkala commented Jan 6, 2023

Thanks! Background, why this popped up in the first place: I use DBeaver sometimes to generate DDL for changes like the ones in this issue, and DBeaver by default put that dummy NULL there.

fabriziomello added a commit that referenced this issue Jan 6, 2023
Adding new column with NULL constraint to a compressed hypertable is
raising an error but it make no sense because NULL constraints in
Postgres does nothing, I mean it is useless and exist just for
compatibility with other database systems:
https://www.postgresql.org/docs/current/ddl-constraints.html#id-1.5.4.6.6

Fixed it by ignoring the NULL constraints when we check for `ALTER TABLE
.. ADD COLUMN ..` to a compressed hypertable.

Fixes #5151
sb230132 pushed a commit that referenced this issue Jan 23, 2023
Adding new column with NULL constraint to a compressed hypertable is
raising an error but it make no sense because NULL constraints in
Postgres does nothing, I mean it is useless and exist just for
compatibility with other database systems:
https://www.postgresql.org/docs/current/ddl-constraints.html#id-1.5.4.6.6

Fixed it by ignoring the NULL constraints when we check for `ALTER TABLE
.. ADD COLUMN ..` to a compressed hypertable.

Fixes #5151
sb230132 pushed a commit that referenced this issue Jan 24, 2023
Adding new column with NULL constraint to a compressed hypertable is
raising an error but it make no sense because NULL constraints in
Postgres does nothing, I mean it is useless and exist just for
compatibility with other database systems:
https://www.postgresql.org/docs/current/ddl-constraints.html#id-1.5.4.6.6

Fixed it by ignoring the NULL constraints when we check for `ALTER TABLE
.. ADD COLUMN ..` to a compressed hypertable.

Fixes #5151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants