Fix ALTER TABLE SET with normal tables

Running ALTER TABLE SET with multiple SET clauses on a regular PostgreSQL table
produces irrelevant error when timescaledb extension is installed.

Fix #5641
This commit is contained in:
Dmitry Simonenko 2023-05-04 14:54:27 +03:00 committed by Dmitry Simonenko
parent 9259311275
commit 8ca17e704c
4 changed files with 27 additions and 7 deletions

View File

@ -32,6 +32,7 @@ accidentally triggering the load of a previous DB version.**
* #5578 Fix on-insert decompression after schema changes
* #5613 Quote username identifier appropriately
* #5525 Fix tablespace for compressed hypertable and corresponding toast
* #5642 Fix ALTER TABLE SET with normal tables
**Thanks**
* @kovetskiy and @DZDomi for reporting peformance regression in Realtime Continuous Aggregates

View File

@ -3411,6 +3411,8 @@ process_altertable_start_table(ProcessUtilityArgs *args)
break;
}
case AT_SetRelOptions:
{
if (ht != NULL)
{
if (num_cmds != 1)
{
@ -3419,8 +3421,6 @@ process_altertable_start_table(ProcessUtilityArgs *args)
errmsg("ALTER TABLE <hypertable> SET does not support multiple "
"clauses")));
}
if (ht != NULL)
{
EventTriggerAlterTableStart(args->parsetree);
result = process_altertable_set_options(cmd, ht);
}

View File

@ -22,6 +22,10 @@ WHERE relname ~ '^_hyper.*' AND relkind = 'r';
-- Alter reloptions
ALTER TABLE reloptions_test SET (fillfactor=80, parallel_workers=8);
\set ON_ERROR_STOP 0
ALTER TABLE reloptions_test SET (fillfactor=80), SET (parallel_workers=8);
ERROR: ALTER TABLE <hypertable> SET does not support multiple clauses
\set ON_ERROR_STOP 1
SELECT relname, reloptions FROM pg_class
WHERE relname ~ '^_hyper.*' AND relkind = 'r';
relname | reloptions
@ -39,3 +43,8 @@ WHERE relname ~ '^_hyper.*' AND relkind = 'r';
_hyper_1_2_chunk | {autovacuum_vacuum_threshold=100,parallel_workers=8}
(2 rows)
-- Test reloptions on a regular table
CREATE TABLE reloptions_test2(time integer, temp float8, color integer);
ALTER TABLE reloptions_test2 SET (fillfactor=80, parallel_workers=8);
ALTER TABLE reloptions_test2 SET (fillfactor=80), SET (parallel_workers=8);
DROP TABLE reloptions_test2;

View File

@ -16,6 +16,10 @@ WHERE relname ~ '^_hyper.*' AND relkind = 'r';
-- Alter reloptions
ALTER TABLE reloptions_test SET (fillfactor=80, parallel_workers=8);
\set ON_ERROR_STOP 0
ALTER TABLE reloptions_test SET (fillfactor=80), SET (parallel_workers=8);
\set ON_ERROR_STOP 1
SELECT relname, reloptions FROM pg_class
WHERE relname ~ '^_hyper.*' AND relkind = 'r';
@ -23,3 +27,9 @@ ALTER TABLE reloptions_test RESET (fillfactor);
SELECT relname, reloptions FROM pg_class
WHERE relname ~ '^_hyper.*' AND relkind = 'r';
-- Test reloptions on a regular table
CREATE TABLE reloptions_test2(time integer, temp float8, color integer);
ALTER TABLE reloptions_test2 SET (fillfactor=80, parallel_workers=8);
ALTER TABLE reloptions_test2 SET (fillfactor=80), SET (parallel_workers=8);
DROP TABLE reloptions_test2;