Thread: Bug: pg_regress makefile does not always copy refint.so

Bug: pg_regress makefile does not always copy refint.so

From
Donghang Lin
Date:

Hi hackers,

 

When I was building pg_regress, it didn’t always copy a rebuilt version of refint.so to the folder.   

 

Steps to reproduce:

OS: centos7

PSQL version: 14.5

 

1. configure and build postgres

2. edit file src/include/utils/rel.h so that contrib/spi will rebuild

3. cd ${builddir}/src/test/regress

4. make

We’ll find refint.so is rebuilt in contrib/spi, but not copied over to regress folder.

While autoinc.so is rebuilt and copied over.

 

Attach the potential patch to fix the issue.

 

Regards,

Donghang Lin

(ServiceNow)

 

 

Attachment

Re: Bug: pg_regress makefile does not always copy refint.so

From
Alvaro Herrera
Date:
On 2022-Oct-14, Donghang Lin wrote:

> Hi hackers,
> 
> When I was building pg_regress, it didn’t always copy a rebuilt version of refint.so to the folder.
> 
> Steps to reproduce:
> OS: centos7
> PSQL version: 14.5
> 
> 1. configure and build postgres
> 2. edit file src/include/utils/rel.h so that contrib/spi will rebuild
> 3. cd ${builddir}/src/test/regress
> 4. make
> We’ll find refint.so is rebuilt in contrib/spi, but not copied over to regress folder.
> While autoinc.so is rebuilt and copied over.

I have a somewhat-related-but-not-really complaint.  I recently had need to
have refint.so, autoinc.so and regress.so in the install directory; but it
turns out that there's no provision at all to get them installed.

Packagers have long have had a need for this; for example the postgresql-test
RPM file is built using this icky recipe:

%if %test
        # tests. There are many files included here that are unnecessary,
        # but include them anyway for completeness.  We replace the original
        # Makefiles, however.
        %{__mkdir} -p %{buildroot}%{pgbaseinstdir}/lib/test
        %{__cp} -a src/test/regress %{buildroot}%{pgbaseinstdir}/lib/test
        %{__install} -m 0755 contrib/spi/refint.so %{buildroot}%{pgbaseinstdir}/lib/test/regress
        %{__install} -m 0755 contrib/spi/autoinc.so %{buildroot}%{pgbaseinstdir}/lib/test/regress

I assume that the DEB does something similar, but I didn't look.

I think it would be better to provide a Make rule to allow these files to be
installed.  I'll see about a proposed patch.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
"Saca el libro que tu religión considere como el indicado para encontrar la
oración que traiga paz a tu alma. Luego rebootea el computador
y ve si funciona" (Carlos Duclós)



Re: Bug: pg_regress makefile does not always copy refint.so

From
Donghang Lin
Date:

Hi Alvaro,

 

> I have a somewhat-related-but-not-really complaint.  I recently had need to

> have refint.so, autoinc.so and regress.so in the install directory; but it

> turns out that there's no provision at all to get them installed.

 

True, we also noticed this build bug described above by copying *.so and pg_regress binary around.

 

> I think it would be better to provide a Make rule to allow these files to be
> installed. 

I looked at what postgresql-test package provides today :

 

$ ls /usr/pgsql-15/lib/test/regress

autoinc.so  data  expected  Makefile  parallel_schedule  pg_regress  pg_regress.c  pg_regress.h  pg_regress_main.c  README  refint.so  regress.c  regressplans.sh  regress.so  resultmap  sql

