From: | Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org> |
---|---|
To: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
Cc: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: manipulating pg_control file from Perl |
Date: | 2025-03-14 12:12:50 |
Message-ID: | 87senfzu7x.fsf@wibble.ilmari.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Aleksander Alekseev <aleksander(at)timescale(dot)com> writes:
> Hi,
>
> Previously it was pointed out [1] that manipulating the pg_control
> file from Cluster.pm may be beneficial under certain conditions.
[...]
> Unfortunately this can't be done at the moment. One of the reasons is
> that the ControlFileData structure stores platform-dependent types
> like `int`. The size of the structure and all the offsets within it
> are variable. The second reason is that integer representation may be
> little- or big-endian depending on the platform. The third reason is
> that the alignment of the fields may differ even if we switch to types
> of the known size like int32 / int64.
Notwitstanding Tom's objections, these are not reasons for not being
able to manipulate these values from Perl. The `i` and `I` formats for
pack/unpack (see https://perldoc.perl.org/functions/pack) use what the C
compiler calls `int`, in terms of both endianness and size.
> For named reasons, manipulating pg_upgrade from Perl is impractical,
> considering the number of environments we support.
>
> I see two possible solutions:
>
> 1) Provide a tool written in C that allows changing pg_control, e.g.
> `pg_writecontoldata` or maybe a flat like `pg_controldata -w`. The
> tool can be executed from Perl, so it shouldn't know about
> sizeof(int), alignment and endiness.
1.5) Use Perl's pack/unpack functions, which are explicitly desgined for
exactly this use case.
- ilmari
From | Date | Subject | |
---|---|---|---|
Next Message | Nisha Moond | 2025-03-14 12:13:30 | Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided. |
Previous Message | Bertrand Drouvot | 2025-03-14 12:08:46 | Re: Draft for basic NUMA observability |