Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PGlite version to a VFS file and report with select version() #369

Open
samwillis opened this issue Oct 7, 2024 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@samwillis
Copy link
Collaborator

There are a few things that would be useful here:

  1. For the VFS to have a PGLITE_VERSION file containing the PGlite version number that created the database. This is useful to track which version of PGlite was used to run INITDB. It should probable not be updated when running the same datadir with a newer PGlite, it's purely a history of what version ran initdb (the PG_VERSION only contains the numeric major version of postgres that created the database and so we can't reuse this file)
  2. Report the PGlite version when a user calls SELECT VERSION()

Postgres has it's version compiled into it via a PG_VERSION env var, which is used to construct PG_VERSION_STR here:

https://github.com/postgres/postgres/blob/53b2c921a0f9b56465ab65165c1909f9616ffa98/configure#L19226

Both are added to confdefs.h before compiling.

PGlite has a split compilation process, the WASM is built first, then the JS/TS wrapper and packaging. Our CI caches the WASM for faster builds. Ideally we use the existing changesets tooling to bump a version file somewhere that will trigger the rebuild of the WASM, and we patch the build config to something like:

cat >>confdefs.h <<_ACEOF
#define PG_VERSION_STR "PostgreSQL $PG_VERSION (PGlite $PGLITE_VERSION) on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"
_ACEOF

so that the resulting string is something like:

PostgreSQL 16.4 (PGlite v0.2.11) on x86_64-pc-linux-gnu, compiled by emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.68-git (20697f11b8f0fcb4c190acbf605e2361e39829ab), 32-bit

We should then modify our initdb to add the PGLITE_VERSION' file - it should probably be the full output of SELECT VERSION()but maybe prefixed withCreated by: ` to make it apparent its the version stat created the database.

I would prefer all this to be baked into the WASM (or native build with libpglite) rather than in the JS/TS code.

@pmp-p
Copy link
Collaborator

pmp-p commented Oct 8, 2024

right after initdb we could issues a :
COPY (SELECT CONCAT('Created by : ',version())) TO '/tmp/pglite/base/PGLITE_VERSION';

vs4vijay added a commit to vs4vijay/pglite that referenced this issue Oct 11, 2024
@pmp-p pmp-p self-assigned this Oct 12, 2024
@pmp-p pmp-p added the enhancement New feature or request label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants