pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Daniel Gustafsson <daniel@yesql.se>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Peter Eisentraut <peter@eisentraut.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: Clean up role created in new subscription test.
Date: Fri, 1 Dec 2023 13:37:02 +0200
Message-ID: <8dbff2ac-eada-4f32-bc4f-d7b3b807a35b@iki.fi> (raw)
In-Reply-To: <E0EB10CE-9B58-44C0-8CBC-807BC8E5A84A@yesql.se>
References: <202311081232.rn3aho5ay6yx@alvherre.pgsql>
	<E0EB10CE-9B58-44C0-8CBC-807BC8E5A84A@yesql.se>

On 01/12/2023 13:22, Daniel Gustafsson wrote:
>> On 8 Nov 2023, at 13:32, Alvaro Herrera <alvherre@alvh.no-ip.org> 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)






view thread (28+ messages)  latest in thread

Message-ID: <8dbff2ac-eada-4f32-bc4f-d7b3b807a35b@iki.fi>
Permalink:  ../8dbff2ac-eada-4f32-bc4f-d7b3b807a35b@iki.fi/
Also on:    postgresql.org/message-id/8dbff2ac-eada-4f32-bc4f-d7b3b807a35b@iki.fi

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: hlinnaka@iki.fi, daniel@yesql.se, alvherre@alvh.no-ip.org, peter@eisentraut.org, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: pgsql: Clean up role created in new subscription test.
  In-Reply-To: <8dbff2ac-eada-4f32-bc4f-d7b3b807a35b@iki.fi>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox