tursodatabase / pg_turso

Postgres output plugin for replicating data to Turso.
MIT License
72 stars 4 forks source link

PostgreSQL 14 support? #7

Open penberg opened 1 year ago

penberg commented 1 year ago

We currently target PostgreSQL 15, but Fedora, for example, has PostgreSQL 14. Unfortunately due to PostgreSQL differences, the extension doesn't build:

zig build-lib pgturso Debug native: error: the following command failed with 2 compilation errors:
/home/penberg/src/turso/pgturso/zig/zig-linux-x86_64-0.11.0-dev.3724+32cb9462f/zig build-lib /home/penberg/src/turso/pgturso/src/main.zig -lc --cache-dir /home/penberg/src/turso/pgturso/zig-cache --global-cache-dir /home/penberg/.cache/zig --name pgturso -dynamic --version 0.1.0 -I /home/penberg/src/turso/pgturso/postgres/src/include --listen=-
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install pgturso transitive failure
   └─ zig build-lib pgturso Debug native 2 errors
src/main.zig:124:60: error: root struct of file '.home.penberg.src.turso.pgturso.zig-cache.o.6ed60b876cfd6a06a91994233d262fa0.cimport' has no member named 'String'
            const url_string = std.mem.span(@ptrCast([*c]pg.String, @alignCast(@import("std").meta.alignment([*c]pg.String), elem.*.arg)).*.sval);
                                                         ~~^~~~~~~
referenced by:
    _PG_output_plugin_init: src/main.zig:51:24
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

/home/penberg/src/turso/pgturso/zig-cache/o/6ed60b876cfd6a06a91994233d262fa0/cimport.zig:12087:25: error: unable to translate C expr: expected ')' instead got '='
pub const fastgetattr = @compileError("unable to translate C expr: expected ')' instead got '='"); // /home/penberg/src/turso/pgturso/postgres/src/include/access/htup_details.h:711:9
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:18: all] Error 2
hirefrank commented 1 year ago

I'm running into the same issue.

hirefrank commented 1 year ago

FWIW, I was able to build for Pg 15 with zig version 0.11.0-dev.3857+7322aa118 -- but can't get it to build for 14.

@psarna

psarna commented 1 year ago

I wonder if this issue is platform-specific, with that specific zig 0.11 version as well. First thing, I'll try to make pg_turso work with zig 0.12 -- last time I tried, I hit a TODO implement readFromMemory for more types. Zigs are released daily, so it might have been fixed already, otherwise I'll dig further and try to fix the compiler issue. Once I have that, I'll try to figure out why postgres 14 headers get properly generated for me, and not on your arch/OS.

psarna commented 1 year ago

Now I hit either https://github.com/ziglang/zig/issues/17287 or similar:

zig build-lib pg_turso Debug native: error: the following command failed with 2 compilation errors:
/usr/lib/zig/zig build-lib -freference-trace=256 /home/sarna/repo/pgturso/src/main.zig -lc --cache-dir /home/sarna/repo/pgturso/zig-cache --global-cache-dir /home/sarna/.cache/zig --name pg_turso -dynamic --version 0.1.0 -I /home/sarna/repo/pgturso/postgres/src/include --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install pg_turso transitive failure
   └─ zig build-lib pg_turso Debug native 2 errors
/home/sarna/repo/pgturso/zig-cache/o/96c3fe63658d93a8238a5b8dd049db43/cimport.zig:4783:49: error: struct '.home.sarna.repo.pgturso.zig-cache.o.96c3fe63658d93a8238a5b8dd049db43.cimport.struct_OutputPluginCallbacks' depends on itself
pub const struct_OutputPluginCallbacks = extern struct {
                                         ~~~~~~~^~~~~~
psarna commented 1 year ago

it's weird though, when I look at the generated zig code, the struct doesn't seem to depend on itself... maybe it's some indirect dependency