(I’m not sure what this package is supposed to do,  it contains both source files and the executables.

 

The current pgsql install directory of regress only contains pg_regress binary,   
Do you suggest we add these files (excluding the scratched files) to the regress install directory?

autoinc.so  data  expected  Makefile  parallel_schedule  pg_regress  pg_regress.c  pg_regress.h  pg_regress_main.c  README  refint.so  regress.c  regressplans.sh  regress.so  resultmap  sql

 

>> 1. configure and build postgres
>> 2. edit file src/include/utils/rel.h so that contrib/spi will rebuild
>> 3. cd ${builddir}/src/test/regress
>> 4. make
>> We’ll find refint.so is rebuilt in contrib/spi, but not copied over to regress folder.
>> While autoinc.so is rebuilt and copied over.

 

I think this build bug is orthogonal to the inconvenient installation/packaging.

It produces inconsistent build result, e.g you have to run `make` twice to ensure newly built refint.so is copied to the build dir.

 

Regards,

Donghang Lin

(ServiceNow)

 

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Friday, October 14, 2022 at 8:15 PM
To: Donghang Lin <donghang.lin@servicenow.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: Bug: pg_regress makefile does not always copy refint.so

[External Email]


On 2022-Oct-14, Donghang Lin wrote:

> Hi hackers,
>
> When I was building pg_regress, it didn’t always copy a rebuilt version of refint.so to the folder.
>
> Steps to reproduce:
> OS: centos7
> PSQL version: 14.5
>
> 1. configure and build postgres
> 2. edit file src/include/utils/rel.h so that contrib/spi will rebuild
> 3. cd ${builddir}/src/test/regress
> 4. make
> We’ll find refint.so is rebuilt in contrib/spi, but not copied over to regress folder.
> While autoinc.so is rebuilt and copied over.

I have a somewhat-related-but-not-really complaint.  I recently had need to
have refint.so, autoinc.so and regress.so in the install directory; but it
turns out that there's no provision at all to get them installed.

Packagers have long have had a need for this; for example the postgresql-test
RPM file is built using this icky recipe:

%if %test
        # tests. There are many files included here that are unnecessary,
        # but include them anyway for completeness.  We replace the original
        # Makefiles, however.
        %{__mkdir} -p %{buildroot}%{pgbaseinstdir}/lib/test
        %{__cp} -a src/test/regress %{buildroot}%{pgbaseinstdir}/lib/test
        %{__install} -m 0755 contrib/spi/refint.so %{buildroot}%{pgbaseinstdir}/lib/test/regress
        %{__install} -m 0755 contrib/spi/autoinc.so %{buildroot}%{pgbaseinstdir}/lib/test/regress

I assume that the DEB does something similar, but I didn't look.

I think it would be better to provide a Make rule to allow these files to be
installed.  I'll see about a proposed patch.

--
Álvaro Herrera        Breisgau, Deutschland  —  https://urldefense.com/v3/__https://www.EnterpriseDB.com/__;!!N4vogdjhuJM!Gz471V39hPgZI8Uabm3fUUHoZIuoMKlnz6_W38wwQvH20ZKfYaIWioPYtBJU2U75apWuCP6NmZutZfZ92EDwq5vIcvs$
"Saca el libro que tu religión considere como el indicado para encontrar la
oración que traiga paz a tu alma. Luego rebootea el computador
y ve si funciona" (Carlos Duclós)

Re: Bug: pg_regress makefile does not always copy refint.so

From
Alvaro Herrera
Date:
Hi,

On 2022-Oct-18, Donghang Lin wrote:

> > I have a somewhat-related-but-not-really complaint.  I recently had need to
> > have refint.so, autoinc.so and regress.so in the install directory; but it
> > turns out that there's no provision at all to get them installed.

> The current pgsql install directory of regress only contains pg_regress binary,
> Do you suggest we add these files (excluding the scratched files) to the regress install directory?
> autoinc.so  data  expected  Makefile  parallel_schedule  pg_regress  pg_regress.c  pg_regress.h  pg_regress_main.c
README refint.so  regress.c  regressplans.sh  regress.so  resultmap  sql
 

No, I think the .c/.h files are likely included only because the RPM
rule is written somewhat carelessly.  If we add support in our
makefiles, it would have to be something better-considered.

> I think this build bug is orthogonal to the inconvenient installation/packaging.
> It produces inconsistent build result, e.g you have to run `make` twice to ensure newly built refint.so is copied to
thebuild dir.
 

Yes, I agree that it is orthogonal.  I'm not sure that what you propose
(changing these order-only dependencies into regular dependencies) is
the best possible fix, but I agree we need *some* fix.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/