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.94.2) (envelope-from ) id 1r91pb-00DaF3-CK for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 11:37:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r91pZ-007FHC-OV for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 11:37:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r91pZ-007FH4-BH for pgsql-hackers@lists.postgresql.org; Fri, 01 Dec 2023 11:37:13 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r91pV-008GM3-UD for pgsql-hackers@postgresql.org; Fri, 01 Dec 2023 11:37:12 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4ShWHj3CrKzyT0; Fri, 1 Dec 2023 13:37:02 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1701430626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BjymwWdqb+mN4lnneJZIU9d78D4djec8Ex1xKm5WNnw=; b=nEELa1Xv5wLgTzv84rCF02TYGEnae4nGuI/NDys835bhRXeY73aBewWJCJ8QfgIoef4Xft Pqhx1KGRcgR6PTSe37zdnte6akcncN9ijIj1WsjttSLEBxtOBSNtZ88lVnlveCrLH6qGeS zdgfqarkSqLw8cVjB1BOoz8VwaDp45Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1701430626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BjymwWdqb+mN4lnneJZIU9d78D4djec8Ex1xKm5WNnw=; b=hc7Ugi3RBq3mzSn0Ke6pI9SnzwDGNMrEGltkPqNH00Bz0dn3QuJcEUU4dSSgUjcYneGgBa PJNWHB5/DV4QmBf7ID3rtj97CZuepelV2p1o3wMgtqVic2XoQmyrjBs1lhSoy8epUROR5c zzb6AKXLAJiVtbhhZ+bW9Pu1MwysxeU= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1701430626; a=rsa-sha256; cv=none; b=P+HsfBJSGt9+z1MNtlVyx/Nwe5i1gQULXVtB40/fdzB+oIV0AQUIvjKjNZSds/IXrT9gPo 3ygkC9OAvaVjo4rRcvq5/+eYLr6MFWE98GMAJs0R1X3RWPqpQP9KPYfP6jmXmGULRgP+Ao +FsAwA6Qmby8eU0On0mEYM1YPu0ikwI= Message-ID: <8dbff2ac-eada-4f32-bc4f-d7b3b807a35b@iki.fi> Date: Fri, 1 Dec 2023 13:37:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgsql: Clean up role created in new subscription test. Content-Language: en-US To: Daniel Gustafsson , Alvaro Herrera Cc: Peter Eisentraut , Tom Lane , Robert Haas , PostgreSQL Hackers References: <202311081232.rn3aho5ay6yx@alvherre.pgsql> From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 01/12/2023 13:22, Daniel Gustafsson wrote: >> On 8 Nov 2023, at 13:32, Alvaro Herrera wrote: > >> I suppose you're just thinking of using PQexec() or whatever, run one >> query with sufficient ORDER BY, save the result, and at the end of the >> test run just run the same query and compare that they are cell-by-cell >> identical? This sounds a lot simpler than the patch you posted. > > I found some spare cycles for this and came up with the attached. The idea was > to keep it in-line with how pg_regress already today manipulate and traverse > _stringlists for various things. With the addition of the 0001 patch to clean > up global objects left in test_pg_dump it passes check-world. Do we want to impose this policy to all extensions too? > + /* > + * Store the global objects before the test starts such that we can check > + * for any objects left behind after the tests finish. > + */ > + query_to_stringlist("postgres", > + "(SELECT rolname AS obj FROM pg_catalog.pg_roles ORDER BY 1) " > + "UNION ALL " > + "(SELECT spcname AS obj FROM pg_catalog.pg_tablespace ORDER BY 1) " > + "UNION ALL " > + "(SELECT subname AS obj FROM pg_catalog.pg_subscription ORDER BY 1)", > + &globals_before); > + Strictly speaking, the order of this query isn't guaranteed to be stable, although in practice it probably is. Maybe something like this: (SELECT 'role', rolname AS obj FROM pg_catalog.pg_roles UNION ALL SELECT 'tablespace', spcname AS obj FROM pg_catalog.pg_tablespace UNION ALL SELECT 'subscription', subname AS obj FROM pg_catalog.pg_subscription ) ORDER BY 1, 2 Is it OK to leave behind extra databases? -- Heikki Linnakangas Neon (https://neon.tech)