Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEB3t-0007r1-6N for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jul 2022 14:52:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oEB3s-00022K-2C for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jul 2022 14:52:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEB3r-00022B-LK for pgsql-hackers@lists.postgresql.org; Wed, 20 Jul 2022 14:52:27 +0000 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oEB3n-0006wl-Nj for pgsql-hackers@postgresql.org; Wed, 20 Jul 2022 14:52:26 +0000 Received: by mail-qk1-x731.google.com with SMTP id c24so8275289qkm.4 for ; Wed, 20 Jul 2022 07:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=RV8eT6GL1GS3gLrwUp25ZhdE9aWsX7e0J7gcAvwt2Ro=; b=jASOhrrseTMTdqoMplOaMMg4ftD3GKtgV53VaJ+XJrp3uAy8FdILetRbvCn79rYffv 92EdBE9iBif/41BDxpqYGo7cnFRTKHWA0IHW/NQUwD/5LAJxAbdhuEGzsME+/rPs6Evu tKYA4fifs9fcEbCzybfdDIOUcb3HEaB0pBHyk0XRsgftm4sauoOT0e2Qfyh7/w/fVOAK oHgGiqt/UlI2Y2KuEn0bp8TijaeXn1iDopYlVPtSj8kDyqmp0Y9mdfKzETsUb2F4x4tC 1e1sDA7NOh8C8OScTdQiwgBMnep8Tl4QFGL7MGEXUgSVK5ZWoi27jiRg9XeHN0fnb426 GrVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=RV8eT6GL1GS3gLrwUp25ZhdE9aWsX7e0J7gcAvwt2Ro=; b=xsoE45J2lO2O7ktH+GGKyFrCvQAhgi6oXiueKk4BGlhCsJwP5sG1qD1DUyTeEs9hxb p6sNMIcCgm+JymIRFZcxzBQWoMzmTkjUqmzaSWDPdIdkfiSK61xAj+vM5rRiLvjYmwb3 VY8ljW2IjzSpDLEvSFkvWO6u67sBYhLgd6TfmaisA6QQQbEZ5nsLcbvdflV2ZwUe73CX ZSw0XuR4YrLbDwnH0bRxZW5BIfrHEnGHsFh0IMkctVJEeAec/+nLWEhzsFQzsaxqNhK9 +/vDMydnRx5j8E07GP3ljFxuSv0yh2weYsqUdwTmXKjHDZViirmYs1ltPd59mgp02JZv QNEQ== X-Gm-Message-State: AJIora8vElEDu6A+5KouHklsDCumblN6CbvsNykQQhjsyiWWi/vigfzG in7ND46XB27XQ+K1GZE8ffcqvg== X-Google-Smtp-Source: AGRyM1sDq+cSeOVYjRmEOLIIME7j4ONVMXZVWr7ldmnPqyTwh4vgQbl/uNfet6ggCoanSOiCg54cvA== X-Received: by 2002:a05:620a:c01:b0:6b6:1aaf:bade with SMTP id l1-20020a05620a0c0100b006b61aafbademr232561qki.524.1658328742991; Wed, 20 Jul 2022 07:52:22 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id dt18-20020a05620a479200b006b5cb0c512asm16026118qkb.101.2022.07.20.07.52.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2022 07:52:22 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 35806800957; Wed, 20 Jul 2022 09:52:21 -0500 (CDT) Date: Wed, 20 Jul 2022 09:52:21 -0500 From: Justin Pryzby To: Beena Emerson Cc: Andres Freund , pgsql-hackers@postgresql.org Subject: [PATCH] Renumber confusing value for GUC_UNIT_BYTE Message-ID: <20220720145220.GJ12702@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 |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.gmail.com commit 162e4838103e7957cccfe7868fc28397b55ca1d7 Author: Justin Pryzby 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.gmail.com diff --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 */