Re: Should contrib modules install .h files?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Should contrib modules install .h files?
Date: 2018-07-02 13:26:30
Message-ID: 63444.1530537990@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> I'm thinking that $(includedir_server)/$(MODULEDIR) would be a
> reasonable place? MODULEDIR defaults to either "contrib" or "extension"
> depending on whether EXTENSION is set.
> Something like the attached patch seem reasonable?

FWIW, I agree with Andres' thought that each contrib module should have
its own subdirectory under $(includedir_server). Otherwise we're going
to be faced with questions about whether .h files need to be renamed
because they're not globally unique enough. There are already some that
are pretty shaky from this standpoint:

contrib$ ls */*.h
bloom/bloom.h pg_trgm/trgm.h
btree_gist/btree_gist.h pgcrypto/blf.h
btree_gist/btree_utils_num.h pgcrypto/imath.h
btree_gist/btree_utils_var.h pgcrypto/mbuf.h
cube/cubedata.h pgcrypto/md5.h
hstore/hstore.h pgcrypto/pgcrypto.h
intarray/_int.h pgcrypto/pgp.h
isn/EAN13.h pgcrypto/px-crypt.h
isn/ISBN.h pgcrypto/px.h
isn/ISMN.h pgcrypto/rijndael.h
isn/ISSN.h pgcrypto/sha1.h
isn/UPC.h postgres_fdw/postgres_fdw.h
isn/isn.h seg/segdata.h
ltree/crc32.h sepgsql/sepgsql.h
ltree/ltree.h tablefunc/tablefunc.h
pageinspect/pageinspect.h

Not sure about whether the MODULEDIR part is useful. Seems like
making a distinction between extensions and other contrib is
likely to create more headaches than it avoids.

BTW, it's somewhat interesting to think about whether we ought to
change the coding conventions so that extensions refer to their
own headers with a subdirectory, e.g., #include "bloom/bloom.h".
Having done that, all of contrib could build with a single
centrally-provided -I switch pointing at BUILDDIR/contrib/,
and there would be a path to allowing the code to build out of
tree by pointing that common -I at $(includedir_server)/ or
$(includedir_server)/MODULEDIR. This seems like it could be
a lot less messy as we accrete more cross-module references.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-07-02 13:37:43 Re: Test-cases for deferred constraints in plpgsql_transaction.sql
Previous Message Michael Paquier 2018-07-02 13:25:16 Re: Monitoring time of fsyncing WALs