From 96274f45d5ded8e0d00e3ff59ffb7c046501e99c Mon Sep 17 00:00:00 2001 From: usernamedt Date: Wed, 12 Jan 2022 23:14:02 +0500 Subject: [PATCH 3/3] Turn on zlib compression for CI test runs --- src/backend/utils/misc/guc.c | 2 +- src/common/zpq_stream.c | 34 ++++++++----------------------- src/interfaces/libpq/fe-connect.c | 2 +- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index fdf77e383d..74e2f617ad 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4589,7 +4589,7 @@ static struct config_string ConfigureNamesString[] = NULL }, &libpq_compress_algorithms, - "off", + "zlib", check_libpq_compression, NULL, NULL }, diff --git a/src/common/zpq_stream.c b/src/common/zpq_stream.c index c72b434c5d..69f1b4bba9 100644 --- a/src/common/zpq_stream.c +++ b/src/common/zpq_stream.c @@ -156,21 +156,8 @@ zpq_build_msg_compression_map(ZpqStream * zpq) for (i = 0; i < 256; i++) { - zpq->compressor_by_msg_type[i] = -1; - } - - for (i = 0; i < zpq->n_compressors; i++) - { - /* compress CopyData, DataRow and Query messages */ - if (zpq->compressor_by_msg_type['d'] == -1) { - zpq->compressor_by_msg_type['d'] = i; - } - if (zpq->compressor_by_msg_type['D'] == -1) { - zpq->compressor_by_msg_type['D'] = i; - } - if (zpq->compressor_by_msg_type['Q'] == -1) { - zpq->compressor_by_msg_type['Q'] = i; - } + /* Compress all messages during the CI test runs */ + zpq->compressor_by_msg_type[i] = 0; } } @@ -183,11 +170,8 @@ zpq_build_msg_compression_map(ZpqStream * zpq) static inline int zpq_choose_compressor(ZpqStream * zpq, char msg_type, uint32 msg_len) { - if (msg_len >= ZPQ_COMPRESS_THRESHOLD) - { - return zpq->compressor_by_msg_type[(unsigned char) msg_type]; - } - return -1; + /* Compress messages with any length during the CI test runs */ + return zpq->compressor_by_msg_type[(unsigned char) msg_type]; } /* @@ -197,7 +181,7 @@ zpq_choose_compressor(ZpqStream * zpq, char msg_type, uint32 msg_len) static inline bool zpq_should_compress(ZpqStream * zpq, char msg_type, uint32 msg_len) { - return zpq_choose_compressor(zpq, msg_type, msg_len) != -1; + return zpq_choose_compressor(zpq, msg_type, msg_len) != -1; } /* @@ -990,7 +974,7 @@ zpq_serialize_compressors(zpq_compressor const *compressors, size_t n_compressor /* * single entry looks like "alg_name:compression_level," so +2 is for - * ":" and "," symbols (or trailing null) + * ":" and "," symbols (or trailing null) */ total_len += strlen(supported_algorithms[compressors[i].impl]) + level_len + 2; } @@ -999,9 +983,9 @@ zpq_serialize_compressors(zpq_compressor const *compressors, size_t n_compressor for (i = 0; i < n_compressors; i++) { - p += sprintf(p, "%s:%d", supported_algorithms[compressors[i].impl], compressors[i].level); - if (i < n_compressors - 1) - *p++ = ','; + p += sprintf(p, "%s:%d", supported_algorithms[compressors[i].impl], compressors[i].level); + if (i < n_compressors - 1) + *p++ = ','; } return res; } diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index d02b74b9a9..7c7a0c1a3b 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -340,7 +340,7 @@ static const internalPQconninfoOption PQconninfoOptions[] = { "Replication", "D", 5, offsetof(struct pg_conn, replication)}, - {"compression", "PGCOMPRESSION", "off", NULL, + {"compression", "PGCOMPRESSION", "zlib", NULL, "Libpq-compression", "", 16, offsetof(struct pg_conn, compression)}, -- 2.30.2