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 1nIZjn-0001kB-Cq for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 17:29:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIZjl-0006Sv-Ak for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Feb 2022 17:29:37 +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 1nIZjk-0006Sm-Uo for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 17:29:37 +0000 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nIZjh-0000gw-6R for pgsql-hackers@lists.postgresql.org; Fri, 11 Feb 2022 17:29:36 +0000 Received: by mail-io1-xd33.google.com with SMTP id i62so12277956ioa.1 for ; Fri, 11 Feb 2022 09:29:33 -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=sscbsjVmjLM38q79CXGlzlvX5b9aVPgw62EJBpoZE5s=; b=1pdRWg6OnYdpXWsIiN8WiWy1aOyx71DAB3CQPo1d2cC8okrjJMIfsFA/4ZVGHoHd7v 2li7QniSE6e6pSR0xMsdnVu/6SrNeZzqcUn43hKmvrazRx4iAl+tYjkycUXySRV2za9m dwHG+QpfvzkD0pDPSJXzAqU+qWP1CIBKdJ6dc9jOG1fIxeWdDCfY/2fYxuoPgL7xvke7 81DTPN1gdoSUEvXuWGck1cg2rCIiuro5UP78IJk/D7O8EtNtpA6bkx3R2ScYEzR8b8dm lQFXwCUr8/8SqFBFs+yJnCfbVa5iVwW1+5Ag5N6P3Vl1ZzKwmTQB/UWVA9knu7MpPEu0 zRQQ== 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=sscbsjVmjLM38q79CXGlzlvX5b9aVPgw62EJBpoZE5s=; b=WCpEaPSTCL3rRe7QEhM5NXwaXFk9EqtkACxNPRdPPg7feDVrt43iHO/xNRxBLEWpA5 GIG6tKuu5MLmW3V/K+hlXnMpxGVRuCGWZl2/ZO0ZSRnec1TY7jbI7/vKwMzoBclLtnMm bcRsx8QuVPqMQ1Vgjovds+1riJ2mTCrvQdjv8QxxCQvy42mRzAhYYJBdwlvxZ6PRcqv3 WBt3DnhBAIXTgAxrbbWMw0hnED6RWFb05dauatUACgY/nbF/NbDhJW7RF/UMNquEmh9u pkLoHiu31XDMIWwYg6nzoRLq/7WumsKior6cl3DWeLOO0IwWtf+h8xrs3OF8wT+0M3yK Voog== X-Gm-Message-State: AOAM530dRcDD3dOXJnTdJH1YzZji7iKZHk33mNvmrDl9WYaBcy8MNpTT aQmTzZAiOBrLMH22cJ21JP0NJw== X-Google-Smtp-Source: ABdhPJxepApE8CqxRXz1VnBQDwKS9cnzdUFg2HU/s1IFb0eKgHBoYoI+OOI/PhuY6If93V94m1XxHA== X-Received: by 2002:a05:6638:a8d:: with SMTP id 13mr1480848jas.104.1644600571526; Fri, 11 Feb 2022 09:29:31 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h19sm12080058ila.4.2022.02.11.09.29.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Feb 2022 09:29:31 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id E52B0800A8D; Fri, 11 Feb 2022 11:29:29 -0600 (CST) Date: Fri, 11 Feb 2022 11:29:29 -0600 From: Justin Pryzby To: Tom Lane Cc: Christoph Berg , Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Add TAP test to automate the equivalent of check_guc Message-ID: <20220211172929.GF31460@telsasoft.com> References: <2023925.1644591595@sss.pgh.pa.us> <20220211153549.GE31460@telsasoft.com> <2027230.1644594087@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2027230.1644594087@sss.pgh.pa.us> 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 On Fri, Feb 11, 2022 at 10:41:27AM -0500, Tom Lane wrote: > Justin Pryzby writes: > > On Fri, Feb 11, 2022 at 09:59:55AM -0500, Tom Lane wrote: > >> This seems like a pretty bad idea even if it weren't failing outright. > >> We should be examining the version of the file that's in the source > >> tree; the one in the installation tree might have version-skew > >> problems, if you've not yet done "make install". > > > My original way used the source tree, but Michael thought it would be an issue > > for "installcheck" where the config may not be available. > > Yeah, you are at risk either way, but in practice nobody is going to be > running these TAP tests without a source tree. > > > This is what I had written: > > FROM (SELECT regexp_split_to_table(pg_read_file('postgresql.conf'), '\n') AS ln) conf > > That's not using the source tree either, but the copy in the > cluster-under-test. I'd fear it to be unstable in the buildfarm, where > animals can append whatever they please to the config file being used by > tests. The important test is that "new GUCs exist in sample.conf". The converse test is less interesting, so I think the important half would be okay. I see the BF client appends to postgresql.conf. https://github.com/PGBuildFarm/client-code/blob/main/run_build.pl#L1374 It could use "include", which was added in v8.2. Or it could add a marker, like pg_regress does: src/test/regress/pg_regress.c: fputs("\n# Configuration added by pg_regress\n\n", pg_conf); If it were desirable to also check that "things that look like GUCs in the conf are actually GUCs", either of those would avoid false positives. Or, is it okay to use ABS_SRCDIR? +\getenv abs_srcdir PG_ABS_SRCDIR +\set filename :abs_srcdir '../../../../src/backend/utils/misc/postgresql.conf.sample' +-- test that GUCS are in postgresql.conf +SELECT lower(name) FROM tab_settings_flags WHERE NOT not_in_sample EXCEPT +SELECT regexp_replace(ln, '^#?([_[:alpha:]]+) (= .*|[^ ]*$)', '\1') AS guc +FROM (SELECT regexp_split_to_table(pg_read_file(:'filename'), '\n') AS ln) conf +WHERE ln ~ '^#?[[:alpha:]]' +ORDER BY 1; + +-- test that lines in postgresql.conf that look like GUCs are GUCs +SELECT regexp_replace(ln, '^#?([_[:alpha:]]+) (= .*|[^ ]*$)', '\1') AS guc +FROM (SELECT regexp_split_to_table(pg_read_file(:'filename'), '\n') AS ln) conf +WHERE ln ~ '^#?[[:alpha:]]' +EXCEPT SELECT lower(name) FROM tab_settings_flags WHERE NOT not_in_sample +ORDER BY 1; -- Justin