pganalyze / libpg_query

C library for accessing the PostgreSQL parser outside of the server environment
BSD 3-Clause "New" or "Revised" License
1.21k stars 182 forks source link

Fix type cast for normalizing alter subscription statement #223

Closed anuraaga closed 12 months ago

anuraaga commented 12 months ago

I am compiling this library to WebAssembly and ran into this issue. This test failed for me

https://github.com/pganalyze/libpg_query/blob/15-latest/test/normalize_tests.c#L30

The bug is obvious, though I'm not sure what it is about the WebAssembly toolchain that causes it to break vs how these tests are normally run, it could be the usage of musl as libc or just the LLVM Wasm backend itself.

lfittl commented 12 months ago

Good catch!

I suspect this might be a struct alignment detail that behaves differently in the WASM toolchain, thus causing a problem only in that case. It was by sheer luck that this worked otherwise.