Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x0iij-004mKk-1M for pgsql-hackers@arkaria.postgresql.org; Sun, 30 Aug 2026 16:49:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x0ihh-00DsDu-0r for pgsql-hackers@arkaria.postgresql.org; Sun, 30 Aug 2026 16:48:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x0ihg-00DsDl-37 for pgsql-hackers@lists.postgresql.org; Sun, 30 Aug 2026 16:48:20 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x0ihe-000000023lY-1gBy for pgsql-hackers@postgresql.org; Sun, 30 Aug 2026 16:48:20 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-51c0006ea8eso26807801cf.1 for ; Sun, 30 Aug 2026 09:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788108496; x=1788713296; darn=postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=oBRlyc8411MNWvat3lUyqM1a0TE3CNFMG5DqIyuqzME=; b=ektfbvAVfpupfpc+GiyTAyMDeUoqX3/hCipAPrj2CdATKIR1T95Fvtm2E9dtgF5RAo McuhiX58ABlUlp8aFQOd3RIct4k3AkOCwyDR9fK3ILfHiXwUNalftylgyy1V5Nbi5lXG 42HjZMsYYLf41pSLZ6imzpDFJyl4mIIMNsj8T+sEOEga6n1A+xDdX/rkhlof06048nAd qAmyXxoqcWZfKak4v4Umcvh3e4A9Vsny9C0gQngJA9EyxMTORYhs9UkwzIOYk2FhpDu9 NgV5+yLO8CgW4Xrup+etjwr7zI0+sbKkTSHkGJQeghrrWOXpFZRoVhlD44HRF0kVCreq Cpfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788108496; x=1788713296; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oBRlyc8411MNWvat3lUyqM1a0TE3CNFMG5DqIyuqzME=; b=SVeEha6sjdULU5V7NfOwi2UfReaJdKKjp14eFKqgJQt4tEQEqGVtN7K9+2Gm4zml/d tLUka9uqgtJO+j3JXuISjUiXVFCtCteHm100N3vxSAkJ3P2bpJ3Pcfpr4pGQMoqQla/Q gofJ2F45KZjt7J/1dMzEepSOreCuCXoMXj2KjqmGacXAqtHR/zpGwp81c/8zhEQqkxAh /gzFW59oaSekR3GCWjHdJO+02QSrEO9ChYLXdH8diqFAReazG1Y7ndTQusMiw6syvn8k zWz/glR/9CHADR2aqNk56mT8GJnTPJB6vmlUsF0l4zgcdt8NtLmxQvBKoOYXu3wXXCMq 2l5A== X-Forwarded-Encrypted: i=1; AHgh+Rp1BDr0UlA5pWxhfveXRCl9Y7feNUmHRIRj8rOl4ivZgqNmv1uCFQl5p8Fp6xJUYw322/eu3Aj20xntqSEG@postgresql.org X-Gm-Message-State: AFuF++l3pMXEzLKwfETm9pv+m1ZkhObZhfaeGJxnmn2kTi6Wc30e/Qpz sUpjEE+mlnmHLxCqDl63suzH+apb07nn8U1SoE/UT1q7iWn1ufes4EmKQXroLw== X-Gm-Gg: AR+sD10i6BjLm65wnQZhrgU+67gHgIktJ6eKGYPYZ/Z4LVV15zqGwdy+m4eMPvDHUfa bkeVz/xmX4ayhjtstmEKER50fJ6ieXmMiALYtAA/90VaKd/vxi38ZaVGE9HLbVcKEbyR6jwUyBB bZJWHQps2uvqxLoY5lHYsRAONd4SOfeOAytLO9xgMz+ShpR92/5V2Os/zSAlGkDg8Nmb3EggWJO ugwZx9KmJCRpKI6a3klGt0uja0K2o/2TKG1HhvdYwF5Rzm+AJIp53XJYzzkg+59K08SOnVL9mWT g/U3pfyhYFTD0HRRRaWAsHj009XiB8XHpJJsCU22W57GOjVDAHmHA2O+XkmjVRQnVrdqgjVbiuJ eDMe+/JpXWAv68WqXBXZg1ge668mPTMUvFgimf1KNCh2w+0aXQrjHscZWGtu38qqrNCFbh4h8Vp S/4F7rwdOZAjU/CublWDGoDvDq2Hm1t7dnJHZotY9BGvN44BDaoLLhD1mjLjewIM3J5O1BAODL8 K/8MyPLYH+g5QkYtxpnpTCRwv2m9/q2x2npAkUOkwHYeJtFLztuMoyBByoW2Dda4pyuRasZdhje 4aYaKwBfv48LEpM= X-Received: by 2002:ac8:5d10:0:b0:52d:3ff0:62ad with SMTP id d75a77b69052e-52fb965795fmr259613211cf.29.1788108496461; Sun, 30 Aug 2026 09:48:16 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-52ff6f363fasm38853451cf.16.2026.08.30.09.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Aug 2026 09:48:14 -0700 (PDT) Date: Sun, 30 Aug 2026 11:48:12 -0500 From: Nathan Bossart To: Chao Li Cc: Tom Lane , pgsql-hackers@postgresql.org Subject: Re: postgresql.conf.sample tab width Message-ID: References: <3230808.1763151915@sss.pgh.pa.us> <3238135.1763156048@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LmuKoVBvdv4SZ7R6" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --LmuKoVBvdv4SZ7R6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I noticed that initdb still adds tabs to postgresql.conf. Here is a patch to fix that, which simplifies replace_guc_value() a bit. -- nathan --LmuKoVBvdv4SZ7R6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0001-initdb-Pad-rewritten-GUC-lines-with-spaces-not-ta.patch From 7894bcefd428bd77c926a605b620e946a5b86ade Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Sun, 30 Aug 2026 11:41:41 -0500 Subject: [PATCH v1 1/1] initdb: Pad rewritten GUC lines with spaces, not tabs. Commit f63ae72bbc converted postgresql.conf.sample to spaces so that it lines up at any tab width, but replace_guc_value() still pads with tabs when it re-aligns the trailing comment of a setting it rewrites. The postgresql.conf that initdb generates therefore mixes the two. To fix, pad with spaces. While at it, simplify the calculation of the original comment column: with no tabs left in the sample file or in the lines we write out in its place, the de-tab-ifying loop is only ever counting bytes, so have it count bytes directly. Oversight in commit f63ae72bbc. Discussion: https://postgr.es/m/aReNUKdMgKxLqmq7%40nathan Backpatch-through: 19 --- src/bin/initdb/initdb.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index b3d496372ad..86d42a98a27 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -587,37 +587,16 @@ replace_guc_value(char **lines, const char *guc_name, const char *guc_value, { /* * We try to preserve original indentation, which is tedious. - * oldindent and newindent are measured in de-tab-ified columns. */ - const char *ptr; - int oldindent = 0; - int newindent; + int oldindent = (int) (where - lines[i]); + int newindent = newline->len; - for (ptr = lines[i]; ptr < where; ptr++) - { - if (*ptr == '\t') - oldindent += 8 - (oldindent % 8); - else - oldindent++; - } - /* ignore the possibility of tabs in guc_value */ - newindent = newline->len; - /* append appropriate tabs and spaces, forcing at least one */ + /* append appropriate spaces, forcing at least one */ oldindent = Max(oldindent, newindent + 1); while (newindent < oldindent) { - int newindent_if_tab = newindent + 8 - (newindent % 8); - - if (newindent_if_tab <= oldindent) - { - appendPQExpBufferChar(newline, '\t'); - newindent = newindent_if_tab; - } - else - { - appendPQExpBufferChar(newline, ' '); - newindent++; - } + appendPQExpBufferChar(newline, ' '); + newindent++; } /* and finally append the old comment */ appendPQExpBufferStr(newline, where); -- 2.55.0 --LmuKoVBvdv4SZ7R6--