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

PGlite changes to Postgres v16 #7

Draft
wants to merge 37 commits into
base: REL_16_STABLE
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f6834d8
test adding pglite diffs
Dec 4, 2024
61574be
added postgres-pglite extra sources
Dec 4, 2024
dba88a5
added more pglite-extra files
Dec 4, 2024
4af3c59
fix include paths - I believe this can be removed altogether
Dec 4, 2024
03039f4
added tests to this repo - unsure if needed
Dec 9, 2024
fea0c71
added cibuild folder
Dec 9, 2024
728bd61
added buildconfig
Dec 9, 2024
85ba95e
added extra folder
Dec 9, 2024
d15244b
added main cibuild.sh script
Dec 9, 2024
f408575
added imports and exports folders
Dec 9, 2024
0d16322
added patches/*.js
Dec 9, 2024
a562813
added pglite gitignore
Dec 9, 2024
71831db
store docker build on host
Dec 9, 2024
bde0227
modified gitignore
Dec 9, 2024
a8e98e0
cleanup
Dec 9, 2024
7576ca0
update cibuild.sh
Dec 10, 2024
430ef0a
Merge branch 'pglite/16.4' of https://github.com/electric-sql/postgre…
Dec 10, 2024
5bcf7b4
updated WORKSPACE variable
Dec 10, 2024
d9b4092
cleanup
Dec 11, 2024
6dce1a2
updates from pglite main
Jan 15, 2025
c6f5ca2
cleanup
Jan 15, 2025
6cb2741
small improvement to script
Jan 16, 2025
b1523ba
Update readme (#3)
samwillis Jan 16, 2025
2df0599
SDK_VERSION was wrong
Jan 16, 2025
e02a059
Update sdk version (#6)
copiltembel Jan 20, 2025
7768942
check return value instead of output
Jan 20, 2025
fd292c5
add gh action buildkite
Jan 21, 2025
c81cff3
Tudor/sdk dockerfile (#10)
copiltembel Jan 21, 2025
ff1aa5d
just a test
Jan 21, 2025
f9307d0
test gh actions
Jan 21, 2025
3c461da
New SDK_VERSION 3.1.74.3bi (#12)
copiltembel Jan 27, 2025
cc93dc8
add a llvm-ar step before link optimisation (#9)
pmp-p Jan 27, 2025
2326e20
force buildkite to build the sdk using the new repo (#13)
copiltembel Jan 29, 2025
4db5952
added CI action to build the project (#14)
copiltembel Feb 4, 2025
a033a05
Tudor/remove import exports (#16)
copiltembel Feb 7, 2025
f0e5fe0
Delete pglite/patches directory (#17)
pmp-p Feb 7, 2025
8e4580c
2 less bash scripts (#15)
copiltembel Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .buildkite/builder-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
env:
DOCKERHUB_REPO: electricsql
IMAGE_NAME: pglite-builder

agent:
docker: true
gcp: true

steps:
- label: '🚀 Build & publish the builder image to Docker Hub'
if: build.env("TRIGGERED_FROM_GHA") == 'true'
command:
- |
source ./pglite/.buildconfig
export PG_VERSION=$$PG_VERSION
export SDK_VERSION=$$SDK_VERSION
export IMGNAME="${DOCKERHUB_REPO}/${IMAGE_NAME}"
export IMGTAG="$${PG_VERSION}_$${SDK_VERSION}"
- echo "Building with PG_VERSION $$PG_VERSION and SDK_VERSION $$SDK_VERSION"
- |
if docker manifest inspect $${IMGNAME}:$${IMGTAG} >/dev/null 2>&1; then
echo "Image $${IMGNAME}:$${IMGTAG} already exists on Docker Hub. Exiting successfully."
exit 0
fi
- docker buildx build --platform linux/arm64/v8,linux/amd64 --push
--build-arg PG_VERSION=$${PG_VERSION}
--build-arg SDK_VERSION=$${SDK_VERSION}
-t $${IMGNAME}:$${IMGTAG}
-t $${IMGNAME}:latest
./pglite
39 changes: 39 additions & 0 deletions .github/workflows/build_wasm_postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build postgres-pglite (aka Postgresql WASM)

permissions:
pull-requests: write
issues: write
contents: read

on:
workflow_call:
push:
branches: ['pglite/REL_16_STABLE']
pull_request:

jobs:
build:
name: Build postgres-pglite (WASM Postgres)
runs-on: ubuntu-22.04
env:
BUILD_CONFIG_FILE: pglite/.buildconfig
PGROOT: /tmp/pglite
TOTAL_MEMORY: 128MB
CMA_MB: 16
DEBUG: false
OBJDUMP: true
contrib: contrib
extra: extra
EXTRA_EXT: vector

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Build postgres WASM via emsdk
working-directory: ${{ github.workspace }}
env:
PGSRC: ${{ github.workspace }}
run: |
pglite/cibuild/build-with-docker.sh
25 changes: 25 additions & 0 deletions .github/workflows/trigger_buildkite_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Trigger BuildKite build of Docker image for building PGlite

on:
push:
branches: ['pglite/REL_16_STABLE']
paths:
- pglite/.buildconfig
pull_request:
paths:
- pglite/.buildconfig

jobs:
build:
name: Build Docker image
runs-on: ubuntu-22.04
steps:
- name: Trigger a Buildkite Build on Push using v2.0.0
uses: buildkite/[email protected]
with:
buildkite_api_access_token: ${{ secrets.TRIGGER_BK_BUILD_TOKEN }}
pipeline: 'vaxine/build-pglite-builder-docker-image'
branch: ${{ github.head_ref || github.ref_name }}
commit: HEAD
message: '🚀 Triggered from a GitHub Action'
build_env_vars: '{"TRIGGERED_FROM_GHA": "true"}'
9 changes: 9 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
PGlite PostgreSQL Fork
======================

This is a fork of PostgreSQL used by PGlite.

For more information, please visit the PGlite website at https://pglite.dev or see the main PGlite repository at https://github.com/electric-sql/pglite.

We use the issues tracker on the main PGlite repository to track issues with this fork.

PostgreSQL Database Management System
=====================================

Expand Down
4 changes: 2 additions & 2 deletions contrib/pgstattuple/pgstatindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,9 +656,9 @@ pgstathashindex(PG_FUNCTION_ARGS)
stats.unused_pages++;
else if (PageGetSpecialSize(page) !=
MAXALIGN(sizeof(HashPageOpaqueData)))
ereport(ERROR,
ereport(WARNING,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("index \"%s\" contains corrupted page at block %u",
errmsg("# 661(FATAL block=%d): index \"%s\" contains corrupted page at block %u", blkno,
RelationGetRelationName(rel),
BufferGetBlockNumber(buf))));
else
Expand Down
2 changes: 1 addition & 1 deletion contrib/xml2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DATA = xml2--1.1.sql xml2--1.0--1.1.sql
PGFILEDESC = "xml2 - XPath querying and XSLT"

REGRESS = xml2

PG_CFLAGS=$(shell xml2-config --cflags)
SHLIB_LINK += $(filter -lxslt, $(LIBS)) -lxml2

ifdef USE_PGXS
Expand Down
4 changes: 4 additions & 0 deletions pglite/.buildconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PG_VERSION=16.4
SDK_VERSION=3.1.74.3bi
WASI_SDK_VERSION=24.0.4
SDKROOT=/opt/python-wasm-sdk
4 changes: 4 additions & 0 deletions pglite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
patches/imports.pgcore
dist
patches/imports
patches/exports
68 changes: 68 additions & 0 deletions pglite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM ubuntu:22.04 AS build_sdk

ARG PG_VERSION=16.4
ARG SDK_VERSION=3.1.74.3bi
ARG DEBUG=false
ARG OBJDUMP=true

ENV \
PG_VERSION=$PG_VERSION \
SDK_VERSION=$SDK_VERSION \
SDKROOT=/opt/python-wasm-sdk \
SYS_PYTHON=/usr/bin/python3 \
DEBUG=$DEBUG \
BUILDS=3.12 \
EMFLAVOUR=3.1.74

WORKDIR /workspace

# Install dependencies to build python-wasm-sdk
RUN \
apt-get update &&\
apt-get install -y \
sudo patchelf git clang unzip autoconf libtool \
libsqlite3-dev libffi-dev libssl-dev zlib1g-dev pkg-config \
libncursesw5-dev python3 python3-pip \
make build-essential wget lz4 bzip2 pv curl

# Download the python-wasm-sdk source for the given version
# RUN git clone --depth 1 --branch ${SDK_VERSION} https://github.com/pygame-web/python-wasm-sdk.git
RUN git clone --depth 1 https://github.com/electric-sql/portable-sdk.git

WORKDIR /workspace/portable-sdk/python-wasm-sdk

# Make python-wasm-sdk
RUN chmod +x python-wasm-sdk.sh

RUN bash -c "./python-wasm-sdk.sh"

FROM ubuntu:22.04

# Install dependencies to build postgres wasm
RUN \
apt-get update &&\
apt-get install -y lz4 wget pv bash bzip2 python3 build-essential libreadline-dev zlib1g-dev bison flex &&\
apt-get clean

ARG PG_VERSION=16.4
ARG SDK_VERSION=3.1.74.3bi
ARG DEBUG=false
ARG OBJDUMP=true

ENV \
PG_VERSION=$PG_VERSION \
SDK_VERSION=$SDK_VERSION \
SDK_ARCHIVE=python3.12-wasm-sdk-Ubuntu-22.04.tar.lz4 \
SDKROOT=/opt/python-wasm-sdk \
SYS_PYTHON=/usr/bin/python3 \
PGROOT=/tmp/pglite \
DEBUG=$DEBUG \
OBJDUMP=$OBJDUMP

COPY --from=build_sdk /tmp/sdk /tmp/sdk

RUN tar --use-compress-program=lz4 -xvf /tmp/sdk/${SDK_ARCHIVE} -C /

RUN rm -r /tmp/sdk

WORKDIR /workspace
Loading