The use of atooid() on non-Oid results - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject The use of atooid() on non-Oid results
Date
Msg-id 41AB5F1F-4389-4B25-9668-5C430375836C@yesql.se
Whole thread Raw
Responses Re: The use of atooid() on non-Oid results  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
When looking at the report in [0] an API choice in the relevant pg_upgrade code
path stood out as curious.  check_is_install_user() runs this query to ensure
that only the install user is present in the cluster:

    res = executeQueryOrDie(conn,
                            "SELECT COUNT(*) "
                            "FROM pg_catalog.pg_roles "
                            "WHERE rolname !~ '^pg_'");

The result is then verified with the following:

    if (cluster == &new_cluster && atooid(PQgetvalue(res, 0, 0)) != 1)
        pg_fatal("Only the install user can be defined in the new cluster.");

This was changed from atoi() in ee646df59 with no specific comment on why.
This is not a bug, since atooid() will do the right thing here, but it threw me
off reading the code and might well confuse others.  Is there a reason not to
change this back to atoi() for code clarity as we're not reading an Oid here?

--
Daniel Gustafsson

[0] VE1P191MB1118E9752D4EAD45205E995CD6BF9@VE1P191MB1118.EURP191.PROD.OUTLOOK.COM


pgsql-hackers by date:

Previous
From: Sandro Santilli
Date:
Subject: Re: Ability to reference other extensions by schema in extension scripts
Next
From: Peter Eisentraut
Date:
Subject: Re: Transparent column encryption