Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed conversion of i64 and f64 to datums on 32-bit machines #1859

Merged

Conversation

YohDeadfall
Copy link
Contributor

No tests in CI at the moment because GitHub Actions are .NET based which: actions/runner/issues/1181. May spend some time later on that, but for now let's keep the warning about official support of x64 only.

@workingjubilee
Copy link
Member

I will accept this if you also run down places like

8 => pg_sys::Datum::from(byval_read::<u64>(ptr)),

@workingjubilee
Copy link
Member

workingjubilee commented Sep 12, 2024

Actually that specific place may be harmless even, but the point is that there's other locations that make assumptions about sizes, and I would rather not bother even with this amount of positive signaling unless we've made a cursory effort to check them.

@workingjubilee
Copy link
Member

I realize "search for all instances of the number 8 and make sure they aren't obviously bad" is a lot of effort but...

@YohDeadfall
Copy link
Contributor Author

I realize "search for all instances of the number 8 and make sure they aren't obviously bad" is a lot of effort but...

That's fine, it requires checking only the src directory with focus mostly on datums which are untyped.

@YohDeadfall
Copy link
Contributor Author

According to the PostgreSQL source code float8 type metadata reflects its storage with depednency on the architecture:

That implies that on 32-bit architectures the following code will always fall onto ByRef arm:

