Skip to content

Commit

Permalink
Make GUC a boolean instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mkindahl committed Nov 12, 2024
1 parent d93b4ec commit a60ea0c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 47 deletions.
28 changes: 6 additions & 22 deletions src/guc.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ bool ts_guc_enable_custom_hashagg = false;
TSDLLEXPORT bool ts_guc_enable_compression_indexscan = false;
TSDLLEXPORT bool ts_guc_enable_bulk_decompression = true;
TSDLLEXPORT bool ts_guc_auto_sparse_indexes = true;
TSDLLEXPORT int ts_guc_default_hypercore_use_access_method = USE_AM_NULL;
TSDLLEXPORT bool ts_guc_default_hypercore_use_access_method = false;
bool ts_guc_enable_chunk_skipping = false;
TSDLLEXPORT bool ts_guc_enable_segmentwise_recompression = true;

Expand Down Expand Up @@ -415,20 +415,6 @@ ts_guc_default_orderby_fn_oid()
return get_orderby_func(ts_guc_default_orderby_fn);
}

/*
* Options for the default value of hypercore_use_access_method.
*
* We are following the conventions use by PostgreSQL and use "none" for the
* "unset" value.
*/
static const struct config_enum_entry useam_options[] = {
{ "none", USE_AM_NULL, false }, { "on", USE_AM_TRUE, false },
{ "off", USE_AM_FALSE, false }, { "true", USE_AM_TRUE, true },
{ "false", USE_AM_FALSE, true }, { "yes", USE_AM_TRUE, true },
{ "no", USE_AM_FALSE, true }, { "1", USE_AM_TRUE, true },
{ "0", USE_AM_FALSE, true }, { NULL, 0, false }
};

void
_guc_init(void)
{
Expand Down Expand Up @@ -1133,14 +1119,12 @@ _guc_init(void)
/* show_hook= */ NULL);
#endif

