Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o85x6-0008JK-3V for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Jul 2022 20:12:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o85x4-000375-UH for pgsql-hackers@arkaria.postgresql.org; Sun, 03 Jul 2022 20:12:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o85x4-00036w-KK for pgsql-hackers@lists.postgresql.org; Sun, 03 Jul 2022 20:12:18 +0000 Received: from mail1.dalibo.net ([212.83.143.11] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o85x1-0004VF-Uc for pgsql-hackers@postgresql.org; Sun, 03 Jul 2022 20:12:18 +0000 Received: from karst (larco.ioguix.net [78.202.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id 3BBDD1F9FD; Sun, 3 Jul 2022 22:12:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1656879134; bh=n7sqZlt+7ddHMik1PIx2T6Fmu6RggxAdo6o1XU2d75g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=M/arqSweZysGTCFEXcitqMmV8aMiQasaNXt0f4xGf/yEDp56n2PrCW1qrjFUFZ8R+ /jnGZo/PMGN+k1wx1lWB0iyoEyNB6r+0eXJWSPWTZoB8PbfqF54iQcHszMkApGHNEv 0iTPI8+aRGK/iIYekrDXUNpePZArfClD+nIygXEk= Date: Sun, 3 Jul 2022 22:12:13 +0200 From: Jehan-Guillaume de Rorthais To: Andrew Dunstan Cc: pgsql-hackers Subject: Re: Fix proposal for comparaison bugs in PostgreSQL::Version Message-ID: <20220703221213.3bee4790@karst> In-Reply-To: References: <20220628225325.53d97b8d@karst> <20220629110937.19fb2ca9@karst> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 3 Jul 2022 10:40:21 -0400 Andrew Dunstan wrote: > On 2022-06-29 We 05:09, Jehan-Guillaume de Rorthais wrote: > > On Tue, 28 Jun 2022 18:17:40 -0400 > > Andrew Dunstan wrote: > > > >> On 2022-06-28 Tu 16:53, Jehan-Guillaume de Rorthais wrote: > >>> ... > >>> A better fix would be to store the version internally as version_num that > >>> are trivial to compute and compare. Please, find in attachment an > >>> implementation of this. > >>> > >>> The patch is a bit bigger because it improved the devel version to support > >>> rc/beta/alpha comparison like 14rc2 > 14rc1. > >>> > >>> Moreover, it adds a bunch of TAP tests to check various use cases. > >> > >> Nice catch, but this looks like massive overkill. I think we can very > >> simply fix the test in just a few lines of code, instead of a 190 line > >> fix and a 130 line TAP test. > > I explained why the patch was a little bit larger than required: it fixes > > the bugs and do a little bit more. The _version_cmp sub is shorter and > > easier to understand, I use multi-line code where I could probably fold > > them in a one-liner, added some comments... Anyway, I don't feel the number > > of line changed is "massive". But I can probably remove some code and > > shrink some other if it is really important... > > > > Moreover, to be honest, I don't mind the number of additional lines of TAP > > tests. Especially since it runs really, really fast and doesn't hurt > > day-to-day devs as it is independent from other TAP tests anyway. It could > > be 1k, if it runs fast, is meaningful and helps avoiding futur regressions, > > I would welcome the addition. > > > I don't see the point of having a TAP test at all. We have TAP tests for > testing the substantive products we test, not for the test suite > infrastructure. Otherwise, where will we stop? Shall we have tests for > the things that test the test suite? Tons of perl module have regression tests. When questioning where testing should stop, it seems the Test::More module itself is not the last frontier: https://github.com/Test-More/test-more/tree/master/t Moreover, the PostgreSQL::Version is not a TAP test module, but a module to deal with PostgreSQL versions and compare them. Testing makes development faster as well when it comes to test the code. Instead of testing vaguely manually, you can test a whole bunch of situations and add accumulate some more when you think about a new one or when a bug is reported. Having TAP test helps to make sure the code work as expected. It helped me when creating my patch. With all due respect, I just don't understand your arguments against them. The number of lines or questioning when testing should stop doesn't hold much. > > If we really want to save some bytes, I have a two lines worth of code fix > > that looks more readable to me than fixing _version_cmp: > > > > +++ b/src/test/perl/PostgreSQL/Version.pm > > @@ -92,9 +92,13 @@ sub new > > # Split into an array > > my @numbers = split(/\./, $arg); > > > > + # make sure all digit of the array-represented version are set so > > we can > > + # keep _version_cmp code as a "simple" digit-to-digit comparison > > loop > > + $numbers[$_] += 0 for 0..3; > > + > > # Treat development versions as having a minor/micro version one > > less than # the first released version of that branch. > > - push @numbers, -1 if ($devel); > > + $numbers[3] = -1 if $devel; > > > > $devel ||= ""; > > I don't see why this is any more readable. The _version_cmp is much more readable. But anyway, this is not the point. Using an array to compare versions where we can use version_num seems like useless and buggy convolutions to me. Regards,