diff --git a/cstore.c b/cstore.c index f04fc4fc6..94fc401a1 100644 --- a/cstore.c +++ b/cstore.c @@ -17,10 +17,65 @@ #include #include "miscadmin.h" +#include "utils/guc.h" #include "utils/rel.h" #include "cstore.h" +int cstore_compression = DEFAULT_COMPRESSION_TYPE; +int cstore_stripe_row_count = DEFAULT_STRIPE_ROW_COUNT; +int cstore_block_row_count = DEFAULT_BLOCK_ROW_COUNT; + +static const struct config_enum_entry cstore_compression_options[] = +{ + {"none", COMPRESSION_NONE, false}, + {"pglz", COMPRESSION_PG_LZ, false}, + {NULL, 0, false} +}; + +void +cstore_init() +{ + DefineCustomEnumVariable("cstore.compression", + "Sets the maximum number of statements tracked by pg_stat_statements.", + NULL, + &cstore_compression, + DEFAULT_COMPRESSION_TYPE, + cstore_compression_options, + PGC_POSTMASTER, + 0, + NULL, + NULL, + NULL); + + DefineCustomIntVariable("cstore.stripe_row_count", + "Sets the maximum number of statements tracked by pg_stat_statements.", + NULL, + &cstore_stripe_row_count, + DEFAULT_STRIPE_ROW_COUNT, + STRIPE_ROW_COUNT_MINIMUM, + STRIPE_ROW_COUNT_MAXIMUM, + PGC_USERSET, + 0, + NULL, + NULL, + NULL); + + DefineCustomIntVariable("cstore.block_row_count", + "Sets the maximum number of statements tracked by pg_stat_statements.", + NULL, + &cstore_block_row_count, + DEFAULT_BLOCK_ROW_COUNT, + BLOCK_ROW_COUNT_MINIMUM, + BLOCK_ROW_COUNT_MAXIMUM, + PGC_USERSET, + 0, + NULL, + NULL, + NULL); +} + + /* ParseCompressionType converts a string to a compression type. */ CompressionType ParseCompressionType(const char *compressionTypeString) diff --git a/cstore.h b/cstore.h index 9a1764972..cbd60fca1 100644 --- a/cstore.h +++ b/cstore.h @@ -249,6 +249,12 @@ typedef struct TableWriteState StringInfo compressionBuffer; } TableWriteState; +extern int cstore_compression; +extern int cstore_stripe_row_count; +extern int cstore_block_row_count; + +extern void cstore_init(void); + extern CompressionType ParseCompressionType(const char *compressionTypeString); extern void InitializeCStoreTableFile(Oid relationId, Relation relation, CStoreOptions *cstoreOptions); diff --git a/mod.c b/mod.c index 3e041dd7a..e81f7a6e5 100644 --- a/mod.c +++ b/mod.c @@ -15,6 +15,7 @@ #include "fmgr.h" +#include "cstore.h" #include "mod.h" #ifdef USE_TABLEAM @@ -30,6 +31,8 @@ PG_MODULE_MAGIC; void _PG_init(void) { + cstore_init(); + #ifdef USE_TABLEAM cstore_tableam_init(); #endif