DefineCustomEnumVariable(MAKE_EXTOPTION("default_hypercore_use_access_method"),
gettext_noop(
"Enable to always use Hypercore TAM when compressing."),
gettext_noop(
"Sets the global default for using Hypercore TAM when compressing chunks."),
DefineCustomBoolVariable(MAKE_EXTOPTION("default_hypercore_use_access_method"),
gettext_noop("Enable to always use Hypercore TAM when compressing."),
gettext_noop("Sets the global default for using Hypercore TAM when "
"compressing chunks."),
&ts_guc_default_hypercore_use_access_method,
USE_AM_NULL,
/* options= */ useam_options,
false,
/* context= */ PGC_USERSET,
/* flags= */ 0,
/* check_hook= */ NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ extern TSDLLEXPORT DebugRequireOption ts_guc_debug_require_vector_agg;

extern TSDLLEXPORT bool ts_guc_debug_compression_path_info;
extern TSDLLEXPORT bool ts_guc_enable_rowlevel_compression_locking;
extern TSDLLEXPORT int ts_guc_default_hypercore_use_access_method;
extern TSDLLEXPORT bool ts_guc_default_hypercore_use_access_method;

extern TSDLLEXPORT bool ts_guc_debug_require_batch_sorted_merge;

Expand Down
2 changes: 2 additions & 0 deletions tsl/test/expected/hypercore.out
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ SELECT sum(_ts_meta_count) FROM :cchunk;

CALL recompress_chunk(:'chunk');
WARNING: procedure public.recompress_chunk(regclass,boolean) is deprecated and the functionality is now included in public.compress_chunk. this compatibility function will be removed in a future version.
NOTICE: cannot compress hypercore "_hyper_1_1_chunk" using heap, recompressing instead
-- Data should be returned even after recompress, but now from the
-- compressed relation. Still using index scan.
EXPLAIN (verbose, costs off)
Expand Down Expand Up @@ -575,6 +576,7 @@ SELECT * FROM :chunk WHERE time = '2022-06-01 00:06:15'::timestamptz;
-- Can't recompress twice without new non-compressed rows
CALL recompress_chunk(:'chunk');
WARNING: procedure public.recompress_chunk(regclass,boolean) is deprecated and the functionality is now included in public.compress_chunk. this compatibility function will be removed in a future version.
NOTICE: cannot compress hypercore "_hyper_1_1_chunk" using heap, recompressing instead
NOTICE: chunk "_hyper_1_1_chunk" is already compressed
\set ON_ERROR_STOP 1
-- Compressed count after recompression
Expand Down
19 changes: 3 additions & 16 deletions tsl/test/expected/hypercore_create.out
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ select ctid from :chunk where created_at = '2022-06-01 10:01' and device_id = 6;
(1 row)

select compress_chunk(:'chunk');
NOTICE: cannot compress hypercore "_hyper_1_1_chunk" using heap, recompressing instead
compress_chunk
----------------------------------------
_timescaledb_internal._hyper_1_1_chunk
Expand Down Expand Up @@ -925,7 +926,7 @@ select * from rides order by pickup_datetime;
show timescaledb.default_hypercore_use_access_method;
timescaledb.default_hypercore_use_access_method
-------------------------------------------------
none
off
(1 row)

set timescaledb.default_hypercore_use_access_method to on;
Expand All @@ -942,26 +943,12 @@ show timescaledb.default_hypercore_use_access_method;
on
(1 row)

-- This should generate an error and not change the value
\set ON_ERROR_STOP 0
\set VERBOSITY default
set timescaledb.default_hypercore_use_access_method to magic;
ERROR: invalid value for parameter "timescaledb.default_hypercore_use_access_method": "magic"
HINT: Available values: none, on, off.
show timescaledb.default_hypercore_use_access_method;
timescaledb.default_hypercore_use_access_method
-------------------------------------------------
on
(1 row)

\set VERBOSITY terse
\set ON_ERROR_STOP 1
-- This should unset the value
reset timescaledb.default_hypercore_use_access_method;
show timescaledb.default_hypercore_use_access_method;
timescaledb.default_hypercore_use_access_method
-------------------------------------------------
none
off
(1 row)

-- Using GUC should compress using the hyperstore
Expand Down
2 changes: 2 additions & 0 deletions tsl/test/expected/hypercore_vacuum.out
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ insert into hystable (time, location, device, temp)
values ('2022-06-01 00:01', 1, 1, 1.0);
-- Recompress to get data back into compressed form
select compress_chunk(:'hystable_chunk');
NOTICE: cannot compress hypercore "_hyper_1_2_chunk" using heap, recompressing instead
compress_chunk
----------------------------------------
_timescaledb_internal._hyper_1_2_chunk
Expand Down Expand Up @@ -310,6 +311,7 @@ select tuple_count from pgstattuple(:'hystable_device_chunk_idx');
-- rebuild indexes. It will optimize the structure of the index and
-- thus reduce the number of index tuples
select compress_chunk(:'hystable_chunk');
NOTICE: cannot compress hypercore "_hyper_1_2_chunk" using heap, recompressing instead
compress_chunk
----------------------------------------
_timescaledb_internal._hyper_1_2_chunk
Expand Down
8 changes: 0 additions & 8 deletions tsl/test/sql/hypercore_create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,6 @@ set timescaledb.default_hypercore_use_access_method to 0;
set timescaledb.default_hypercore_use_access_method to 1;
show timescaledb.default_hypercore_use_access_method;

-- This should generate an error and not change the value
\set ON_ERROR_STOP 0
\set VERBOSITY default
set timescaledb.default_hypercore_use_access_method to magic;
show timescaledb.default_hypercore_use_access_method;
\set VERBOSITY terse
\set ON_ERROR_STOP 1

-- This should unset the value
reset timescaledb.default_hypercore_use_access_method;
show timescaledb.default_hypercore_use_access_method;
Expand Down

0 comments on commit a60ea0c

Please sign in to comment.