Postgres perl module namespace

Started by Andrew Dunstanalmost 5 years ago63 messageshackers
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

While solving a problem with the Beta RPMs, I noticed that they export
our perl test modules as capabilities like this:

[andrew@f34 x86_64]$ rpm -q --provides -p
postgresql14-devel-14-beta1_PGDG.fc34.x86_64.rpm | grep ^perl
perl(PostgresNode)
perl(PostgresVersion)
perl(RecursiveCopy)
perl(SimpleTee)
perl(TestLib)

I don't think we should be putting this stuff in a global namespace like
that. We should invent a namespace that's not likely to conflict with
other people, like, say, 'PostgreSQL::Test' to put these modules. That
would require moving some code around and adjusting a bunch of scripts,
but it would not be difficult. Maybe something to be done post-14?
Meanwhile I would suggest that RPM maintainers exclude both requires and
provides for these five names.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#1)
Re: Postgres perl module namespace

Andrew Dunstan <andrew@dunslane.net> writes:

While solving a problem with the Beta RPMs, I noticed that they export
our perl test modules as capabilities like this:

[andrew@f34 x86_64]$ rpm -q --provides -p
postgresql14-devel-14-beta1_PGDG.fc34.x86_64.rpm | grep ^perl
perl(PostgresNode)
perl(PostgresVersion)
perl(RecursiveCopy)
perl(SimpleTee)
perl(TestLib)

I don't think we should be putting this stuff in a global namespace like
that. We should invent a namespace that's not likely to conflict with
other people, like, say, 'PostgreSQL::Test' to put these modules. That
would require moving some code around and adjusting a bunch of scripts,
but it would not be difficult. Maybe something to be done post-14?

Agreed that we ought to namespace these better. It looks to me like most
of these are several versions old. Given the lack of field complaints,
I'm content to wait for v15 for a fix, rather than treating it as an open
item for v14.

Meanwhile I would suggest that RPM maintainers exclude both requires and
provides for these five names.

+1

regards, tom lane

