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 1mu6hb-0003Pt-0s for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Dec 2021 05:38:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mu6hZ-000206-Gs for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Dec 2021 05:38:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mu6hZ-0001zx-1f for pgsql-hackers@lists.postgresql.org; Mon, 06 Dec 2021 05:38:13 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mu6hV-0005fN-Oq for pgsql-hackers@lists.postgresql.org; Mon, 06 Dec 2021 05:38:12 +0000 Received: by mail-ot1-x333.google.com with SMTP id u18-20020a9d7212000000b00560cb1dc10bso12216724otj.11 for ; Sun, 05 Dec 2021 21:38:09 -0800 (PST) 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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hb1/I3qCCI65uB5MHl+SsNdX92ncN7MrHYOxa29YnE0=; b=8XQEYGKai88QuYJRhvs1vrdvVlYNOmhJEhamUzib8LthaaZg8onjLV7jQVTDOuEds7 8J8lLApNdsrRTE+qADFP9JoZUsNBzLlNVMUjBhm/+HzB/Re4zOQBLVcL52cCfRH5ddiZ K7e5wykZkxKmx9Y1kw314HK7tDmqHGHZLhJJFh0VaLyBN5CPjjUUDoK+77GW0kwuudvV WAdUNUONDCI4SLpWj/oyouoXr5sq8yeLj2wl29v8QelnwFiNu10shmWtk5mhJDPSbc2M 5H6aWT4Zw4PWjDZdIbLpTLPgYKGbpL/fMg8PcrN8VUDIHrdt3WjpUbQ/sTeCA+E0MtRF e/gg== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hb1/I3qCCI65uB5MHl+SsNdX92ncN7MrHYOxa29YnE0=; b=R+m2LhQOu22hpGIw2dMxZ07dgO+SBWz+uavEweAxxiFaxjp99MAYOcp3UkOKyqgOtH 5czwGITbO5ggc5u4Nqd3uMvqOGUU0fiYfGwCKiRaBmoi77p7pFAZW20/sTHXe88s9Zml +SSBMo/LN6vxpyu7L5I52i0t2d7Ah7KqsxCUzmHJmE+ZnQE77oSiKw7qvDzN0FtYPUpa H0exvJsSvLUeNSPm+/tYM69ZyTeqReoS0R9bTAvwO1xc8Sjia6e6glIV3M+ELrglAWys d5pvF85miLVHGqDjn+4Q7yaSA8b810NI5B4scPNKBpvujS6/tXmmOQc9D3I67+xbnw8V Oe7Q== X-Gm-Message-State: AOAM532HKDOFzG+9WCyf2vcQGjm5hriOIRFK5koVmjAciHAkWpFmWYt3 +IkNOFhw/B5dHcz2SzSocSUy7fHRsu/CYQ== X-Google-Smtp-Source: ABdhPJwvWmYiKv+ukL2AarirsAormoAhIJ7ihZP2a+M3X4g+9pQxdnK/NlKK5CIWW4sy8eP2IXf+rQ== X-Received: by 2002:a05:6830:244c:: with SMTP id x12mr27203951otr.213.1638769087233; Sun, 05 Dec 2021 21:38:07 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id bi20sm2575911oib.29.2021.12.05.21.38.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Dec 2021 21:38:06 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 6EBEE8009C7; Sun, 5 Dec 2021 23:38:05 -0600 (CST) Date: Sun, 5 Dec 2021 23:38:05 -0600 From: Justin Pryzby To: Michael Paquier Cc: pgsql-hackers@lists.postgresql.org Subject: Re: GUC flags Message-ID: <20211206053805.GG17618@telsasoft.com> References: <20211129030833.GJ17618@telsasoft.com> <20211201075904.GW17618@telsasoft.com> <20211202033439.GL17618@telsasoft.com> <20211202051734.GN17618@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Zr5irScySb2At5ws" Content-Disposition: inline In-Reply-To: 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 --Zr5irScySb2At5ws Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Dec 03, 2021 at 10:06:47AM +0900, Michael Paquier wrote: > On Wed, Dec 01, 2021 at 11:17:34PM -0600, Justin Pryzby wrote: > > I find it easier to read "wait before authentication ..." than "wait ... before > > authentication". > > I have a hard time seeing a strong difference here. At the end, I > have used what you suggested, adjusted the rest based on your set of > comments, and applied the patch. Thanks. One more item. The check_guc script currently outputs 68 false positives - even though it includes a list of 20 exceptions. This is not useful. $ (cd ./src/backend/utils/misc/; ./check_guc) |wc -l 68 With the attached: $ (cd ./src/backend/utils/misc/; ./check_guc) config_file seems to be missing from postgresql.conf.sample That has a defacto exception for the "include" directive, which seems reasonable. This requires GNU awk. I'm not sure if that's a limitation of any significance. -- Justin --Zr5irScySb2At5ws Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-check_guc-fix-absurd-number-of-false-positives.patch" From 8d9130a25a59630063e644a884d354eb085faa4e Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Sun, 5 Dec 2021 23:22:04 -0600 Subject: [PATCH] check_guc: fix absurd number of false positives Avoid false positives; Avoid various assumptions; Avoid list of exceptions; Simplify shell/awk/sed/grep; This requires GNU awk for RS as a regex. --- src/backend/utils/misc/check_guc | 69 +++++--------------------------- 1 file changed, 10 insertions(+), 59 deletions(-) diff --git a/src/backend/utils/misc/check_guc b/src/backend/utils/misc/check_guc index b171ef0e4f..323ca13191 100755 --- a/src/backend/utils/misc/check_guc +++ b/src/backend/utils/misc/check_guc @@ -1,78 +1,29 @@ -#!/bin/sh +#! /bin/sh +set -e -## currently, this script makes a lot of assumptions: +## this script makes some assumptions about the formatting of files it parses. ## in postgresql.conf.sample: ## 1) the valid config settings may be preceded by a '#', but NOT '# ' ## (we use this to skip comments) -## 2) the valid config settings will be followed immediately by ' =' -## (at least one space preceding the '=') -## in guc.c: -## 3) the options have PGC_ on the same line as the option -## 4) the options have '{' on the same line as the option - -## Problems -## 1) Don't know what to do with TRANSACTION ISOLATION LEVEL - -## if an option is valid but shows up in only one file (guc.c but not -## postgresql.conf.sample), it should be listed here so that it -## can be ignored -INTENTIONALLY_NOT_INCLUDED="debug_deadlocks in_hot_standby \ -is_superuser lc_collate lc_ctype lc_messages lc_monetary lc_numeric lc_time \ -pre_auth_delay role seed server_encoding server_version server_version_num \ -session_authorization trace_lock_oidmin trace_lock_table trace_locks trace_lwlocks \ -trace_notify trace_userlocks transaction_isolation transaction_read_only \ -zero_damaged_pages" ### What options are listed in postgresql.conf.sample, but don't appear ### in guc.c? -# grab everything that looks like a setting and convert it to lower case -SETTINGS=`grep ' =' postgresql.conf.sample | -grep -v '^# ' | # strip comments -sed -e 's/^#//' | -awk '{print $1}'` - -SETTINGS=`echo "$SETTINGS" | tr 'A-Z' 'a-z'` +# grab everything that looks like a setting +SETTINGS=`sed '/^#[[:alnum:]]/!d; s/^#//; s/ =.*//; /^include/d' postgresql.conf.sample` for i in $SETTINGS ; do - hidden=0 ## it sure would be nice to replace this with an sql "not in" statement - ## it doesn't seem to make sense to have things in .sample and not in guc.c -# for hidethis in $INTENTIONALLY_NOT_INCLUDED ; do -# if [ "$hidethis" = "$i" ] ; then -# hidden=1 -# fi -# done - if [ "$hidden" -eq 0 ] ; then - grep -i '"'$i'"' guc.c > /dev/null - if [ $? -ne 0 ] ; then - echo "$i seems to be missing from guc.c"; - fi; - fi + grep -i "\"$i\"" guc.c >/dev/null || + echo "$i seems to be missing from guc.c"; done ### What options are listed in guc.c, but don't appear ### in postgresql.conf.sample? # grab everything that looks like a setting and convert it to lower case - -SETTINGS=`grep '{.* PGC_' guc.c | awk '{print $1}' | \ - sed -e 's/{//g' -e 's/"//g' -e 's/,//'` - -SETTINGS=`echo "$SETTINGS" | tr 'A-Z' 'a-z'` - +SETTINGS=`gawk -F '[",]' 'BEGIN{RS="\n\t\\\\{\n"} /",[[:space:]]*PGC_.*.*gettext_noop/ && !/NOT_IN_SAMPLE/{print tolower($2)}' guc.c` for i in $SETTINGS ; do - hidden=0 - ## it sure would be nice to replace this with an sql "not in" statement - for hidethis in $INTENTIONALLY_NOT_INCLUDED ; do - if [ "$hidethis" = "$i" ] ; then - hidden=1 - fi - done - if [ "$hidden" -eq 0 ] ; then - grep -i '#'$i' ' postgresql.conf.sample > /dev/null - if [ $? -ne 0 ] ; then - echo "$i seems to be missing from postgresql.conf.sample"; - fi - fi + grep "#$i " postgresql.conf.sample >/dev/null || + echo "$i seems to be missing from postgresql.conf.sample"; done -- 2.17.0 --Zr5irScySb2At5ws--