Skip to content

Commit 6e7baa3

Browse files
committed
Introduce BYTES unit for GUCs.
This is already useful for track_activity_query_size, and will further be used in a later commit making the WAL segment size configurable. Author: Beena Emerson Reviewed-By: Andres Freund Discussion: https://postgr.es/m/CAOG9ApEu8bXVwBxkOO9J7ZpM76TASK_vFMEEiCEjwhMmSLiaqQ@mail.gmail.com
1 parent 2d4a614 commit 6e7baa3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/backend/utils/misc/guc.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,11 @@ static const char *memory_units_hint = gettext_noop("Valid units for this parame
722722

723723
static const unit_conversion memory_unit_conversion_table[] =
724724
{
725+
{"GB", GUC_UNIT_BYTE, 1024 * 1024 * 1024},
726+
{"MB", GUC_UNIT_BYTE, 1024 * 1024},
727+
{"kB", GUC_UNIT_BYTE, 1024},
728+
{"B", GUC_UNIT_BYTE, 1},
729+
725730
{"TB", GUC_UNIT_KB, 1024 * 1024 * 1024},
726731
{"GB", GUC_UNIT_KB, 1024 * 1024},
727732
{"MB", GUC_UNIT_KB, 1024},
@@ -2863,11 +2868,7 @@ static struct config_int ConfigureNamesInt[] =
28632868
{"track_activity_query_size", PGC_POSTMASTER, RESOURCES_MEM,
28642869
gettext_noop("Sets the size reserved for pg_stat_activity.query, in bytes."),
28652870
NULL,
2866-
2867-
/*
2868-
* There is no _bytes_ unit, so the user can't supply units for
2869-
* this.
2870-
*/
2871+
GUC_UNIT_BYTE
28712872
},
28722873
&pgstat_track_activity_query_size,
28732874
1024, 100, 102400,
@@ -8113,6 +8114,9 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
81138114
{
81148115
switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
81158116
{
8117+
case GUC_UNIT_BYTE:
8118+
values[2] = "B";
8119+
break;
81168120
case GUC_UNIT_KB:
81178121
values[2] = "kB";
81188122
break;

src/include/utils/guc.h

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ typedef enum
219219
#define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */
220220
#define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */
221221
#define GUC_UNIT_MB 0x4000 /* value is in megabytes */
222+
#define GUC_UNIT_BYTE 0x8000 /* value is in bytes */
222223
#define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */
223224

224225
#define GUC_UNIT_MS 0x10000 /* value is in milliseconds */

0 commit comments

Comments
 (0)