pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.71k stars 249 forks source link

fix cargo-pgrx and pgrx-tests on Windows #1934

Open usamoi opened 3 weeks ago

usamoi commented 3 weeks ago

Notes:

  1. postgres must run without administrator privileges, so switch calling postgres directly to starting postgres by pg_ctl in testing
  2. pgrx-cshim.c is compiled with -flto: without this flag, pgrx_embed.exe is linked to postgres.exe
  3. postgres binaries are download from EDB website, because I don't know how to compile postgres on Windows targeting msvc, and https://github.com/pgcentralfoundation/pgrx/pull/1934#issuecomment-2455265667
  4. this pull request fixes PgLwLock and PgAtomic but introduces a breaking change about PgLwLock and PgAtomic: name must be provided at PgLwLock/PgAtomic::new, PgLwLock::from_named is removed and a parameter of PgLwLock::attach changes
  5. cargo pgrx run and cargo pgrx test always print logs for pg_ctl start on Windows (pipes generated by std::process::Command are leaked to postgres, a command with Stdio::piped() hangs, so we use Stdio::inherit() on Windows)
  6. https://github.com/pgcentralfoundation/pgrx/pull/1934#issuecomment-2452114015
  7. Windows CI is added
usamoi commented 3 weeks ago

~raw syntax is stablized in 1.82 but it seems that CI does not know it~ fixed

usamoi commented 3 weeks ago

It seems that https://patchwork.kernel.org/project/linux-hardening/patch/20180416175918.GA13494@beast/ breaks --runas on linux. I think the best solution is just telling user to execute sudo sysctl fs.protected_fifos=0 before using --runas.

YohDeadfall commented 3 weeks ago

postgres binaries are download from EDB website, because I don't know how to compile postgres on Windows targeting msvc

The process is explained in the official documentation: https://www.postgresql.org/docs/16/install-windows.html

Not a Windows user for years, but can help if you're stuck with something (:

usamoi commented 3 weeks ago

postgres binaries are download from EDB website, because I don't know how to compile postgres on Windows targeting msvc

The process is explained in the official documentation: https://www.postgresql.org/docs/16/install-windows.html

Not a Windows user for years, but can help if you're stuck with something (:

I'm curious if there are really any Windows developers. So, I'm planning to leave this feature here to see if anyone fixes it.