This is an automated email from the ASF dual-hosted git repository.

jgemignani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/age.git


The following commit(s) were added to refs/heads/master by this push:
     new c979380e feat: Add 32-bit platform support for graphid type (#2286)
c979380e is described below

commit c979380e9865a624ad73eef01ec84717bb817f2b
Author: Jean-Paul Abbuehl <[email protected]>
AuthorDate: Mon Jan 12 21:10:08 2026 +0100

    feat: Add 32-bit platform support for graphid type (#2286)
    
    * feat: Add 32-bit platform support for graphid type
    
    This enables AGE to work on 32-bit platforms including WebAssembly (WASM).
    
    Problem:
    - graphid is int64 (8 bytes) with PASSEDBYVALUE
    - On 32-bit systems, Datum is only 4 bytes
    - PostgreSQL rejects pass-by-value types larger than Datum
    
    Solution:
    - Makefile-only change (no C code modifications)
    - When SIZEOF_DATUM=4 is passed to make, strip PASSEDBYVALUE from the 
generated SQL
    - If not specified, normal 64-bit behavior is preserved (PASSEDBYVALUE kept)
    
    This change is backward compatible:
    - 64-bit systems continue using pass-by-value
    - 32-bit systems now work with pass-by-reference
    
    Motivation: PGlite (PostgreSQL compiled to WebAssembly) uses 32-bit
    pointers and requires this patch to run AGE.
    
    Tested on:
    - 64-bit Linux (regression tests pass)
    - 32-bit WebAssembly via PGlite (all operations work)
    
    Co-authored-by: abbuehlj <[email protected]>
---
 Makefile | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 0392d8b8..17f2ed65 100644
--- a/Makefile
+++ b/Makefile
@@ -138,6 +138,10 @@ PG_CONFIG ?= pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
 include $(PGXS)
 
+# 32-bit platform support: pass SIZEOF_DATUM=4 to enable (e.g., make 
SIZEOF_DATUM=4)
+# When SIZEOF_DATUM=4, PASSEDBYVALUE is stripped from graphid type for 
pass-by-reference.
+# If not specified, normal 64-bit behavior is used (PASSEDBYVALUE preserved).
+
 src/backend/parser/cypher_keywords.o: src/include/parser/cypher_kwlist_d.h
 
 src/include/parser/cypher_kwlist_d.h: src/include/parser/cypher_kwlist.h 
$(GEN_KEYWORDLIST_DEPS)
@@ -152,8 +156,14 @@ src/backend/parser/cypher_parser.bc: 
src/backend/parser/cypher_gram.c src/includ
 src/backend/parser/cypher_keywords.o: src/backend/parser/cypher_gram.c 
src/include/parser/cypher_gram_def.h
 src/backend/parser/cypher_keywords.bc: src/backend/parser/cypher_gram.c 
src/include/parser/cypher_gram_def.h
 
-$(age_sql):
+# Strip PASSEDBYVALUE on 32-bit (SIZEOF_DATUM=4) for graphid pass-by-reference
+$(age_sql): $(SQLS)
        @cat $(SQLS) > $@
+ifeq ($(SIZEOF_DATUM),4)
+       @echo "32-bit build: removing PASSEDBYVALUE from graphid type"
+       @sed 's/^  PASSEDBYVALUE,$$/  -- PASSEDBYVALUE removed for 32-bit (see 
Makefile)/' $@ > [email protected] && mv [email protected] $@
+       @grep -q 'PASSEDBYVALUE removed for 32-bit' $@ || { echo "Error: 
PASSEDBYVALUE replacement failed in $@"; exit 1; }
+endif
 
 src/backend/parser/ag_scanner.c: FLEX_NO_BACKUP=yes
 

Reply via email to