提交 724f9d27 编写于 作者: I Ivan Leskin 提交者: Heikki Linnakangas

Add Zstandard compression option for append-optimized tables.

Add a new compression option for append-optimized tables, "zstd". It is
generally faster than zlib or quicklz, and compresses better. Or at least
it can be faster or compress better, if not both at the same time, by
adjusting the compression level. A major advantage of Zstandard is the wide
range of tuning, to choose the trade-off between compression speed and
ratio.

Update documentation to mention "zstd" alongside "zlib" and "quicklz". More
could be done; all the examples still use zlib or quicklz, for example, and
I think we want to emphasize Zstandard more in the docs, over those other
options. But this is the bare minimum to keep the docs factually correct.

Using the new option requires building the server with the libzstd library.
A new --with-zstd option is added for that. The default is to build without
libzstd, for now, but we should probably change the default to be on, after
we have had a chance to update all the buildfarm machines to have libzstd.

Patch by Ivan Leskin, Dmitriy Pavlov, Anton Chevychalov. Test case, docs
changes, and some minor editorialization by Heikki Linnakangas.
上级 b15e993f
......@@ -714,6 +714,7 @@ with_apu_config
with_apr_config
with_libcurl
with_rt
with_zstd
with_libbz2
with_zlib
with_system_tzdata
......@@ -892,6 +893,7 @@ with_libxslt
with_system_tzdata
with_zlib
with_libbz2
with_zstd
with_rt
with_libcurl
with_apr_config
......@@ -1607,6 +1609,7 @@ Optional Packages:
use system time zone data in DIR
--without-zlib do not use Zlib
--without-libbz2 do not use bzip2
--with-zstd build with Zstandard support (requires zstd library)
--without-rt do not use Realtime Library
--without-libcurl do not use libcurl
--with-apr-config=PATH path to apr-1-config utility
......@@ -8159,6 +8162,36 @@ fi
#
# zstd
#
pgac_args="$pgac_args with_zstd"
# Check whether --with-zstd was given.
if test "${with_zstd+set}" = set; then :
withval=$with_zstd;
case $withval in
yes)
:
;;
no)
:
;;
*)
as_fn_error $? "no argument expected for --with-zstd option" "$LINENO" 5
;;
esac
else
with_zstd=no
fi
#
# Realtime library
#
......@@ -10524,6 +10557,56 @@ fi
fi
if test "$with_zstd" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZSTD_compressCCtx in -lzstd" >&5
$as_echo_n "checking for ZSTD_compressCCtx in -lzstd... " >&6; }
if ${ac_cv_lib_zstd_ZSTD_compressCCtx+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lzstd $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char ZSTD_compressCCtx ();
int
main ()
{
return ZSTD_compressCCtx ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_zstd_ZSTD_compressCCtx=yes
else
ac_cv_lib_zstd_ZSTD_compressCCtx=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zstd_ZSTD_compressCCtx" >&5
$as_echo "$ac_cv_lib_zstd_ZSTD_compressCCtx" >&6; }
if test "x$ac_cv_lib_zstd_ZSTD_compressCCtx" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBZSTD 1
_ACEOF
LIBS="-lzstd $LIBS"
else
as_fn_error $? "zstd library not found." "$LINENO" 5
fi
fi
if test "$enable_spinlocks" = yes; then
$as_echo "#define HAVE_SPINLOCKS 1" >>confdefs.h
......@@ -13151,6 +13234,18 @@ else
fi
fi
# Check for zstd.h
if test "$with_zstd" = yes; then
ac_fn_c_check_header_mongrel "$LINENO" "zstd.h" "ac_cv_header_zstd_h" "$ac_includes_default"
if test "x$ac_cv_header_zstd_h" = xyes; then :
else
as_fn_error $? "header file <zstd.h> is required for zstd support" "$LINENO" 5
fi
fi
if test "$with_gssapi" = yes ; then
......@@ -18989,7 +19084,6 @@ fi
# error should be last step after all autoconf checks are performed, otherwise
# false side-effects happens.
if test "$GCC" = yes -a "$ICC" = no; then
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -Werror=uninitialized" >&5
$as_echo_n "checking if $CC supports -Werror=uninitialized... " >&6; }
pgac_save_CFLAGS=$CFLAGS
......
......@@ -1158,6 +1158,13 @@ PGAC_ARG_BOOL(with, libbz2, yes,
[do not use bzip2])
AC_SUBST(with_libbz2)
#
# zstd
#
PGAC_ARG_BOOL(with, zstd, no,
[build with Zstandard support (requires zstd library)])
AC_SUBST(with_zstd)
#
# Realtime library
#
......@@ -1344,6 +1351,11 @@ failure. It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.])])
fi
if test "$with_zstd" = yes; then
AC_CHECK_LIB(zstd, ZSTD_compressCCtx, [],
[AC_MSG_ERROR([zstd library not found.])])
fi
if test "$enable_spinlocks" = yes; then
AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
else
......@@ -1579,6 +1591,11 @@ if test "$with_libbz2" = yes ; then
AC_CHECK_HEADER(bzlib.h, [], [AC_MSG_ERROR([header file <bzlib.h> is required for bzip2 support])], [])
fi
# Check for zstd.h
if test "$with_zstd" = yes; then
AC_CHECK_HEADER(zstd.h, [], [AC_MSG_ERROR([header file <zstd.h> is required for zstd support])])
fi
if test "$with_gssapi" = yes ; then
AC_CHECK_HEADERS(gssapi/gssapi.h, [],
[AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
......
......@@ -173,13 +173,13 @@
<row>
<entry colname="col1">Row</entry>
<entry colname="col2">Table</entry>
<entry colname="col3"><codeph>ZLIB</codeph> and
<entry colname="col3"><codeph>ZLIB</codeph>, <codeph>ZSTD</codeph>, and
<codeph>QUICKLZ</codeph><sup>1</sup></entry>
</row>
<row>
<entry colname="col1">Column</entry>
<entry colname="col2">Column and Table</entry>
<entry colname="col3"><codeph>RLE_TYPE</codeph>, <codeph>ZLIB</codeph>, and
<entry colname="col3"><codeph>RLE_TYPE</codeph>, <codeph>ZLIB</codeph>, <codeph>ZSTD</codeph>, and
<codeph>QUICKLZ</codeph><sup>1</sup></entry>
</row>
</tbody>
......@@ -204,7 +204,8 @@
(<codeph>compresslevel=1</codeph>), QuickLZ and zlib have comparable compression
ratios, though at different speeds. Using zlib with <codeph>compresslevel=6</codeph> can
significantly increase the compression ratio compared to QuickLZ, though with lower
compression speed.</p></li>
compression speed. ZStandard compression can provide for either good compression ratio or
speed, depending on compression level, or a good compromise on both. </p></li>
<li id="im201783">Speed of decompression/scan rate. Performance with compressed
append-optimized tables depends on hardware, query tuning settings, and other factors.
Perform comparison testing to determine the actual performance in your
......@@ -216,7 +217,8 @@
<p>Performance with compressed append-optimized tables depends on hardware, query tuning
settings, and other factors. You should perform comparison testing to determine
the actual performance in your environment.</p>
<note type="note">QuickLZ compression level can only be set to level 1; no other options are
<note type="note">Zstd compression level can be set between 1 and 19.
QuickLZ compression level can only be set to level 1; no other options are
available. Compression level with zlib can be set at values from 1 - 9. Compression level
with RLE can be set at values from 1 - 4.<p>An <codeph>ENCODING</codeph> clause specifies
compression type and level for individual columns. When an <codeph>ENCODING</codeph>
......@@ -355,7 +357,8 @@
<codeph>COMPRESSTYPE</codeph>
</entry>
<entry colname="col2">Type of compression.</entry>
<entry colname="col3"><codeph>zlib: </codeph>deflate
<entry colname="col3"><codeph>zstd: </codeph>ZStandard
algorithm<p><codeph>zlib: </codeph>deflate
algorithm<p><codeph>quicklz</codeph>: fast
compression</p><p><codeph>RLE_TYPE</codeph>: run-length encoding
</p><p><codeph>none</codeph>: no compression</p></entry>
......@@ -367,9 +370,9 @@
</entry>
<entry colname="col2" morerows="2">Compression level.</entry>
<entry colname="col3"><codeph>zlib</codeph> compression:
<codeph>1</codeph>-<codeph>9</codeph></entry>
<codeph>1</codeph>-<codeph>19</codeph></entry>
<entry colname="col4"><codeph>1</codeph> is the fastest method with the least
compression. <codeph>1</codeph> is the default.<p><codeph>9</codeph> is the slowest
compression. <codeph>1</codeph> is the default.<p><codeph>19</codeph> is the slowest
method with the most compression.</p></entry>
</row>
<row>
......
......@@ -130,7 +130,7 @@
compression. </p>
<p>Data compression should never be used for data that is stored on a compressed file system. </p>
<p>Test different compression types and ordering methods to determine the best compression for
your specific data. For example, you might start zlib compression at level 4 or 5 and adjust
your specific data. For example, you might start zstd compression at level 4 or 5 and adjust
for best results. RLE compression works best with files that contain repetitive data.</p>
</body>
</topic>
......
......@@ -2940,10 +2940,11 @@
2097152 </p><p><cmdname>CHECKSUM</cmdname>= <codeph>TRUE</codeph> |
<codeph>FALSE</codeph>
</p><p><cmdname>COMPRESSTYPE</cmdname>= <codeph>ZLIB</codeph> |
<codeph>ZSTD</codeph><sup>2</sup> |
<codeph>QUICKLZ</codeph><sup>2</sup> |
<codeph>RLE</codeph>_<codeph>TYPE</codeph> | <codeph>NONE</codeph>
</p><p><cmdname>COMPRESSLEVEL</cmdname>= integer between 0 and
9</p><p><cmdname>ORIENTATION</cmdname>= <codeph>ROW</codeph> |
19</p><p><cmdname>ORIENTATION</cmdname>= <codeph>ROW</codeph> |
<codeph>COLUMN</codeph>
</p></entry>
<entry colname="col2"><cmdname>APPENDONLY</cmdname>=<codeph>FALSE</codeph>
......
......@@ -100,7 +100,7 @@ ALTER TABLE <varname>name</varname>
<codeblock>   APPENDONLY={TRUE|FALSE}
   BLOCKSIZE={8192-2097152}
   ORIENTATION={COLUMN|ROW}
   COMPRESSTYPE={ZLIB|QUICKLZ|RLE_TYPE|NONE}
   COMPRESSTYPE={ZLIB|ZSTD|QUICKLZ|RLE_TYPE|NONE}
   COMPRESSLEVEL={0-9}
   FILLFACTOR={10-100}
   OIDS[=TRUE|FALSE]</codeblock>
......
......@@ -48,7 +48,7 @@
            [ key_match_type ]
            [ key_action ]</codeblock>
<p>where <varname>storage_directive</varname> for a column is:</p>
<codeblock> COMPRESSTYPE={ZLIB | QUICKLZ | RLE_TYPE | NONE}
<codeblock> COMPRESSTYPE={ZLIB | ZSTD | QUICKLZ | RLE_TYPE | NONE}
[COMPRESSLEVEL={0-9} ]
[BLOCKSIZE={8192-2097152} ]</codeblock>
<p>where <varname>storage_parameter</varname> for the table is:</p>
......@@ -56,7 +56,7 @@
   BLOCKSIZE={8192-2097152}
   ORIENTATION={COLUMN|ROW}
CHECKSUM={TRUE|FALSE}
   COMPRESSTYPE={ZLIB|QUICKLZ|RLE_TYPE|NONE}
   COMPRESSTYPE={ZLIB|ZSTD|QUICKLZ|RLE_TYPE|NONE}
   COMPRESSLEVEL={0-9}
   FILLFACTOR={10-100}
   OIDS[=TRUE|FALSE]</codeblock>
......@@ -126,7 +126,7 @@
   BLOCKSIZE={8192-2097152}
   ORIENTATION={COLUMN|ROW}
CHECKSUM={TRUE|FALSE}
  COMPRESSTYPE={ZLIB|QUICKLZ|RLE_TYPE|NONE}
  COMPRESSTYPE={ZLIB|ZSTD|QUICKLZ|RLE_TYPE|NONE}
   COMPRESSLEVEL={1-9}
   FILLFACTOR={10-100}
   OIDS[=TRUE|FALSE]</codeblock>
......@@ -384,11 +384,12 @@
checksum, the transaction is aborted. If you set the value to <codeph>FALSE</codeph> to
disable checksum validation, checking the table data for on-disk corruption will not be
performed.</pd>
<pd><b>COMPRESSTYPE</b> — Set to <codeph>ZLIB</codeph> (the default),
<pd><b>COMPRESSTYPE</b> — Set to <codeph>ZLIB</codeph> (the default), <codeph>ZSTD</codeph>,
<codeph>RLE-TYPE</codeph>, or <codeph>QUICKLZ</codeph><sup>1</sup> to specify the type
of compression used. The value <codeph>NONE</codeph>disables compression. QuickLZ uses
less CPU power and compresses data faster at a lower compression ratio than zlib.
Conversely, zlib provides more compact compression ratios at lower speeds. This option
of compression used. The value <codeph>NONE</codeph>disables compression. Zstd provides
for both speed or a good compression ratio, tunable with the compression level option.
QuickLZ and zlib are provided for backwards-compatibility, they are less flexible and
zstd outperforms them on usual workloads. This option
is only valid if <codeph>APPENDONLY=TRUE</codeph>.<p>
<note type="note"><sup>1</sup>QuickLZ compression is available only in the commercial
release of Pivotal Greenplum Database.</note>
......@@ -405,8 +406,9 @@
in sorted order or the compression is applied to column data that is in sorted
order.</p><p>For information about using table compression, see "Choosing the Table
Storage Model" in the <cite>Greenplum Database Administrator Guide</cite>.</p></pd>
<pd><b>COMPRESSLEVEL</b> — For zlib compression of append-optimized tables, set to an
integer value between 1 (fastest compression) to 9 (highest compression ratio). QuickLZ
<pd><b>COMPRESSLEVEL</b> — For Zstd compression of append-optimized tables, set to an
integer values between 1 (fastest compression) to 19 (highest compression ratio).
For zlib compression, the valid range is between 1 and 9. QuickLZ
compression level can only be set to 1. If not declared, the default is 1. For
<codeph>RLE_TYPE</codeph>, the compression level can be set an integer value between 1
(fastest compression) to 4 (highest compression ratio). </pd>
......
......@@ -18,7 +18,7 @@
<codeblock>   APPENDONLY={TRUE|FALSE}
   BLOCKSIZE={8192-2097152}
   ORIENTATION={COLUMN|ROW}
   COMPRESSTYPE={ZLIB|QUICKLZ}
   COMPRESSTYPE={ZLIB|ZSTD|QUICKLZ}
   COMPRESSLEVEL={1-9 | 1}
   FILLFACTOR={10-100}
   OIDS[=TRUE|FALSE]</codeblock>
......@@ -80,17 +80,20 @@
<pd>ORIENTATION — Set to <codeph>column</codeph> for column-oriented storage, or
<codeph>row</codeph> (the default) for row-oriented storage. This option is only valid
if <codeph>APPENDONLY=TRUE</codeph>. Heap-storage tables can only be row-oriented.</pd>
<pd>COMPRESSTYPE — Set to <codeph>ZLIB</codeph> (the default) or
<codeph>QUICKLZ</codeph><sup>1</sup> to specify the type of compression used. QuickLZ
uses less CPU power and compresses data faster at a lower compression ratio than zlib.
Conversely, zlib provides more compact compression ratios at lower speeds. This option
is only valid if <codeph>APPENDONLY=TRUE</codeph>. <note type="note"><sup>1</sup>QuickLZ
compression is available only in the commercial release of Pivotal Greenplum
Database.</note></pd>
<pd>COMPRESSLEVEL — For zlib compression of append-optimized tables, set to a value
between 1 (fastest compression) to 9 (highest compression ratio). QuickLZ compression
level can only be set to 1. If not declared, the default is 1. This option is only valid
if <codeph>APPENDONLY=TRUE</codeph>.</pd>
<pd>COMPRESSTYPE — Set to <codeph>ZLIB</codeph> (the default), <codeph>ZSTD</codeph>,
or <codeph>QUICKLZ</codeph><sup>1</sup> to specify the type
of compression used. The value <codeph>NONE</codeph>disables compression. Zstd provides
for both speed or a good compression ratio, tunable with the compression level option.
QuickLZ and zlib are provided for backwards-compatibility, they are less flexible and
zstd outperforms them on usual workloads. This option
is only valid if <codeph>APPENDONLY=TRUE</codeph>.<p>
<note type="note"><sup>1</sup>QuickLZ compression is available only in the commercial
release of Pivotal Greenplum Database.</note>
<pd><b>COMPRESSLEVEL</b> — For Zstd compression of append-optimized tables, set to an
integer values between 1 (fastest compression) to 19 (highest compression ratio).
For zlib compression, the valid range is between 1 and 9. QuickLZ
compression level can only be set to 1. If not declared, the default is 1.
This option is valid only if <codeph>APPENDONLY=TRUE</codeph>.</pd>
<pd>FILLFACTOR — See <codeph><xref href="CREATE_INDEX.xml#topic1" type="topic"
format="dita"/></codeph> for more information about this index storage parameter. </pd>
<pd>OIDS — Set to <codeph>OIDS=FALSE</codeph> (the default) so that rows do not have
......
......@@ -57,7 +57,7 @@
<entry colname="col2">smallint</entry>
<entry colname="col3"/>
<entry colname="col4">The compression level, with compression ratio increasing from 1 to
9. <p otherprops="pivotal">When <codeph>quicklz</codeph><sup>1</sup> is specified for
19. <p otherprops="pivotal">When <codeph>quicklz</codeph><sup>1</sup> is specified for
compresstype, valid values are 1 or 3. With <codeph>zlib</codeph> specified, valid
values are 1-9. </p></entry>
</row>
......@@ -95,6 +95,7 @@
<entry colname="col4">Type of compression used to compress append-optimized tables.
Valid values are:<ul id="ul_mrr_hwj_f1b">
<li><codeph>zlib</codeph> (gzip compression)</li>
<li><codeph>zstd</codeph> (Zstandard compression)</li>
<li otherprops="pivotal"><codeph>quicklz</codeph><sup>1</sup></li>
</ul></entry>
</row>
......
......@@ -979,17 +979,15 @@ validate_and_adjust_options(StdRdOptions *result,
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresstype can\'t be used with compresslevel 0")));
if (result->compresslevel < 0 || result->compresslevel > 9)
if (result->compresslevel < 0)
{
if (validate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range (should be "
"between 0 and 9)",
errmsg("compresslevel=%d is out of range (should be positive)",
result->compresslevel)));
result->compresslevel = setDefaultCompressionLevel(
result->compresstype);
result->compresslevel = setDefaultCompressionLevel(result->compresstype);
}
/*
......@@ -1000,6 +998,36 @@ validate_and_adjust_options(StdRdOptions *result,
if (result->compresslevel > 0 && !result->compresstype)
result->compresstype = pstrdup(AO_DEFAULT_COMPRESSTYPE);
/* Check upper bound of compresslevel for each compression type */
if (result->compresstype &&
(pg_strcasecmp(result->compresstype, "zlib") == 0) &&
(result->compresslevel > 9))
{
if (validate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range for zlib "
"(should be in the range 1 to 9)",
result->compresslevel)));
result->compresslevel = setDefaultCompressionLevel(result->compresstype);
}
if (result->compresstype &&
(pg_strcasecmp(result->compresstype, "zstd") == 0) &&
(result->compresslevel > 19))
{
if (validate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range for zstd "
"(should be in the range 1 to 19)",
result->compresslevel)));
result->compresslevel = setDefaultCompressionLevel(result->compresstype);
}
if (result->compresstype &&
(pg_strcasecmp(result->compresstype, "quicklz") == 0) &&
(result->compresslevel != 1))
......@@ -1007,12 +1035,11 @@ validate_and_adjust_options(StdRdOptions *result,
if (validate)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range for "
"quicklz (should be 1)",
errmsg("compresslevel=%d is out of range for quicklz "
"(should be 1)",
result->compresslevel)));
result->compresslevel = setDefaultCompressionLevel(
result->compresstype);
result->compresslevel = setDefaultCompressionLevel(result->compresstype);
}
if (result->compresstype &&
......@@ -1022,12 +1049,11 @@ validate_and_adjust_options(StdRdOptions *result,
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 4)",
result->compresslevel)));
result->compresslevel = setDefaultCompressionLevel(
result->compresstype);
result->compresslevel = setDefaultCompressionLevel(result->compresstype);
}
}
......@@ -1095,8 +1121,7 @@ validate_and_adjust_options(StdRdOptions *result,
if (result->appendonly && result->compresstype != NULL)
if (result->compresslevel == AO_DEFAULT_COMPRESSLEVEL)
result->compresslevel = setDefaultCompressionLevel(
result->compresstype);
result->compresslevel = setDefaultCompressionLevel(result->compresstype);
}
void
......@@ -1188,9 +1213,9 @@ validateAppendOnlyRelOptions(bool ao,
if (comptype &&
(pg_strcasecmp(comptype, "quicklz") == 0 ||
pg_strcasecmp(comptype, "zlib") == 0 ||
pg_strcasecmp(comptype, "rle_type") == 0))
pg_strcasecmp(comptype, "rle_type") == 0 ||
pg_strcasecmp(comptype, "zstd") == 0))
{
if (!co &&
pg_strcasecmp(comptype, "rle_type") == 0)
{
......@@ -1205,11 +1230,23 @@ validateAppendOnlyRelOptions(bool ao,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresstype cannot be used with compresslevel 0")));
if (complevel < 0 || complevel > 9)
if (comptype && (pg_strcasecmp(comptype, "zlib") == 0) &&
(complevel < 0 || complevel > 9))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range (should be between 0 and 9)",
complevel)));
}
if (comptype && (pg_strcasecmp(comptype, "zstd") == 0) &&
(complevel < 0 || complevel > 19))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("compresslevel=%d is out of range for zstd "
"(should be in the range 1 to 19)", complevel)));
}
if (comptype && (pg_strcasecmp(comptype, "quicklz") == 0) &&
(complevel != 1))
......@@ -1220,7 +1257,7 @@ validateAppendOnlyRelOptions(bool ao,
"(should be 1)", complevel)));
}
if (comptype && (pg_strcasecmp(comptype, "rle_type") == 0) &&
(complevel > 4))
(complevel < 0 || complevel > 4))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
......@@ -1254,7 +1291,7 @@ validateAppendOnlyRelOptions(bool ao,
/*
* if no compressor type was specified, we set to no compression (level 0)
* otherwise default for both zlib, quicklz and RLE to level 1.
* otherwise default for both zlib, quicklz, zstd and RLE to level 1.
*/
static int
setDefaultCompressionLevel(char *compresstype)
......
......@@ -23,7 +23,7 @@ OBJS = catalog.o dependency.o heap.o index.o indexing.o namespace.o aclchk.o \
aoseg.o aoblkdir.o gp_fastsequence.o gp_segment_config.o \
pg_attribute_encoding.o pg_compression.o aovisimap.o \
gp_global_sequence.o gp_persistent.o pg_appendonly.o \
oid_dispatch.o aocatalog.o $(QUICKLZ_COMPRESSION)
oid_dispatch.o aocatalog.o zstd_compression.o $(QUICKLZ_COMPRESSION)
BKIFILES = postgres.bki postgres.description postgres.shdescription
......
......@@ -466,7 +466,7 @@ compresstype_is_valid(char *comptype)
* must change!
*/
static const char *const valid_comptypes[] =
{"quicklz", "zlib", "rle_type", "none"};
{"quicklz", "zlib", "rle_type", "none", "zstd"};
for (i = 0; !found && i < ARRAY_SIZE(valid_comptypes); ++i)
{
if (pg_strcasecmp(valid_comptypes[i], comptype) == 0)
......
/*---------------------------------------------------------------------
*
* zstd_compression.c
*
* IDENTIFICATION
* src/backend/catalog/zstd_compression.c
*
*---------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/genam.h"
#include "catalog/pg_compression.h"
#include "fmgr.h"
#include "utils/builtins.h"
#ifdef HAVE_LIBZSTD
/* Zstandard library is provided */
#include <zstd.h>
/* Internal state for zstd */
typedef struct zstd_state
{
int level; /* Compression level */
bool compress; /* Compress if true, decompress otherwise */
ZSTD_CCtx *zstd_compress_context; /* ZSTD compression context */
ZSTD_DCtx *zstd_decompress_context; /* ZSTD decompression context */
} zstd_state;
Datum
zstd_constructor(PG_FUNCTION_ARGS)
{
/* PG_GETARG_POINTER(0) is TupleDesc that is currently unused. */
StorageAttributes *sa = (StorageAttributes *) PG_GETARG_POINTER(1);
CompressionState *cs = palloc0(sizeof(CompressionState));
zstd_state *state = palloc0(sizeof(zstd_state));
bool compress = PG_GETARG_BOOL(2);
if (!PointerIsValid(sa->comptype))
elog(ERROR, "zstd_constructor called with no compression type");
cs->opaque = (void *) state;
cs->desired_sz = NULL;
if (sa->complevel == 0)
sa->complevel = 1;
state->level = sa->complevel;
state->compress = compress;
state->zstd_compress_context = ZSTD_createCCtx();
state->zstd_decompress_context = ZSTD_createDCtx();
PG_RETURN_POINTER(cs);
}
Datum
zstd_destructor(PG_FUNCTION_ARGS)
{
CompressionState *cs = (CompressionState *) PG_GETARG_POINTER(0);
zstd_state *state = (zstd_state *) cs->opaque;
if (cs != NULL && cs->opaque != NULL)
{
ZSTD_freeCCtx(state->zstd_compress_context);
ZSTD_freeDCtx(state->zstd_decompress_context);
pfree(cs->opaque);
}
PG_RETURN_VOID();
}
Datum
zstd_compress(PG_FUNCTION_ARGS)
{
/* FIXME: Change types to ZSTD::size_t */
const void *src = PG_GETARG_POINTER(0);
int32 src_sz = PG_GETARG_INT32(1);
void *dst = PG_GETARG_POINTER(2);
int32 dst_sz = PG_GETARG_INT32(3);
int32 *dst_used = (int32 *) PG_GETARG_POINTER(4);
CompressionState *cs = (CompressionState *) PG_GETARG_POINTER(5);
zstd_state *state = (zstd_state *) cs->opaque;
unsigned long dst_length_used;
dst_length_used = ZSTD_compressCCtx(state->zstd_compress_context,
dst, dst_sz,
src, src_sz,
state->level);
if (ZSTD_isError(dst_length_used))
{
elog(ERROR, "%s", ZSTD_getErrorName(dst_length_used));
}
*dst_used = (int32) dst_length_used;
PG_RETURN_VOID();
}
Datum
zstd_decompress(PG_FUNCTION_ARGS)
{
/* FIXME: Change types to ZSTD::size_t */
const void *src = PG_GETARG_POINTER(0);
int32 src_sz = PG_GETARG_INT32(1);
void *dst = PG_GETARG_POINTER(2);
int32 dst_sz = PG_GETARG_INT32(3);
int32 *dst_used = (int32 *) PG_GETARG_POINTER(4);
CompressionState *cs = (CompressionState *) PG_GETARG_POINTER(5);
zstd_state *state = (zstd_state *) cs->opaque;
unsigned long dst_length_used;
if (src_sz <= 0)
elog(ERROR, "invalid source buffer size %d", src_sz);
if (dst_sz <= 0)
elog(ERROR, "invalid destination buffer size %d", dst_sz);
dst_length_used = ZSTD_decompressDCtx(state->zstd_decompress_context,
dst, dst_sz,
src, src_sz);
if (ZSTD_isError(dst_length_used))
{
elog(ERROR, "%s", ZSTD_getErrorName(dst_length_used));
}
*dst_used = (int32) dst_length_used;
PG_RETURN_VOID();
}
Datum
zstd_validator(PG_FUNCTION_ARGS)
{
PG_RETURN_VOID();
}
#else /* HAVE_LIBZSTD */
/* Zstandard library is not provided; use dummy functions instead */
#define NO_ZSTD_SUPPORT() \
ereport(ERROR, \
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), \
errmsg("Zstandard library is not supported by this build"), \
errhint("Compile with --with-zstd to use Zstandard compression.")))
Datum
zstd_constructor(PG_FUNCTION_ARGS)
{
NO_ZSTD_SUPPORT();
}
Datum
zstd_destructor(PG_FUNCTION_ARGS)
{
NO_ZSTD_SUPPORT();
}
Datum
zstd_compress(PG_FUNCTION_ARGS)
{
NO_ZSTD_SUPPORT();
}
Datum
zstd_decompress(PG_FUNCTION_ARGS)
{
NO_ZSTD_SUPPORT();
}
Datum
zstd_validator(PG_FUNCTION_ARGS)
{
NO_ZSTD_SUPPORT();
}
#endif /* HAVE_LIBZSTD */
......@@ -27,7 +27,7 @@
/* Compression is turned off by default. */
#define AO_DEFAULT_COMPRESSLEVEL 0
#define AO_MIN_COMPRESSLEVEL 0
#define AO_MAX_COMPRESSLEVEL 9
#define AO_MAX_COMPRESSLEVEL 19
/*
* If compression is turned on without specifying compresstype, this
* is the default.
......
......@@ -77,6 +77,8 @@ DATA(insert OID = 3062 ( rle_type gp_rle_type_constructor gp_rle_type_destructor
DATA(insert OID = 3063 ( none gp_dummy_compression_constructor gp_dummy_compression_destructor gp_dummy_compression_compress gp_dummy_compression_decompress gp_dummy_compression_validator PGUID ));
DATA(insert OID = 3070 ( zstd gp_zstd_constructor gp_zstd_destructor gp_zstd_compress gp_zstd_decompress gp_zstd_validator PGUID ));
#define NUM_COMPRESS_FUNCS 5
#define COMPRESSION_CONSTRUCTOR 0
......
......@@ -476,6 +476,16 @@ CREATE FUNCTION gp_nondbspecific_ptcat_verification() RETURNS bool LANGUAGE inte
CREATE FUNCTION gp_rle_type_validator(internal) RETURNS void LANGUAGE internal IMMUTABLE AS 'rle_type_validator' WITH(OID=9923, DESCRIPTION="Type speific RLE compression validator");
CREATE FUNCTION gp_zstd_constructor(internal, internal, bool) RETURNS internal LANGUAGE internal VOLATILE AS 'zstd_constructor' WITH (OID=3071, DESCRIPTION="zstd compressor and decompressor constructor");
CREATE FUNCTION gp_zstd_destructor(internal) RETURNS void LANGUAGE internal VOLATILE AS 'zstd_destructor' WITH(OID=3072, DESCRIPTION="zstd compressor and decompressor destructor");
CREATE FUNCTION gp_zstd_compress(internal, int4, internal, int4, internal, internal) RETURNS void LANGUAGE internal IMMUTABLE AS 'zstd_compress' WITH(OID=3073, DESCRIPTION="zstd compressor");
CREATE FUNCTION gp_zstd_decompress(internal, int4, internal, int4, internal, internal) RETURNS void LANGUAGE internal IMMUTABLE AS 'zstd_decompress' WITH(OID=3074, DESCRIPTION="zstd decompressor");
CREATE FUNCTION gp_zstd_validator(internal) RETURNS void LANGUAGE internal IMMUTABLE AS 'zstd_validator' WITH(OID=3075, DESCRIPTION="zstdcompression validator");
CREATE FUNCTION gp_dummy_compression_constructor(internal, internal, bool) RETURNS internal LANGUAGE internal VOLATILE AS 'dummy_compression_constructor' WITH (OID=3064, DESCRIPTION="Dummy compression destructor");
CREATE FUNCTION gp_dummy_compression_destructor(internal) RETURNS internal LANGUAGE internal VOLATILE AS 'dummy_compression_destructor' WITH (OID=3065, DESCRIPTION="Dummy compression destructor");
......
......@@ -22,7 +22,7 @@
WARNING: DO NOT MODIFY THE FOLLOWING SECTION:
Generated by catullus.pl version 8
on Thu Nov 23 10:04:03 2017
on Mon Nov 27 15:17:02 2017
Please make your changes in pg_proc.sql
*/
......@@ -946,6 +946,26 @@ DESCR("Type specific RLE decompressor");
DATA(insert OID = 9923 ( gp_rle_type_validator PGNSP PGUID 12 1 0 0 f f f f f i 1 0 2278 "2281" _null_ _null_ _null_ _null_ rle_type_validator _null_ _null_ _null_ n a ));
DESCR("Type speific RLE compression validator");
/* gp_zstd_constructor(internal, internal, bool) => internal */
DATA(insert OID = 3071 ( gp_zstd_constructor PGNSP PGUID 12 1 0 0 f f f f f v 3 0 2281 "2281 2281 16" _null_ _null_ _null_ _null_ zstd_constructor _null_ _null_ _null_ n a ));
DESCR("zstd compressor and decompressor constructor");
/* gp_zstd_destructor(internal) => void */
DATA(insert OID = 3072 ( gp_zstd_destructor PGNSP PGUID 12 1 0 0 f f f f f v 1 0 2278 "2281" _null_ _null_ _null_ _null_ zstd_destructor _null_ _null_ _null_ n a ));
DESCR("zstd compressor and decompressor destructor");
/* gp_zstd_compress(internal, int4, internal, int4, internal, internal) => void */
DATA(insert OID = 3073 ( gp_zstd_compress PGNSP PGUID 12 1 0 0 f f f f f i 6 0 2278 "2281 23 2281 23 2281 2281" _null_ _null_ _null_ _null_ zstd_compress _null_ _null_ _null_ n a ));
DESCR("zstd compressor");
/* gp_zstd_decompress(internal, int4, internal, int4, internal, internal) => void */
DATA(insert OID = 3074 ( gp_zstd_decompress PGNSP PGUID 12 1 0 0 f f f f f i 6 0 2278 "2281 23 2281 23 2281 2281" _null_ _null_ _null_ _null_ zstd_decompress _null_ _null_ _null_ n a ));
DESCR("zstd decompressor");
/* gp_zstd_validator(internal) => void */
DATA(insert OID = 3075 ( gp_zstd_validator PGNSP PGUID 12 1 0 0 f f f f f i 1 0 2278 "2281" _null_ _null_ _null_ _null_ zstd_validator _null_ _null_ _null_ n a ));
DESCR("zstdcompression validator");
/* gp_dummy_compression_constructor(internal, internal, bool) => internal */
DATA(insert OID = 3064 ( gp_dummy_compression_constructor PGNSP PGUID 12 1 0 0 f f f f f v 3 0 2281 "2281 2281 16" _null_ _null_ _null_ _null_ dummy_compression_constructor _null_ _null_ _null_ n a ));
DESCR("Dummy compression destructor");
......
......@@ -404,6 +404,9 @@
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the `zstd' library (-lzstd). */
#undef HAVE_LIBZSTD
/* Define to 1 if constants of type 'long long int' should have the suffix LL.
*/
#undef HAVE_LL_CONSTANTS
......
......@@ -1224,6 +1224,12 @@ extern Datum rle_type_compress(PG_FUNCTION_ARGS);
extern Datum rle_type_decompress(PG_FUNCTION_ARGS);
extern Datum rle_type_validator(PG_FUNCTION_ARGS);
extern Datum zstd_constructor(PG_FUNCTION_ARGS);
extern Datum zstd_destructor(PG_FUNCTION_ARGS);
extern Datum zstd_compress(PG_FUNCTION_ARGS);
extern Datum zstd_decompress(PG_FUNCTION_ARGS);
extern Datum zstd_validator(PG_FUNCTION_ARGS);
extern Datum delta_constructor(PG_FUNCTION_ARGS);
extern Datum delta_destructor(PG_FUNCTION_ARGS);
extern Datum delta_compress(PG_FUNCTION_ARGS);
......
......@@ -448,7 +448,7 @@ ERROR: unknown compresstype "yawn"
alter table ccddl add column j int encoding(compresstype=zlib,
compresslevel=100000);
ERROR: value 100000 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "9".
DETAIL: Valid values are between "0" and "19".
alter table ccddl add column j int encoding(a=b);
ERROR: unrecognized parameter "a"
drop table ccddl;
......@@ -471,8 +471,7 @@ ERROR: DEFAULT COLUMN ENCODING clause cannot override values set in WITH clause
-- Invalid encoding clauses
create table t1 (i int encoding (compresstype=zlib, compresslevel=19))
with (appendonly=true, orientation=column);
ERROR: value 19 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "9".
ERROR: compresslevel=19 is out of range for zlib (should be in the range 1 to 9)
create table t1 (i int encoding (compresstype=zlib, ahhhh=boooooo))
with (appendonly=true, orientation=column);
ERROR: unrecognized parameter "ahhhh"
......@@ -1843,7 +1842,7 @@ alter type text set default encoding (compresstype=10);
ERROR: unknown compresstype "10"
alter type text set default encoding (compresstype=zlib, compresslevel=100);
ERROR: value 100 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "9".
DETAIL: Valid values are between "0" and "19".
-- dependency check on drop type
drop type int42 cascade;
NOTICE: drop cascades to 2 other objects
......
-- Tests for zstd compression.
CREATE TABLE zstdtest (id int4, t text) WITH (appendonly=true, compresstype=zstd, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO zstdtest SELECT g, 'foo' || g FROM generate_series(1, 100000) g;
INSERT INTO zstdtest SELECT g, 'bar' || g FROM generate_series(1, 100000) g;
-- Check contents, at the beginning of the table and at the end.
SELECT * FROM zstdtest ORDER BY id LIMIT 5;
id | t
----+------
1 | bar1
1 | foo1
2 | foo2
2 | bar2
3 | bar3
(5 rows)
SELECT * FROM zstdtest ORDER BY id DESC LIMIT 5;
id | t
--------+-----------
100000 | bar100000
100000 | foo100000
99999 | bar99999
99999 | foo99999
99998 | foo99998
(5 rows)
-- Test different compression levels:
CREATE TABLE zstdtest_1 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=1);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE zstdtest_10 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=10);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE zstdtest_19 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=19);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO zstdtest_1 SELECT g, 'foo' || g FROM generate_series(1, 10000) g;
INSERT INTO zstdtest_1 SELECT g, 'bar' || g FROM generate_series(1, 10000) g;
SELECT * FROM zstdtest_1 ORDER BY id LIMIT 5;
id | t
----+------
1 | bar1
1 | foo1
2 | foo2
2 | bar2
3 | bar3
(5 rows)
SELECT * FROM zstdtest_1 ORDER BY id DESC LIMIT 5;
id | t
-------+----------
10000 | foo10000
10000 | bar10000
9999 | bar9999
9999 | foo9999
9998 | bar9998
(5 rows)
INSERT INTO zstdtest_19 SELECT g, 'foo' || g FROM generate_series(1, 10000) g;
INSERT INTO zstdtest_19 SELECT g, 'bar' || g FROM generate_series(1, 10000) g;
SELECT * FROM zstdtest_19 ORDER BY id LIMIT 5;
id | t
----+------
1 | bar1
1 | foo1
2 | foo2
2 | bar2
3 | bar3
(5 rows)
SELECT * FROM zstdtest_19 ORDER BY id DESC LIMIT 5;
id | t
-------+----------
10000 | foo10000
10000 | bar10000
9999 | bar9999
9999 | foo9999
9998 | bar9998
(5 rows)
-- Test the bounds of compresslevel. None of these are allowed.
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=-1);
ERROR: value -1 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "19".
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=0);
ERROR: compresstype can't be used with compresslevel 0
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=20);
ERROR: value 20 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "19".
-- Tests for zstd compression.
CREATE TABLE zstdtest (id int4, t text) WITH (appendonly=true, compresstype=zstd, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO zstdtest SELECT g, 'foo' || g FROM generate_series(1, 100000) g;
ERROR: Zstandard library is not supported by this build (seg1 127.0.0.1:40001 pid=19721)
INSERT INTO zstdtest SELECT g, 'bar' || g FROM generate_series(1, 100000) g;
ERROR: Zstandard library is not supported by this build (seg1 127.0.0.1:40001 pid=19721)
-- Check contents, at the beginning of the table and at the end.
SELECT * FROM zstdtest ORDER BY id LIMIT 5;
ERROR: Zstandard library is not supported by this build (seg0 slice1 127.0.0.1:40000 pid=19720)
SELECT * FROM zstdtest ORDER BY id DESC LIMIT 5;
ERROR: Zstandard library is not supported by this build (seg0 slice1 127.0.0.1:40000 pid=19720)
-- Test different compression levels:
CREATE TABLE zstdtest_1 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=1);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE zstdtest_10 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=10);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE zstdtest_19 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=19);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO zstdtest_1 SELECT g, 'foo' || g FROM generate_series(1, 10000) g;
ERROR: Zstandard library is not supported by this build (seg0 127.0.0.1:40000 pid=19720)
INSERT INTO zstdtest_1 SELECT g, 'bar' || g FROM generate_series(1, 10000) g;
ERROR: Zstandard library is not supported by this build (seg0 127.0.0.1:40000 pid=19720)
SELECT * FROM zstdtest_1 ORDER BY id LIMIT 5;
ERROR: Zstandard library is not supported by this build (seg0 slice1 127.0.0.1:40000 pid=19720)
SELECT * FROM zstdtest_1 ORDER BY id DESC LIMIT 5;
ERROR: Zstandard library is not supported by this build (seg0 slice1 127.0.0.1:40000 pid=19720)
INSERT INTO zstdtest_19 SELECT g, 'foo' || g FROM generate_series(1, 10000) g;
ERROR: Zstandard library is not supported by this build (seg1 127.0.0.1:40001 pid=19721)
INSERT INTO zstdtest_19 SELECT g, 'bar' || g FROM generate_series(1, 10000) g;
ERROR: Zstandard library is not supported by this build (seg1 127.0.0.1:40001 pid=19721)
SELECT * FROM zstdtest_19 ORDER BY id LIMIT 5;
ERROR: Zstandard library is not supported by this build (seg0 slice1 127.0.0.1:40000 pid=19720)
SELECT * FROM zstdtest_19 ORDER BY id DESC LIMIT 5;
ERROR: Zstandard library is not supported by this build (seg0 slice1 127.0.0.1:40000 pid=19720)
-- Test the bounds of compresslevel. None of these are allowed.
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=-1);
ERROR: value -1 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "19".
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=0);
ERROR: compresstype can't be used with compresslevel 0
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=20);
ERROR: value 20 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "19".
......@@ -508,8 +508,7 @@ create table co7(a int, b float,
ERROR: compresslevel=7 is out of range for rle_type (should be in the range 1 to 4)
-- negative tests - session level set
set gp_default_storage_options="compresstype=zlib,compresslevel=11";
ERROR: value 11 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "9".
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";
......
......@@ -67,7 +67,7 @@ test: sreh
# ERROR: parameter "gp_interconnect_type" cannot be set after connection start
ignore: gp_portal_error
test: external_table external_table_create_privs column_compression eagerfree gpdtm_plpgsql alter_table_aocs alter_table_aocs2 alter_distribution_policy ic aoco_privileges aocs
test: external_table external_table_create_privs column_compression compression_zstd eagerfree gpdtm_plpgsql alter_table_aocs alter_table_aocs2 alter_distribution_policy ic aoco_privileges aocs
test: alter_table_set alter_table_gp alter_table_ao ao_create_alter_valid_table subtransaction_visibility oid_consistency udf_exception_blocks
ignore: icudp_full
......
......@@ -45,8 +45,7 @@ CREATE TABLE tenk_ao5 (like tenk_heap) with (appendonly=true, compresslevel=6, c
CREATE TABLE tenk_ao6 (like tenk_heap) with (appendonly=false, compresslevel=6, checksum=true) distributed by(unique1);
ERROR: invalid option 'compresslevel' for base relation. Only valid for Append Only relations
CREATE TABLE tenk_ao7 (like tenk_heap) with (appendonly=true, compresslevel=16, compresstype=zlib) distributed by(unique1);
ERROR: value 16 out of bounds for option "compresslevel"
DETAIL: Valid values are between "0" and "9".
ERROR: compresslevel=16 is out of range for zlib (should be in the range 1 to 9)
CREATE TABLE tenk_ao8 (like tenk_heap) with (appendonly=true, blocksize=100) distributed by(unique1);
ERROR: value 100 out of bounds for option "blocksize"
DETAIL: Valid values are between "8192" and "2097152".
......
-- Tests for zstd compression.
CREATE TABLE zstdtest (id int4, t text) WITH (appendonly=true, compresstype=zstd, orientation=column);
INSERT INTO zstdtest SELECT g, 'foo' || g FROM generate_series(1, 100000) g;
INSERT INTO zstdtest SELECT g, 'bar' || g FROM generate_series(1, 100000) g;
-- Check contents, at the beginning of the table and at the end.
SELECT * FROM zstdtest ORDER BY id LIMIT 5;
SELECT * FROM zstdtest ORDER BY id DESC LIMIT 5;
-- Test different compression levels:
CREATE TABLE zstdtest_1 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=1);
CREATE TABLE zstdtest_10 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=10);
CREATE TABLE zstdtest_19 (id int4, t text) WITH (appendonly=true, compresstype=zstd, compresslevel=19);
INSERT INTO zstdtest_1 SELECT g, 'foo' || g FROM generate_series(1, 10000) g;
INSERT INTO zstdtest_1 SELECT g, 'bar' || g FROM generate_series(1, 10000) g;
SELECT * FROM zstdtest_1 ORDER BY id LIMIT 5;
SELECT * FROM zstdtest_1 ORDER BY id DESC LIMIT 5;
INSERT INTO zstdtest_19 SELECT g, 'foo' || g FROM generate_series(1, 10000) g;
INSERT INTO zstdtest_19 SELECT g, 'bar' || g FROM generate_series(1, 10000) g;
SELECT * FROM zstdtest_19 ORDER BY id LIMIT 5;
SELECT * FROM zstdtest_19 ORDER BY id DESC LIMIT 5;
-- Test the bounds of compresslevel. None of these are allowed.
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=-1);
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=0);
CREATE TABLE zstdtest_invalid (id int4) WITH (appendonly=true, compresstype=zstd, compresslevel=20);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册