Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/backend/access/common/reloptions_gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "utils/memutils.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "storage/gp_compress.h"

/*
* Helper macro used for validation
Expand Down Expand Up @@ -960,12 +961,12 @@ validate_and_adjust_options(StdRdOptions *result,

if (result->compresstype[0] &&
(pg_strcasecmp(result->compresstype, "rle_type") == 0) &&
(result->compresslevel > 4))
(result->compresslevel > RLE_MAX_LEVEL))
{
if (validate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range for rle_type (should be in the range 1 to 4)",
errmsg("compresslevel=%d is out of range for rle_type (should be in the range 1 to 6)",
result->compresslevel)));

result->compresslevel = setDefaultCompressionLevel(result->compresstype);
Expand Down
12 changes: 12 additions & 0 deletions src/backend/utils/datumstream/datumstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,19 @@ init_datumstream_info(
ao_attr->compressType = "zlib";
ao_attr->compressLevel = 9;
break;
#ifdef HAVE_LIBZSTD
case 5:
ao_attr->compress = true;
ao_attr->compressType = "zstd";
ao_attr->compressLevel = 1;
break;

case 6:
ao_attr->compress = true;
ao_attr->compressType = "zstd";
ao_attr->compressLevel = 3; /* zstd recommended default */
break;
#endif
default:
ereport(ERROR,
(errmsg("Unexpected compresslevel %d",
Expand Down
8 changes: 7 additions & 1 deletion src/include/storage/gp_compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ typedef struct
extern void zstd_free_context(zstd_context *context);
extern zstd_context *zstd_alloc_context(void);

#endif /* USE_ZSTD */
#define RLE_MAX_LEVEL (6)

#else

#define RLE_MAX_LEVEL (4)

#endif /* HAVE_LIBZSTD */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

Suggested change
#endif /* HAVE_LIBZSTD */
#endif /* USE_ZSTD */



#endif
7 changes: 3 additions & 4 deletions src/test/regress/expected/dsp.out
Original file line number Diff line number Diff line change
Expand Up @@ -561,17 +561,16 @@ create table co6(
a int encoding (compresstype=rle_type),
b float encoding (blocksize=8192))
distributed by (a);
ERROR: compresslevel=5 is out of range for rle_type (should be in the range 1 to 4)
create table co7(a int, b float,
default column encoding (compresstype=RLE_TYPE, compresslevel=7))
distributed by (a);
ERROR: compresslevel=7 is out of range for rle_type (should be in the range 1 to 4)
ERROR: compresslevel=7 is out of range for rle_type (should be in the range 1 to 6)
-- negative tests - session level set
set gp_default_storage_options = "compresstype=zlib,compresslevel=11";
ERROR: compresslevel=11 is out of range for zlib (should be in the range 1 to 9)
set gp_default_storage_options = "compresslevel=5,compresstype=RLE_TYPE";
ERROR: compresslevel=5 is out of range for rle_type (should be in the range 1 to 4)
set gp_default_storage_options = "compresslevel=1,compresstype=rle";
ERROR: rle_type cannot be used with Append Only relations row orientation
set gp_default_storage_options="compresslevel=1,compresstype=rle";
ERROR: unknown compresstype "rle"
set gp_default_storage_options = "checksum=1234";
ERROR: invalid bool value "1234" for storage option "checksum"
Expand Down
35 changes: 35 additions & 0 deletions src/test/regress/expected/rle.out
Original file line number Diff line number Diff line change
Expand Up @@ -11329,3 +11329,38 @@ insert into sml_rle_hdr values (-1,-1.1);
set client_min_messages=warning;
update sml_rle_hdr set b = b + 10 where a = -1;
commit;
-- Some smoke tests against rle's levels using zstd
create table co_rle_zstd1(i int encoding(compresstype=rle_type, compresslevel=5)) with (appendonly=true, orientation=column);
create table co_rle_zstd3(i int encoding(compresstype=rle_type, compresslevel=6)) with (appendonly=true, orientation=column);
\d+ co_rle_zstd1
Append-Only Columnar Table "public.co_rle_zstd1"
Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description
--------+---------+-----------+---------+--------------+------------------+-------------------+------------+-------------
i | integer | | plain | | rle_type | 5 | 32768 |
Checksum: t
Distributed by: (i)
Options: appendonly=true, orientation=column

\d+ co_rle_zstd3
Append-Only Columnar Table "public.co_rle_zstd3"
Column | Type | Modifiers | Storage | Stats target | Compression Type | Compression Level | Block Size | Description
--------+---------+-----------+---------+--------------+------------------+-------------------+------------+-------------
i | integer | | plain | | rle_type | 6 | 32768 |
Checksum: t
Distributed by: (i)
Options: appendonly=true, orientation=column

insert into co_rle_zstd1 select generate_series(1, 100000);
insert into co_rle_zstd3 select generate_series(1, 100000);
select count(distinct i) from co_rle_zstd1;
count
--------
100000
(1 row)

select count(distinct i) from co_rle_zstd3;
count
--------
100000
(1 row)

10 changes: 10 additions & 0 deletions src/test/regress/sql/rle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4851,3 +4851,13 @@ insert into sml_rle_hdr values (-1,-1.1);
set client_min_messages=warning;
update sml_rle_hdr set b = b + 10 where a = -1;
commit;

-- Some smoke tests against rle's levels using zstd
create table co_rle_zstd1(i int encoding(compresstype=rle_type, compresslevel=5)) with (appendonly=true, orientation=column);
create table co_rle_zstd3(i int encoding(compresstype=rle_type, compresslevel=6)) with (appendonly=true, orientation=column);
\d+ co_rle_zstd1
\d+ co_rle_zstd3
insert into co_rle_zstd1 select generate_series(1, 100000);
insert into co_rle_zstd3 select generate_series(1, 100000);
select count(distinct i) from co_rle_zstd1;
select count(distinct i) from co_rle_zstd3;
Loading