Skip to content

Commit 79bf3ad

Browse files
jpabbuehlabbuehlj
authored andcommitted
feat: Add 32-bit platform support for graphid type (apache#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]>
1 parent 60eeda1 commit 79bf3ad

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ PG_CONFIG ?= pg_config
138138
PGXS := $(shell $(PG_CONFIG) --pgxs)
139139
include $(PGXS)
140140

141+
# 32-bit platform support: pass SIZEOF_DATUM=4 to enable (e.g., make SIZEOF_DATUM=4)
142+
# When SIZEOF_DATUM=4, PASSEDBYVALUE is stripped from graphid type for pass-by-reference.
143+
# If not specified, normal 64-bit behavior is used (PASSEDBYVALUE preserved).
144+
141145
src/backend/parser/cypher_keywords.o: src/include/parser/cypher_kwlist_d.h
142146

143147
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
152156
src/backend/parser/cypher_keywords.o: src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h
153157
src/backend/parser/cypher_keywords.bc: src/backend/parser/cypher_gram.c src/include/parser/cypher_gram_def.h
154158

155-
$(age_sql):
159+
# Strip PASSEDBYVALUE on 32-bit (SIZEOF_DATUM=4) for graphid pass-by-reference
160+
$(age_sql): $(SQLS)
156161
@cat $(SQLS) > $@
162+
ifeq ($(SIZEOF_DATUM),4)
163+
@echo "32-bit build: removing PASSEDBYVALUE from graphid type"
164+
@sed 's/^ PASSEDBYVALUE,$$/ -- PASSEDBYVALUE removed for 32-bit (see Makefile)/' $@ > [email protected] && mv [email protected] $@
165+
@grep -q 'PASSEDBYVALUE removed for 32-bit' $@ || { echo "Error: PASSEDBYVALUE replacement failed in $@"; exit 1; }
166+
endif
157167

158168
src/backend/parser/ag_scanner.c: FLEX_NO_BACKUP=yes
159169

0 commit comments

Comments
 (0)