Re: PL/Java new build plugin

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Kartik Ohri <kartikohri13(at)gmail(dot)com>
Cc: pljava-dev(at)lists(dot)postgresql(dot)org
Subject: Re: PL/Java new build plugin
Date: 2020-07-05 00:58:36
Message-ID: 5F0125BC.5000609@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

On 07/03/20 06:20, Kartik Ohri wrote:
> Hi! I have pushed a commit to branch modifying the mojo to create a
> pgxs.properties file. It works fine on Linux except the version
> classifier regex. I copied it from the build.xml file. I do not know what
> the pattern of a version is so I am unable to debug this. Can you explain
> this a bit ?

The stuff in the filterchain/tokenfilter elements, right?

Hmm, well well, it looks like I wrote those, back in 2015, and then
tweaked them slightly in 2016 because some builds of PostgreSQL can have
extra custom information appended to the version. Then tweaked them again
in 2017 for PG 10 where the numbering scheme changed.

The commit where I tweaked for the custom suffixes was bf59577, and
the one for the PG10 numbering change was c434748. The commit comments
and diffs give some insight into what was changed and why. (Have you
played with 'blame' in git before?)

There are two steps there. The first will just replace any suffix
like BETA1 or RC2 with a .99 numeric component, so the next step can
just: skip some possible non-digits at the front, then look for
some groups of digits separated by real dots, then skip anything else
at the end. Replace all that with pg\1.\2 where the references are to
the first two groups of digits.

Now that I think of it, that wasn't quite the right tweak for the PG10
version-scheme change. Prior to 10, a PG version had three numeric
components, and the first two together made a major version (9.4, 9.5,
etc.) and the third component was a minor update.

In 10 and later, there are two numeric components, and just the first one
is the major version, and the second is the minor.

So, if the way the script previously worked was to make, say, a
...-pg9.5-amd64-Linux-gpp.jar (where the classifier mentioned just
the PG major version 9.5, and not the minor version), then in 10 and
later it should just produce ...-pg10-amd64-Linux-gpp.jar. Right now
it produces -pg10.12 (that is, it still includes two components, so
now the jar name reflects the minor version updates, which it previously
did not).

I also see I was careless writing the earlier, replaceregex pattern.
I am prone to forgetting that pretty much everything binds more tightly
than | does, so the way I wrote that pattern, the $ at the end only applies
to the last alternative. It turns out not to make much difference because
every alternative ends with .*, but it could be a subtle trap if there is
ever a reason to tweak that pattern. It would be clearer to enclose all the
alternatives in a non-capturing group and have the $ follow that.

It looks as if you copied the expressions faithfully, except perhaps
for the flags that are set for the first one. That probably doesn't
explain any problem you're having (though it should be fixed anyway),
as that first pattern isn't even in play unless you are building against
a devel, alpha, beta, or rc version of PostgreSQL.

Can you supply an example of what is going wrong?

One last thing, not regex related:

You can see the original build.xml code invokes pg_config multiple
times, reading one configuration value each time, and the same is
done by PGXS in Makefile.global [1].

It does seem more efficient to invoke pg_config only once and parse
its output for the various values, as you are doing here.

What could be the reason existing code avoided doing that?

Regards,
-Chap

[1]
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/Makefile.global.in;h=20d7a1d;hb=4fc935a#l119

In response to

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Kartik Ohri 2020-07-05 04:35:46 Re: PL/Java new build plugin
Previous Message Kartik Ohri 2020-07-03 10:20:08 Re: PL/Java new build plugin