Improve correlation names in sanity tests

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Improve correlation names in sanity tests
Date: 2022-02-08 13:52:09
Message-ID: c538308b-319c-8784-e250-1284d12d5411@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I had to do some analysis on the "sanity" tests in the regression test
suite (opr_sanity, type_sanity) recently, and I found some of the
queries very confusing. One main stumbling block is that for some
probably ancient reason many of the older queries are written with
correlation names p1, p2, etc. independent of the name of the catalog.
This one is a good example:

SELECT p1.oid, p1.oprname, p2.oid, p2.proname
FROM pg_operator AS p1, pg_proc AS p2 <-- HUH?!?
WHERE p1.oprcode = p2.oid AND
p1.oprkind = 'l' AND
(p2.pronargs != 1
OR NOT binary_coercible(p2.prorettype, p1.oprresult)
OR NOT binary_coercible(p1.oprright, p2.proargtypes[0])
OR p1.oprleft != 0);

I think this is better written as

SELECT o1.oid, o1.oprname, p1.oid, p1.proname
FROM pg_operator AS o1, pg_proc AS p1
WHERE o1.oprcode = p1.oid AND
o1.oprkind = 'l' AND
(p1.pronargs != 1
OR NOT binary_coercible(p1.prorettype, o1.oprresult)
OR NOT binary_coercible(o1.oprright, p1.proargtypes[0])
OR o1.oprleft != 0);

Attached is a patch that cleans up all the queries in this manner.

(As in the above case, I kept the digits like o1 and p1 even in cases
where only one of each letter is used in a query. This is mainly to
keep the style consistent, but if people don't like that at all, it
could be changed.)

Attachment Content-Type Size
0001-Improve-correlation-names-in-sanity-tests.patch text/plain 100.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2022-02-08 14:08:43 Re: Database-level collation version tracking
Previous Message Robert Haas 2022-02-08 13:45:53 Re: [PATCH v2] use has_privs_for_role for predefined roles