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 1oZmJ0-0004s6-Lo for pgsql-hackers@arkaria.postgresql.org; Sun, 18 Sep 2022 04:53:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oZmIz-00025n-3w for pgsql-hackers@arkaria.postgresql.org; Sun, 18 Sep 2022 04:53:21 +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 1oZmIy-00025c-Dl for pgsql-hackers@lists.postgresql.org; Sun, 18 Sep 2022 04:53:20 +0000 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oZmIq-00061d-Ea for pgsql-hackers@postgresql.org; Sun, 18 Sep 2022 04:53:19 +0000 Received: by mail-io1-xd2a.google.com with SMTP id z191so20519320iof.10 for ; Sat, 17 Sep 2022 21:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date; bh=lO5zgVklOcu0Yx6oU6MZjBdvzzX6GNVCe+qfFB0KIiY=; b=qUUOXzxtUGrdavCTRFFRrOkucngPZzlRhFpxq+s+ERZU93cWVdJjtQjQKidOzTc58I 0Htdbp1j4KOecz/c4npdapTN6A137DeXe3LFUR0R7rj/Co5tieyp0qBQzz8yPkHCwHzI Wm1ogcc4/9CFwO5PoGXBfPX4vF6fmLIOi6E+sKgxiHuqyHZot+GfHyAM/eyF1DBPp5TI 6KUlefdv7xXj86c3o17xn45aX+f8Ec8CkygsC6BsQXDexPNOuzF+c+FlWIHJnXN68RYO rh00LDF7YuZzDHjofoL+9TkGsKELeXuL/ynmlPIcjH5BNZYl+nfhxinRdp/1E4XmlqR/ sSbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=lO5zgVklOcu0Yx6oU6MZjBdvzzX6GNVCe+qfFB0KIiY=; b=YRuFjDG4DiFLxE+V9Y1Npfb8eiCYavVHzMjHwfePxYiG/8GN5CUVQVJigcwfHS9h2+ R6YiJ+Kszc9AmQmazAsdYTcnzY/yCN4lzUki7JNcgi+MuyZa94ZxsLTDfFRLmT6KDbYK uPxg9YhhT2BXVWM7NPwXtqdikn5+zQfdvWHgiznkgupk8n8Owoc4J3FUHFvbBdJPL939 d0zoOXhaUy/PwKF0KkbKDZQRMXYDJk0Fjl6a24WcPPmKGS502B0p83A+onTi3YZ8PsL6 AvTuZ7mvIdnx70zlGtbfH/V2mePdWzgIdpu1wUE/F3O9W+fsBRf8ljS540xWtoM6zqc4 vj0w== X-Gm-Message-State: ACrzQf3hGWg4Z5TzUeT5yxiuBICPJnB0+pxDjz/JUMWnniAJ/uhB+sq6 JfnLxvCuZWaG3jL9tIMz2cDonA== X-Google-Smtp-Source: AMsMyM7zhWOV4AKFaimLi8rqKNEHw8wQDCu0cnlNutsLhYDi8pXkyqqeL/719SwKVYqM2KZAQw/KJQ== X-Received: by 2002:a05:6638:2686:b0:35a:413a:b7a0 with SMTP id o6-20020a056638268600b0035a413ab7a0mr5593004jat.224.1663476790665; Sat, 17 Sep 2022 21:53:10 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id o18-20020a02a1d2000000b00358329bd6cbsm4074543jah.122.2022.09.17.21.53.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Sep 2022 21:53:08 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 6295E801044; Sat, 17 Sep 2022 23:53:07 -0500 (CDT) Date: Sat, 17 Sep 2022 23:53:07 -0500 From: Justin Pryzby To: Kyotaro Horiguchi Cc: michael@paquier.xyz, andres@anarazel.de, nathandbossart@gmail.com, pgsql-hackers@postgresql.org Subject: Re: fix stats_fetch_consistency value in postgresql.conf.sample Message-ID: <20220918045306.GT31833@telsasoft.com> References: <20220713173000.GD18011@telsasoft.com> <20220713235444.GF18011@telsasoft.com> <20220719.150427.952514686871468436.horikyota.ntt@gmail.com> <20220720051226.GH12702@telsasoft.com> <20220728222734.GA1913@telsasoft.com> <20220913004303.GM31833@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="NSyv3PxMn0vTUI/G" Content-Disposition: inline In-Reply-To: <20220913004303.GM31833@telsasoft.com> 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 --NSyv3PxMn0vTUI/G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This is an alternative implementation, which still relies on adding the GUC_DYNAMIC, flag but doesn't require adding a new, sql-accessible function to convert the GUC to a pretty/human display value. --NSyv3PxMn0vTUI/G Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-add-DYNAMIC_DEFAULT-for-settings-which-vary-by-.-con.patch" From 25ee6d6ed23ff273e622551fd033c8d086953fe5 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Tue, 19 Jul 2022 08:31:56 -0500 Subject: [PATCH 1/2] add DYNAMIC_DEFAULT for settings which vary by ./configure or platform or initdb --- doc/src/sgml/func.sgml | 8 ++++++ src/backend/utils/misc/guc_funcs.c | 4 ++- src/backend/utils/misc/guc_tables.c | 39 ++++++++++++++++------------- src/include/utils/guc.h | 2 ++ 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 67eb3806326..63063d054c5 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -24341,6 +24341,14 @@ SELECT collation for ('foo' COLLATE "de_DE"); FlagDescription + + + DYNAMIC_DEFAULT + Parameters with this flag have default values which vary by + platform, or compile-time options, or are set dynamically during initdb. + + + EXPLAIN Parameters with this flag are included in diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index 3d2df18659b..3376f23e076 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -539,7 +539,7 @@ ShowAllGUCConfig(DestReceiver *dest) Datum pg_settings_get_flags(PG_FUNCTION_ARGS) { -#define MAX_GUC_FLAGS 5 +#define MAX_GUC_FLAGS 6 char *varname = TextDatumGetCString(PG_GETARG_DATUM(0)); struct config_generic *record; int cnt = 0; @@ -552,6 +552,8 @@ pg_settings_get_flags(PG_FUNCTION_ARGS) if (record == NULL) PG_RETURN_NULL(); + if (record->flags & GUC_DYNAMIC_DEFAULT) + flags[cnt++] = CStringGetTextDatum("DYNAMIC_DEFAULT"); if (record->flags & GUC_EXPLAIN) flags[cnt++] = CStringGetTextDatum("EXPLAIN"); if (record->flags & GUC_NO_RESET_ALL) diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 7bff45e10d6..bd3c84bc7b8 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -1201,7 +1201,7 @@ struct config_bool ConfigureNamesBool[] = {"debug_assertions", PGC_INTERNAL, PRESET_OPTIONS, gettext_noop("Shows whether the running server has assertion checks enabled."), NULL, - GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE + GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_DYNAMIC_DEFAULT }, &assert_enabled, #ifdef USE_ASSERT_CHECKING @@ -1377,7 +1377,8 @@ struct config_bool ConfigureNamesBool[] = { {"update_process_title", PGC_SUSET, PROCESS_TITLE, gettext_noop("Updates the process title to show the active SQL command."), - gettext_noop("Enables updating of the process title every time a new SQL command is received by the server.") + gettext_noop("Enables updating of the process title every time a new SQL command is received by the server."), + GUC_DYNAMIC_DEFAULT }, &update_process_title, #ifdef WIN32 @@ -2126,7 +2127,8 @@ struct config_int ConfigureNamesInt[] = { {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS, gettext_noop("Sets the maximum number of concurrent connections."), - NULL + NULL, + GUC_DYNAMIC_DEFAULT }, &MaxConnections, 100, 1, MAX_BACKENDS, @@ -2163,7 +2165,7 @@ struct config_int ConfigureNamesInt[] = {"shared_buffers", PGC_POSTMASTER, RESOURCES_MEM, gettext_noop("Sets the number of shared memory buffers used by the server."), NULL, - GUC_UNIT_BLOCKS + GUC_UNIT_BLOCKS | GUC_DYNAMIC_DEFAULT }, &NBuffers, 16384, 16, INT_MAX / 2, @@ -2677,7 +2679,7 @@ struct config_int ConfigureNamesInt[] = {"checkpoint_flush_after", PGC_SIGHUP, WAL_CHECKPOINTS, gettext_noop("Number of pages after which previously performed writes are flushed to disk."), NULL, - GUC_UNIT_BLOCKS + GUC_UNIT_BLOCKS | GUC_DYNAMIC_DEFAULT }, &checkpoint_flush_after, DEFAULT_CHECKPOINT_FLUSH_AFTER, 0, WRITEBACK_MAX_PENDING_FLUSHES, @@ -2895,7 +2897,7 @@ struct config_int ConfigureNamesInt[] = {"bgwriter_flush_after", PGC_SIGHUP, RESOURCES_BGWRITER, gettext_noop("Number of pages after which previously performed writes are flushed to disk."), NULL, - GUC_UNIT_BLOCKS + GUC_UNIT_BLOCKS | GUC_DYNAMIC_DEFAULT }, &bgwriter_flush_after, DEFAULT_BGWRITER_FLUSH_AFTER, 0, WRITEBACK_MAX_PENDING_FLUSHES, @@ -2908,7 +2910,7 @@ struct config_int ConfigureNamesInt[] = RESOURCES_ASYNCHRONOUS, gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."), NULL, - GUC_EXPLAIN + GUC_EXPLAIN | GUC_DYNAMIC_DEFAULT }, &effective_io_concurrency, #ifdef USE_PREFETCH @@ -2926,7 +2928,7 @@ struct config_int ConfigureNamesInt[] = RESOURCES_ASYNCHRONOUS, gettext_noop("A variant of effective_io_concurrency that is used for maintenance work."), NULL, - GUC_EXPLAIN + GUC_EXPLAIN | GUC_DYNAMIC_DEFAULT }, &maintenance_io_concurrency, #ifdef USE_PREFETCH @@ -2943,7 +2945,7 @@ struct config_int ConfigureNamesInt[] = {"backend_flush_after", PGC_USERSET, RESOURCES_ASYNCHRONOUS, gettext_noop("Number of pages after which previously performed writes are flushed to disk."), NULL, - GUC_UNIT_BLOCKS + GUC_UNIT_BLOCKS | GUC_DYNAMIC_DEFAULT }, &backend_flush_after, DEFAULT_BACKEND_FLUSH_AFTER, 0, WRITEBACK_MAX_PENDING_FLUSHES, @@ -3397,7 +3399,7 @@ struct config_int ConfigureNamesInt[] = {"debug_discard_caches", PGC_SUSET, DEVELOPER_OPTIONS, gettext_noop("Aggressively flush system caches for debugging purposes."), NULL, - GUC_NOT_IN_SAMPLE + GUC_NOT_IN_SAMPLE | GUC_DYNAMIC_DEFAULT }, &debug_discard_caches, #ifdef DISCARD_CACHES_ENABLED @@ -4224,7 +4226,7 @@ struct config_string ConfigureNamesString[] = {"unix_socket_directories", PGC_POSTMASTER, CONN_AUTH_SETTINGS, gettext_noop("Sets the directories where Unix-domain sockets will be created."), NULL, - GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY + GUC_LIST_INPUT | GUC_LIST_QUOTE | GUC_SUPERUSER_ONLY | GUC_DYNAMIC_DEFAULT }, &Unix_socket_directories, DEFAULT_PGSOCKET_DIR, @@ -4305,7 +4307,7 @@ struct config_string ConfigureNamesString[] = {"ssl_library", PGC_INTERNAL, PRESET_OPTIONS, gettext_noop("Shows the name of the SSL library."), NULL, - GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE + GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_DYNAMIC_DEFAULT }, &ssl_library, #ifdef USE_SSL @@ -4391,7 +4393,7 @@ struct config_string ConfigureNamesString[] = {"ssl_ciphers", PGC_SIGHUP, CONN_AUTH_SSL, gettext_noop("Sets the list of allowed SSL ciphers."), NULL, - GUC_SUPERUSER_ONLY + GUC_SUPERUSER_ONLY | GUC_DYNAMIC_DEFAULT }, &SSLCipherSuites, #ifdef USE_OPENSSL @@ -4406,7 +4408,7 @@ struct config_string ConfigureNamesString[] = {"ssl_ecdh_curve", PGC_SIGHUP, CONN_AUTH_SSL, gettext_noop("Sets the curve to use for ECDH."), NULL, - GUC_SUPERUSER_ONLY + GUC_SUPERUSER_ONLY | GUC_DYNAMIC_DEFAULT }, &SSLECDHCurve, #ifdef USE_SSL @@ -4644,7 +4646,8 @@ struct config_enum ConfigureNamesEnum[] = { {"syslog_facility", PGC_SIGHUP, LOGGING_WHERE, gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."), - NULL + NULL, + GUC_DYNAMIC_DEFAULT }, &syslog_facility, #ifdef HAVE_SYSLOG @@ -4757,7 +4760,8 @@ struct config_enum ConfigureNamesEnum[] = { {"dynamic_shared_memory_type", PGC_POSTMASTER, RESOURCES_MEM, gettext_noop("Selects the dynamic shared memory implementation used."), - NULL + NULL, + GUC_DYNAMIC_DEFAULT }, &dynamic_shared_memory_type, DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE, dynamic_shared_memory_options, @@ -4777,7 +4781,8 @@ struct config_enum ConfigureNamesEnum[] = { {"wal_sync_method", PGC_SIGHUP, WAL_SETTINGS, gettext_noop("Selects the method used for forcing WAL updates to disk."), - NULL + NULL, + GUC_DYNAMIC_DEFAULT }, &sync_method, DEFAULT_SYNC_METHOD, sync_method_options, diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index e426dd757d9..0447d3eb56a 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -238,6 +238,8 @@ typedef enum */ #define GUC_RUNTIME_COMPUTED 0x200000 +#define GUC_DYNAMIC_DEFAULT 0x400000 /* default value is dynamic */ + #define GUC_UNIT (GUC_UNIT_MEMORY | GUC_UNIT_TIME) -- 2.25.1 --NSyv3PxMn0vTUI/G Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0002-WIP-test-guc-default-values.patch" From d7940be9ac7f1e4d29b6651a315c8dbfc54f84e2 Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Wed, 25 May 2022 05:14:43 -0500 Subject: [PATCH 2/2] WIP: test guc default values --- src/backend/utils/misc/postgresql.conf.sample | 2 +- src/test/modules/test_misc/t/003_check_guc.pl | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 8a0b383eb71..88a033103d1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -721,7 +721,7 @@ # share/timezonesets/. #extra_float_digits = 1 # min -15, max 3; any value >0 actually # selects precise output mode -#client_encoding = sql_ascii # actually, defaults to database +#client_encoding = SQL_ASCII # actually, defaults to database # encoding # These settings are initialized by initdb, but they can be changed. diff --git a/src/test/modules/test_misc/t/003_check_guc.pl b/src/test/modules/test_misc/t/003_check_guc.pl index 60459ef759e..dd5ac2c8bc4 100644 --- a/src/test/modules/test_misc/t/003_check_guc.pl +++ b/src/test/modules/test_misc/t/003_check_guc.pl @@ -107,4 +107,36 @@ foreach my $param (@sample_intersect) ); } +# Test that GUCs in postgresql.conf.sample show the correct default values +my $check_defaults = $node->safe_psql( + 'postgres', + " + CREATE TABLE sample_conf AS + SELECT m[1] AS name, COALESCE(m[3], m[5]) AS sample_value + FROM (SELECT regexp_split_to_table(pg_read_file('../../../$sample_file'), '\n') AS ln) conf, + regexp_match(ln, '^#?([_[:alpha:]]+) (= ''([^'']*)''|(= ([^[:space:]]*))).*') AS m + WHERE ln ~ '^#?[[:alpha:]]' + "); + +$check_defaults = $node->safe_psql( + 'postgres', + " + SELECT name, current_setting(name), sc.sample_value, boot_val + FROM pg_show_all_settings() psas + JOIN sample_conf sc USING(name) + WHERE sc.sample_value != boot_val -- same value + AND sc.sample_value != current_setting(name) -- same value, with human units + AND sc.sample_value != current_setting(name)||'.0' -- same value with .0 suffix + AND 'DYNAMIC_DEFAULT' != ALL(pg_settings_get_flags(psas.name)) -- dynamically-set defaults + AND NOT (sc.sample_value ~ '^0' AND current_setting(name) ~ '^0') -- zeros may be written differently + AND NOT (sc.sample_value='60s' AND current_setting(name) = '1min') -- two ways to write 1min + AND name NOT IN ('krb_server_keyfile', 'wal_retrieve_retry_interval', 'log_autovacuum_min_duration'); -- exceptions + "); + +my @check_defaults_array = split("\n", lc($check_defaults)); +print(STDERR "$check_defaults\n"); + +is (@check_defaults_array, 0, + 'check for consistency of defaults in postgresql.conf.sample'); + done_testing(); -- 2.25.1 --NSyv3PxMn0vTUI/G--