#3Devrim GÜNDÜZ
devrim@gunduz.org
In reply to: Andrew Dunstan (#1)
Re: Postgres perl module namespace

Hi,

On Thu, 2021-05-20 at 15:47 -0400, Andrew Dunstan wrote:

Meanwhile I would suggest that RPM maintainers exclude both requires
and provides for these five names.

Done, thanks. Will appear in next beta build.

Regards,
--
Devrim Gündüz
Open Source Solution Architect, Red Hat Certified Engineer
Twitter: @DevrimGunduz , @DevrimGunduzTR

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#2)
Re: Postgres perl module namespace

On 5/20/21 5:18 PM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

While solving a problem with the Beta RPMs, I noticed that they export
our perl test modules as capabilities like this:
[andrew@f34 x86_64]$ rpm -q --provides -p
postgresql14-devel-14-beta1_PGDG.fc34.x86_64.rpm | grep ^perl
perl(PostgresNode)
perl(PostgresVersion)
perl(RecursiveCopy)
perl(SimpleTee)
perl(TestLib)
I don't think we should be putting this stuff in a global namespace like
that. We should invent a namespace that's not likely to conflict with
other people, like, say, 'PostgreSQL::Test' to put these modules. That
would require moving some code around and adjusting a bunch of scripts,
but it would not be difficult. Maybe something to be done post-14?

Agreed that we ought to namespace these better. It looks to me like most
of these are several versions old. Given the lack of field complaints,
I'm content to wait for v15 for a fix, rather than treating it as an open
item for v14.

So now the dev tree is open for v15 it's time to get back to this item.
I will undertake to do the work, once we get the bike-shedding part done.

I'll kick that off by suggesting we move all of these to the namespace
PgTest, and rename TestLib to Utils, so instead of

    use TestLib;
    use PostgresNode;

you would say

    use PgTest::Utils;
    use PgTest::PostgresNode;

cheers

andrew

--

Andrew Dunstan
EDB: https://www.enterprisedb.com

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#4)
Re: Postgres perl module namespace

Andrew Dunstan <andrew@dunslane.net> writes:

I will undertake to do the work, once we get the bike-shedding part done.

I'll kick that off by suggesting we move all of these to the namespace
PgTest, and rename TestLib to Utils, so instead of
    use TestLib;
    use PostgresNode;
you would say
    use PgTest::Utils;
    use PgTest::PostgresNode;

Using both "Pg" and "Postgres" seems a bit inconsistent.
Maybe "PgTest::PgNode"?

More generally, I've never thought that "Node" was a great name
here; it's a very vague term. While we're renaming, maybe we
could change it to "PgTest::PgCluster" or the like?

regards, tom lane

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Andrew Dunstan (#4)
Re: Postgres perl module namespace

On 2021-Aug-10, Andrew Dunstan wrote:

I'll kick that off by suggesting we move all of these to the namespace
PgTest, and rename TestLib to Utils, so [...] you would say

    use PgTest::Utils;
    use PgTest::PostgresNode;

WFM.

--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
"Hay que recordar que la existencia en el cosmos, y particularmente la
elaboración de civilizaciones dentro de él no son, por desgracia,
nada idílicas" (Ijon Tichy)

#7Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#5)
Re: Postgres perl module namespace

On 8/10/21 10:40 AM, Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

I will undertake to do the work, once we get the bike-shedding part done.
I'll kick that off by suggesting we move all of these to the namespace
PgTest, and rename TestLib to Utils, so instead of
    use TestLib;
    use PostgresNode;
you would say
    use PgTest::Utils;
    use PgTest::PostgresNode;

Using both "Pg" and "Postgres" seems a bit inconsistent.
Maybe "PgTest::PgNode"?

More generally, I've never thought that "Node" was a great name
here; it's a very vague term. While we're renaming, maybe we
could change it to "PgTest::PgCluster" or the like?

I can live with that. I guess to be consistent we would also rename
PostgresVersion to PgVersion

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#8Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#7)
Re: Postgres perl module namespace

On Tue, Aug 10, 2021 at 11:02:13AM -0400, Andrew Dunstan wrote:

I can live with that. I guess to be consistent we would also rename
PostgresVersion to PgVersion

Are RewindTest.pm and SSLServer.pm things you are considering for a
renaming as well? It may be more consistent to put everything in the
same namespace if this move is done.
--
Michael

#9Mark Dilger
mark.dilger@enterprisedb.com
In reply to: Andrew Dunstan (#4)
Re: Postgres perl module namespace

On Aug 10, 2021, at 7:10 AM, Andrew Dunstan <andrew@dunslane.net> wrote:

use PgTest::Utils;
use PgTest::PostgresNode;

Checking CPAN, it seems there are three older modules with names starting with "Postgres":

Postgres
Postgres::Handler
Postgres::Handler::HTML

It would be confusing to combine official PostgreSQL modules with those third party ones, so perhaps we can claim the PostgreSQL namespace for official project modules. How about:

PostgreSQL::Test::Cluster
PostgreSQL::Test::Lib
PostgreSQL::Test::Utils

and then if we ever wanted to have official packages for non-test purposes, we could start another namespace under PostgreSQL.


Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#10Julien Rouhaud
rjuju123@gmail.com
In reply to: Mark Dilger (#9)
Re: Postgres perl module namespace

On Wed, Aug 11, 2021 at 9:37 AM Mark Dilger
<mark.dilger@enterprisedb.com> wrote:

On Aug 10, 2021, at 7:10 AM, Andrew Dunstan <andrew@dunslane.net> wrote:

use PgTest::Utils;
use PgTest::PostgresNode;

Checking CPAN, it seems there are three older modules with names starting with "Postgres":

Postgres
Postgres::Handler
Postgres::Handler::HTML

It would be confusing to combine official PostgreSQL modules with those third party ones, so perhaps we can claim the PostgreSQL namespace for official project modules. How about:

PostgreSQL::Test::Cluster
PostgreSQL::Test::Lib
PostgreSQL::Test::Utils

and then if we ever wanted to have official packages for non-test purposes, we could start another namespace under PostgreSQL.

Maybe it's me but I would find that more confusing. Also, to actually
claim PostgreSQL namespace, we would have to actually publish them on
CPAN right?

#11Andrew Dunstan
andrew@dunslane.net
In reply to: Mark Dilger (#9)
Re: Postgres perl module namespace

On 8/10/21 9:37 PM, Mark Dilger wrote:

On Aug 10, 2021, at 7:10 AM, Andrew Dunstan <andrew@dunslane.net> wrote:

use PgTest::Utils;
use PgTest::PostgresNode;

Checking CPAN, it seems there are three older modules with names starting with "Postgres":

Postgres
Postgres::Handler
Postgres::Handler::HTML

It would be confusing to combine official PostgreSQL modules with those third party ones, so perhaps we can claim the PostgreSQL namespace for official project modules. How about:

PostgreSQL::Test::Cluster
PostgreSQL::Test::Lib
PostgreSQL::Test::Utils

and then if we ever wanted to have official packages for non-test purposes, we could start another namespace under PostgreSQL.

If we were publishing them on CPAN that would be reasonable. But we're
not, nor are we likely to, I believe. I'd rather not have to add two
level of directory hierarchy for this, and this also seems a bit
long-winded:

    my $node = PostgreSQL::Test::Cluster->new('nodename');

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#12Mark Dilger
mark.dilger@enterprisedb.com
In reply to: Andrew Dunstan (#11)
Re: Postgres perl module namespace

On Aug 10, 2021, at 7:11 PM, Andrew Dunstan <andrew@dunslane.net> wrote:

If we were publishing them on CPAN that would be reasonable. But we're
not, nor are we likely to, I believe.

I'm now trying to understand the purpose of the renaming. I thought the problem was that RPM packagers wanted something that was unlikely to collide. Publishing on CPAN would be the way to claim the namespace.

What's the purpose of this idea then? If there isn't one, I'd rather just keep the current names.


Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#13Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#8)
Re: Postgres perl module namespace

On 8/10/21 9:25 PM, Michael Paquier wrote:

On Tue, Aug 10, 2021 at 11:02:13AM -0400, Andrew Dunstan wrote:

I can live with that. I guess to be consistent we would also rename
PostgresVersion to PgVersion

Are RewindTest.pm and SSLServer.pm things you are considering for a
renaming as well? It may be more consistent to put everything in the
same namespace if this move is done.

It could be very easily done. But I doubt these will make their way into
packages, which is how this discussion started. There's good reason to
package src/test/perl, so you can use those modules to write TAP tests
for extensions. The same reasoning doesn't apply to SSLServer.pm and
RewindTest.pm.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#14Andrew Dunstan
andrew@dunslane.net
In reply to: Mark Dilger (#12)
Re: Postgres perl module namespace

On 8/10/21 10:13 PM, Mark Dilger wrote:

On Aug 10, 2021, at 7:11 PM, Andrew Dunstan <andrew@dunslane.net> wrote:

If we were publishing them on CPAN that would be reasonable. But we're
not, nor are we likely to, I believe.

I'm now trying to understand the purpose of the renaming. I thought the problem was that RPM packagers wanted something that was unlikely to collide. Publishing on CPAN would be the way to claim the namespace.

What's the purpose of this idea then? If there isn't one, I'd rather just keep the current names.

Yes we want them to be in a namespace where they are unlikely to collide
with anything else. No, you don't have to publish on CPAN to achieve that.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#15Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#14)
Re: Postgres perl module namespace

On 8/10/21 10:26 PM, Andrew Dunstan wrote:

On 8/10/21 10:13 PM, Mark Dilger wrote:

On Aug 10, 2021, at 7:11 PM, Andrew Dunstan <andrew@dunslane.net> wrote:

If we were publishing them on CPAN that would be reasonable. But we're
not, nor are we likely to, I believe.

I'm now trying to understand the purpose of the renaming. I thought the problem was that RPM packagers wanted something that was unlikely to collide. Publishing on CPAN would be the way to claim the namespace.

What's the purpose of this idea then? If there isn't one, I'd rather just keep the current names.

Yes we want them to be in a namespace where they are unlikely to collide
with anything else. No, you don't have to publish on CPAN to achieve that.

Incidentally, not publishing on CPAN was a major reason given a few
years ago for using fairly lax perlcritic policies. If we publish these
on CPAN now some people at least might want to revisit that decision.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#16Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Andrew Dunstan (#11)
Re: Postgres perl module namespace

On 2021-Aug-10, Andrew Dunstan wrote:

If we were publishing them on CPAN that would be reasonable. But we're
not, nor are we likely to, I believe. I'd rather not have to add two
level of directory hierarchy for this, and this also seems a bit
long-winded:

    my $node = PostgreSQL::Test::Cluster->new('nodename');

I'll recast my vote to make this line be

    my $node = PgTest::Cluster->new('nodename');

which seems succint enough. I could get behind PgTest::PgCluster too,
but having a second Pg there seems unnecessary.

--
Álvaro Herrera Valdivia, Chile — https://www.EnterpriseDB.com/
"Cada quien es cada cual y baja las escaleras como quiere" (JMSerrat)

#17Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#16)
Re: Postgres perl module namespace

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:

I'll recast my vote to make this line be
    my $node = PgTest::Cluster->new('nodename');
which seems succint enough. I could get behind PgTest::PgCluster too,
but having a second Pg there seems unnecessary.

Either of those WFM.

regards, tom lane

#18Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#17)
Re: Postgres perl module namespace

On 8/11/21 9:30 AM, Tom Lane wrote:

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:

I'll recast my vote to make this line be
    my $node = PgTest::Cluster->new('nodename');
which seems succint enough. I could get behind PgTest::PgCluster too,
but having a second Pg there seems unnecessary.

Either of those WFM.

OK, I count 3 in favor of changing to PgTest::Cluster, 1 against,
remainder don't care.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#19Robert Haas
robertmhaas@gmail.com
In reply to: Andrew Dunstan (#18)
Re: Postgres perl module namespace

On Mon, Aug 23, 2021 at 3:03 PM Andrew Dunstan <andrew@dunslane.net> wrote:

OK, I count 3 in favor of changing to PgTest::Cluster, 1 against,
remainder don't care.

I'd have gone with something starting with Postgres:: ... but I don't care much.

--
Robert Haas
EDB: http://www.enterprisedb.com

#20Michael Paquier
michael@paquier.xyz
In reply to: Robert Haas (#19)
Re: Postgres perl module namespace

On Mon, Aug 23, 2021 at 03:39:15PM -0400, Robert Haas wrote:

On Mon, Aug 23, 2021 at 3:03 PM Andrew Dunstan <andrew@dunslane.net> wrote:

OK, I count 3 in favor of changing to PgTest::Cluster, 1 against,
remainder don't care.

I'd have gone with something starting with Postgres:: ... but I don't care much.

PgTest seems like a better choice to me, as "Postgres" could be used
for other purposes than a testing framework, and the argument that
multiple paths makes things annoying for hackers is sensible.
--
Michael

#21Robert Haas
robertmhaas@gmail.com
In reply to: Michael Paquier (#20)
#22Andrew Dunstan
andrew@dunslane.net
In reply to: Robert Haas (#21)
#23Noah Misch
noah@leadboat.com
In reply to: Andrew Dunstan (#22)
#24Andrew Dunstan
andrew@dunslane.net
In reply to: Noah Misch (#23)
#25Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#24)
#26Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#25)
#27Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#25)
#28Noah Misch
noah@leadboat.com
In reply to: Andrew Dunstan (#27)
#29Mark Dilger
mark.dilger@enterprisedb.com
In reply to: Noah Misch (#28)
#30Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#27)
#31Erik Rijkers
er@xs4all.nl
In reply to: Andrew Dunstan (#30)
#32Michael Paquier
michael@paquier.xyz
In reply to: Erik Rijkers (#31)
#33Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#32)
#34Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#33)
#35Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#34)
#36Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#35)
#37Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andres Freund (#36)
#38Andres Freund
andres@anarazel.de
In reply to: Tom Lane (#37)
#39Noah Misch
noah@leadboat.com
In reply to: Andres Freund (#36)
#40Andrew Dunstan
andrew@dunslane.net
In reply to: Noah Misch (#39)
#41Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#40)
#42Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#41)
#43Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#42)
#44Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#43)
#45Mark Dilger
mark.dilger@enterprisedb.com
In reply to: Andrew Dunstan (#42)
#46Andrew Dunstan
andrew@dunslane.net
In reply to: Mark Dilger (#45)
#47Mark Dilger
mark.dilger@enterprisedb.com
In reply to: Andrew Dunstan (#46)
#48Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#42)
#49Daniel Gustafsson
daniel@yesql.se
In reply to: Andrew Dunstan (#42)
#50Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#43)
#51Andres Freund
andres@anarazel.de
In reply to: Andrew Dunstan (#50)
#52Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#50)
#53Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#52)
#54Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#53)
#55Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#54)
#56Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#55)
#57Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#56)
#58Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#57)
#59Andres Freund
andres@anarazel.de
In reply to: Andrew Dunstan (#58)
#60Noah Misch
noah@leadboat.com
In reply to: Andrew Dunstan (#54)
#61Andrew Dunstan
andrew@dunslane.net
In reply to: Noah Misch (#60)
#62Noah Misch
noah@leadboat.com
In reply to: Andrew Dunstan (#61)
#63Noah Misch
noah@leadboat.com
In reply to: Noah Misch (#62)