let slide_impl: ChaChaSlideImpl<T> = match elem_layout.pass {
PassBy::Value => match elem_layout.size {
// The layout is one that we know how to handle efficiently.
Size::Fixed(1) => Box::new(casper::FixedSizeByVal::<1>),
Size::Fixed(2) => Box::new(casper::FixedSizeByVal::<2>),
Size::Fixed(4) => Box::new(casper::FixedSizeByVal::<4>),
#[cfg(target_pointer_width = "64")]
Size::Fixed(8) => Box::new(casper::FixedSizeByVal::<8>),
_ => {
panic!("unrecognized pass-by-value array element layout: {elem_layout:?}")
}
},
PassBy::Ref => match elem_layout.size {

Moreover, FixedSizeByVal<8> cannot be used on a platform different from 64-bit.

@YohDeadfall
Copy link
Contributor Author

I realize "search for all instances of the number 8 and make sure they aren't obviously bad" is a lot of effort but...

grep -r --include=*.rs --exclude-dir=*build* --exclude-dir=*sys* 8 gave nothing which should be addressed.

@workingjubilee
Copy link
Member

Cool.

if size_of::<u64>() <= size_of::<usize>() {
Datum::from(val as usize)
} else {
Datum::from(Box::into_raw(Box::new(val)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a palloc.

if size_of::<i64>() <= size_of::<usize>() {
Datum::from(val as usize)
} else {
Datum::from(Box::into_raw(Box::new(val)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a palloc.

README.md Outdated Show resolved Hide resolved
@YohDeadfall
Copy link
Contributor Author

cargo c pg16 works fine after switching to palloc, but cargo t pg16 fails with the following error:

   Compiling pgrx-pg-sys v0.12.4 (/home/yoh/src/pgrx/pgrx-pg-sys)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/yoh/.local/share/gem/ruby/3.2.0/bin:/home/yoh/.omnisharp:/home/yoh/.dotnet:/home/yoh/.cargo/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" VSLANG="1033" "cc" "-m64" "/tmp/rustcvAjAu0/symbols.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.05sgmwhndq4y1l1r41rtbyc9b.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.1jgziobn4hnx5ujmcyv2fxyle.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.24r5mew6nkwbgedrmjqn5lw7v.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2ajt5s6rwycmdxuppsyhajine.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2fn00kma6itcxx8hed2nnn947.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2y35exsw3m92lmwfu8bft765h.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2ykipamv4nift36syqjpxshg7.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.31ceew8ouxbfzxrs58h3yzv2k.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.31qz2up61rbukowceh1k2htra.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.38zkyn0i44ujjt8ow6e59e3hb.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3c6ry4nqvefq1996g272ojwnz.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3pr19u8h2f63j6n62udnl8nhy.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3s557tgohs38xpg7mkfzm823k.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.49js0rmf38wri1hmcpefkf77z.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.4jaebo631oulu1exf61f4k7k0.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.4k5r86gjc4ogqkjtesug2c68c.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.5a3zouhnlmtf5xg6lz514oa2f.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.6wi9s10taonpuik864zxk74cr.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.72papy3wycjvfmse3qptlm7a5.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.7a3bkhakow3p9wga4eli1r1l2.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.7lq87x70vpl0gunarvhjkqvpy.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.8kmn0vglx491xtof3826o6yuh.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.8rltmltm2g8t3b8d2f0r1vmzv.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.8wj3pbq7lvn44f7zeob0z7g9r.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.93gz3ft3zbj7ou3usbzo3oi4j.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.97ycbal66ova7uzssztfd5rxe.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.9891s5ayrwh5kqiau2fa7abyl.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.9ri5ot38rbv8xyzq2gdi8acrj.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.9yhuf5xrvw6roiwe9ypmblcjv.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.a9l3vair1cukr1e49o8l1qu7m.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.am6cfo3hddiv7ewhaxx1r29as.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.b4y6v0dheovm0eomu9ovvcpub.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.b9wxs6f3uymf5n0on0fubs2tl.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.baxm1fzsgztqn9as04jg9wh5h.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.bc5v92c7c6tx9o8c967vfvn4x.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.bgq1mlsg12hwzwobyz6le41jj.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.blz27pyppjwq68343ifkgmt9o.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.bs123mo9osxl0tl4o27wr115t.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.c3jd1ravw6gvldwauhhv4ellb.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.chzfcz2hsw9vkrrfipg6mlsp1.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.cj2lu15glttea3ouiwi4vbxmn.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.crn3gdpykv3awwu248pggyea0.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.ct2egluy0asg6nrjbhyucfyc8.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.ctwm5v79v7dh2frdkq5opm3vb.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.d2rixsmwqllgdrjpri75lbqqg.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.daxdtiduh4how4o0xhk98fbv5.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.dj0ithp59j8n9egkc56k6dl1j.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.dk884qjmle32ldejkb85nvapj.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.dohmc1y5ndnlpy5s8kbktek28.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.draha1547jdyqbapf9d8mdxh0.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.dx9a0wzhtezbb5s8znanho1fl.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.e21kvq9z2uv0fe0erf3vzqkvf.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.e6esj70kbisf0w4zzx42e37yk.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.e6isuuaztqwzfnyzive8co0sz.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.epeyqaf7j49k79uesnnnascmz.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.etzjiysyuvpg0dg1n74ocamqq.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.ezrl34gxkcao21llyly2cawyt.rcgu.o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3cvohq68ql3wwpk2isougx3f7.rcgu.o" "-Wl,--as-needed" "-L" "/home/yoh/src/pgrx/target/debug/deps" "-L" "/home/yoh/src/pgrx/target/debug/build/pgrx-pg-sys-f298184b10bba90c/out/cshim" "-L" "/home/yoh/src/pgrx/target/debug/build/cee-scape-14df383b0b34067e/out" "-L" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-lresolv" "-Wl,-Bstatic" "-Wl,--whole-archive" "-lpgrx-cshim-16" "-Wl,--no-whole-archive" "/home/yoh/src/pgrx/target/debug/deps/libsptr-098575f08333f30e.rlib" "/home/yoh/src/pgrx/target/debug/deps/libserde-3bc16b1a59055395.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-95407a28b34cb7d8.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-6cf033bd0623f965.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-92be448731e25aff.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-9c68449f4da60201.rlib" "/home/yoh/src/pgrx/target/debug/deps/libpgrx_sql_entity_graph-56bfcb03d2a9c761.rlib" "/home/yoh/src/pgrx/target/debug/deps/libunescape-9f9ad90b1e80bc21.rlib" "/home/yoh/src/pgrx/target/debug/deps/libpetgraph-5ec83cacb091c274.rlib" "/home/yoh/src/pgrx/target/debug/deps/libindexmap-6d060d4740881062.rlib" "/home/yoh/src/pgrx/target/debug/deps/libequivalent-ed28696be1200308.rlib" "/home/yoh/src/pgrx/target/debug/deps/libhashbrown-f68aa7311c1745f1.rlib" "/home/yoh/src/pgrx/target/debug/deps/libfixedbitset-e4eedac1f6c32ffe.rlib" "/home/yoh/src/pgrx/target/debug/deps/libthiserror-30d93bdbc55d24d3.rlib" "/home/yoh/src/pgrx/target/debug/deps/libconvert_case-ca70b3343870681c.rlib" "/home/yoh/src/pgrx/target/debug/deps/libunicode_segmentation-296f60c23fb94688.rlib" "/home/yoh/src/pgrx/target/debug/deps/libeyre-e73d8c495d4104fb.rlib" "/home/yoh/src/pgrx/target/debug/deps/libindenter-f174056b9b6df479.rlib" "/home/yoh/src/pgrx/target/debug/deps/libonce_cell-36c412165f3c363c.rlib" "/home/yoh/src/pgrx/target/debug/deps/libsyn-778b9893ff59b4f5.rlib" "/home/yoh/src/pgrx/target/debug/deps/libquote-14c3d43d67173256.rlib" "/home/yoh/src/pgrx/target/debug/deps/libproc_macro2-11cf56b1b406302e.rlib" "/home/yoh/src/pgrx/target/debug/deps/libunicode_ident-615ecb1a3efafc73.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-37a00aea1affa1af.rlib" "/home/yoh/src/pgrx/target/debug/deps/libcee_scape-a6490e0f83264f56.rlib" "/home/yoh/src/pgrx/target/debug/deps/liblibc-f4b32e6cb3b92e1f.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-52417a9a08ba8fb9.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-1b238e97929fdc18.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-3692c2663daa48a5.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-5c1e2d61611c0240.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-e55c5186b9bbabcb.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-7911d2fe92903c6c.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-c03510cdc48cfa52.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-7ec6f3765287c7b7.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-ab3f1b788cf79cfc.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-6db4226b4e34b1a6.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-f5bb1a38d410fa1e.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-e585efe74c64604d.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-03f8e93b59ffc316.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-669e9182bfe197a6.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-64b53226be979181.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-26921ac7e6a44d2b.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-6703049be165ebf1.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-04bfdf6b094564ce.rlib" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-6648dc218e522d87.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/yoh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o: in function `pgrx_pg_sys::include::pg16::CopyErrorData':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:112:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x77): undefined reference to `CurrentMemoryContext'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o: in function `pg_guard_ffi_boundary_impl<*mut pgrx_pg_sys::include::pg16::ErrorData, pgrx_pg_sys::include::pg16::CopyErrorData::{closure_env#0}>':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:113:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x86): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:114:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x95): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:144:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0xe2): undefined reference to `CurrentMemoryContext'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:176:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x445): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:177:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x44f): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:130:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x77a): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:131:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData17h31c26dc928cdef83E+0x784): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o: in function `pgrx_pg_sys::include::pg16::FreeErrorData':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:112:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0x8e): undefined reference to `CurrentMemoryContext'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o: in function `pg_guard_ffi_boundary_impl<(), pgrx_pg_sys::include::pg16::FreeErrorData::{closure_env#0}>':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:113:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0x9d): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:114:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0xac): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:144:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0xef): undefined reference to `CurrentMemoryContext'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:176:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0x455): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:177:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0x45f): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:130:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0x790): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:131:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData17hf95913b1d669dfcdE+0x79a): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o: in function `pgrx_pg_sys::include::pg16::palloc':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:112:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0x8e): undefined reference to `CurrentMemoryContext'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.2s8s4pged4gi5s56dq2854313.rcgu.o: in function `pg_guard_ffi_boundary_impl<*mut core::ffi::c_void, pgrx_pg_sys::include::pg16::palloc::{closure_env#0}>':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:113:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0x9d): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:114:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0xac): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:144:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0xff): undefined reference to `CurrentMemoryContext'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:176:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0x465): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:177:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0x46f): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:130:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0x7a0): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:131:(.text._ZN11pgrx_pg_sys7include4pg166palloc17hf2ea698787f52d7eE+0x7aa): undefined reference to `error_context_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3s557tgohs38xpg7mkfzm823k.rcgu.o: in function `pgrx_pg_sys::submodules::ffi::pg_guard_ffi_boundary_impl::{{closure}}':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:119:(.text._ZN11pgrx_pg_sys10submodules3ffi26pg_guard_ffi_boundary_impl28_$u7b$$u7b$closure$u7d$$u7d$17h0db1748f652b9876E+0x16): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3s557tgohs38xpg7mkfzm823k.rcgu.o: in function `pgrx_pg_sys::submodules::ffi::pg_guard_ffi_boundary_impl::{{closure}}':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:119:(.text._ZN11pgrx_pg_sys10submodules3ffi26pg_guard_ffi_boundary_impl28_$u7b$$u7b$closure$u7d$$u7d$17hbd519d35058f2000E+0x1b): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.3s557tgohs38xpg7mkfzm823k.rcgu.o: in function `pgrx_pg_sys::submodules::ffi::pg_guard_ffi_boundary_impl::{{closure}}':
          /home/yoh/src/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:119:(.text._ZN11pgrx_pg_sys10submodules3ffi26pg_guard_ffi_boundary_impl28_$u7b$$u7b$closure$u7d$$u7d$17hc88af17d98be8099E+0x1a): undefined reference to `PG_exception_stack'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.e6isuuaztqwzfnyzive8co0sz.rcgu.o: in function `pgrx_pg_sys::include::pg16::CopyErrorData::{{closure}}':
          /home/yoh/src/pgrx/target/debug/build/pgrx-pg-sys-f298184b10bba90c/out/pg16.rs:34291:(.text._ZN11pgrx_pg_sys7include4pg1613CopyErrorData28_$u7b$$u7b$closure$u7d$$u7d$17h2cbf3b832081c784E+0x3): undefined reference to `CopyErrorData'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.e6isuuaztqwzfnyzive8co0sz.rcgu.o: in function `pgrx_pg_sys::include::pg16::FreeErrorData::{{closure}}':
          /home/yoh/src/pgrx/target/debug/build/pgrx-pg-sys-f298184b10bba90c/out/pg16.rs:34291:(.text._ZN11pgrx_pg_sys7include4pg1613FreeErrorData28_$u7b$$u7b$closure$u7d$$u7d$17h2df406c9a32a66d9E+0x3): undefined reference to `FreeErrorData'
          /usr/bin/ld: /home/yoh/src/pgrx/target/debug/deps/pgrx_pg_sys-ccf40e22fbf97d0e.e6isuuaztqwzfnyzive8co0sz.rcgu.o: in function `pgrx_pg_sys::include::pg16::palloc::{{closure}}':
          /home/yoh/src/pgrx/target/debug/build/pgrx-pg-sys-f298184b10bba90c/out/pg16.rs:34291:(.text._ZN11pgrx_pg_sys7include4pg166palloc28_$u7b$$u7b$closure$u7d$$u7d$17hb9ec106cbbfc412fE+0x3): undefined reference to `palloc'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

error: could not compile `pgrx-pg-sys` (lib test) due to 1 previous error

@workingjubilee
Copy link
Member

we probably have unit tests that don't happen inside #[pg_test] for this

Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final nit, sorry.

We can fix the palloc thing for now by doing a #[cfg(target_pointer_width)] and running down the test later, or you can go hunt down the test.

@@ -157,7 +161,11 @@ impl From<i32> for Datum {
impl From<i64> for Datum {
#[inline]
fn from(val: i64) -> Datum {
Datum::from(val as usize)
if size_of::<i64>() <= size_of::<usize>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if size_of::<i64>() <= size_of::<usize>() {
if size_of::<i64>() <= size_of::<Datum>() {

@@ -129,7 +129,11 @@ impl From<u32> for Datum {
impl From<u64> for Datum {
#[inline]
fn from(val: u64) -> Datum {
Datum::from(val as usize)
if size_of::<u64>() <= size_of::<usize>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if size_of::<u64>() <= size_of::<usize>() {
if size_of::<u64>() <= size_of::<Datum>() {

@@ -283,7 +283,12 @@ impl FromDatum for i64 {
if is_null {
None
} else {
Some(datum.value() as _)
let value = if size_of::<i64>() <= size_of::<usize>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let value = if size_of::<i64>() <= size_of::<usize>() {
let value = if size_of::<i64>() <= size_of::<pg_sys::Datum>() {

@@ -315,7 +320,12 @@ impl FromDatum for f64 {
if is_null {
None
} else {
Some(f64::from_bits(datum.value() as _))
let value = if size_of::<i64>() <= size_of::<usize>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let value = if size_of::<i64>() <= size_of::<usize>() {
let value = if size_of::<f64>() <= size_of::<pg_sys::Datum>() {

@YohDeadfall
Copy link
Contributor Author

The roundtrip_integers test from pgrx-pg-sys breaks the build.

@workingjubilee
Copy link
Member

sigh.

@workingjubilee
Copy link
Member

Either the tests need to be moved out into pgrx-tests in a #[pg_test] or the code needs to change to be a cfg on target_pointer_width.

@YohDeadfall
Copy link
Contributor Author

Decided to go with cfg for now, but later it can be moved I guess to make pg_sys::Datum as simple as possible and less developer friendly. That should stimulate the move to Datum<'scr>.

@workingjubilee
Copy link
Member

This seems viable-enough for now.

@workingjubilee workingjubilee merged commit f4a1036 into pgcentralfoundation:develop Sep 18, 2024
14 checks passed
@YohDeadfall YohDeadfall deleted the fix-i64-f64-datums branch September 30, 2024 09:24
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