pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Beena Emerson <memissemerson@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: [PATCH] Renumber confusing value for GUC_UNIT_BYTE
Date: Wed, 20 Jul 2022 09:52:21 -0500
Message-ID: <20220720145220.GJ12702@telsasoft.com> (raw)

The GUC units are currently defined like:

#define GUC_UNIT_KB                             0x1000  /* value is in kilobytes */
#define GUC_UNIT_BLOCKS                 0x2000  /* value is in blocks */
#define GUC_UNIT_XBLOCKS                0x3000  /* value is in xlog blocks */
#define GUC_UNIT_MB                             0x4000  /* value is in megabytes */
#define GUC_UNIT_BYTE                   0x8000  /* value is in bytes */
#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 time-related units */

0x3000 and 0x30000 seemed wrong, since they're a combination of other flags
rather than being an independant power of two.

But actually, these aren't flags:  they're tested in a "case" statement for
equality, not in a bitwise & test.

So the outlier is actually 0x8000, added at:
|commit 6e7baa322773ff8c79d4d8883c99fdeff5bfa679
|Author: Andres Freund <andres@anarazel.de>
|Date:   Tue Sep 12 12:13:12 2017 -0700
|
|    Introduce BYTES unit for GUCs.

It looks like that originated here:

https://www.postgresql.org/message-id/CAOG9ApEu8bXVwBxkOO9J7ZpM76TASK_vFMEEiCEjwhMmSLiaqQ%40mail.gma...

commit 162e4838103e7957cccfe7868fc28397b55ca1d7
Author: Justin Pryzby <pryzbyj@telsasoft.com>
Date:   Wed Jul 20 09:27:24 2022 -0500

    Renumber confusing value for GUC_UNIT_BYTE
    
    It had a power-of-two value, which looks right, and causes the other values
    which aren't powers-of-two to look wrong.  But this is tested for equality and
    not a bitwise test.
    
    See also:
    6e7baa322773ff8c79d4d8883c99fdeff5bfa679
    https://www.postgresql.org/message-id/CAOG9ApEu8bXVwBxkOO9J7ZpM76TASK_vFMEEiCEjwhMmSLiaqQ%40mail.gma...

inline patch 1: src/include/utils/guc.h (+2/-1 lines) download inline-1.patchdiff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 4d0920c42e2..be928fac881 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -219,11 +219,12 @@ typedef enum #define GUC_DISALLOW_IN_AUTO_FILE 0x0800 /* can't set in * PG_AUTOCONF_FILENAME */ +/* GUC_UNIT_* are not flags - they're tested for equality */ #define GUC_UNIT_KB 0x1000 /* value is in kilobytes */ #define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */ #define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */ #define GUC_UNIT_MB 0x4000 /* value is in megabytes */ -#define GUC_UNIT_BYTE 0x8000 /* value is in bytes */ +#define GUC_UNIT_BYTE 0x5000 /* value is in bytes */ #define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */ #define GUC_UNIT_MS 0x10000 /* value is in milliseconds */

view thread (6+ messages)  latest in thread

Message-ID: <20220720145220.GJ12702@telsasoft.com>
Permalink:  ../20220720145220.GJ12702@telsasoft.com/
Also on:    postgresql.org/message-id/20220720145220.GJ12702@telsasoft.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: pryzby@telsasoft.com, memissemerson@gmail.com, andres@anarazel.de, pgsql-hackers@postgresql.org
  Subject: Re: [PATCH] Renumber confusing value for GUC_UNIT_BYTE
  In-Reply-To: <20220720145220.GJ12702@telsasoft.com>
  References: <20220720145220.GJ12702@telsasoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox