Subject: Re: pgsql: Clean up role created in new subscription test.

From: Alvaro Herrera <[email-masked]>
Date: Wed, 8 Nov 2023 12:42:26 +0100

On 2023-Nov-08, Peter Eisentraut wrote:

> I think the earlier idea of just counting roles, tablespaces, etc. before
> and after would be sufficient.

Maybe record global objects in a permanent table in test_setup.sql

create table global_objs as
select 'role', rolname from pg_roles
union all
select 'tablespace', spcname from pg_tablespace;

and at the end (maybe in test tablespace, though it's unrelated but it's
what runs last and drops regress_tablespace), have

(select 'role', rolname from pg_roles
union all
select 'tablespace', spcname from pg_tablespace)
except
select * from global_objs;

and check the expected as empty.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"La verdad no siempre es bonita, pero el hambre de ella sí"

---

From: Daniel Gustafsson <[email-masked]>
Date: Wed, 8 Nov 2023 13:24:41 +0100

> On 8 Nov 2023, at 12:42, Alvaro Herrera <[email-masked]> wrote:

> Maybe record global objects in a permanent table in test_setup.sql

Since test_setup.sql is part of the regress schedule and not pg_regress we
would have to implement this for each test run (regress, contribs etc), which
is what Peter didn't like about the original suggestion.

--
Daniel Gustafsson

---

From: Alvaro Herrera <[email-masked]>
Date: Wed, 8 Nov 2023 13:32:41 +0100

> is what Peter didn't like about the original suggestion.

Oh, somehow that aspect of his reply failed to register with me.  I
agree with your approach of using libpq in pg_regress then.

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.