/* unit */
if (conf->vartype == PGC_INT)
{
- static char buf[8];
-
switch (conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
{
case GUC_UNIT_KB:
values[2] = "kB";
break;
case GUC_UNIT_BLOCKS:
- snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
- values[2] = buf;
+ snprintf(buffer, sizeof(buffer), "%dkB", BLCKSZ / 1024);
+ values[2] = pstrdup(buffer);
break;
case GUC_UNIT_XBLOCKS:
- snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
- values[2] = buf;
+ snprintf(buffer, sizeof(buffer), "%dkB", XLOG_BLCKSZ / 1024);
+ values[2] = pstrdup(buffer);
+ break;
+ case GUC_UNIT_XSEGS:
+ snprintf(buffer, sizeof(buffer), "%dMB",
+ XLOG_SEG_SIZE / (1024 * 1024));
+ values[2] = pstrdup(buffer);
break;
case GUC_UNIT_MS:
values[2] = "ms";
case GUC_UNIT_MIN:
values[2] = "min";
break;
+ case 0:
+ values[2] = NULL;
+ break;
default:
+ elog(ERROR, "unrecognized GUC units value: %d",
+ conf->flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME));
values[2] = NULL;
break;
}
#define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */
#define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */
#define GUC_UNIT_XSEGS 0x4000 /* value is in xlog segments */
-#define GUC_UNIT_MEMORY 0xF000 /* mask for KB, BLOCKS, XBLOCKS */
+#define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */
#define GUC_UNIT_MS 0x10000 /* value is in milliseconds */
#define GUC_UNIT_S 0x20000 /* value is in seconds */
#define GUC_UNIT_MIN 0x30000 /* value is in minutes */
-#define GUC_UNIT_TIME 0xF0000 /* mask for MS, S, MIN */
+#define GUC_UNIT_TIME 0xF0000 /* mask for time-related units */
#define GUC_UNIT (GUC_UNIT_MEMORY | GUC_UNIT_TIME)