⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@jpabbuehl
Copy link

@jpabbuehl jpabbuehl commented Dec 23, 2025

Summary

Add support for Apache AGE (A Graph Extension) which brings graph database capabilities and Cypher query language to PGlite.

Changes

Build Configuration

File Change
pglite/Makefile Add age to SUBDIRS, add age-specific build rule with SIZEOF_DATUM=4
pglite-wasm/included.pglite.imports Export hook symbols for AGE
pglite-wasm/excluded.pglite.imports Add invoke_jii pattern

AGE Submodule

Added AGE as a submodule from jpabbuehl/age branch feat/32bit-wasm-support.

This fork uses a Makefile-only approach for 32-bit WASM compatibility:

  • No changes to graphid.h or age_main.sql source files
  • Makefile conditionally strips PASSEDBYVALUE from graphid type when SIZEOF_DATUM=4 is passed

Upstream PR pending: apache/age@master...jpabbuehl:age:feat/32bit-wasm-support

Symbol Exports

AGE requires these PostgreSQL hook symbols:

  • post_parse_analyze_hook — Cypher query parsing
  • set_rel_pathlist_hook — Query planning
  • ProcessUtility_hook — DDL handling
  • RegisterExtensibleNodeMethods — Custom node types
  • object_access_hook — Access control

Also added invoke_jii to excluded imports (AGE uses int64(*)(int,int) function pointer pattern).

Technical Details

32-bit WASM Compatibility

PGlite compiles with -m32 (32-bit WASM). AGE's graphid type is 8 bytes, which doesn't fit in a 32-bit Datum.

Build-time solution (Makefile-only):

In pglite/Makefile - passes SIZEOF_DATUM=4 to AGE build:

age.tar.gz:
    rm -f age/age--*.sql  # Force SQL regeneration
    $(MAKE) -C age install SIZEOF_DATUM=4

In AGE's Makefile - strips PASSEDBYVALUE when SIZEOF_DATUM=4:

$(age_sql): $(SQLS)
    @cat $(SQLS) > $@
ifeq ($(SIZEOF_DATUM),4)
    @sed 's/^  PASSEDBYVALUE,$$/  -- PASSEDBYVALUE removed for 32-bit/' $@ > [email protected] && mv [email protected] $@
endif

This approach:

  • Keeps AGE source files unchanged from upstream
  • Relies on PostgreSQL's existing Int64GetDatum/DatumGetInt64 macros (already handle 32-bit pass-by-reference)
  • Only modifies the generated SQL at build time

Testing

  • AGE compiles to WASM successfully
  • age.tar.gz generated (140KB compressed)
  • All 34 TypeScript tests pass

Related PRs

Checklist

  • Build succeeds with ./build-with-docker.sh
  • AGE extension tarball generated
  • No regressions in existing extensions

tdrz and others added 6 commits November 5, 2025 13:53
Add support for Apache AGE (A Graph Extension) which brings graph
database capabilities and Cypher query language to PostgreSQL.

Changes:
- Add AGE as submodule from jpabbuehl/age (32-bit WASM compatible fork)
- Add AGE to SUBDIRS in pglite/Makefile
- Export required hook symbols in included.pglite.imports:
  - post_parse_analyze_hook (Cypher parsing)
  - set_rel_pathlist_hook (query planning)
  - ProcessUtility_hook (DDL handling)
  - RegisterExtensibleNodeMethods (custom nodes)
  - object_access_hook (access control)
- Add invoke_jii to excluded.pglite.imports (function pointer pattern)

The AGE submodule points to a fork with 32-bit WASM compatibility:
- graphid type uses pass-by-reference on 32-bit systems
- Upstream PR pending at apache/age

Related: electric-sql/pglite PR for TypeScript wrapper
- Update pglite/Makefile with age-specific build rule that passes SIZEOF_DATUM=4
- Forces SQL regeneration to apply PASSEDBYVALUE stripping for graphid type
- Update AGE submodule to 0a4f4b3 (Makefile-only 32-bit support approach)

The AGE fork now uses a Makefile-only approach:
- No changes to graphid.h or age_main.sql source files
- Makefile conditionally strips PASSEDBYVALUE when SIZEOF_DATUM=4 is passed
- PostgreSQL's Int64GetDatum/DatumGetInt64 macros handle the rest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants