Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: electric-sql/pglite
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @electric-sql/pglite@0.2.13
Choose a base ref
...
head repository: electric-sql/pglite
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @electric-sql/pglite@0.2.14
Choose a head ref
  • 14 commits
  • 98 files changed
  • 9 contributors

Commits on Nov 12, 2024

  1. feat(pglite/live): Windowed live queries with offset and limit (#421)

    * Add window option to live query
    
    * Changeset
    
    * Docs
    
    * Address feedback
    
    * formatting
    
    * Style fix
    
    * Address feedback to react hook
    samwillis authored Nov 12, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    75f9f6d View commit details

Commits on Nov 14, 2024

  1. fix: make pglite compatible with @jest-environment: node (#424)

    * Make pglite compatible with @jest-environment: node
    
    * Add changeset
    
    ---------
    
    Co-authored-by: Ethan Reesor <ethan.reesor@gmail.com>
    samwillis and firelizzard18 authored Nov 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    df5c290 View commit details

Commits on Nov 20, 2024

  1. chore: Single command to build everything; minor fixes to build. (#429)

    * readme 'how to contribut' fix; build-with-docker script explicit volume permissions such that it is easier to understand where the output goes
    
    * feature: enable building fontend and backend in a single command
    
    * main README.md update
    
    * Update package.json
    
    Use the pnpm -r to build all packages,added a filter to only do packages (React, Vue, Sync etc). This will exclude the /docs and /demos (we we add them)
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    
    * integrated @samwillis README.md suggestions
    
    ---------
    
    Co-authored-by: tudor <tudor@swisstch.com>
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    3 people authored Nov 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    458ca42 View commit details

Commits on Nov 22, 2024

  1. set for sdk 3.1.72.0 (latest) (#410)

    * test 3.1.70.11
    
    * version
    
    * 3.1.71
    
    * Update .buildconfig
    
    * 3.1.72 no web opt / no closure
    
    * Chageset
    
    ---------
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    pmp-p and samwillis authored Nov 22, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1784d04 View commit details

Commits on Nov 25, 2024

  1. fix: pipelining prepared statements (#417)

    * fix socket pipelining read
    
    * one rfq after Parse, none for bind/descr/exec and one after each sync
    
    * match psycopg3 wire pipeline expectations
    
    * follow ppg3
    
    * follow ppg3
    
    * style
    
    * Chageset
    
    ---------
    
    Co-authored-by: User <user@pp.local>
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    3 people authored Nov 25, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ae36974 View commit details
  2. chore: Use "WITH RECURSIVE" CTE to traverse the live query dependenci…

    …es (#434)
    
    * Use PG "WITH RECURSIVE" to traverse the live query dependencies: https://www.postgresql.org/docs/current/queries-with.html#QUERIES-WITH-RECURSIVE
    
    * stylefix?
    
    * ran prettier
    
    * added changeset
    
    ---------
    
    Co-authored-by: tudor <tudor@swisstch.com>
    copiltembel and tudor authored Nov 25, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ce212cf View commit details

Commits on Nov 26, 2024

  1. fix socketfile comms (#436)

    * fix socketfile comms
    
    * fix the fix
    
    * fix the fix
    
    * fix the fix
    
    * fix the fix
    
    * remove wasm opt
    
    * remove wasm opt
    
    * no sdk checks for demo-site
    pmp-p authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1a53bb8 View commit details
  2. set a valid sdk rev. for postgis (#438)

    * set postgis-able sdk
    
    * test postgis extra build
    
    * fix sdk-extra url
    
    * missing files
    pmp-p authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    0bdd658 View commit details
  3. fix the build (#440)

    Co-authored-by: tudor <tudor@swisstch.com>
    copiltembel and tudor authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    328ed3a View commit details
  4. fix: pg-sync (#435)

    * fix: pg-sync
    
    * fix(lint): exception for lint rule in hook
    
    * fix(doc): update pglite-sync  example
    
    * fix(lint):
    
    * fix(doc): docs and docker-compose example
    
    * fix(doc):
    
    * fix(doc):
    
    * Update docs/docs/sync.md
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    
    * Update docs/docs/sync.md
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    
    * Update packages/pglite-sync/example/index.html
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    
    * fix:  electric extention parameters in tests
    
    * Update docs/docs/sync.md
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    
    * fix: duplicate in doc
    
    * Changeset
    
    * Tweak example readme
    
    ---------
    
    Co-authored-by: Sam Willis <sam.willis@gmail.com>
    yacineb and samwillis authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d1dd12b View commit details
  5. feat(pglite-tools): pg_dump (#425)

    * initial import of easywasi.js code
    
    * initial port of easywasi to typescript
    
    * Fix stylecheck
    
    * Add wasi to the build and as a package export
    
    * Fix types
    
    * WIP code for pg_dump (not working)
    
    * WIP
    
    * WIP
    
    * Refactor into seporate package
    
    * Add WASM loading for node
    
    * Update wasi shim
    
    * Node example
    
    * Working pg_dump!
    
    * FIx args and style
    
    * Readme
    
    * Tweaks and fix packaging
    
    * Add tests for pg_dump
    
    * Changeset
    
    * Increase test timeout
    
    * Fix test timeout on CI
    
    * Fix foratting and typos
    
    * Remove incorrect export from the pglite package
    samwillis authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6547374 View commit details
  6. fix(pglite/tools): package publishing config (#441)

    samwillis authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6050ce3 View commit details
  7. chore: wasi comms (#439)

    * closer to wasi branch
    
    * final test
    
    * -Os
    
    * +wasm-opt
    
    * only wasm-opt
    
    * do not bundle pgxs and contrib
    
    * cache key update
    pmp-p authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d7844ff View commit details
  8. Publish new versions (#422)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Nov 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    34cd616 View commit details
Showing with 9,598 additions and 990 deletions.
  1. +3 −1 .buildconfig
  2. +1 −1 .github/workflows/build_and_test.yml
  3. +10 −4 .github/workflows/build_wasm_postgres.yml
  4. +36 −5 README.md
  5. +17 −8 cibuild.sh
  6. +11 −5 cibuild/build-with-docker.sh
  7. +58 −45 cibuild/getsyms.py
  8. +6 −5 cibuild/linkexport.sh
  9. 0 cibuild/linkimports.sh
  10. +6 −3 cibuild/linkwasi.sh
  11. +4 −8 cibuild/linkweb.sh
  12. 0 cibuild/pg-16.x.sh
  13. +1 −2 cibuild/pg-git.sh
  14. +56 −34 cibuild/pgbuild.sh
  15. 0 cibuild/pglite-ts.sh
  16. +113 −0 cibuild/sdk.sh
  17. +37 −3 docs/docs/live-queries.md
  18. +6 −6 docs/docs/sync.md
  19. +11 −0 extra/postgis.diff
  20. +74 −0 extra/postgis.sh
  21. +3 −3 extra/vector.sh
  22. +2 −0 package.json
  23. +13 −0 packages/benchmark/CHANGELOG.md
  24. +1 −1 packages/benchmark/package.json
  25. +14 −0 packages/pglite-react/CHANGELOG.md
  26. +1 −1 packages/pglite-react/package.json
  27. +24 −13 packages/pglite-react/src/hooks.ts
  28. +14 −0 packages/pglite-repl/CHANGELOG.md
  29. +1 −1 packages/pglite-repl/package.json
  30. +14 −0 packages/pglite-sync/CHANGELOG.md
  31. +1 −1 packages/pglite-sync/README.md
  32. +1 −1 packages/pglite-sync/example/README.md
  33. +4 −6 packages/pglite-sync/example/docker-compose.yaml
  34. +1 −1 packages/pglite-sync/example/index.html
  35. +2 −2 packages/pglite-sync/package.json
  36. +22 −24 packages/pglite-sync/src/index.ts
  37. +26 −30 packages/pglite-sync/test/sync.test.ts
  38. +2 −0 packages/pglite-sync/vitest.config.ts
  39. +1 −0 packages/pglite-tools/.gitignore
  40. +7 −0 packages/pglite-tools/CHANGELOG.md
  41. +53 −0 packages/pglite-tools/README.md
  42. +29 −0 packages/pglite-tools/eslint.config.js
  43. +45 −0 packages/pglite-tools/package.json
  44. +43 −0 packages/pglite-tools/scripts/bundle-wasm.ts
  45. +1 −0 packages/pglite-tools/src/index.ts
  46. +233 −0 packages/pglite-tools/src/pg_dump.ts
  47. +202 −0 packages/pglite-tools/src/wasi/defs.js
  48. +1,344 −0 packages/pglite-tools/src/wasi/easywasi.js
  49. +96 −0 packages/pglite-tools/tests/pg_dump.test.ts
  50. +15 −0 packages/pglite-tools/tests/setup.ts
  51. +10 −0 packages/pglite-tools/tsconfig.json
  52. +21 −0 packages/pglite-tools/tsup.config.ts
  53. +10 −0 packages/pglite-tools/vitest.config.ts
  54. +13 −0 packages/pglite-vue/CHANGELOG.md
  55. +1 −1 packages/pglite-vue/package.json
  56. +12 −0 packages/pglite/CHANGELOG.md
  57. +74 −0 packages/pglite/examples/pg_dump.html
  58. +20 −0 packages/pglite/examples/pg_dump.js
  59. +1 −1 packages/pglite/package.json
  60. +12 −0 packages/pglite/src/base.ts
  61. +1 −0 packages/pglite/src/index.ts
  62. +1 −0 packages/pglite/src/interface.ts
  63. +189 −70 packages/pglite/src/live/index.ts
  64. +14 −4 packages/pglite/src/live/interface.ts
  65. +17 −0 packages/pglite/src/pglite.ts
  66. +1 −1 packages/pglite/src/postgresMod.ts
  67. +52 −0 packages/pglite/src/utils.ts
  68. +8 −4 packages/pglite/tests/exec-protocol.test.ts
  69. +133 −0 packages/pglite/tests/live.test.ts
  70. +56 −0 packages/pglite/tests/utils.test.ts
  71. +4,345 −82 patches/exports/pglite
  72. +24 −14 patches/imports/pgcore
  73. +36 −10 patches/imports/plpgsql
  74. +11 −10 patches/imports/vector
  75. +115 −65 patches/interactive_one.c
  76. +0 −36 patches/postgresql-wasm-16.3/src-backend-bootstrap-bootstrap.c.diff
  77. +0 −180 patches/postgresql-wasm-16.3/src-backend-libpq-pqcomm.c.diff
  78. +0 −32 patches/postgresql-wasm-16.3/src-backend-postmaster-postmaster.c.diff
  79. +0 −17 patches/postgresql-wasm-16.3/src-include-common-file_utils.h.diff
  80. +0 −22 patches/postgresql-wasm-16.3/src-include-storage-fd.h.diff
  81. +0 −80 patches/postgresql-wasm-16.3/src-interfaces-libpq-fe-connect.c.diff
  82. +18 −16 patches/postgresql-wasm-16.4/src-backend-libpq-pqcomm.c.diff
  83. +2 −3 patches/postgresql-wasm-16.4/src-backend-postmaster-postmaster.c.diff
  84. +0 −39 patches/postgresql-wasm-16.4/src-backend-storage-ipc-dsm_impl.c.diff
  85. +24 −0 patches/postgresql-wasm-16.4/src-backend-storage-lmgr-proc.c.diff
  86. +319 −10 patches/postgresql-wasm-16.4/src-interfaces-libpq-fe-connect.c.diff
  87. +18 −0 patches/postgresql-wasm/src-backend-storage-ipc-ipc.c.diff
  88. +14 −0 patches/postgresql-wasm/src-backend-utils-init-miscinit.c.diff
  89. +12 −4 patches/postgresql-wasm/src-backend-utils-init-postinit.c.diff
  90. +20 −0 patches/postgresql-wasm/src-bin-pg_config-pg_config.c.diff
  91. +53 −2 patches/postgresql-wasm/src-bin-pg_dump-pg_dump.c.diff
  92. +1 −16 patches/postgresql-wasm/src-include-common-logging.h.diff
  93. +26 −14 patches/postgresql-wasm/src-include-port-wasi.h.diff
  94. +50 −3 patches/postgresql-wasm/src-interfaces-libpq-fe-auth.c.diff
  95. +6 −14 patches/postgresql-wasm/src-interfaces-libpq-fe-exec.c.diff
  96. +245 −1 patches/wasi_port.c
  97. +367 −5 pnpm-lock.yaml
  98. +581 −20 tests/repl.html
4 changes: 3 additions & 1 deletion .buildconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
PG_VERSION=16.4
SDK_VERSION=3.1.68.3bi
SDK_VERSION=3.1.72.3bi
WASI_SDK_VERSION=24.0.4
SDKROOT=/opt/python-wasm-sdk
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -207,7 +207,7 @@ jobs:

- name: Build demo site
run: |
bash ./cibuild.sh demo-site
NO_SDK_CHECK=true SDKROOT=/opt/python-wasm-sdk bash ./cibuild.sh demo-site
- name: Build docs
working-directory: ./docs
14 changes: 10 additions & 4 deletions .github/workflows/build_wasm_postgres.yml
Original file line number Diff line number Diff line change
@@ -14,14 +14,18 @@ jobs:
runs-on: ubuntu-22.04
env:
BUILD_CONFIG_FILE: .buildconfig
SDK_ARCHIVE: python3.12-wasm-sdk-Ubuntu-22.04.tar.lz4
SDK_ARCHIVE: python3.13-wasm-sdk-Ubuntu-22.04.tar.lz4
WASI_SDK_ARCHIVE: python3.13-wasi-sdk-Ubuntu-22.04.tar.lz4
SDKROOT: /opt/python-wasm-sdk
SYS_PYTHON: /usr/bin/python3
PGROOT: /tmp/pglite
TOTAL_MEMORY: 128MB
CMA_MB: 16
DEBUG: false
OBJDUMP: true
EXTRA_EXT: vector
contrib: contrib
extra: extra
EXTRA_EXT: vector postgis

steps:
- uses: actions/checkout@v4
@@ -43,15 +47,17 @@ jobs:
/tmp/sdk/postgres-*.tar.gz
postgres
postgresql-*
key: build-cache-${{ hashFiles('.buildconfig', 'cibuild.sh', '.github/workflows/build_wasm_postgres.yml', 'package.json', 'cibuild/**', 'patches/*.c', 'patches/*.h', 'patches/**/*.diff') }}
key: build-cache-${{ hashFiles('.buildconfig', 'cibuild.sh', '.github/workflows/build_wasm_postgres.yml', 'package.json', 'cibuild/**', 'extra/**', 'patches/*.c', 'patches/*.h', 'patches/**/*.diff') }}

- name: Install python-wasm-sdk for emsdk/wasi+prebuilts
if: steps.cache-restore.outputs.cache-hit != 'true'
working-directory: /
run: |
sudo apt-get install -y lz4 wget pv bash
echo https://github.com/pygame-web/python-wasm-sdk/releases/download/$SDK_VERSION/$SDK_ARCHIVE
curl -sL --retry 5 https://github.com/pygame-web/python-wasm-sdk/releases/download/$SDK_VERSION/$SDK_ARCHIVE | tar xvP --use-compress-program=lz4 | pv -p -l -s 24400 >/dev/null
curl -sL --retry 5 https://github.com/pygame-web/python-wasm-sdk/releases/download/$SDK_VERSION/$SDK_ARCHIVE | tar xvP --use-compress-program=lz4 | pv -p -l -s 34500 >/dev/null
echo https://github.com/pygame-web/python-wasi-sdk/releases/download/$WASI_SDK_VERSION/$WASI_SDK_ARCHIVE
curl -sL --retry 5 https://github.com/pygame-web/python-wasi-sdk/releases/download/$WASI_SDK_VERSION/$WASI_SDK_ARCHIVE | tar xvP --use-compress-program=lz4 | pv -p -l -s 23000 >/dev/null
- name: Build postgres WASM via emsdk
if: steps.cache-restore.outputs.cache-hit != 'true'
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -124,20 +124,51 @@ Fortunately, PostgreSQL includes a "single user mode" primarily intended for com

- PGlite is single user/connection.

## How to contribute
## How to build PGlite and contribute

You will need [pnpm](https://pnpm.io/) installed, and a recent version of Node.js (v20 and above).
The build process of PGlite is split into two parts:

You will also need the Postgres WASM build files, which you download from a comment under the most recently merged PR, labeled as _interim build files_, and place them under `packages/pglite/release`. These are necessary to build PGlite and the dependent workspace projects. We plan to enable a local build in the future to streamline this step.
1. Building the Postgres WASM module.
2. Building the PGlite client library and other TypeScript packages.

Docker is required to build the WASM module, along with Node (v20 or above) and [pnpm](https://pnpm.io/) for package management and building the TypeScript packages.

To start checkout the repository and install dependencies:

Once the requirements are met, you can install dependencies and build the workspace projects:
```bash
git clone https://github.com/electric-sql/pglite
cd pglite
pnpm install
pnpm build
```

To build everything, we have the convenient `pnpm build:all` command in the root of the repository. This command will:

1. Use Docker to build the Postgres WASM module. The artifacts from this are then copied to `/packages/pglite/release`.
2. Build the PGlite client library and other TypeScript packages.

To _only_ build the Postgres WASM module (i.e. point 1 above), run

```bash
pnpm wasm:build
```

If you don't want to build the WASM module and assorted WASM binaries from scratch, you can download them from a comment under the most recently merged PR, labeled as _interim build files_, and place them under `packages/pglite/release`.

To build all TypeScript packages (i.e. point 2 of the above), run:

```bash
pnpm ts:build
```

This will build all packages in the correct order based on their dependency relationships. You can now develop any individual package using the `build` and `test` scripts, as well as the `stylecheck` and `typecheck` scripts to ensure style and type validity.

Or alternatively to build a single package, move into the package directory and run:

```bash
cd packages/pglite
pnpm build
```

When ready to open a PR, run the following command at the root of the repository:
```bash
pnpm changeset
25 changes: 17 additions & 8 deletions cibuild.sh
Original file line number Diff line number Diff line change
@@ -6,10 +6,11 @@ export CMA_MB=${CMA_MB:-64}

export CI=${CI:-false}

if $CI
then
. .buildconfig
fi
chmod +x ./extra/*.sh cibuild/*.sh

. .buildconfig

export PG_VERSION SDK_VERSION WASI_SDK_VERSION SDKROOT

export PG_VERSION=${PG_VERSION:-16.4}
export WORKSPACE=${GITHUB_WORKSPACE:-$(pwd)}
@@ -26,7 +27,15 @@ export WASI=${WASI:-false}
# exit on error
EOE=false

mkdir -p /tmp/sdk

if ./cibuild/sdk.sh
then
echo "sdk check passed (emscripten)"
else
echo sdk failed
exit 44
fi


# the default is a user writeable path.
if mkdir -p ${PGROOT}/sdk
@@ -369,7 +378,7 @@ then
. /etc/lsb-release
DISTRIB="${DISTRIB_ID}-${DISTRIB_RELEASE}"
CIVER=${CIVER:-$DISTRIB}
SDK_URL=https://github.com/pygame-web/python-wasm-sdk-extra/releases/download/$SDK_VERSION/python-emsdk-sdk-extra-${CIVER}.tar.lz4
SDK_URL=https://github.com/pygame-web/python-wasm-sdk-extra/releases/download/$SDK_VERSION/python3.13-emsdk-sdk-extra-${CIVER}.tar.lz4
echo "Installing $SDK_URL"
curl -sL --retry 5 $SDK_URL | tar xvP --use-compress-program=lz4 | pv -p -l -s 15000 >/dev/null
chmod +x ./extra/*.sh
@@ -463,8 +472,8 @@ ________________________________________________________________________________

# debug CI does not use pnpm/npm for building pg, so call the typescript build
# part from here
pnpm --filter "pglite^..." build || exit 450

#pnpm --filter "pglite^..." build || exit 450
pnpm run build:js || exit 476
pnpm pack || exit 31
packed=$(echo -n electric-sql-pglite-*.tgz)

16 changes: 11 additions & 5 deletions cibuild/build-with-docker.sh
Original file line number Diff line number Diff line change
@@ -14,14 +14,20 @@ fi

IMG_NAME="electricsql/pglite-builder"
IMG_TAG="${PG_VERSION}_${SDK_VERSION}"
SDK_ARCHIVE="${SDK_ARCHIVE:-python3.13-wasm-sdk-Ubuntu-22.04.tar.lz4}"
WASI_SDK_ARCHIVE="${WASI_SDK_ARCHIVE:-python3.13-wasi-sdk-Ubuntu-22.04.tar.lz4}"

docker run \
--rm \
-e OBJDUMP=${OBJDUMP:-true} \
-v ./cibuild.sh:/workspace/cibuild.sh \
-v ./cibuild:/workspace/cibuild \
-v ./patches:/opt/patches \
-v ./tests:/workspace/tests \
-v ./packages/pglite:/workspace/packages/pglite \
-e SDK_ARCHIVE \
-e WASI_SDK_ARCHIVE \
-v ./cibuild.sh:/workspace/cibuild.sh:rw \
-v ./.buildconfig:/workspace/.buildconfig:rw \
-v ./extra:/workspace/extra:rw \
-v ./cibuild:/workspace/cibuild:rw \
-v ./patches:/opt/patches:rw \
-v ./tests:/workspace/tests:rw \
-v ./packages/pglite:/workspace/packages/pglite:rw \
$IMG_NAME:$IMG_TAG \
bash ./cibuild/build-all.sh
Loading