Обсуждение: pgsql: Generate syscache info from catalog files

Поиск
Список
Период
Сортировка

pgsql: Generate syscache info from catalog files

От
Peter Eisentraut
Дата:
Generate syscache info from catalog files

Add a new genbki macros MAKE_SYSCACHE that specifies the syscache ID
macro, the underlying index, and the number of buckets.  From that, we
can generate the existing tables in syscache.h and syscache.c via
genbki.pl.

Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/75ae5875-3abc-dafc-8aec-73247ed41cde@eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9b1a6f50b91dca6610932650c8c81a3c924259f9

Modified Files
--------------
src/backend/catalog/.gitignore                 |   2 +
src/backend/catalog/Catalog.pm                 |  10 +
src/backend/catalog/Makefile                   |   2 +-
src/backend/catalog/genbki.pl                  |  75 +++
src/backend/utils/cache/syscache.c             | 632 +------------------------
src/include/catalog/.gitignore                 |   2 +
src/include/catalog/genbki.h                   |   6 +
src/include/catalog/meson.build                |  18 +-
src/include/catalog/pg_aggregate.h             |   2 +
src/include/catalog/pg_am.h                    |   3 +
src/include/catalog/pg_amop.h                  |   3 +
src/include/catalog/pg_amproc.h                |   2 +
src/include/catalog/pg_attribute.h             |   3 +
src/include/catalog/pg_auth_members.h          |   3 +
src/include/catalog/pg_authid.h                |   3 +
src/include/catalog/pg_cast.h                  |   2 +
src/include/catalog/pg_class.h                 |   3 +
src/include/catalog/pg_collation.h             |   3 +
src/include/catalog/pg_constraint.h            |   2 +
src/include/catalog/pg_conversion.h            |   4 +
src/include/catalog/pg_database.h              |   2 +
src/include/catalog/pg_default_acl.h           |   2 +
src/include/catalog/pg_enum.h                  |   3 +
src/include/catalog/pg_event_trigger.h         |   3 +
src/include/catalog/pg_foreign_data_wrapper.h  |   3 +
src/include/catalog/pg_foreign_server.h        |   3 +
src/include/catalog/pg_foreign_table.h         |   2 +
src/include/catalog/pg_index.h                 |   2 +
src/include/catalog/pg_language.h              |   3 +
src/include/catalog/pg_namespace.h             |   3 +
src/include/catalog/pg_opclass.h               |   3 +
src/include/catalog/pg_operator.h              |   2 +
src/include/catalog/pg_opfamily.h              |   3 +
src/include/catalog/pg_parameter_acl.h         |   2 +
src/include/catalog/pg_partitioned_table.h     |   2 +
src/include/catalog/pg_proc.h                  |   3 +
src/include/catalog/pg_publication.h           |   3 +
src/include/catalog/pg_publication_namespace.h |   3 +
src/include/catalog/pg_publication_rel.h       |   3 +
src/include/catalog/pg_range.h                 |   3 +
src/include/catalog/pg_replication_origin.h    |   3 +
src/include/catalog/pg_rewrite.h               |   2 +
src/include/catalog/pg_sequence.h              |   2 +
src/include/catalog/pg_statistic.h             |   2 +
src/include/catalog/pg_statistic_ext.h         |   3 +
src/include/catalog/pg_statistic_ext_data.h    |   1 +
src/include/catalog/pg_subscription.h          |   3 +
src/include/catalog/pg_subscription_rel.h      |   2 +
src/include/catalog/pg_tablespace.h            |   2 +
src/include/catalog/pg_transform.h             |   3 +
src/include/catalog/pg_ts_config.h             |   3 +
src/include/catalog/pg_ts_config_map.h         |   2 +
src/include/catalog/pg_ts_dict.h               |   3 +
src/include/catalog/pg_ts_parser.h             |   3 +
src/include/catalog/pg_ts_template.h           |   3 +
src/include/catalog/pg_type.h                  |   3 +
src/include/catalog/pg_user_mapping.h          |   3 +
src/include/utils/syscache.h                   |  98 +---
src/tools/pginclude/cpluspluscheck             |   5 +
src/tools/pginclude/headerscheck               |   5 +
60 files changed, 267 insertions(+), 717 deletions(-)


Re: pgsql: Generate syscache info from catalog files

От
Tom Lane
Дата:
Peter Eisentraut <peter@eisentraut.org> writes:
> Generate syscache info from catalog files

Per guaibasaurus[1], this commit broke "make dist":

...
rm -rf tmp_install/ portlock/
rm -f config.cache config.log config.status GNUmakefile
make[1]: Leaving directory '/home/pgsql/buildfarm/buildroot/HEAD/pgsql.build/postgresql-17devel'
/bin/tar chf postgresql-17devel.tar postgresql-17devel
/bin/tar: postgresql-17devel/src/include/catalog/syscache_ids.h: File removed before we read it
/bin/tar: postgresql-17devel/src/include/catalog/syscache_info.h: File removed before we read it
make: *** [GNUmakefile:94: postgresql-17devel.tar] Error 1
make: *** Deleting file 'postgresql-17devel.tar'

I'm not sure why --- the makefile changes treat these new files
exactly like other generated files.  It doesn't repro here,
either, which is odd.  It looks like a timing problem, but how
could there be one?

            regards, tom lane

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=guaibasaurus&dt=2024-01-23%2012%3A20%3A03



Re: pgsql: Generate syscache info from catalog files

От
Tom Lane
Дата:
I wrote:
> Peter Eisentraut <peter@eisentraut.org> writes:
>> Generate syscache info from catalog files

> Per guaibasaurus[1], this commit broke "make dist":
> ...
> I'm not sure why --- the makefile changes treat these new files
> exactly like other generated files.  It doesn't repro here,
> either, which is odd.  It looks like a timing problem, but how
> could there be one?

Even odder: I did a test tarball build, and that worked too.
That runs on the very same VM as guaibasaurus, so what the heck?

            regards, tom lane



Re: pgsql: Generate syscache info from catalog files

От
Peter Eisentraut
Дата:
On 23.01.24 15:08, Tom Lane wrote:
> Peter Eisentraut <peter@eisentraut.org> writes:
>> Generate syscache info from catalog files
> 
> Per guaibasaurus[1], this commit broke "make dist":
> 
> ...
> rm -rf tmp_install/ portlock/
> rm -f config.cache config.log config.status GNUmakefile
> make[1]: Leaving directory '/home/pgsql/buildfarm/buildroot/HEAD/pgsql.build/postgresql-17devel'
> /bin/tar chf postgresql-17devel.tar postgresql-17devel
> /bin/tar: postgresql-17devel/src/include/catalog/syscache_ids.h: File removed before we read it
> /bin/tar: postgresql-17devel/src/include/catalog/syscache_info.h: File removed before we read it
> make: *** [GNUmakefile:94: postgresql-17devel.tar] Error 1
> make: *** Deleting file 'postgresql-17devel.tar'
> 
> I'm not sure why --- the makefile changes treat these new files
> exactly like other generated files.  It doesn't repro here,
> either, which is odd.  It looks like a timing problem, but how
> could there be one?

I have found that the files are not listed in the clean target in 
src/include/Makefile.  That might explain it, but it's gotta be fixed 
anyway.  I'll go ahead with that.




Re: pgsql: Generate syscache info from catalog files

От
Tom Lane
Дата:
Peter Eisentraut <peter@eisentraut.org> writes:
> On 23.01.24 15:08, Tom Lane wrote:
>> Per guaibasaurus[1], this commit broke "make dist":
>> I'm not sure why --- the makefile changes treat these new files
>> exactly like other generated files.  It doesn't repro here,
>> either, which is odd.  It looks like a timing problem, but how
>> could there be one?

> I have found that the files are not listed in the clean target in 
> src/include/Makefile.  That might explain it, but it's gotta be fixed 
> anyway.  I'll go ahead with that.

Looks like that made guaibasaurus happy, but I'm still mystified
as to what was wrong and why it didn't repro elsewhere.

            regards, tom lane



Re: pgsql: Generate syscache info from catalog files

От
Aleksander Alekseev
Дата:
Hi,

> > I have found that the files are not listed in the clean target in
> > src/include/Makefile.  That might explain it, but it's gotta be fixed
> > anyway.  I'll go ahead with that.
>
> Looks like that made guaibasaurus happy, but I'm still mystified
> as to what was wrong and why it didn't repro elsewhere.

I noticed that catalog/syscache_ids.h is not installed when using
Meson. This breaks 3rd party extensions like this:

```
In file included from
/Users/eax/projects/c/timescaledb/tsl/test/src/compression_unit_test.c:19:
/Users/eax/pginstall/include/postgresql/server/utils/syscache.h:23:10:
fatal error: 'catalog/syscache_ids.h' file not found
#include "catalog/syscache_ids.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~
```

It seems to me that include/catalog/meson.build should be modified,
however syscache_info.h *is* installed and I don't see why it would be
processed differently from syscache_ids.h.

There is no such problem with Autotools, it looks like 6eb6086faa38
did the trick.

-- 
Best regards,
Aleksander Alekseev



Re: pgsql: Generate syscache info from catalog files

От
Peter Eisentraut
Дата:
On 05.02.24 13:48, Aleksander Alekseev wrote:
> Hi,
> 
>>> I have found that the files are not listed in the clean target in
>>> src/include/Makefile.  That might explain it, but it's gotta be fixed
>>> anyway.  I'll go ahead with that.
>>
>> Looks like that made guaibasaurus happy, but I'm still mystified
>> as to what was wrong and why it didn't repro elsewhere.
> 
> I noticed that catalog/syscache_ids.h is not installed when using
> Meson. This breaks 3rd party extensions like this:
> 
> ```
> In file included from
> /Users/eax/projects/c/timescaledb/tsl/test/src/compression_unit_test.c:19:
> /Users/eax/pginstall/include/postgresql/server/utils/syscache.h:23:10:
> fatal error: 'catalog/syscache_ids.h' file not found
> #include "catalog/syscache_ids.h"
>           ^~~~~~~~~~~~~~~~~~~~~~~~
> ```
> 
> It seems to me that include/catalog/meson.build should be modified,
> however syscache_info.h *is* installed and I don't see why it would be
> processed differently from syscache_ids.h.

The code had this backward accidentally: syscache_ids.h should be 
installed, but syscache_info.h not.  I have fixed this.  Thanks.